rbd: set max_segments to USHRT_MAX
Subsystems (2)
Ilya Dryomov
maintainerPATCH 1/1 rbd: set max_segments to USHRT_MAX
Commit d3834fefcfe5 ("rbd: bump queue_max_segments") bumped max_segments (unsigned short) to max_hw_sectors (unsigned int). max_hw_sectors is set to the number of 512-byte sectors in an object and overflows unsigned short for 32M (largest possible) objects, making the block layer resort to handing us single segment (i.e. single page or even smaller) bios in that case.
--- drivers/block/rbd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/block/rbd.c +1 -1
@@ -4381,7 +4381,7 @@ static int rbd_init_disk(struct rbd_device *rbd_dev) segment_size =rbd_obj_bytes (&rbd_dev->header);blk_queue_max_hw_sectors (q, segment_size /SECTOR_SIZE ); q->limits.max_sectors =queue_max_hw_sectors (q); -blk_queue_max_segments (q, segment_size /SECTOR_SIZE ); +blk_queue_max_segments (q,USHRT_MAX );blk_queue_max_segment_size (q, segment_size);blk_queue_io_min (q, segment_size);blk_queue_io_opt (q, segment_size);
Signature · 1 line
2.4.3
Quoted 10 lines · Ilya Dryomov
Commit
d3834fefcfe5("rbd: bumpqueue_max_segments") bumpedmax_segments(unsigned short) tomax_hw_sectors(unsigned int).max_hw_sectorsis set to the number of 512-byte sectors in an object and overflows unsigned short for 32M (largest possible) objects, making the block layer resort to handing us single segment (i.e. single page or even smaller) bios in that case.Fixes d3834fefcfe5 ("rbd: bump queue_max_segments")Signed-off-by Ilya Dryomov <[email protected]>
Is it OK for max_segments to be bigger than max_hw_sectors?
I didn't investigate but the question occurred to me, since you're fixing max_segments regardless of segment size, but not doing that to the other limits being set.
If that is not a problem:
Quoted 18 lines
--- drivers/block/rbd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/block/rbd.c +1
-1@@ -4381,7 +4381,7 @@ static int rbd_init_disk(struct rbd_device *rbd_dev) segment_size =rbd_obj_bytes (&rbd_dev->header);blk_queue_max_hw_sectors (q, segment_size /SECTOR_SIZE ); q->limits.max_sectors =queue_max_hw_sectors (q); -blk_queue_max_segments (q, segment_size /SECTOR_SIZE ); +blk_queue_max_segments (q,USHRT_MAX );blk_queue_max_segment_size (q, segment_size);blk_queue_io_min (q, segment_size);blk_queue_io_opt (q, segment_size);
Ilya Dryomov
maintainerQuoted 8 lines · Alex Elder
Quoted 7 lines · Ilya Dryomov
Commit
d3834fefcfe5("rbd: bumpqueue_max_segments") bumpedmax_segments(unsigned short) tomax_hw_sectors(unsigned int).max_hw_sectorsis set to the number of 512-byte sectors in an object and overflows unsigned short for 32M (largest possible) objects, making the block layer resort to handing us single segment (i.e. single page or even smaller) bios in that case.
Quoted 5 lines
Quoted 3 lines
Fixes d3834fefcfe5 ("rbd: bump queue_max_segments")Signed-off-by Ilya Dryomov <[email protected]>Is it OK for
max_segmentsto be bigger thanmax_hw_sectors?
I think so. max_hw_sectors (or rather max_sectors -- a soft limit capped by max_hw_sectors hard limit) limits the size of the request. max_segments limits the number of segments (~ bvecs) and rbd is fine with any number.
Quoted 4 lines
I didn't investigate but the question occurred to me, since you're fixing
max_segmentsregardless of segment size, but not doing that to the other limits being set.
Yeah, queue_max_segment_size could be UINT_MAX and we could probably disable SG merging (BLK_MQ_F_SG_MERGE) which we don't benefit from. This is a small fix intended for stable though.
Thanks for the review!
Ilya