[PATCH 0/3] nvmet: add buffered_io support for bdev-ns

Christoph Hellwig hch at lst.de
Thu Jan 27 02:07:39 PST 2022


On Thu, Jan 27, 2022 at 07:46:22AM +0000, Chaitanya Kulkarni wrote:
> This is exactly how I stared this patch-series, but above doesn't
> work since it errors out in the nvme_identify_ns() due to ncap value
> set to 0 (set from ns->size in id-ns admin on target side) see [1],
> since ns->size value we get is 0, that is set using call to
> vfs_getattr(STATX_SIZE) in the nvmet_file_ns_revalidate()
> for file backend.

Something like this should solve that issue:

diff --git a/drivers/nvme/target/io-cmd-file.c b/drivers/nvme/target/io-cmd-file.c
index 6be6e59d273bb..fb7f4dd72daf6 100644
--- a/drivers/nvme/target/io-cmd-file.c
+++ b/drivers/nvme/target/io-cmd-file.c
@@ -16,14 +16,8 @@
 
 int nvmet_file_ns_revalidate(struct nvmet_ns *ns)
 {
-	struct kstat stat;
-	int ret;
-
-	ret = vfs_getattr(&ns->file->f_path, &stat, STATX_SIZE,
-			  AT_STATX_FORCE_SYNC);
-	if (!ret)
-		ns->size = stat.size;
-	return ret;
+	ns->size = i_size_read(ns->file->f_mapping->host);
+	return 0;
 }
 
 void nvmet_file_ns_disable(struct nvmet_ns *ns)



More information about the Linux-nvme mailing list