From patchwork Thu Mar 1 22:26:29 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 10252757 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 DFD9660365 for ; Thu, 1 Mar 2018 22:26:45 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D099327816 for ; Thu, 1 Mar 2018 22:26:45 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C5AE3286A9; Thu, 1 Mar 2018 22:26:45 +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.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID 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 4149927816 for ; Thu, 1 Mar 2018 22:26:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1162557AbeCAW0o (ORCPT ); Thu, 1 Mar 2018 17:26:44 -0500 Received: from esa4.hgst.iphmx.com ([216.71.154.42]:41196 "EHLO esa4.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1162590AbeCAW0k (ORCPT ); Thu, 1 Mar 2018 17:26:40 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1519943201; x=1551479201; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=MQenVSCJlOdT9wEQZXvw1nmrP2LClQ1ZAJKB2WYw3Hk=; b=a0Xg2f5Ce3vkrvkylQ+IdlQMB2xDPfO7ZRxJTMClTxUkfe44FrCyYES+ NenSUGsKc0yQOhgeldDnQDkw5o731WC5oIpbmns9SddJRJ9ZntVMcKMiq vNNtV2SRccLhHU33FxfM0k+BxyAVZx2i3Ydu05hz7Xy5ZWaN0hfPrQYYv uBhW6ZfQdKipNC2/vBERgRCBcDYg2stnf/50H4iIHwqbNc15mjGfvQ4zo X9E/5xJMsoEK0mQqqLGZjXnR05j5bwn80bS8+GN4kKTRLQ00qHBHrO2f2 A5EMqawEYy+lcdcAS3UCX7P5OLrVbY3bEIzcXjwQPznkEImQ5H+mJPxq4 g==; X-IronPort-AV: E=Sophos;i="5.47,409,1515427200"; d="scan'208";a="72564606" Received: from uls-op-cesaip01.wdc.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 02 Mar 2018 06:26:35 +0800 Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep01.wdc.com with ESMTP; 01 Mar 2018 14:20:38 -0800 Received: from thinkpad-bart.sdcorp.global.sandisk.com (HELO thinkpad-bart.int.fusionio.com) ([10.11.171.236]) by uls-op-cesaip01.wdc.com with ESMTP; 01 Mar 2018 14:26:35 -0800 From: Bart Van Assche To: Nicholas Bellinger Cc: Christoph Hellwig , target-devel@vger.kernel.org, Bart Van Assche , Varun Prakash , Hannes Reinecke , Mike Christie Subject: [PATCH 11/14] target/iscsi: Reduce number of __iscsit_free_cmd() callers Date: Thu, 1 Mar 2018 14:26:29 -0800 Message-Id: <20180301222632.31507-12-bart.vanassche@wdc.com> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180301222632.31507-1-bart.vanassche@wdc.com> References: <20180301222632.31507-1-bart.vanassche@wdc.com> 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 Instead of calling __iscsit_free_cmd() from inside iscsit_aborted_task() if a command has been aborted and from inside iscsit_free_cmd() if a command has not been aborted, call __iscsit_free_cmd() from inside lio_release_cmd(). The latter function is namely called for all commands once the reference count has dropped to zero. Signed-off-by: Bart Van Assche Cc: Varun Prakash Cc: Hannes Reinecke Cc: Christoph Hellwig Cc: Mike Christie --- drivers/target/iscsi/iscsi_target.c | 2 -- drivers/target/iscsi/iscsi_target_configfs.c | 1 + drivers/target/iscsi/iscsi_target_util.c | 4 +--- 3 files changed, 2 insertions(+), 5 deletions(-) diff --git a/drivers/target/iscsi/iscsi_target.c b/drivers/target/iscsi/iscsi_target.c index 9eb10d34682c..5b79e1d992bc 100644 --- a/drivers/target/iscsi/iscsi_target.c +++ b/drivers/target/iscsi/iscsi_target.c @@ -496,8 +496,6 @@ void iscsit_aborted_task(struct iscsi_conn *conn, struct iscsi_cmd *cmd) !(cmd->se_cmd.transport_state & CMD_T_FABRIC_STOP)) list_del_init(&cmd->i_conn_node); spin_unlock_bh(&conn->cmd_lock); - - __iscsit_free_cmd(cmd, true); } EXPORT_SYMBOL(iscsit_aborted_task); diff --git a/drivers/target/iscsi/iscsi_target_configfs.c b/drivers/target/iscsi/iscsi_target_configfs.c index 0ebc4818e132..0bc346b2c27c 100644 --- a/drivers/target/iscsi/iscsi_target_configfs.c +++ b/drivers/target/iscsi/iscsi_target_configfs.c @@ -1546,6 +1546,7 @@ static void lio_release_cmd(struct se_cmd *se_cmd) struct iscsi_cmd *cmd = container_of(se_cmd, struct iscsi_cmd, se_cmd); pr_debug("Entering lio_release_cmd for se_cmd: %p\n", se_cmd); + __iscsit_free_cmd(cmd, true); iscsit_release_cmd(cmd); } diff --git a/drivers/target/iscsi/iscsi_target_util.c b/drivers/target/iscsi/iscsi_target_util.c index 4435bf374d2d..7693bfcddf03 100644 --- a/drivers/target/iscsi/iscsi_target_util.c +++ b/drivers/target/iscsi/iscsi_target_util.c @@ -745,10 +745,8 @@ void iscsit_free_cmd(struct iscsi_cmd *cmd, bool shutdown) __iscsit_free_cmd(cmd, shutdown); if (se_cmd) { rc = transport_generic_free_cmd(se_cmd, shutdown); - if (!rc && shutdown && se_cmd->se_sess) { - __iscsit_free_cmd(cmd, shutdown); + if (!rc && shutdown && se_cmd->se_sess) target_put_sess_cmd(se_cmd); - } } else { iscsit_release_cmd(cmd); }