linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Tran, Quinn" <Quinn.Tran@cavium.com>
To: "Nicholas A. Bellinger" <nab@linux-iscsi.org>,
	target-devel <target-devel@vger.kernel.org>
Cc: linux-scsi <linux-scsi@vger.kernel.org>,
	lkml <linux-kernel@vger.kernel.org>,
	"Madhani, Himanshu" <Himanshu.Madhani@cavium.com>,
	Mike Christie <mchristi@redhat.com>,
	Hannes Reinecke <hare@suse.com>, Christoph Hellwig <hch@lst.de>
Subject: Re: [PATCH 1/3] target: Add support for TMR percpu reference counting
Date: Wed, 7 Jun 2017 01:13:32 +0000	[thread overview]
Message-ID: <386D71C4-353C-4237-8345-3043E8773EAF@cavium.com> (raw)
In-Reply-To: <1496527808-28789-2-git-send-email-nab@linux-iscsi.org>

Looks good.

Regards,
Quinn Tran

-----Original Message-----
From: Nicholas Bellinger <nab@linux-iscsi.org>
Date: Saturday, June 3, 2017 at 3:10 PM
To: target-devel <target-devel@vger.kernel.org>
Cc: linux-scsi <linux-scsi@vger.kernel.org>, lkml <linux-kernel@vger.kernel.org>, Nicholas Bellinger <nab@linux-iscsi.org>, "Madhani, Himanshu" <Himanshu.Madhani@cavium.com>, "Tran, Quinn" <Quinn.Tran@cavium.com>, Mike Christie <mchristi@redhat.com>, Hannes Reinecke <hare@suse.com>, Christoph Hellwig <hch@lst.de>
Subject: [PATCH 1/3] target: Add support for TMR percpu reference counting

    From: Nicholas Bellinger <nab@linux-iscsi.org>
    
    This patch introduces TMR percpu reference counting using
    se_lun->lun_ref in transport_lookup_tmr_lun(), following
    how existing non TMR per se_lun reference counting works
    within transport_lookup_cmd_lun().
    
    It also adds explicit transport_lun_remove_cmd() calls to
    drop the reference in the three tmr related locations that
    invoke transport_cmd_check_stop_to_fabric();
    
       - target_tmr_work() during normal ->queue_tm_rsp()
       - target_complete_tmr_failure() during error ->queue_tm_rsp()
       - transport_generic_handle_tmr() during early failure
    
    Also, note the exception paths in transport_generic_free_cmd()
    and transport_cmd_finish_abort() already check SCF_SE_LUN_CMD,
    and will invoke transport_lun_remove_cmd() when necessary.
    
    Cc: Himanshu Madhani <himanshu.madhani@cavium.com>
    Cc: Quinn Tran <quinn.tran@cavium.com>
    Cc: Mike Christie <mchristi@redhat.com>
    Cc: Hannes Reinecke <hare@suse.com>
    Cc: Christoph Hellwig <hch@lst.de>
    Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
    ---
     drivers/target/target_core_device.c    | 14 ++++++++++----
     drivers/target/target_core_transport.c |  3 +++
     2 files changed, 13 insertions(+), 4 deletions(-)
    
    diff --git a/drivers/target/target_core_device.c b/drivers/target/target_core_device.c
    index 8f0e0e3..11c80c4 100644
    --- a/drivers/target/target_core_device.c
    +++ b/drivers/target/target_core_device.c
    @@ -168,11 +168,20 @@ int transport_lookup_tmr_lun(struct se_cmd *se_cmd, u64 unpacked_lun)
     	rcu_read_lock();
     	deve = target_nacl_find_deve(nacl, unpacked_lun);
     	if (deve) {
    -		se_cmd->se_lun = rcu_dereference(deve->se_lun);
     		se_lun = rcu_dereference(deve->se_lun);
    +
    +		if (!percpu_ref_tryget_live(&se_lun->lun_ref)) {
    +			se_lun = NULL;
    +			goto out_unlock;
    +		}
    +
    +		se_cmd->se_lun = rcu_dereference(deve->se_lun);
     		se_cmd->pr_res_key = deve->pr_res_key;
     		se_cmd->orig_fe_lun = unpacked_lun;
    +		se_cmd->se_cmd_flags |= SCF_SE_LUN_CMD;
    +		se_cmd->lun_ref_active = true;
     	}
    +out_unlock:
     	rcu_read_unlock();
     
     	if (!se_lun) {
    @@ -182,9 +191,6 @@ int transport_lookup_tmr_lun(struct se_cmd *se_cmd, u64 unpacked_lun)
     			unpacked_lun);
     		return -ENODEV;
     	}
    -	/*
    -	 * XXX: Add percpu se_lun->lun_ref reference count for TMR
    -	 */
     	se_cmd->se_dev = rcu_dereference_raw(se_lun->lun_se_dev);
     	se_tmr->tmr_dev = rcu_dereference_raw(se_lun->lun_se_dev);
     
    diff --git a/drivers/target/target_core_transport.c b/drivers/target/target_core_transport.c
    index f16a789..83bfc97 100644
    --- a/drivers/target/target_core_transport.c
    +++ b/drivers/target/target_core_transport.c
    @@ -1588,6 +1588,7 @@ static void target_complete_tmr_failure(struct work_struct *work)
     	se_cmd->se_tmr_req->response = TMR_LUN_DOES_NOT_EXIST;
     	se_cmd->se_tfo->queue_tm_rsp(se_cmd);
     
    +	transport_lun_remove_cmd(se_cmd);
     	transport_cmd_check_stop_to_fabric(se_cmd);
     }
     
    @@ -3199,6 +3200,7 @@ static void target_tmr_work(struct work_struct *work)
     	cmd->se_tfo->queue_tm_rsp(cmd);
     
     check_stop:
    +	transport_lun_remove_cmd(cmd);
     	transport_cmd_check_stop_to_fabric(cmd);
     }
     
    @@ -3221,6 +3223,7 @@ int transport_generic_handle_tmr(
     		pr_warn_ratelimited("handle_tmr caught CMD_T_ABORTED TMR %d"
     			"ref_tag: %llu tag: %llu\n", cmd->se_tmr_req->function,
     			cmd->se_tmr_req->ref_task_tag, cmd->tag);
    +		transport_lun_remove_cmd(cmd);
     		transport_cmd_check_stop_to_fabric(cmd);
     		return 0;
     	}
    -- 
    1.9.1
    
    

  reply	other threads:[~2017-06-07  1:13 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-03 22:10 [PATCH 0/3] target: Add TARGET_SCF_LOOKUP_LUN_FROM_TAG support Nicholas A. Bellinger
2017-06-03 22:10 ` [PATCH 1/3] target: Add support for TMR percpu reference counting Nicholas A. Bellinger
2017-06-07  1:13   ` Tran, Quinn [this message]
2017-06-03 22:10 ` [PATCH 2/3] target: Add TARGET_SCF_LOOKUP_LUN_FROM_TAG support for ABORT_TASK Nicholas A. Bellinger
2017-06-05 15:57   ` Bart Van Assche
2017-06-09  5:52     ` Nicholas A. Bellinger
2017-06-09 18:15       ` Bart Van Assche
2017-06-07  1:13   ` Tran, Quinn
2017-06-03 22:10 ` [PATCH 3/3] qla2xxx: Convert QLA_TGT_ABTS to TARGET_SCF_LOOKUP_LUN_FROM_TAG Nicholas A. Bellinger
2017-06-07  1:12   ` Tran, Quinn
2017-06-05 15:38 ` [PATCH 0/3] target: Add TARGET_SCF_LOOKUP_LUN_FROM_TAG support Madhani, Himanshu
2017-06-07  5:02 ` Madhani, Himanshu
2017-06-09  5:39   ` Nicholas A. Bellinger

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=386D71C4-353C-4237-8345-3043E8773EAF@cavium.com \
    --to=quinn.tran@cavium.com \
    --cc=Himanshu.Madhani@cavium.com \
    --cc=hare@suse.com \
    --cc=hch@lst.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=mchristi@redhat.com \
    --cc=nab@linux-iscsi.org \
    --cc=target-devel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).