Skip to contentSkip to conversation

nvmet: propagate npwg and awupf topology

PATCH Superseded Luis Chamberlain 3 participants 4 messages Dec 12, 2024 – Dec 13, 2024

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 nvmet: propagate npwg and awupf topology

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.

---
 drivers/nvme/target/io-cmd-bdev.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/nvme/target/io-cmd-bdev.c +3 -2
index 0bda83d0fc3e..567e5ac49fb0 100644
@@ -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 */
Signature · 1 line
2.45.2
#1 lore raw
Quoted 5 lines · Luis Chamberlain

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.

nvmet never sets REQ_ATOMIC and thus won't get atomic writes from say SCSI. So supporting atomic writes is a little more work than just propagating the values.

#2 lore raw
Quoted 11 lines · Christoph Hellwig
Quoted 5 lines · Luis Chamberlain

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.

nvmet never sets REQ_ATOMIC and thus won't get atomic writes from say SCSI. So supporting atomic writes is a little more work than just propagating the values.

In case missed, Mike had patches for SCSI target code:
https://lore.kernel.org/linux-scsi/[email protected]/

I still need to check them ...

#3 lore raw
Quoted 1 line · John Garry

I still need to check them ...

We can punt atomics later then.

Luis