linux-scsi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Fam Zheng <famz@redhat.com>
To: "Martin K. Petersen" <martin.petersen@oracle.com>
Cc: linux-scsi@vger.kernel.org, borntraeger@de.ibm.com
Subject: Re: [PATCH] sd: Optimal I/O size is in bytes, not sectors
Date: Thu, 12 May 2016 12:04:33 +0800	[thread overview]
Message-ID: <20160512040433.GA20240@ad.usersys.redhat.com> (raw)
In-Reply-To: <1453305683-22424-1-git-send-email-martin.petersen@oracle.com>

On Wed, 01/20 11:01, Martin K. Petersen wrote:
> Commit ca369d51b3e1 ("block/sd: Fix device-imposed transfer length
> limits") accidentally switched optimal I/O size reporting from bytes to
> block layer sectors.
> 
> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
> Reported-by: Christian Borntraeger <borntraeger@de.ibm.com>
> ---
>  drivers/scsi/sd.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
> index 4e08d1cd704d..ec163d08f6c3 100644
> --- a/drivers/scsi/sd.c
> +++ b/drivers/scsi/sd.c
> @@ -2893,7 +2893,7 @@ static int sd_revalidate_disk(struct gendisk *disk)
>  	    sdkp->opt_xfer_blocks <= SD_DEF_XFER_BLOCKS &&
>  	    sdkp->opt_xfer_blocks * sdp->sector_size >= PAGE_CACHE_SIZE)
>  		rw_max = q->limits.io_opt =
> -			logical_to_sectors(sdp, sdkp->opt_xfer_blocks);
> +			sdkp->opt_xfer_blocks * sdp->sector_size;

Hi Martin,

This looks wrong to me, maybe I'm missing the obvious? Here
sdkp->opt_xfer_blocks is in block size unit, and rw_max is in byte unit.

Following is:

	else
		rw_max = BLK_DEF_MAX_SECTORS;

Which seems in sector unit, and is already making above change suspicious, and
further down:

	/* Combine with controller limits */
	q->limits.max_sectors = min(rw_max, queue_max_hw_sectors(q));

looks like a unit mismatch to me.  IIUC q->limits.max_sectors _is_ in sector
unit, similar to queue_max_hw_sectors().

Is the error reported by Christian fixed just because we are setting an
incorrect high max?

(I noticed this when I see I/O error because a virtio-scsi guest starts to
issue large reads that are rejected by host device.)

Fam

  parent reply	other threads:[~2016-05-12  4:04 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-01-20 16:01 [PATCH] sd: Optimal I/O size is in bytes, not sectors Martin K. Petersen
2016-01-20 16:11 ` Johannes Thumshirn
2016-01-20 16:19 ` James Bottomley
2016-01-20 16:40   ` Martin K. Petersen
2016-01-20 16:47     ` James Bottomley
2016-01-22  8:16       ` Greg Kroah-Hartman
2016-01-20 16:19 ` Matthew R. Ochs
2016-01-20 17:17 ` Ewan Milne
2016-01-20 18:28 ` Christian Borntraeger
2016-05-12  4:04 ` Fam Zheng [this message]
2016-05-12 17:13   ` Tom Yan
2016-05-13  2:32   ` 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=20160512040433.GA20240@ad.usersys.redhat.com \
    --to=famz@redhat.com \
    --cc=borntraeger@de.ibm.com \
    --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).