fix stacking of sd-imposed max_sectors
Subsystems (2)
Hi Jens,
this series fixes a regression in 6.10-rc report by Mike when using device mapper multipath on top of SCSI disks. It is due the sd driver not only setting the hard max_dev_sectors limit but also pre-setting a potentially lower max_sectors value.
Diffstat:
block/blk-settings.c | 2 ++ drivers/scsi/sd.c | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-)
PATCH 1/2 sd: also set max_user_sectors when setting max_sectors
sd can set a max_sectors value that is lower than the max_hw_sectors
limit based on the block limits VPD page. While this is rather unusual,
it used to work until the max_user_sectors field was split out to cleanly deal with conflicting hardware and user limits when the hardware limit changes. Also set max_user_sectors to ensure the limit can properly be stacked.
--- drivers/scsi/sd.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/scsi/sd.c +3 -1
@@ -3700,8 +3700,10 @@ static int sd_revalidate_disk(struct gendisk *disk)*/ if (sdkp->first_scan || q->limits.max_sectors > q->limits.max_dev_sectors || - q->limits.max_sectors > q->limits.max_hw_sectors) + q->limits.max_sectors > q->limits.max_hw_sectors) { q->limits.max_sectors = rw_max; + q->limits.max_user_sectors = rw_max; + } sdkp->first_scan =0 ;
Signature · 1 line
2.43.0
Re: [PATCH 1/2] sd: also set max_user_sectors when setting max_sectors
Christoph,
Quoted 3 lines
sd can set a
max_sectorsvalue that is lower than themax_hw_sectors
limit based on the block limits VPD page. While this is rather
unusual,
It's not particularly unusual. Virtually all arrays have a much smaller stripe or cache line size than what the average HBA can handle in one transfer. Using the device's preferred I/O size to configure max_sectors made a substantial difference performance-wise.
Quoted 4 lines
it used to work until the
max_user_sectorsfield was split out to cleanly deal with conflicting hardware and user limits when the hardware limit changes. Also setmax_user_sectorsto ensure the limit can properly be stacked.
Fine for a quick fix.
Signature · 1 line
Martin K. Petersen Oracle Linux Engineering
Re: [PATCH 1/2] sd: also set max_user_sectors when setting max_sectors
Quoted 11 lines · Martin K. Petersen
Christoph,
Quoted 3 lines
sd can set a
max_sectorsvalue that is lower than themax_hw_sectors
limit based on the block limits VPD page. While this is rather
unusual,It's not particularly unusual. Virtually all arrays have a much smaller stripe or cache line size than what the average HBA can handle in one transfer. Using the device's preferred I/O size to configure
max_sectorsmade a substantial difference performance-wise.
Well, in terms of Linux it is weird in that drivers weren't ever supposed to set max_sectors directly but only provide max_hw_sectors (although nbd also decreases it and rbd increases it in odd ways). Especially as we already have an opt_in limit for the optimal size.
I'll find a way to sort it out and build a grand unified and somewhat coherent theory out of it..
PATCH 2/2 block: stack max_user_sectors
In reply to Christoph HellwigThe max_user_sectors is one of the three factors determining the actual max_sectors limit for READ/WRITE requests. Because of that it needs to be stacked at least for the device mapper multi-path case where requests are directly inserted on the lower device. For SCSI disks this is important because the sd driver actually sets it's own advisory limit that is lower than max_hw_sectors based on the block limits VPD page. While this is a bit odd an unusual, the same effect can happen if a user or udev script tweaks the value manually.
--- block/blk-settings.c | 2 ++ 1 file changed, 2 insertions(+)
block/blk-settings.c +2 -0
@@ -611,6 +611,8 @@ int blk_stack_limits(struct queue_limits *t, struct queue_limits *b,unsigned int top, bottom, alignment, ret =0 ; t->max_sectors =min_not_zero (t->max_sectors, b->max_sectors); + t->max_user_sectors =min_not_zero (t->max_user_sectors, + b->max_user_sectors); t->max_hw_sectors =min_not_zero (t->max_hw_sectors, b->max_hw_sectors); t->max_dev_sectors =min_not_zero (t->max_dev_sectors, b->max_dev_sectors); t->max_write_zeroes_sectors = min(t->max_write_zeroes_sectors,
Signature · 1 line
2.43.0
Re: [PATCH 2/2] block: stack max_user_sectors
Christoph,
Quoted 4 lines
The
max_user_sectorsis one of the three factors determining the actualmax_sectorslimit for READ/WRITE requests. Because of that it needs to be stacked at least for the device mapper multi-path case where requests are directly inserted on the lower device.
Signature · 1 line
Martin K. Petersen Oracle Linux Engineering
Quoted 11 lines · Christoph Hellwig
this series fixes a regression in 6.10-rc report by Mike when using device mapper multipath on top of SCSI disks. It is due the sd driver not only setting the hard
max_dev_sectorslimit but also pre-setting a potentially lowermax_sectorsvalue.Diffstat:
block/blk-settings.c | 2 ++ drivers/scsi/sd.c | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-)[...]
Applied, thanks!
[1/2] sd: also set max_user_sectors when setting max_sectors
commit: bafea1c58b24be594d97841ced1b7ae0347bf6e3
[2/2] block: stack max_user_sectors
commit: e528bede6f4e6822afdf0fa80be46ea9199f0911Best regards,
Signature · 1 line
Jens Axboe