[PATCH] nvmet: propagate npwg and awupf topology

Luis Chamberlain mcgrof at kernel.org
Wed Dec 11 19:31:47 PST 2024


Ensure we propagate npwg and awupf to the target as well instead
of assuming its the same logical blocks per physical block.

This ensures devices with large IUs and large atomics get their
information properly propagated on the target.

Signed-off-by: Luis Chamberlain <mcgrof at kernel.org>
---
 drivers/nvme/target/io-cmd-bdev.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/nvme/target/io-cmd-bdev.c b/drivers/nvme/target/io-cmd-bdev.c
index 0bda83d0fc3e..567e5ac49fb0 100644
--- a/drivers/nvme/target/io-cmd-bdev.c
+++ b/drivers/nvme/target/io-cmd-bdev.c
@@ -26,7 +26,8 @@ void nvmet_bdev_set_limits(struct block_device *bdev, struct nvme_id_ns *id)
 	 */
 	id->nsfeat |= 1 << 1;
 	id->nawun = lpp0b;
-	id->nawupf = lpp0b;
+	id->nawupf = to0based(bdev_atomic_write_unit_max_bytes(bdev) /
+			      bdev_logical_block_size(bdev));
 	id->nacwu = lpp0b;
 
 	/*
@@ -36,7 +37,7 @@ void nvmet_bdev_set_limits(struct block_device *bdev, struct nvme_id_ns *id)
 	 */
 	id->nsfeat |= 1 << 4;
 	/* NPWG = Namespace Preferred Write Granularity. 0's based */
-	id->npwg = lpp0b;
+	id->npwg = to0based(bdev_io_min(bdev) / bdev_logical_block_size(bdev));
 	/* NPWA = Namespace Preferred Write Alignment. 0's based */
 	id->npwa = id->npwg;
 	/* NPDG = Namespace Preferred Deallocate Granularity. 0's based */
-- 
2.45.2




More information about the Linux-nvme mailing list