summaryrefslogtreecommitdiffstats
path: root/drivers/nvme/target
diff options
context:
space:
mode:
authorChaitanya Kulkarni <kch@nvidia.com>2022-02-02 01:04:45 -0800
committerChristoph Hellwig <hch@lst.de>2022-02-28 13:45:05 +0200
commit6f6d604b4ef896793901f213db3b45eefa7288fa (patch)
tree20556d98e7d5f4ff4808366aee4c15f4056f5785 /drivers/nvme/target
parent2caecd62ea5160803b25d96cb1a14ce755c2c259 (diff)
downloadlinux-stable-6f6d604b4ef896793901f213db3b45eefa7288fa.tar.gz
linux-stable-6f6d604b4ef896793901f213db3b45eefa7288fa.tar.bz2
linux-stable-6f6d604b4ef896793901f213db3b45eefa7288fa.zip
nvmet: allow bdev in buffered_io mode
Allow block device to be configured in the buffered I/O mode by using the file backend. In this way now we can use cache for the block device namespace which shows significant performance improvement. We update the block device ns enable function and return early when buffered_io flag is set. Signed-off-by: Chaitanya Kulkarni <kch@nvidia.com> Signed-off-by: Christoph Hellwig <hch@lst.de>
Diffstat (limited to 'drivers/nvme/target')
-rw-r--r--drivers/nvme/target/io-cmd-bdev.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/drivers/nvme/target/io-cmd-bdev.c b/drivers/nvme/target/io-cmd-bdev.c
index 95c2bbb0b2f5..e9194804ddee 100644
--- a/drivers/nvme/target/io-cmd-bdev.c
+++ b/drivers/nvme/target/io-cmd-bdev.c
@@ -76,6 +76,14 @@ int nvmet_bdev_ns_enable(struct nvmet_ns *ns)
{
int ret;
+ /*
+ * When buffered_io namespace attribute is enabled that means user want
+ * this block device to be used as a file, so block device can take
+ * an advantage of cache.
+ */
+ if (ns->buffered_io)
+ return -ENOTBLK;
+
ns->bdev = blkdev_get_by_path(ns->device_path,
FMODE_READ | FMODE_WRITE, NULL);
if (IS_ERR(ns->bdev)) {