linux-scsi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Laurence Oberman <loberman@redhat.com>
To: Fam Zheng <famz@redhat.com>
Cc: linux-kernel@vger.kernel.org,
	"Martin K. Petersen" <martin.petersen@oracle.com>,
	linux-scsi@vger.kernel.org,
	"James E.J. Bottomley" <jejb@linux.vnet.ibm.com>
Subject: Re: [PATCH] sd: Consider max_xfer_blocks if opt_xfer_blocks is unusable
Date: Mon, 27 Mar 2017 12:06:51 -0400 (EDT)	[thread overview]
Message-ID: <1570359368.7021305.1490630811310.JavaMail.zimbra@redhat.com> (raw)
In-Reply-To: <20170327141831.20936-1-famz@redhat.com>



----- Original Message -----
> From: "Fam Zheng" <famz@redhat.com>
> To: linux-kernel@vger.kernel.org
> Cc: "Martin K. Petersen" <martin.petersen@oracle.com>, famz@redhat.com, linux-scsi@vger.kernel.org, "James E.J.
> Bottomley" <jejb@linux.vnet.ibm.com>
> Sent: Monday, March 27, 2017 10:18:31 AM
> Subject: [PATCH] sd: Consider max_xfer_blocks if opt_xfer_blocks is unusable
> 
> If device reports a small max_xfer_blocks and a zero opt_xfer_blocks, we
> end up using BLK_DEF_MAX_SECTORS, which is wrong and r/w of that size
> may get error.
> 
> Fixes: ca369d51b3e ("block/sd: Fix device-imposed transfer length limits")
> Signed-off-by: Fam Zheng <famz@redhat.com>
> ---
>  drivers/scsi/sd.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
> index fcfeddc..e2e21ab 100644
> --- a/drivers/scsi/sd.c
> +++ b/drivers/scsi/sd.c
> @@ -2957,6 +2957,7 @@ static int sd_revalidate_disk(struct gendisk *disk)
>  		rw_max = logical_to_sectors(sdp, sdkp->opt_xfer_blocks);
>  	} else
>  		rw_max = BLK_DEF_MAX_SECTORS;
> +	rw_max = min_not_zero(rw_max, dev_max);
>  
>  	/* Combine with controller limits */
>  	q->limits.max_sectors = min(rw_max, queue_max_hw_sectors(q));
> --
> 2.9.3
> 
> 
Looks good to me and addresses the issue we faced.
FInal confirmation this change is OK to come from Martin or James.

Reviewed-by: Laurence Oberman <loberman@redhat.com>

  reply	other threads:[~2017-03-27 16:07 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-27 14:18 [PATCH] sd: Consider max_xfer_blocks if opt_xfer_blocks is unusable Fam Zheng
2017-03-27 16:06 ` Laurence Oberman [this message]
2017-03-28  2:11 ` Martin K. Petersen

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=1570359368.7021305.1490630811310.JavaMail.zimbra@redhat.com \
    --to=loberman@redhat.com \
    --cc=famz@redhat.com \
    --cc=jejb@linux.vnet.ibm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=martin.petersen@oracle.com \
    /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).