Skip to contentSkip to conversation

block: Increase BLK_DEF_MAX_SECTORS_CAP

PATCH Superseded Damien Le Moal 4 participants 6 messages Jun 17, 2025 – Jun 18, 2025 Block layer

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

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
index 85aab8bc96e7..7c35b2462048 100644
@@ -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
 
 static inline struct queue_limits *bdev_limits(struct block_device *bdev)
 {
Signature · 1 line
2.49.0
#1 lore raw
Quoted 24 lines · Damien Le Moal

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 +0 -0
index 85aab8bc96e7..7c35b2462048 100644

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

#2 lore raw
Quoted 20 lines · Ming Lei
Quoted 19 lines · Damien Le Moal

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(-)
Quoted 13 lines

include/linux/blkdev.h enum blk_default_limits { · line 1241

Quoted 10 lines
include/linux/blkdev.h +1 -1
index 85aab8bc96e7..7c35b2462048 100644
@@ -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?

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
#4 lore raw
In reply to Damien Le Moal
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.

---
 include/linux/blkdev.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
include/linux/blkdev.h +0 -0
index 85aab8bc96e7..7c35b2462048 100644

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.

#5 lore raw
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.

---
 include/linux/blkdev.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
include/linux/blkdev.h +0 -0
index 85aab8bc96e7..7c35b2462048 100644

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

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