]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
nvme: don't set io_opt if NOWS is zero
authorChristoph Hellwig <hch@lst.de>
Mon, 1 Jul 2024 05:17:52 +0000 (07:17 +0200)
committerJens Axboe <axboe@kernel.dk>
Mon, 1 Jul 2024 12:52:42 +0000 (06:52 -0600)
NOWS is one of the annoying "0's based values" in NVMe, where 0 means one
and we thus can't detect if it isn't set.  Thus a NOWS value of 0 means
that the Namespace Optimal Write Size is a single LBA, which is clearly
bogus.  Ignore the value in that case and don't propagate an io_opt
value to the block layer.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Chaitanya Kulkarni <kch@nvidia.com>
Reviewed-by: Sagi Grimberg <sagi@grimberg.me>
Reviewed-by: Nitesh Shetty <nj.shetty@samsung.com>
Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Link: https://lore.kernel.org/r/20240701051800.1245240-4-hch@lst.de
Signed-off-by: Jens Axboe <axboe@kernel.dk>
drivers/nvme/host/core.c

index 89ebfa89613ee6a0ff49f37743ca2d8a1786436d..ef00bfc6b8408a383caa5216e59d14ed1b565e6d 100644 (file)
@@ -2024,7 +2024,8 @@ static bool nvme_update_disk_info(struct nvme_ns *ns, struct nvme_id_ns *id,
                /* NPWG = Namespace Preferred Write Granularity */
                phys_bs = bs * (1 + le16_to_cpu(id->npwg));
                /* NOWS = Namespace Optimal Write Size */
-               io_opt = bs * (1 + le16_to_cpu(id->nows));
+               if (id->nows)
+                       io_opt = bs * (1 + le16_to_cpu(id->nows));
        }
 
        /*