make BLK_DEF_MAX_SECTORS less confusing
Subsystems (3)
Hi Jens,
this series removes a few abuses of BLK_DEF_MAX_SECTORS and then renames and documents that constant to make it's use clear.
Diffstat:
block/blk-settings.c | 2 +- block/blk-sysfs.c | 2 +- drivers/block/aoe/aoeblk.c | 3 ++- drivers/block/loop.c | 3 ++- drivers/block/null_blk/main.c | 12 ++---------- drivers/scsi/sd.c | 2 +- include/linux/blkdev.h | 9 ++++++++- 7 files changed, 17 insertions(+), 16 deletions(-)
PATCH 1/4 null_blk: don't cap max_hw_sectors to BLK_DEF_MAX_SECTORS
null_blk has some rather odd capping of the max_hw_sectors value to BLK_DEF_MAX_SECTORS, which doesn't make sense - max_hw_sector is the hardware limit, and BLK_DEF_MAX_SECTORS despite the confusing name is the default cap for the max_sectors field used for normal file system I/O.
Remove all the capping, and simply leave it to the block layer or user to take up or not all of that for file system I/O.
--- drivers/block/null_blk/main.c | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-)
drivers/block/null_blk/main.c +2 -10
@@ -2186,10 +2186,8 @@ static int null_add_dev(struct nullb_device *dev)blk_queue_logical_block_size (nullb->q, dev->blocksize);blk_queue_physical_block_size (nullb->q, dev->blocksize); -if (!dev->max_sectors) - dev->max_sectors =queue_max_hw_sectors (nullb->q); - dev->max_sectors =min (dev->max_sectors,BLK_DEF_MAX_SECTORS ); -blk_queue_max_hw_sectors (nullb->q, dev->max_sectors); +if (dev->max_sectors) +blk_queue_max_hw_sectors (nullb->q, dev->max_sectors);if (dev->virt_boundary)blk_queue_virt_boundary (nullb->q,PAGE_SIZE -1 );
@@ -2289,12 +2287,6 @@ static int __init null_init(void) g_bs =PAGE_SIZE ; } -if (g_max_sectors >BLK_DEF_MAX_SECTORS ) { -pr_warn ("invalid max sectors\n" ); -pr_warn ("defaults max sectors to %u\n" ,BLK_DEF_MAX_SECTORS ); - g_max_sectors =BLK_DEF_MAX_SECTORS ; - } -if (g_home_node !=NUMA_NO_NODE && g_home_node >= nr_online_nodes) {pr_err ("invalid home_node value\n" ); g_home_node =NUMA_NO_NODE ;
Signature · 1 line
2.39.2
PATCH 2/4 aoe: don't abuse BLK_DEF_MAX_SECTORS
In reply to Christoph HellwigBLK_DEF_MAX_SECTORS despite the confusing name is the default cap for the max_sectors limits. Don't use it to initialize max_hw_setors, which is a hardware / driver capacility.
--- drivers/block/aoe/aoeblk.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/block/aoe/aoeblk.c +2 -1
@@ -383,7 +383,8 @@ aoeblk_gdalloc(void *vp)WARN_ON (d->flags &DEVFL_TKILL );WARN_ON (d->gd);WARN_ON (d->flags &DEVFL_UP ); -blk_queue_max_hw_sectors (gd->queue,BLK_DEF_MAX_SECTORS ); +/* random number picked from the history block max_sectors cap */ +blk_queue_max_hw_sectors (gd->queue,2560u );blk_queue_io_opt (gd->queue,SZ_2M ); d->bufpool = mp; d->blkq = gd->queue;
Signature · 1 line
2.39.2
PATCH 3/4 loop: don't abuse BLK_DEF_MAX_SECTORS
In reply to Christoph HellwigBLK_DEF_MAX_SECTORS despite the confusing name is the default cap for the max_sectors limits. Don't use it to initialize max_hw_setors, which is a hardware / driver capacility.
--- drivers/block/loop.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/block/loop.c +2 -1
@@ -2038,7 +2038,8 @@ static int loop_add(int i) } lo->lo_queue = lo->lo_disk->queue; -blk_queue_max_hw_sectors (lo->lo_queue,BLK_DEF_MAX_SECTORS ); +/* random number picked from the history block max_sectors cap */ +blk_queue_max_hw_sectors (lo->lo_queue,2560u );/* * By default, we do buffer IO, so it doesn't make sense to enable
Signature · 1 line
2.39.2
PATCH 4/4 block: rename and document BLK_DEF_MAX_SECTORS
In reply to Christoph HellwigGive BLK_DEF_MAX_SECTORS a _CAP postfix and document what it is used for.
--- block/blk-settings.c | 2 +- block/blk-sysfs.c | 2 +- drivers/scsi/sd.c | 2 +- include/linux/blkdev.h | 9 ++++++++- 4 files changed, 11 insertions(+), 4 deletions(-)
block/blk-settings.c +1 -1
@@ -139,7 +139,7 @@ void blk_queue_max_hw_sectors(struct request_queue *q, unsigned int max_hw_sectoif (limits->max_user_sectors) max_sectors =min (max_sectors, limits->max_user_sectors);else - max_sectors =min (max_sectors,BLK_DEF_MAX_SECTORS ); + max_sectors =min (max_sectors,BLK_DEF_MAX_SECTORS_CAP ); max_sectors =round_down (max_sectors, limits->logical_block_size >>SECTOR_SHIFT );
block/blk-sysfs.c +1 -1
@@ -241,7 +241,7 @@ queue_max_sectors_store(struct request_queue *q, const char *page, size_t count)if (max_sectors_kb ==0 ) { q->limits.max_user_sectors =0 ; max_sectors_kb =min (max_hw_sectors_kb, -BLK_DEF_MAX_SECTORS >>1 ); +BLK_DEF_MAX_SECTORS_CAP >>1 ); }else {if (max_sectors_kb > max_hw_sectors_kb || max_sectors_kb < page_kb)
drivers/scsi/sd.c +1 -1
@@ -3500,7 +3500,7 @@ static int sd_revalidate_disk(struct gendisk *disk) }else { q->limits.io_opt =0 ; rw_max =min_not_zero (logical_to_sectors (sdp, dev_max), - (sector_t )BLK_DEF_MAX_SECTORS ); + (sector_t )BLK_DEF_MAX_SECTORS_CAP ); }/*
include/linux/blkdev.h +8 -1
@@ -1056,7 +1056,14 @@ enum blk_default_limits { BLK_SEG_BOUNDARY_MASK = 0xFFFFFFFFUL, }; -#define BLK_DEF_MAX_SECTORS 2560u +/* +* Default upper limit for the software max_sectors limit used for +* regular file system I/O. This can be increased through sysfs. +* +* 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 2560ustatic inline unsigned long queue_segment_boundary (const struct request_queue *q) {
Signature · 1 line
2.39.2
Quoted 13 lines · Christoph Hellwig
this series removes a few abuses of
BLK_DEF_MAX_SECTORSand then renames and documents that constant to make it's use clear.Diffstat:
block/blk-settings.c | 2 +- block/blk-sysfs.c | 2 +- drivers/block/aoe/aoeblk.c | 3 ++- drivers/block/loop.c | 3 ++- drivers/block/null_blk/main.c | 12 ++---------- drivers/scsi/sd.c | 2 +- include/linux/blkdev.h | 9 ++++++++- 7 files changed, 17 insertions(+), 16 deletions(-)
Quoted 1 line
[...]
Applied, thanks!
[1/4] null_blk: don't cap max_hw_sectors to BLK_DEF_MAX_SECTORS
commit: 9a9525de865410047fa962867b4fcd33943b206f
[2/4] aoe: don't abuse BLK_DEF_MAX_SECTORS
commit: 3888b2ee6262616dbcbf902bc171963fe345da87
[3/4] loop: don't abuse BLK_DEF_MAX_SECTORS
commit: 3d77976c3a8586ab1fb6845e2061588b7d04934f
[4/4] block: rename and document BLK_DEF_MAX_SECTORS
commit: d6b9f4e6f7fb589d8024a31cc4883d15d0c8def4Best regards,
Signature · 1 line
Jens Axboe