linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] nvmet: disable direct I/O when unavailable
@ 2019-02-21 18:22 Johannes Thumshirn
  2019-02-22  0:41 ` Chaitanya Kulkarni
  0 siblings, 1 reply; 10+ messages in thread
From: Johannes Thumshirn @ 2019-02-21 18:22 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: Linux Kernel Mailinglist, Linux NVMe Mailinglist, Johannes Thumshirn

Some file-systems, like tmpfs, do not support direct IO, but file-backed
namespaces default to using direct IO. If direct IO is unavailable fall
back to using buffered IO for the file-backed namespace.

This might not ultimately be a solution for production environments but
for test environments it sometimes is feasible to use tmpfs.

Signed-off-by: Johannes Thumshirn <jthumshirn@suse.de>
---
 drivers/nvme/target/io-cmd-file.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/drivers/nvme/target/io-cmd-file.c b/drivers/nvme/target/io-cmd-file.c
index 517522305e5c..8a861cc0160e 100644
--- a/drivers/nvme/target/io-cmd-file.c
+++ b/drivers/nvme/target/io-cmd-file.c
@@ -38,11 +38,21 @@ int nvmet_file_ns_enable(struct nvmet_ns *ns)
 
 	ns->file = filp_open(ns->device_path, flags, 0);
 	if (IS_ERR(ns->file)) {
+		if (ns->file == ERR_PTR(-EINVAL) && (flags & O_DIRECT)) {
+			flags &= ~O_DIRECT;
+			ns->buffered_io = 0;
+			ns->file = filp_open(ns->device_path, flags, 0);
+			if (!IS_ERR(ns->file)) {
+				pr_info("direct I/O unavailable, falling back to buffered I/O\n");
+				goto getattr;
+			}
+		}
 		pr_err("failed to open file %s: (%ld)\n",
 				ns->device_path, PTR_ERR(ns->file));
 		return PTR_ERR(ns->file);
 	}
 
+getattr:
 	ret = vfs_getattr(&ns->file->f_path,
 			&stat, STATX_SIZE, AT_STATX_FORCE_SYNC);
 	if (ret)
-- 
2.16.4


^ permalink raw reply related	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2019-03-08 13:26 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-02-21 18:22 [PATCH] nvmet: disable direct I/O when unavailable Johannes Thumshirn
2019-02-22  0:41 ` Chaitanya Kulkarni
2019-02-22  5:55   ` Johannes Thumshirn
2019-02-24 10:54     ` Max Gurtovoy
2019-02-25  9:37       ` Johannes Thumshirn
2019-02-25 14:49         ` Bart Van Assche
2019-02-25 15:38           ` Johannes Thumshirn
2019-02-25 16:10             ` Bart Van Assche
2019-02-25 21:18     ` Sagi Grimberg
2019-03-08 13:26       ` Christoph Hellwig

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).