Skip to content

Commit f3bf25d

Browse files
Christoph Hellwigaxboe
authored andcommitted
nvme: don't set io_opt if NOWS is zero
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 <[email protected]> Reviewed-by: Chaitanya Kulkarni <[email protected]> Reviewed-by: Sagi Grimberg <[email protected]> Reviewed-by: Nitesh Shetty <[email protected]> Reviewed-by: Johannes Thumshirn <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jens Axboe <[email protected]>
1 parent 3710561 commit f3bf25d

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

drivers/nvme/host/core.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2024,7 +2024,8 @@ static bool nvme_update_disk_info(struct nvme_ns *ns, struct nvme_id_ns *id,
20242024
/* NPWG = Namespace Preferred Write Granularity */
20252025
phys_bs = bs * (1 + le16_to_cpu(id->npwg));
20262026
/* NOWS = Namespace Optimal Write Size */
2027-
io_opt = bs * (1 + le16_to_cpu(id->nows));
2027+
if (id->nows)
2028+
io_opt = bs * (1 + le16_to_cpu(id->nows));
20282029
}
20292030

20302031
/*

0 commit comments

Comments
 (0)