linux-scsi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Lee Duncan <lduncan@suse.com>
To: "Nicholas A. Bellinger" <nab@daterainc.com>,
	target-devel <target-devel@vger.kernel.org>
Cc: linux-scsi <linux-scsi@vger.kernel.org>,
	Ilias Tsitsimpis <i.tsitsimpis@gmail.com>,
	James Bottomley <James.Bottomley@HansenPartnership.com>,
	Nicholas Bellinger <nab@linux-iscsi.org>
Subject: Re: [PATCH 1/2] target: Fix R_HOLDER bit usage for AllRegistrants
Date: Wed, 17 Dec 2014 23:01:37 -0800	[thread overview]
Message-ID: <54927BD1.3080805@suse.com> (raw)
In-Reply-To: <1418688544-18825-2-git-send-email-nab@daterainc.com>

On 12/15/2014 04:09 PM, Nicholas A. Bellinger wrote:
> From: Nicholas Bellinger <nab@linux-iscsi.org>
> 
> This patch fixes the usage of R_HOLDER bit for an All Registrants
> reservation in READ_FULL_STATUS, where only the registration who
> issued RESERVE was being reported as having an active reservation.
> 
> It changes core_scsi3_pri_read_full_status() to check ahead of the
> list walk of active registrations to see if All Registrants is active,
> and if so set R_HOLDER bit and scope/type fields for all active
> registrations.
> 
> Reported-by: Ilias Tsitsimpis <i.tsitsimpis@gmail.com>
> Cc: James Bottomley <James.Bottomley@HansenPartnership.com>
> Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
> ---
>  drivers/target/target_core_pr.c | 26 +++++++++++++++++++++++---
>  1 file changed, 23 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/target/target_core_pr.c b/drivers/target/target_core_pr.c
> index f91b6a1..c4a8da5 100644
> --- a/drivers/target/target_core_pr.c
> +++ b/drivers/target/target_core_pr.c
> @@ -3834,7 +3834,8 @@ core_scsi3_pri_read_full_status(struct se_cmd *cmd)
>  	unsigned char *buf;
>  	u32 add_desc_len = 0, add_len = 0, desc_len, exp_desc_len;
>  	u32 off = 8; /* off into first Full Status descriptor */
> -	int format_code = 0;
> +	int format_code = 0, pr_res_type = 0, pr_res_scope = 0;
> +	bool all_reg = false;
>  
>  	if (cmd->data_length < 8) {
>  		pr_err("PRIN SA READ_FULL_STATUS SCSI Data Length: %u"
> @@ -3851,6 +3852,19 @@ core_scsi3_pri_read_full_status(struct se_cmd *cmd)
>  	buf[2] = ((dev->t10_pr.pr_generation >> 8) & 0xff);
>  	buf[3] = (dev->t10_pr.pr_generation & 0xff);
>  
> +	spin_lock(&dev->dev_reservation_lock);
> +	if (dev->dev_pr_res_holder) {
> +		struct t10_pr_registration *pr_holder = dev->dev_pr_res_holder;
> +
> +		if (pr_holder->pr_res_type == PR_TYPE_WRITE_EXCLUSIVE_ALLREG ||
> +		    pr_holder->pr_res_type == PR_TYPE_EXCLUSIVE_ACCESS_ALLREG) {
> +			all_reg = true;
> +			pr_res_type = pr_holder->pr_res_type;
> +			pr_res_scope = pr_holder->pr_res_scope;
> +		}
> +	}
> +	spin_unlock(&dev->dev_reservation_lock);
> +
>  	spin_lock(&pr_tmpl->registration_lock);
>  	list_for_each_entry_safe(pr_reg, pr_reg_tmp,
>  			&pr_tmpl->registration_list, pr_reg_list) {
> @@ -3898,14 +3912,20 @@ core_scsi3_pri_read_full_status(struct se_cmd *cmd)
>  		 * reservation holder for PR_HOLDER bit.
>  		 *
>  		 * Also, if this registration is the reservation
> -		 * holder, fill in SCOPE and TYPE in the next byte.
> +		 * holder or there is an All Registrants reservation
> +		 * active, fill in SCOPE and TYPE in the next byte.
>  		 */
>  		if (pr_reg->pr_res_holder) {
>  			buf[off++] |= 0x01;
>  			buf[off++] = (pr_reg->pr_res_scope & 0xf0) |
>  				     (pr_reg->pr_res_type & 0x0f);
> -		} else
> +		} else if (all_reg) {
> +			buf[off++] |= 0x01;
> +			buf[off++] = (pr_res_scope & 0xf0) |
> +				     (pr_res_type & 0x0f);
> +		} else {
>  			off += 2;
> +		}
>  
>  		off += 4; /* Skip over reserved area */
>  		/*
> 
Passes my test suite now for All Registrants.

Tested-by: Lee Duncan <lduncan@suse.com>

  reply	other threads:[~2014-12-18  7:01 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-12-16  0:09 [PATCH 0/2] target: Fixes for AllRegistrants reservation handling Nicholas A. Bellinger
2014-12-16  0:09 ` [PATCH 1/2] target: Fix R_HOLDER bit usage for AllRegistrants Nicholas A. Bellinger
2014-12-18  7:01   ` Lee Duncan [this message]
2014-12-16  0:09 ` [PATCH 2/2] target: Avoid dropping AllRegistrants reservation during unregister Nicholas A. Bellinger
2014-12-18  7:02   ` Lee Duncan
2014-12-18 14:54 ` [PATCH 0/2] target: Fixes for AllRegistrants reservation handling Ilias Tsitsimpis
2014-12-18 16:53   ` Douglas Gilbert
2014-12-19  8:21     ` Nicholas A. Bellinger
2014-12-19  1:06   ` 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=54927BD1.3080805@suse.com \
    --to=lduncan@suse.com \
    --cc=James.Bottomley@HansenPartnership.com \
    --cc=i.tsitsimpis@gmail.com \
    --cc=linux-scsi@vger.kernel.org \
    --cc=nab@daterainc.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).