Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1610291 > unrolled thread

[PATCH v2] sd: Consider max_xfer_blocks if opt_xfer_blocks is unusable

Started byFam Zheng <famz@redhat.com>
First post2017-03-28 06:50 +0200
Last post2017-03-31 06:10 +0200
Articles 5 — 2 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH v2] sd: Consider max_xfer_blocks if opt_xfer_blocks is unusable Fam Zheng <famz@redhat.com> - 2017-03-28 06:50 +0200
    Re: [PATCH v2] sd: Consider max_xfer_blocks if opt_xfer_blocks is unusable "Martin K. Petersen" <martin.petersen@oracle.com> - 2017-03-30 04:40 +0200
      Re: [PATCH v2] sd: Consider max_xfer_blocks if opt_xfer_blocks is  unusable Fam Zheng <famz@redhat.com> - 2017-03-30 06:20 +0200
        Re: [PATCH v2] sd: Consider max_xfer_blocks if opt_xfer_blocks is unusable "Martin K. Petersen" <martin.petersen@oracle.com> - 2017-03-30 17:40 +0200
          Re: [PATCH v2] sd: Consider max_xfer_blocks if opt_xfer_blocks is  unusable Fam Zheng <famz@redhat.com> - 2017-03-31 06:10 +0200

#1610291 — [PATCH v2] sd: Consider max_xfer_blocks if opt_xfer_blocks is unusable

FromFam Zheng <famz@redhat.com>
Date2017-03-28 06:50 +0200
Subject[PATCH v2] sd: Consider max_xfer_blocks if opt_xfer_blocks is unusable
Message-ID<tpReV-2lO-1@gated-at.bofh.it>
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>

---

v2: Fix granularity mismatch. [Martin]
---
 drivers/scsi/sd.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
index fcfeddc..a5c7e67 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, logical_to_sectors(sdp, dev_max));
 
 	/* Combine with controller limits */
 	q->limits.max_sectors = min(rw_max, queue_max_hw_sectors(q));
-- 
2.9.3

[toc] | [next] | [standalone]


#1612501

From"Martin K. Petersen" <martin.petersen@oracle.com>
Date2017-03-30 04:40 +0200
Message-ID<tqyad-7Yo-3@gated-at.bofh.it>
In reply to#1610291
Fam Zheng <famz@redhat.com> writes:

Fam,

> diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
> index fcfeddc..a5c7e67 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, logical_to_sectors(sdp, dev_max));
>  
>  	/* Combine with controller limits */
>  	q->limits.max_sectors = min(rw_max, queue_max_hw_sectors(q));

Instead of updating rw_max twice, how about:

} else
	rw_max = min_not_zero(logical_to_sectors(sdp, dev_max),
                              BLK_DEF_MAX_SECTORS);

?

-- 
Martin K. Petersen	Oracle Linux Engineering

[toc] | [prev] | [next] | [standalone]


#1612555 — Re: [PATCH v2] sd: Consider max_xfer_blocks if opt_xfer_blocks is unusable

FromFam Zheng <famz@redhat.com>
Date2017-03-30 06:20 +0200
SubjectRe: [PATCH v2] sd: Consider max_xfer_blocks if opt_xfer_blocks is unusable
Message-ID<tqzJ0-HD-13@gated-at.bofh.it>
In reply to#1612501
On Wed, 03/29 22:37, Martin K. Petersen wrote:
> Fam Zheng <famz@redhat.com> writes:
> 
> Fam,
> 
> > diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
> > index fcfeddc..a5c7e67 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, logical_to_sectors(sdp, dev_max));
> >  
> >  	/* Combine with controller limits */
> >  	q->limits.max_sectors = min(rw_max, queue_max_hw_sectors(q));
> 
> Instead of updating rw_max twice, how about:
> 
> } else
> 	rw_max = min_not_zero(logical_to_sectors(sdp, dev_max),
>                               BLK_DEF_MAX_SECTORS);

Yes, it is better. Is it okay to make the change when you apply?

Fam

[toc] | [prev] | [next] | [standalone]


#1613209

From"Martin K. Petersen" <martin.petersen@oracle.com>
Date2017-03-30 17:40 +0200
Message-ID<tqKl5-8nZ-49@gated-at.bofh.it>
In reply to#1612555
Fam Zheng <famz@redhat.com> writes:

>> 	rw_max = min_not_zero(logical_to_sectors(sdp, dev_max),
>>                               BLK_DEF_MAX_SECTORS);
>
> Yes, it is better. Is it okay to make the change when you apply?

Sure. Applied to 4.11/scsi-fixes.

-- 
Martin K. Petersen	Oracle Linux Engineering

[toc] | [prev] | [next] | [standalone]


#1613622 — Re: [PATCH v2] sd: Consider max_xfer_blocks if opt_xfer_blocks is unusable

FromFam Zheng <famz@redhat.com>
Date2017-03-31 06:10 +0200
SubjectRe: [PATCH v2] sd: Consider max_xfer_blocks if opt_xfer_blocks is unusable
Message-ID<tqW2S-7VW-13@gated-at.bofh.it>
In reply to#1613209
On Thu, 03/30 11:30, Martin K. Petersen wrote:
> Fam Zheng <famz@redhat.com> writes:
> 
> >> 	rw_max = min_not_zero(logical_to_sectors(sdp, dev_max),
> >>                               BLK_DEF_MAX_SECTORS);
> >
> > Yes, it is better. Is it okay to make the change when you apply?
> 
> Sure. Applied to 4.11/scsi-fixes.

Cool. Thanks!

Fam

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web