From patchwork Fri Feb 10 01:28:42 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: 9565785 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 49E2D60572 for ; Fri, 10 Feb 2017 01:29:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3BBF228532 for ; Fri, 10 Feb 2017 01:29:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 30A332853B; Fri, 10 Feb 2017 01:29:40 +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 D541E28532 for ; Fri, 10 Feb 2017 01:29:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751479AbdBJB3i (ORCPT ); Thu, 9 Feb 2017 20:29:38 -0500 Received: from esa1.hgst.iphmx.com ([68.232.141.245]:15691 "EHLO esa1.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751457AbdBJB3f (ORCPT ); Thu, 9 Feb 2017 20:29:35 -0500 X-IronPort-AV: E=Sophos;i="5.33,348,1477929600"; d="scan'208";a="82349538" Received: from unknown (HELO milsmgep15.sandisk.com) ([63.163.107.21]) by ob1.hgst.iphmx.com with ESMTP; 10 Feb 2017 09:29:00 +0800 Received: from MILHUBIP04.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 11.97.57638.C571D985; Thu, 9 Feb 2017 17:29:00 -0800 (PST) Received: from milsmgip11.sandisk.com (10.177.9.6) by MILHUBIP04.sdcorp.global.sandisk.com (10.177.9.97) with Microsoft SMTP Server id 14.3.319.2; Thu, 9 Feb 2017 17:28:56 -0800 X-AuditID: 0ac94369-26dee9800001e126-00-589d175cd048 Received: from exp-402881.sdcorp.global.sandisk.com ( [10.177.9.6]) by (Symantec Messaging Gateway) with SMTP id 16.9F.11415.7571D985; Thu, 9 Feb 2017 17:28:55 -0800 (PST) From: Bart Van Assche To: "Nicholas A . Bellinger" CC: , Bart Van Assche , Christoph Hellwig , Andy Grover , David Disseldorp Subject: [PATCH v5 12/22] target: Simplify LUN RESET implementation Date: Thu, 9 Feb 2017 17:28:42 -0800 Message-ID: <20170210012852.15735-13-bart.vanassche@sandisk.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170210012852.15735-1-bart.vanassche@sandisk.com> References: <20170210012852.15735-1-bart.vanassche@sandisk.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrDLMWRmVeSWpSXmKPExsXCddJ5kW6M+NwIg6MfrC32z3rGZPH1/3QW i5WrjzJZtK0+w2jRuvQtkwOrx/3tR5g8dt9sYPN4v+8qm8fm09UenzfJBbBGcdmkpOZklqUW 6dslcGUc7X7KXHCGp+LHZqUGxrNcXYwcHBICJhLH+oFMTg4hgaVMEr2fHboYuYDsrYwSu+Z1 s4MkQGr2bVvPBJHYyCjx4O4zFpAEm4CRxLf3M8FsESB7dc8ysCJmgR2MEhNX7gbrFhZwlphy 4CwLyDYWARWJ3jU+IGFeAQeJHScPM0MskJfY1XaRFcTmBIq/mn2dFaRcSMBeYscuA5CREgJ9 rBIH9vxggugVlDg58wnYXmYBCYmDL14wQ3ygLnFyyXymCYxCs5CUzUJStoCRaRWjWG5mTnFu emqBoalecWJeSmZxtl5yfu4mRkiYZ+5gvPvE+xCjAAejEg/vi5o5EUKsiWXFlbmHGCU4mJVE eO/zzY0Q4k1JrKxKLcqPLyrNSS0+xCjNwaIkzntOZmqEkEB6YklqdmpqQWoRTJaJg1OqgXFW heOqXWIXtXUip05Iyvk1vdu6P+i7wJfMiz037wa9PtJh+XvfRb+GAI3HrDllHjYxFjtFXnbI V0iEic5/xGBYl3tnTeqWJ7VCU25KVtRqLQw2YHuw6vyVlJu5X+b2mfFtrfveJD7lOddC9U1r /tQtfbPsU6YZ529bxwNz63NbZbi3G81oqFZiKc5INNRiLipOBABA29unbwIAAA== X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrHJMWRmVeSWpSXmKPExsXCtZGTTTdcfG6Ewardchb7Zz1jsjj4s43R 4uv/6SwWK1cfZbJoW32G0aJ16VsmBzaP+9uPMHnsvtnA5vF+31U2j2lrzjN5bD5d7fF5k1wA WxSXTUpqTmZZapG+XQJXxtHup8wFZ3gqfmxWamA8y9XFyMkhIWAisW/beqYuRi4OIYH1jBLn VhxjBkmwCRhJfHs/kwXEFgGyV/csAytiFtjFKDF5wgmwhLCAs8SUA2fBbBYBVYnzs9axg9i8 Ag4S97ZcZIfYIC+xq+0iK4jNCRR/Nfs6kM0BtM1eYscugwmM3AsYGVYxiuVm5hTnpmcWGBrq FSfmpWQWZ+sl5+duYoSESOQOxqcTzQ8xMnFwSjUwTtfW3MT9crLOxy0J306ryGxKaOU8rRcU cNRlLt8SF/25ftsdfsVcnGKnG2soWG3CLnx5zVqfrRpTr9kkX418MXOB3Dq25pbAf2F8VeF1 VZoFESpbalYWe+3ylC4RzLa/9+ba7r9mlx9ybr15j00s46gl86ss93nHvwZwLDqp4bz3Bo/1 pm1eSizFGYmGWsxFxYkArhyeI8EBAAA= 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 Due to the task management handling rework it is safe to wait for a TMF that is not in the active state. Hence remove the CMD_T_ACTIVE test from core_tmr_drain_tmr_list(). Additionally, call __target_check_io_state() instead of open coding it. Signed-off-by: Bart Van Assche Reviewed-by: Hannes Reinecke Cc: Christoph Hellwig Cc: Andy Grover Cc: David Disseldorp --- drivers/target/target_core_tmr.c | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/drivers/target/target_core_tmr.c b/drivers/target/target_core_tmr.c index 75ef294106c3..c8f231d0664a 100644 --- a/drivers/target/target_core_tmr.c +++ b/drivers/target/target_core_tmr.c @@ -221,23 +221,13 @@ static void core_tmr_drain_tmr_list( continue; spin_lock(&sess->sess_cmd_lock); - spin_lock(&cmd->t_state_lock); - if (!(cmd->transport_state & CMD_T_ACTIVE) || - (cmd->transport_state & CMD_T_FABRIC_STOP)) { - spin_unlock(&cmd->t_state_lock); - spin_unlock(&sess->sess_cmd_lock); - continue; - } - cmd->transport_state |= CMD_T_ABORTED; - spin_unlock(&cmd->t_state_lock); + rc = __target_check_io_state(cmd, sess, 0); + spin_unlock(&sess->sess_cmd_lock); - rc = kref_get_unless_zero(&cmd->cmd_kref); if (!rc) { printk("LUN_RESET TMR: non-zero kref_get_unless_zero\n"); - spin_unlock(&sess->sess_cmd_lock); continue; } - spin_unlock(&sess->sess_cmd_lock); list_move_tail(&tmr_p->tmr_list, &drain_tmr_list); }