ublk: remove segment count and size limits
Subsystems (2)
PATCH 1/1 ublk: remove segment count and size limits
ublk_drv currently creates block devices with the default max_segments and max_segment_size limits of BLK_MAX_SEGMENTS (128) and BLK_MAX_SEGMENT_SIZE (65536) respectively. These defaults can artificially constrain the I/O size seen by the ublk server - for example, suppose that the ublk server has configured itself to accept I/Os up to 1M and the application is also issuing 1M sized I/Os. If the I/O buffer used by the application is backed by 4K pages, the buffer could consist of up to 1M / 4K = 256 physically discontiguous segments (even if the buffer is virtually contiguous). As such, the I/O could exceed the default max_segments limit and get split. This can cause unnecessary performance issues if the ublk server is optimized to handle 1M I/Os. The block layer's segment count/size limits exist to model hardware constraints which don't exist in ublk_drv's case, so just remove those limits for the block devices created by ublk_drv.
--- drivers/block/ublk_drv.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/block/ublk_drv.c +3 -0
@@ -2209,6 +2209,9 @@ static int ublk_ctrl_start_dev(struct ublk_device *ub, struct io_uring_cmd *cmd) lim.max_zone_append_sectors = p->max_zone_append_sectors; } + lim.max_segments =USHRT_MAX ; + lim.max_segment_size =UINT_MAX ; +if (wait_for_completion_interruptible (&ub->completion) !=0 )return -EINTR ;
Signature · 1 line
2.34.1
Quoted 26 lines · Uday Shankar
ublk_drvcurrently creates block devices with the defaultmax_segmentsandmax_segment_sizelimits ofBLK_MAX_SEGMENTS(128) andBLK_MAX_SEGMENT_SIZE(65536) respectively. These defaults can artificially constrain the I/O size seen by the ublk server - for example, suppose that the ublk server has configured itself to accept I/Os up to 1M and the application is also issuing 1M sized I/Os. If the I/O buffer used by the application is backed by 4K pages, the buffer could consist of up to 1M / 4K = 256 physically discontiguous segments (even if the buffer is virtually contiguous). As such, the I/O could exceed the defaultmax_segmentslimit and get split. This can cause unnecessary performance issues if the ublk server is optimized to handle 1M I/Os. The block layer's segment count/size limits exist to model hardware constraints which don't exist in ublk_drv's case, so just remove those limits for the block devices created byublk_drv.Signed-off-by Uday Shankar <[email protected]>Reviewed-by Riley Thomasson <[email protected]>--- drivers/block/ublk_drv.c | 3 +++ 1 file changed, 3 insertions(+)drivers/block/ublk_drv.c +0
-0
drivers/block/ublk_drv.c static int ublk_ctrl_start_dev(struct ublk_device *ub, struct io_uring_cmd *cmd) · line 2213
Quoted 5 lines
drivers/block/ublk_drv.c +2
-0@@ -2209,6 +2209,9 @@ static int ublk_ctrl_start_dev(struct ublk_device *ub, struct io_uring_cmd *cmd) lim.max_zone_append_sectors = p->max_zone_append_sectors; } + lim.max_segments =USHRT_MAX ; + lim.max_segment_size =UINT_MAX ;
Thanks,
Ming
drivers/block/ublk_drv.c static int ublk_ctrl_start_dev(struct ublk_device *ub, struct io_uring_cmd *cmd) · line 2213
Quoted 2 lines · Uday Shankar
drivers/block/ublk_drv.c +2
-0+ lim.max_segments =USHRT_MAX ; + lim.max_segment_size =UINT_MAX ;
Please initialize thes at the top of the function as part of the declaration for lim, like all the other unconditional limits.