BLK_DEV_MAX_SECTORS is the largest disk capacity the block layer supports: set_capacity() truncates larger capacities and add_disk() rejects them. It is defined in block/blk.h, so drivers cannot use it to validate a capacity they get from the user before calling set_capacity(). Move it to . The next patch uses it in null_blk to reject a configured device size that is too large. No functional change. Cc: stable@vger.kernel.org # 6.14.x Signed-off-by: Yingjie Wang --- block/blk.h | 1 - include/linux/blkdev.h | 6 ++++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/block/blk.h b/block/blk.h index 105fff157bfb..13fa24aa05ea 100644 --- a/block/blk.h +++ b/block/blk.h @@ -23,7 +23,6 @@ struct elv_change_ctx; */ #define BLK_DEF_MAX_SECTORS_CAP (SZ_4M >> SECTOR_SHIFT) -#define BLK_DEV_MAX_SECTORS (LLONG_MAX >> 9) #define BLK_MIN_SEGMENT_SIZE 4096 /* Max future timer expiry for timeouts */ diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h index 215753171cef..75d640cc0e9a 100644 --- a/include/linux/blkdev.h +++ b/include/linux/blkdev.h @@ -834,6 +834,12 @@ static inline bool bdev_read_only(struct block_device *bdev) return bdev_test_flag(bdev, BD_READ_ONLY) || get_disk_ro(bdev->bd_disk); } +/* + * Largest supported disk capacity in sectors: the capacity in bytes must fit + * in a loff_t. + */ +#define BLK_DEV_MAX_SECTORS (LLONG_MAX >> 9) + bool set_capacity_and_notify(struct gendisk *disk, sector_t size); void disk_force_media_change(struct gendisk *disk); void bdev_mark_dead(struct block_device *bdev, bool surprise); base-commit: 5a29cfaf51105039d156dd8a61d2783e8b653667 -- 2.43.0