From patchwork Fri Mar 11 06:30:09 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Nicholas A. Bellinger" X-Patchwork-Id: 8562421 Return-Path: X-Original-To: patchwork-linux-scsi@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id ACAB4C0553 for ; Fri, 11 Mar 2016 06:35:21 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id B5C5D2034F for ; Fri, 11 Mar 2016 06:35:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id C246E2026D for ; Fri, 11 Mar 2016 06:35:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934114AbcCKGe7 (ORCPT ); Fri, 11 Mar 2016 01:34:59 -0500 Received: from mail-ob0-f181.google.com ([209.85.214.181]:34253 "EHLO mail-ob0-f181.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934042AbcCKGey (ORCPT ); Fri, 11 Mar 2016 01:34:54 -0500 Received: by mail-ob0-f181.google.com with SMTP id ts10so104308680obc.1 for ; Thu, 10 Mar 2016 22:34:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daterainc-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=kKvG/S9mMAE2RzyI7myqCHM6xXkLDq5++cPk6ZQ1uRw=; b=zeldecNKFL9cSdv9w1mWRHK9j3IQqm/j6WoC1POzpZyzwYEL9eG/Sl/67N83bPWvss cifwrB0IVkhvxoYzAQMbAU4WfrqwcmMTg6Mo4tHl/aYFy3CvCjOWJe79Dlrm7+cl1OvF GhO+8xjm36CZdaVKOUHPnPK4clrJ+G49hTlMRvPgCE+GQGL2gNJiL5rXieg7pZIG3sm1 Rf6txlUXWbMRDVFEDGLH2C6xbHFX4CAeeHTFnT1Cshc7QFYsptLSgAfVL4AXQLEqt5mh vpNjM2TgFVpO/+T9sHg8PuEU9wmam0IjH5FW9/npaC/rM/uRnCUM1NEgbrniDmw6jGFd TS/Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=kKvG/S9mMAE2RzyI7myqCHM6xXkLDq5++cPk6ZQ1uRw=; b=OyhYkU7CZluUP1Vvwbh5hC45HQsKUXLvCnWbCQ737M1nql887FwZiLEJyaynGZmlcz vnxPd8A/TapnaZnDiRoxq3zzck9A8SNSNXmfz9VWlHEcsOozqOXVG2z5MfJHvmDmdO50 D8DAM89rgsk+GCznLKb0NKIQ9pjxeB+s1K1foZLFi4/DM7/C8XU5V4f7aWoNQSvW0OQS JszQi6Dvc8ktnVLteLB9NOrNVbUgEBFNPhNaeQdatrP35gIJPWZOLVQvQdTUs0L5NS8y KewpG4yfCpmqWScrMJPKVBZb+4O7bPeU92/hoCN3dbV1mr5iUUm0FW0++vrrary1LSLE bPCg== X-Gm-Message-State: AD7BkJJU0sSchBdQi7APqTNKekunXvtjwAKjka3JPob4Y+pP/rgGHdE3YujZI6nbfXKScw== X-Received: by 10.60.15.226 with SMTP id a2mr4837267oed.22.1457678094254; Thu, 10 Mar 2016 22:34:54 -0800 (PST) Received: from localhost.localdomain (mail.linux-iscsi.org. [67.23.28.174]) by smtp.gmail.com with ESMTPSA id s81sm3540631oif.0.2016.03.10.22.34.53 (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 10 Mar 2016 22:34:53 -0800 (PST) From: "Nicholas A. Bellinger" To: target-devel Cc: linux-scsi , Christoph Hellwig , Hannes Reinecke , Mike Christie , Sagi Grimberg , Andy Grover , Sebastian Andrzej Siewior , Juergen Gross , Andrzej Pietrasiewicz , Chris Boot , Felipe Balbi , Nicholas Bellinger , Vasu Dev , Mark Rustad , Robert Love Subject: [PATCH-v4 13/14] tcm_fc: Convert to TARGET_SCF_ACK_KREF I/O + TMR krefs Date: Fri, 11 Mar 2016 06:30:09 +0000 Message-Id: <1457677810-2478-14-git-send-email-nab@daterainc.com> X-Mailer: git-send-email 1.7.2.5 In-Reply-To: <1457677810-2478-1-git-send-email-nab@daterainc.com> References: <1457677810-2478-1-git-send-email-nab@daterainc.com> Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Nicholas Bellinger This patch converts tcm_fc to modern TARGET_SCF_ACK_KREF usage for ft_queue_status(), and fixes ft_check_stop_free() to return transport_generic_free_cmd() for ->cmd_kref. It also converts TM request -> ft_send_tm() to use ACK_KREF, and update ft_queue_tm_resp() to drop the outstanding kref after queueing TM response into fabric code. Cc: Vasu Dev Cc: Mark Rustad Cc: Robert Love Signed-off-by: Nicholas Bellinger --- drivers/target/tcm_fc/tfc_cmd.c | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/drivers/target/tcm_fc/tfc_cmd.c b/drivers/target/tcm_fc/tfc_cmd.c index 064d6df..216e18c 100644 --- a/drivers/target/tcm_fc/tfc_cmd.c +++ b/drivers/target/tcm_fc/tfc_cmd.c @@ -107,8 +107,7 @@ void ft_release_cmd(struct se_cmd *se_cmd) int ft_check_stop_free(struct se_cmd *se_cmd) { - transport_generic_free_cmd(se_cmd, 0); - return 1; + return transport_generic_free_cmd(se_cmd, 0); } /* @@ -179,6 +178,12 @@ int ft_queue_status(struct se_cmd *se_cmd) return -ENOMEM; } lport->tt.exch_done(cmd->seq); + /* + * Drop the extra ACK_KREF reference taken by target_submit_cmd() + * ahead of ft_check_stop_free() -> transport_generic_free_cmd() + * final se_cmd->cmd_kref put. + */ + target_put_sess_cmd(&cmd->se_cmd); return 0; } @@ -387,7 +392,7 @@ static void ft_send_tm(struct ft_cmd *cmd) /* FIXME: Add referenced task tag for ABORT_TASK */ rc = target_submit_tmr(&cmd->se_cmd, cmd->sess->se_sess, &cmd->ft_sense_buffer[0], scsilun_to_int(&fcp->fc_lun), - cmd, tm_func, GFP_KERNEL, 0, 0); + cmd, tm_func, GFP_KERNEL, 0, TARGET_SCF_ACK_KREF); if (rc < 0) ft_send_resp_code_and_free(cmd, FCP_TMF_FAILED); } @@ -422,6 +427,12 @@ void ft_queue_tm_resp(struct se_cmd *se_cmd) pr_debug("tmr fn %d resp %d fcp code %d\n", tmr->function, tmr->response, code); ft_send_resp_code(cmd, code); + /* + * Drop the extra ACK_KREF reference taken by target_submit_tmr() + * ahead of ft_check_stop_free() -> transport_generic_free_cmd() + * final se_cmd->cmd_kref put. + */ + target_put_sess_cmd(&cmd->se_cmd); } void ft_aborted_task(struct se_cmd *se_cmd) @@ -560,7 +571,8 @@ static void ft_send_work(struct work_struct *work) */ if (target_submit_cmd(&cmd->se_cmd, cmd->sess->se_sess, fcp->fc_cdb, &cmd->ft_sense_buffer[0], scsilun_to_int(&fcp->fc_lun), - ntohl(fcp->fc_dl), task_attr, data_dir, 0)) + ntohl(fcp->fc_dl), task_attr, data_dir, + TARGET_SCF_ACK_KREF)) goto err; pr_debug("r_ctl %x alloc target_submit_cmd\n", fh->fh_r_ctl);