From patchwork Tue Oct 31 18:03:11 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: 10035067 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 7856760327 for ; Tue, 31 Oct 2017 18:03:28 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6F2422851D for ; Tue, 31 Oct 2017 18:03:28 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 63ABE28A5F; Tue, 31 Oct 2017 18:03: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.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 F40462851D for ; Tue, 31 Oct 2017 18:03:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932651AbdJaSD0 (ORCPT ); Tue, 31 Oct 2017 14:03:26 -0400 Received: from esa4.hgst.iphmx.com ([216.71.154.42]:25243 "EHLO esa4.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932531AbdJaSDY (ORCPT ); Tue, 31 Oct 2017 14:03:24 -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=1509473004; x=1541009004; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=fmepGLvGTcBtQrrsXPTiKr+dcFHUAV4iHHv/JWAWCT0=; b=n/6ccyR4LGlqlDU6tfCfkE8Shfi4J+Tu28mhsf0tlMWeu28Lguyd9EPO ByzTsuRHBIDE6pps9EfUlzih9Xf2ct2dI8XShN8qcozG/Rn2oBV9ErTBj 49bQdE31+9tzJUcHPH0U94wbNUcTcfyw6HfpU+0Rewh3zHQvBihHgUiX5 Q9eZhrBZgBW2KVETUVv3aZVTgmZTnYVCftLSlSmp3uoIkU8vdblMBwvSa 6aBKdOuZxCy3+4V9wHgNC2RdsZwfZpVD7iMgPosqV6CD7vJzqyjn4aGDc bvxd6Oe3NlEa8Ne9KyhLek5jptcuIHMkV5Iohx5jtp+ih0QDFFD1leMCB w==; X-IronPort-AV: E=Sophos;i="5.44,325,1505750400"; d="scan'208";a="60328618" 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; 01 Nov 2017 02:03:23 +0800 Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP; 31 Oct 2017 11:01:07 -0700 Received: from unknown (HELO MILHUBIP03.sdcorp.global.sandisk.com) ([10.177.9.96]) by uls-op-cesaip02.wdc.com with ESMTP; 31 Oct 2017 11:03:23 -0700 Received: from milsmgip12.sandisk.com (10.177.9.6) by MILHUBIP03.sdcorp.global.sandisk.com (10.177.9.96) with Microsoft SMTP Server id 14.3.319.2; Tue, 31 Oct 2017 11:03:23 -0700 X-AuditID: 0ab1095a-d99e3980000146e4-4e-59f8baea7a7b Received: from thinkpad-bart.int.fusionio.com ( [10.177.8.100]) by (Symantec Messaging Gateway) with SMTP id 09.A9.18148.AEAB8F95; Tue, 31 Oct 2017 11:03:22 -0700 (PDT) From: Bart Van Assche To: "Martin K . Petersen" , "James E . J . Bottomley" CC: Nicholas Bellinger , Christoph Hellwig , , Bart Van Assche , Hannes Reinecke , Mike Christie Subject: [PATCH 03/11] target: Inline transport_put_cmd() Date: Tue, 31 Oct 2017 11:03:11 -0700 Message-ID: <20171031180319.19258-4-bart.vanassche@wdc.com> X-Mailer: git-send-email 2.14.2 In-Reply-To: <20171031180319.19258-1-bart.vanassche@wdc.com> References: <20171031180319.19258-1-bart.vanassche@wdc.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrCJMWRmVeSWpSXmKPExsXCtZEjRffVrh+RBndPKltc+vOF0WLBm71s FitXH2WyWDUxz2L58X9MFuuPbGC0aFt9htGidelbJgcOj/vbjzB5PDi0mcVj980GNo+PT2+x eLzfd5XNY/2WqywenzfJebQf6GYK4IjisklJzcksSy3St0vgyujYdIu54Jd4xZP+BSwNjJ+E uxg5OSQETCTuzX3F3MXIxSEksJpRYvLqmewgCTYBPYlT8/YxgdgiArkSpx7eYAIpYhZ4wijR 8nMfWJGwgKXEpDvtYEUsAqoSN7bNYwGxeQWsJeb+PMIKsUFe4v2C+4wgNqeAjcTbnt1gNUJA Ndf2LmGewMi9gJFhFaNYbmZOcW56ZoGhkV5xYl5KZnG2XnJ+7iZGcDhxRu1gvD7R/BAjEwen VAPjwnM6zxdsvZjYe2+Zgagoc8a8CYKTT5yJMTGZq7/zaKrMr/7Sc/qyeQ+uTU74d8138RbW dS2zthy8Wv99T8lL5YNq7yaGTSvSY859//f+hNfZdcGHtlTWsNwzPnIw5bigsN9NGU9n/Xe/ r1WtCl5ondinv8i1/t2rY5ycp3Z3eEqI3wjaUxPxV4mlOCPRUIu5qDgRAL+joG/XAQAA 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 Since all transput_put_cmd() does is to call target_put_sess_cmd(), inline transport_put_cmd() into its callers. Leave out the BUG_ON() statement because if cmd->se_tfo == NULL then cmd->cmd_kref is 0 and kref_put() will complain anyway. Notes: - transport_init_se_cmd() initializes both .se_tfo and .cmd_kref. - The only target driver that does not call transport_init_se_cmd() for all commands is the iSCSI target driver. See also iscsi_target_rx_opcode(). Signed-off-by: Bart Van Assche Cc: Nicholas Bellinger Cc: Christoph Hellwig Cc: Hannes Reinecke Cc: Mike Christie Reviewed-by: Hannes Reinecke --- drivers/target/target_core_transport.c | 23 +++-------------------- 1 file changed, 3 insertions(+), 20 deletions(-) diff --git a/drivers/target/target_core_transport.c b/drivers/target/target_core_transport.c index e6a2817c8239..8c0dbb048aa7 100644 --- a/drivers/target/target_core_transport.c +++ b/drivers/target/target_core_transport.c @@ -67,7 +67,6 @@ static void transport_complete_task_attr(struct se_cmd *cmd); static int translate_sense_reason(struct se_cmd *cmd, sense_reason_t reason); static void transport_handle_queue_full(struct se_cmd *cmd, struct se_device *dev, int err, bool write_pending); -static int transport_put_cmd(struct se_cmd *cmd); static void target_complete_ok_work(struct work_struct *work); int init_se_kmem_caches(void) @@ -668,7 +667,7 @@ int transport_cmd_finish_abort(struct se_cmd *cmd, int remove) if (transport_cmd_check_stop_to_fabric(cmd)) return 1; if (remove && ack_kref) - ret = transport_put_cmd(cmd); + ret = target_put_sess_cmd(cmd); return ret; } @@ -2352,22 +2351,6 @@ static inline void transport_free_pages(struct se_cmd *cmd) cmd->t_bidi_data_nents = 0; } -/** - * transport_put_cmd - release a reference to a command - * @cmd: command to release - * - * This routine releases our reference to the command and frees it if possible. - */ -static int transport_put_cmd(struct se_cmd *cmd) -{ - BUG_ON(!cmd->se_tfo); - /* - * If this cmd has been setup with target_get_sess_cmd(), drop - * the kref and call ->release_cmd() in kref callback. - */ - return target_put_sess_cmd(cmd); -} - void *transport_kmap_data_sg(struct se_cmd *cmd) { struct scatterlist *sg = cmd->t_data_sg; @@ -2603,7 +2586,7 @@ int transport_generic_free_cmd(struct se_cmd *cmd, int wait_for_tasks) target_wait_free_cmd(cmd, &aborted, &tas); if (!aborted || tas) - ret = transport_put_cmd(cmd); + ret = target_put_sess_cmd(cmd); } else { if (wait_for_tasks) target_wait_free_cmd(cmd, &aborted, &tas); @@ -2619,7 +2602,7 @@ int transport_generic_free_cmd(struct se_cmd *cmd, int wait_for_tasks) transport_lun_remove_cmd(cmd); if (!aborted || tas) - ret = transport_put_cmd(cmd); + ret = target_put_sess_cmd(cmd); } /* * If the task has been internally aborted due to TMR ABORT_TASK