From patchwork Wed Dec 13 23:50:29 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: 10111189 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 9EF37603ED for ; Wed, 13 Dec 2017 23:50:39 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 92105295AB for ; Wed, 13 Dec 2017 23:50:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8705229728; Wed, 13 Dec 2017 23:50:39 +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 1E2FF29677 for ; Wed, 13 Dec 2017 23:50:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751300AbdLMXui (ORCPT ); Wed, 13 Dec 2017 18:50:38 -0500 Received: from esa6.hgst.iphmx.com ([216.71.154.45]:30830 "EHLO esa6.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751422AbdLMXug (ORCPT ); Wed, 13 Dec 2017 18:50:36 -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=1513209036; x=1544745036; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=MdpFgry478ZoHnPRfnS7XkezA6iBGvwn8HG/2JAZTwA=; b=aKVkgs3jdbTiR7BZJfzZeXRgWcw+L1HcmagB77D0D6uz749K8QYqysfY BF/g82gPJSv+wiC0xjavRRcEliwg2vJuuLrSZXzC83vt6835zEDZE4uLf eC+u1jdl8+3TxPaY/3MFAsLZlq+9wRYodK9W8r7SALl1N8onYhKdjGR7R EqONeFtDgap0O0NUGPh6xYaYaSb0DHJvCzfzYYvEQzlrXM2jkFhGibrg/ xsRYgv0DS5S4phZ9RWTE1FNLSoPD+Ruh8VBJhVZ9rQKrAumwo3w9tVbBF 0zJBAyLAi2B3CANHxI2saxSwCFKupgkttNr7yliIkVDGxVr1Vj1P5Tf7z g==; X-IronPort-AV: E=Sophos;i="5.45,398,1508774400"; d="scan'208";a="65384159" Received: from h199-255-45-15.hgst.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 14 Dec 2017 07:50:33 +0800 Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP; 13 Dec 2017 15:46:56 -0800 Received: from thinkpad-bart.sdcorp.global.sandisk.com (HELO thinkpad-bart.int.fusionio.com) ([10.11.166.51]) by uls-op-cesaip02.wdc.com with ESMTP; 13 Dec 2017 15:50:33 -0800 From: Bart Van Assche To: "Martin K . Petersen" , "James E . J . Bottomley" Cc: Nicholas Bellinger , Christoph Hellwig , target-devel@vger.kernel.org, Bart Van Assche , Varun Prakash , Hannes Reinecke , Mike Christie Subject: [PATCH 11/11] target/iscsi: Reduce number of __iscsit_free_cmd() callers Date: Wed, 13 Dec 2017 15:50:29 -0800 Message-Id: <20171213235029.581-12-bart.vanassche@wdc.com> X-Mailer: git-send-email 2.15.1 In-Reply-To: <20171213235029.581-1-bart.vanassche@wdc.com> References: <20171213235029.581-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: Nicholas Bellinger Cc: Varun Prakash Cc: Christoph Hellwig Cc: Hannes Reinecke 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); }