]> www.infradead.org Git - nvme.git/commitdiff
nvme: use blk_validate_block_size() for max LBA check
authorLuis Chamberlain <mcgrof@kernel.org>
Wed, 18 Dec 2024 02:02:12 +0000 (18:02 -0800)
committerJens Axboe <axboe@kernel.dk>
Wed, 18 Dec 2024 14:22:30 +0000 (07:22 -0700)
The block layer already has support to validates proper block sizes
with blk_validate_block_size(), we can leverage that as well.

No functional changes.

Signed-off-by: Luis Chamberlain <mcgrof@kernel.org>
Reviewed-by: John Garry <john.g.garry@oracle.com>
Reviewed-by: Keith Busch <kbusch@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Link: https://lore.kernel.org/r/20241218020212.3657139-3-mcgrof@kernel.org
Signed-off-by: Jens Axboe <axboe@kernel.dk>
drivers/nvme/host/core.c

index d169a30eb935e034bfbb78d1a31751dbedf0e397..a970168a3014e665006ed5576017bd764652eaa8 100644 (file)
@@ -2034,7 +2034,7 @@ static bool nvme_update_disk_info(struct nvme_ns *ns, struct nvme_id_ns *id,
         * or smaller than a sector size yet, so catch this early and don't
         * allow block I/O.
         */
-       if (head->lba_shift > PAGE_SHIFT || head->lba_shift < SECTOR_SHIFT) {
+       if (blk_validate_block_size(bs)) {
                bs = (1 << 9);
                valid = false;
        }