]> www.infradead.org Git - users/hch/misc.git/commitdiff
nvmet: set WZDS and DRB if device enables unmap write zeroes operation
authorZhang Yi <yi.zhang@huawei.com>
Thu, 19 Jun 2025 11:18:00 +0000 (19:18 +0800)
committerChristian Brauner <brauner@kernel.org>
Mon, 23 Jun 2025 10:45:13 +0000 (12:45 +0200)
Set the WZDS and DRB bits to the namespace dlfeat if the underlying
block device enables the unmap write zeroes operation, make the nvme
target device supports the unmap write zeroes command.

Signed-off-by: Zhang Yi <yi.zhang@huawei.com>
Link: https://lore.kernel.org/20250619111806.3546162-4-yi.zhang@huaweicloud.com
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: "Martin K. Petersen" <martin.petersen@oracle.com>
Signed-off-by: Christian Brauner <brauner@kernel.org>
drivers/nvme/target/io-cmd-bdev.c

index eba42df2f8215e41277102a922d2a67a72243f1e..31d6c4a63fa58bd8492ae83901dd916234344890 100644 (file)
@@ -46,6 +46,10 @@ void nvmet_bdev_set_limits(struct block_device *bdev, struct nvme_id_ns *id)
        id->npda = id->npdg;
        /* NOWS = Namespace Optimal Write Size */
        id->nows = to0based(bdev_io_opt(bdev) / bdev_logical_block_size(bdev));
+
+       /* Set WZDS and DRB if device supports unmapped write zeroes */
+       if (bdev_write_zeroes_unmap_sectors(bdev))
+               id->dlfeat = (1 << 3) | 0x1;
 }
 
 void nvmet_bdev_ns_disable(struct nvmet_ns *ns)