block: Increase BLK_DEF_MAX_SECTORS_CAP
PATCH 1/1 block: Increase BLK_DEF_MAX_SECTORS_CAP
Back in 2015, commit d2be537c3ba3 ("block: bump BLK_DEF_MAX_SECTORS to 2560") increased the default maximum size of a block device I/O to 2560 sectors (1280 KiB) to "accommodate a 10-data-disk stripe write with chunk size 128k". This choice is rather arbitrary and since then, improvements to the block layer have software RAID drivers correctly advertize their stripe width through chunk_sectors and abuses of BLK_DEF_MAX_SECTORS_CAP by drivers (to set the HW limit rather than the default user controlled maximum I/O size) have been fixed.
Since many block devices can benefit from a larger value of BLK_DEF_MAX_SECTORS_CAP, and in particular HDDs, increase this value to be 4MiB, or 8192 sectors.
--- include/linux/blkdev.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
include/linux/blkdev.h +1 -1
@@ -1238,7 +1238,7 @@ enum blk_default_limits {* Not to be confused with the max_hw_sector limit that is entirely * controlled by the driver, usually based on hardware limits. */ -#define BLK_DEF_MAX_SECTORS_CAP 2560u +#define BLK_DEF_MAX_SECTORS_CAP 8192ustatic inline struct queue_limits *bdev_limits (struct block_device *bdev) {
Signature · 1 line
2.49.0
Quoted 24 lines · Damien Le Moal
Back in 2015, commit
d2be537c3ba3("block: bumpBLK_DEF_MAX_SECTORSto 2560") increased the default maximum size of a block device I/O to 2560 sectors (1280 KiB) to "accommodate a 10-data-disk stripe write with chunk size 128k". This choice is rather arbitrary and since then, improvements to the block layer have software RAID drivers correctly advertize their stripe width throughchunk_sectorsand abuses ofBLK_DEF_MAX_SECTORS_CAPby drivers (to set the HW limit rather than the default user controlled maximum I/O size) have been fixed.Since many block devices can benefit from a larger value of
BLK_DEF_MAX_SECTORS_CAP, and in particular HDDs, increase this value to be 4MiB, or 8192 sectors.Suggested-by Martin K . Petersen <[email protected]>Signed-off-by Damien Le Moal <[email protected]>--- include/linux/blkdev.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)include/linux/blkdev.h +0
-0
include/linux/blkdev.h enum blk_default_limits { · line 1241
Quoted 5 lines
include/linux/blkdev.h +1
-1@@ -1238,7 +1238,7 @@ enum blk_default_limits {* Not to be confused with the max_hw_sector limit that is entirely * controlled by the driver, usually based on hardware limits. */ -#define BLK_DEF_MAX_SECTORS_CAP 2560u +#define BLK_DEF_MAX_SECTORS_CAP 8192u
The change itself looks good, but the definition should belong to block layer internal, so why not move it into internal header?
thanks,
Ming
Damien,
Quoted 3 lines
Since many block devices can benefit from a larger value of
BLK_DEF_MAX_SECTORS_CAP, and in particular HDDs, increase this value to be 4MiB, or 8192 sectors.
Signature · 1 line
Martin K. Petersen
Quoted 20 lines · Ming Lei
Quoted 19 lines · Damien Le Moal
Back in 2015, commit
d2be537c3ba3("block: bumpBLK_DEF_MAX_SECTORSto 2560") increased the default maximum size of a block device I/O to 2560 sectors (1280 KiB) to "accommodate a 10-data-disk stripe write with chunk size 128k". This choice is rather arbitrary and since then, improvements to the block layer have software RAID drivers correctly advertize their stripe width throughchunk_sectorsand abuses ofBLK_DEF_MAX_SECTORS_CAPby drivers (to set the HW limit rather than the default user controlled maximum I/O size) have been fixed.Since many block devices can benefit from a larger value of
BLK_DEF_MAX_SECTORS_CAP, and in particular HDDs, increase this value to be 4MiB, or 8192 sectors.Suggested-by Martin K . Petersen <[email protected]>Signed-off-by Damien Le Moal <[email protected]>--- include/linux/blkdev.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 13 lines
include/linux/blkdev.h enum blk_default_limits { · line 1241
Quoted 10 lines
include/linux/blkdev.h +1
-1@@ -1238,7 +1238,7 @@ enum blk_default_limits {* Not to be confused with the max_hw_sector limit that is entirely * controlled by the driver, usually based on hardware limits. */ -#define BLK_DEF_MAX_SECTORS_CAP 2560u +#define BLK_DEF_MAX_SECTORS_CAP 8192uThe change itself looks good, but the definition should belong to block layer internal, so why not move it into internal header?
Good point. Now that no driver uses this macro directly, we can do that. I will send a V2.
Signature · 2 lines
Damien Le Moal Western Digital Research
Quoted 15 lines · Damien Le Moal
Since many block devices can benefit from a larger value of
BLK_DEF_MAX_SECTORS_CAP, and in particular HDDs, increase this value to be 4MiB, or 8192 sectors.Suggested-by Martin K . Petersen <[email protected]>Signed-off-by Damien Le Moal <[email protected]>--- include/linux/blkdev.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)include/linux/blkdev.h +0
-0
include/linux/blkdev.h enum blk_default_limits { · line 1241
Quoted 5 lines
include/linux/blkdev.h +1
-1@@ -1238,7 +1238,7 @@ enum blk_default_limits {* Not to be confused with the max_hw_sector limit that is entirely * controlled by the driver, usually based on hardware limits. */ -#define BLK_DEF_MAX_SECTORS_CAP 2560u +#define BLK_DEF_MAX_SECTORS_CAP 8192u
While we're at nitpicking, maybe define this as
(SZ_4M >> SECTOR_SHIFT)
to make it a bit more readable?
Otherwise this looks good, the odd number was always rather weird.
Quoted 24 lines · Christoph Hellwig
Quoted 15 lines · Damien Le Moal
Since many block devices can benefit from a larger value of
BLK_DEF_MAX_SECTORS_CAP, and in particular HDDs, increase this value to be 4MiB, or 8192 sectors.Suggested-by Martin K . Petersen <[email protected]>Signed-off-by Damien Le Moal <[email protected]>--- include/linux/blkdev.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)include/linux/blkdev.h +0
-0include/linux/blkdev.h enum blk_default_limits { · line 1241
Quoted 5 lines
include/linux/blkdev.h +1
-1@@ -1238,7 +1238,7 @@ enum blk_default_limits {* Not to be confused with the max_hw_sector limit that is entirely * controlled by the driver, usually based on hardware limits. */ -#define BLK_DEF_MAX_SECTORS_CAP 2560u +#define BLK_DEF_MAX_SECTORS_CAP 8192uWhile we're at nitpicking, maybe define this as
Quoted 3 lines
(SZ_4M >> SECTOR_SHIFT)to make it a bit more readable?
Sure thing.
Quoted 4 lines
Otherwise this looks good, the odd number was always rather weird.
Signature · 2 lines
Damien Le Moal Western Digital Research