diff options
author | John Garry <john.g.garry@oracle.com> | 2024-07-08 09:16:48 +0000 |
---|---|---|
committer | Jens Axboe <axboe@kernel.dk> | 2024-07-09 00:00:17 -0600 |
commit | fe3d508ba95bc63adba661355115be340275c0d1 (patch) | |
tree | 3bdc8d5d24f1457da73ae129de10f455ee2e9aa2 /block/blk-settings.c | |
parent | 4ff3d01275dee10ed1f40c314ba5133e3c7a6e1b (diff) | |
download | lwn-fe3d508ba95bc63adba661355115be340275c0d1.tar.gz lwn-fe3d508ba95bc63adba661355115be340275c0d1.zip |
block: Validate logical block size in blk_validate_limits()
Some drivers validate that their own logical block size. It is no harm to
always do this, so validate in blk_validate_limits().
This allows us to remove the validation in most of those drivers.
Add a comment to blk_validate_block_size() to inform users that self-
validation of LBS is usually unnecessary.
Signed-off-by: John Garry <john.g.garry@oracle.com>
Reviewed-by: Damien Le Moal <dlemoal@kernel.org>
Link: https://lore.kernel.org/r/20240708091651.177447-3-john.g.garry@oracle.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'block/blk-settings.c')
-rw-r--r-- | block/blk-settings.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/block/blk-settings.c b/block/blk-settings.c index 9fa4eed4df06..cd8a8eabc9a5 100644 --- a/block/blk-settings.c +++ b/block/blk-settings.c @@ -235,6 +235,10 @@ static int blk_validate_limits(struct queue_limits *lim) */ if (!lim->logical_block_size) lim->logical_block_size = SECTOR_SIZE; + else if (blk_validate_block_size(lim->logical_block_size)) { + pr_warn("Invalid logical block size (%d)\n", lim->logical_block_size); + return -EINVAL; + } if (lim->physical_block_size < lim->logical_block_size) lim->physical_block_size = lim->logical_block_size; |