From patchwork Wed Feb 8 22:24:43 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: 9563615 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 6B8616020F for ; Wed, 8 Feb 2017 22:27:28 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3FABF2840B for ; Wed, 8 Feb 2017 22:27:28 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 34883284F2; Wed, 8 Feb 2017 22:27:28 +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 DB9692852C for ; Wed, 8 Feb 2017 22:27:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751235AbdBHW11 (ORCPT ); Wed, 8 Feb 2017 17:27:27 -0500 Received: from esa2.hgst.iphmx.com ([68.232.143.124]:63832 "EHLO esa2.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751307AbdBHW1Z (ORCPT ); Wed, 8 Feb 2017 17:27:25 -0500 X-IronPort-AV: E=Sophos;i="5.35,348,1483977600"; d="scan'208";a="76618137" Received: from unknown (HELO milsmgep15.sandisk.com) ([63.163.107.21]) by ob1.hgst.iphmx.com with ESMTP; 09 Feb 2017 06:28:18 +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 93.54.57638.9CA9B985; Wed, 8 Feb 2017 14:25:13 -0800 (PST) Received: from milsmgip12.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; Wed, 8 Feb 2017 14:25:11 -0800 X-AuditID: 0ac94369-26dee9800001e126-f2-589b9ac95fb3 Received: from exp-402881.sdcorp.global.sandisk.com ( [10.177.9.6]) by (Symantec Messaging Gateway) with SMTP id A1.42.18148.7CA9B985; Wed, 8 Feb 2017 14:25:11 -0800 (PST) From: Bart Van Assche To: Bart Van Assche CC: , Christoph Hellwig , Andy Grover , David Disseldorp Subject: [PATCH v4 13/37] target: Stop execution if CMD_T_STOP has been set Date: Wed, 8 Feb 2017 14:24:43 -0800 Message-ID: <20170208222507.25715-14-bart.vanassche@sandisk.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170208222507.25715-1-bart.vanassche@sandisk.com> References: <20170208222507.25715-1-bart.vanassche@sandisk.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrKLMWRmVeSWpSXmKPExsXCddJ5ke7JWbMjDGYeVrHYP+sZk8XX/9NZ LFauPspk0br0LZMDi8fumw1sHu/3XWXz2Hy62uPzJrkAligum5TUnMyy1CJ9uwSujK4tv5kL LnJVzDu5lLmBsY2zi5GTQ0LAROLHskPMILaQwFImiUWTi7sYuYDs7YwSyydtY4YpevnnDztE 0UagxGknEJtNwEji2/uZLCC2iICBxO/eC4wgzcwCHYwS83uesYIkhAW8JXavbwJrZhFQkVh2 qxkszivgILFm3ktGiAXyErvaLoLFOYHiE14+Y4RYZi/x6sAXsKESAm2sErPProBqFpQ4OfMJ 2GZmAQmJgy9eQL2gLnFyyXymCYxCs5CUzUJStoCRaRWjWG5mTnFuemqBoalecWJeSmZxtl5y fu4mRkhgZ+5gvPvE+xCjAAejEg9vheXsCCHWxLLiytxDjBIczEoivCnTgEK8KYmVValF+fFF pTmpxYcYpTlYlMR5z8lMjRASSE8sSc1OTS1ILYLJMnFwSjUwVs6srajJD3r2TDev6qNm2CER 8avsk/M3RK3007o39WVZzO4fsf0ZfuYsWj9KHzQnOJ9fXSbL0ynEW/Iid0Ka/KL9V618QqeL aLsoZ+7hcFBZIXSsrmrzt3VzJr8VE1R4r7nUjOG1U+OyVPVa26OZ4T+/feZUY+0RS1EzWXD4 RP765KwS1XQlluKMREMt5qLiRADeZvDVaAIAAA== X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrGJMWRmVeSWpSXmKPExsXCtZGTTff4rNkRBhd3qlrsn/WMyeLgzzZG i6//p7NYrFx9lMmidelbJgdWj903G9g83u+7yuYxbc15Jo/Np6s9Pm+SC2CN4rJJSc3JLEst 0rdL4Mro2vKbueAiV8W8k0uZGxjbOLsYOTkkBEwkXv75w97FyMUhJLCeUeLv9EvMIAk2ASOJ b+9nsoDYIgIGEr97LzCCFDELdDFKbDpzih0kISzgLbF7fROYzSKgKrFg5SQwm1fAQWLxzDvM EBvkJXa1XWQFsTmB4hNePmMEsYUE7CVeHfjCOIGRewEjwypGsdzMnOLc9MwCQyO94sS8lMzi bL3k/NxNjJCQiNrBeH2i+SFGJg5OqQbGzv8LF+vv/PSo78fBurOTHRusw0vOywss/fix5OnV iYcYAqrc9m2ZG7R030JDiS6/yXItm8t4crbesLFtufrjxqsNZyv3nlPd4fp0kU7I9ONPepxY XDZuTvngnz5bqvRewiPeucf+m24PeNHRuK9K6+32btN17Hdyz8qn7AveeHXLBOHjwhqXMpVY ijMSDbWYi4oTAZj8Kku5AQAA 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 Stop execution if CMD_T_STOP has been set for a command just after the command has been added to the device command list and before .write_pending() is called. The following sequence can trigger this: - transport_handle_cdb_direct() gets called. This function namely sets CMD_T_ACTIVE before it calls transport_generic_new_cmd(). - __transport_wait_for_tasks() is called concurrently. This function sets CMD_T_STOP for all active commands that have not been aborted. Signed-off-by: Bart Van Assche Reviewed-by: Hannes Reinecke Cc: Christoph Hellwig Cc: Andy Grover Cc: David Disseldorp --- drivers/target/target_core_transport.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/target/target_core_transport.c b/drivers/target/target_core_transport.c index 01fd61eb2e12..1e1f1ed2ef17 100644 --- a/drivers/target/target_core_transport.c +++ b/drivers/target/target_core_transport.c @@ -2450,7 +2450,8 @@ transport_generic_new_cmd(struct se_cmd *cmd) target_execute_cmd(cmd); return 0; } - transport_cmd_check_stop(cmd, false, true); + if (transport_cmd_check_stop(cmd, false, true)) + return 0; ret = cmd->se_tfo->write_pending(cmd); if (ret == -EAGAIN || ret == -ENOMEM)