From patchwork Wed Feb 15 00:25:53 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 9573071 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 544B9600F6 for ; Wed, 15 Feb 2017 00:26:43 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 45367283F4 for ; Wed, 15 Feb 2017 00:26:43 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3A08A2842B; Wed, 15 Feb 2017 00:26:43 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B374D283F4 for ; Wed, 15 Feb 2017 00:26:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750943AbdBOA0l (ORCPT ); Tue, 14 Feb 2017 19:26:41 -0500 Received: from esa1.hgst.iphmx.com ([68.232.141.245]:61609 "EHLO esa1.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750902AbdBOA0j (ORCPT ); Tue, 14 Feb 2017 19:26:39 -0500 X-IronPort-AV: E=Sophos;i="5.33,348,1477929600"; d="scan'208";a="86867743" Received: from unknown (HELO milsmgep15.sandisk.com) ([63.163.107.21]) by ob1.hgst.iphmx.com with ESMTP; 15 Feb 2017 08:26:19 +0800 Received: from MILHUBIP03.sdcorp.global.sandisk.com (Unknown_Domain [10.201.67.162]) (using TLS with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by (Symantec Messaging Gateway) with SMTP id 48.E4.57638.B20A3A85; Tue, 14 Feb 2017 16:26:19 -0800 (PST) Received: from milsmgip11.sandisk.com (10.177.8.100) by MILHUBIP03.sdcorp.global.sandisk.com (10.177.9.96) with Microsoft SMTP Server id 14.3.319.2; Tue, 14 Feb 2017 16:26:15 -0800 X-AuditID: 0ac94369-26dee9800001e126-6c-58a3a02bdd2d Received: from exp-402881.sdcorp.global.sandisk.com ( [10.177.9.6]) by (Symantec Messaging Gateway) with SMTP id 6C.7D.11415.720A3A85; Tue, 14 Feb 2017 16:26:15 -0800 (PST) From: Bart Van Assche To: "Nicholas A . Bellinger" CC: , Bart Van Assche , Subject: [PATCH v6 14/33] target: Avoid that target drivers hang if a command is aborted Date: Tue, 14 Feb 2017 16:25:53 -0800 Message-ID: <20170215002612.14566-15-bart.vanassche@sandisk.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170215002612.14566-1-bart.vanassche@sandisk.com> References: <20170215002612.14566-1-bart.vanassche@sandisk.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrGLMWRmVeSWpSXmKPExsXCddJ5ka72gsURBjv+CVq0rT7DaLFg4yNG i9alb5kcmD3ubz/C5PF5k1wAUxSXTUpqTmZZapG+XQJXRuupRqaC6cIVL+99ZW1gbBDoYuTk kBAwkTg1qZERxBYSWMok8bk5s4uRC8jewSjxZslFJpiithNbWCASGxkl7uy4zQqSYBMwkvj2 fiYLiC0CZK/uWQbWwCyQI/HrZT8biC0sECGx7PltsDiLgKrEuSsXwLbxCjhIfO9rY4VYIC+x q+0imM0JFJ+x4yTQTA6gZfYSj85Yg+yVEHjNItF35RwLRK+gxMmZT1ggdklIHHzxghniA3WJ k0vmM01gFJqFpGwWkrIFjEyrGMVyM3OKc9NTCwxN9YoT81Iyi7P1kvNzNzFCQjdzB+PdJ96H GAU4GJV4eE/ILo4QYk0sK67MPcQowcGsJMLLVg8U4k1JrKxKLcqPLyrNSS0+xCjNwaIkzntO ZmqEkEB6YklqdmpqQWoRTJaJg1OqgVErbJHm1qDf7xd6XtG1YJNgeluksHLh7dObZplMW2bY wjs72OJVPdem3SqhXbtK/gg9dZTsWLTKpd7UY4/CwqK9uqrpgda/qpkYNXsXxXxY6LFfMOKI zazAsLydxz9WeDkmzrtvp8vWOWnVCsfgI6vDN8/SqZZxVWIpuGYgIpeiZ3jxR6fyYSWW4oxE Qy3mouJEANDqhxxZAgAA X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprKJMWRmVeSWpSXmKPExsXCtZGTTVd9weIIg9sTJS0O/mxjtGhbfYbR YsHGR4wWrUvfMjmweNzffoTJY9qa80wenzfJBTBHcdmkpOZklqUW6dslcGW0nmpkKpguXPHy 3lfWBsYGgS5GTg4JAROJthNbWLoYuTiEBNYzSrzftZkFJMEmYCTx7f1MMFsEyF7ds4ypi5GD g1kgS2LxtDyQsLBAhMSy57eZQGwWAVWJc1cuMILYvAIOEt17PjFCzJeX2NV2kRXE5gSKz9hx kgVkjJCAvcSjM9YTGLkXMDKsYhTLzcwpzk3PLDA01CtOzEvJLM7WS87P3cQI8XjkDsanE80P MTJxcEo1MOq+FfcquFgqw3T9mYlrO5f+Y/n4ZR167ke/q9zb9cXMxUomfvtS3+ZsCdGCHwsK /Kfx8+y9qlsgxiFyh91g8tq8Gz8vTL9wWNOO4/MTlsOvQqrd17SkFnI+tPOsNpjbs0V6p8Pq 6h3RqmIz7f/Ou+k+ZdP5TXPZFi6UPuLIL+tgZPBMizurU4mlOCPRUIu5qDgRAHieTxGoAQAA MIME-Version: 1.0 Sender: target-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: target-devel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP For several target drivers (e.g. ib_srpt and ib_isert) sleeping inside transport_generic_free_cmd() causes RDMA completion processing to stall. Hence only sleep inside this function if the (iSCSI) target driver requires this. This patch avoids that messages similar to the following appear in the kernel log: INFO: task kworker/u25:0:1013 blocked for more than 480 seconds. Tainted: G W 4.10.0-rc7-dbg+ #3 "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message. kworker/u25:0 D 0 1013 2 0x00000000 Workqueue: ib-comp-wq ib_cq_poll_work [ib_core] Call Trace: __schedule+0x2da/0xb00 schedule+0x38/0x90 schedule_timeout+0x2fe/0x640 wait_for_completion+0xfe/0x160 transport_generic_free_cmd+0x2e/0x80 [target_core_mod] srpt_send_done+0x59/0x9f [ib_srpt] __ib_process_cq+0x4b/0xd0 [ib_core] ib_cq_poll_work+0x1b/0x60 [ib_core] process_one_work+0x208/0x6a0 worker_thread+0x49/0x4a0 kthread+0x107/0x140 ret_from_fork+0x2e/0x40 Signed-off-by: Bart Van Assche Cc: --- drivers/target/target_core_transport.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/drivers/target/target_core_transport.c b/drivers/target/target_core_transport.c index 2ed9721a7202..ab1c493a9a16 100644 --- a/drivers/target/target_core_transport.c +++ b/drivers/target/target_core_transport.c @@ -2504,15 +2504,13 @@ int transport_generic_free_cmd(struct se_cmd *cmd, int wait_for_tasks) int ret = 0; bool aborted = false, tas = false; - if (!(cmd->se_cmd_flags & SCF_SE_LUN_CMD)) { - if (wait_for_tasks && (cmd->se_cmd_flags & SCF_SCSI_TMR_CDB)) - target_wait_free_cmd(cmd, &aborted, &tas); + if (wait_for_tasks) + target_wait_free_cmd(cmd, &aborted, &tas); + if (!(cmd->se_cmd_flags & SCF_SE_LUN_CMD)) { if (!aborted || tas) ret = transport_put_cmd(cmd); } else { - if (wait_for_tasks) - target_wait_free_cmd(cmd, &aborted, &tas); /* * Handle WRITE failure case where transport_generic_new_cmd() * has already added se_cmd to state_list, but fabric has @@ -2535,7 +2533,6 @@ int transport_generic_free_cmd(struct se_cmd *cmd, int wait_for_tasks) */ if (aborted) { pr_debug("Detected CMD_T_ABORTED for ITT: %llu\n", cmd->tag); - wait_for_completion(&cmd->cmd_wait_comp); cmd->se_tfo->release_cmd(cmd); ret = 1; }