From patchwork Fri Jun 22 21:53:00 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: 10483115 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 9CD356023A for ; Fri, 22 Jun 2018 21:53:18 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8C3D629042 for ; Fri, 22 Jun 2018 21:53:18 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8113229043; Fri, 22 Jun 2018 21:53:18 +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=-7.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI, 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 074242903B for ; Fri, 22 Jun 2018 21:53:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933440AbeFVVxR (ORCPT ); Fri, 22 Jun 2018 17:53:17 -0400 Received: from esa2.hgst.iphmx.com ([68.232.143.124]:64357 "EHLO esa2.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933463AbeFVVxN (ORCPT ); Fri, 22 Jun 2018 17:53:13 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1529704421; x=1561240421; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=z0EnC6obNKztcOLf/LV0ufsas83ocHvEexUmFsiGnqQ=; b=MOXCq0JK1uaO5l301megnpuL4DX0UkZk3vlWngovfTBjeHDXX511bRUE SbPOO7W7/HBJytnNpFibnlhneLAATH1ks+jg3toUMObroDr84rBGKPtRe JEQ5Xtt2GWl64OPwpu9tS8eytCQfgcpiOeNP+WZZBuEh3WCALam/bNcfO 49PIhx58kl73khgvbCWLTSQgFeLyWENB7/6TvjJWA5SMGHp6AqlL/cpaY WDZkxxTKysz36TAy8igyHHqgo4AQDDAogbTC405TE5mP9Y6abPHCw7ZkH Q94ygTg9z/TuYh14w64fOJM/ipZv1y49c4hUAno7CMwIr06g7F26JR2eT Q==; X-IronPort-AV: E=Sophos;i="5.51,259,1526313600"; d="scan'208";a="178351008" Received: from uls-op-cesaip01.wdc.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 23 Jun 2018 05:53:36 +0800 Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep01.wdc.com with ESMTP; 22 Jun 2018 14:42:57 -0700 Received: from thinkpad-bart.sdcorp.global.sandisk.com ([10.111.67.248]) by uls-op-cesaip01.wdc.com with ESMTP; 22 Jun 2018 14:53:11 -0700 From: Bart Van Assche To: "Martin K . Petersen" Cc: Christoph Hellwig , target-devel@vger.kernel.org, Bart Van Assche , Varun Prakash , Hannes Reinecke Subject: [PATCH 13/20] target/iscsi: Reduce number of __iscsit_free_cmd() callers Date: Fri, 22 Jun 2018 14:53:00 -0700 Message-Id: <20180622215307.8758-14-bart.vanassche@wdc.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180622215307.8758-1-bart.vanassche@wdc.com> References: <20180622215307.8758-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 Reviewed-by: Mike Christie Cc: Varun Prakash Cc: Hannes Reinecke Cc: Christoph Hellwig --- 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 8e223799347a..d547dcd625d9 100644 --- a/drivers/target/iscsi/iscsi_target.c +++ b/drivers/target/iscsi/iscsi_target.c @@ -497,8 +497,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 8cfcf9033507..5a645b5f1eb4 100644 --- a/drivers/target/iscsi/iscsi_target_util.c +++ b/drivers/target/iscsi/iscsi_target_util.c @@ -772,10 +772,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); }