[PATCH RFC] nvmet: fix tmpfs-based backstores support

Maurizio Lombardi mlombard at redhat.com
Wed Nov 17 07:24:54 PST 2021


commit 50a909db36f2 ("nvmet: use IOCB_NOWAIT for file-ns buffered I/O")
optimized the read command behaviour  when buffered file-ns
configurations are used.
It issues the read commands with the IOCB_NOWAIT flag set to try
to access the data from the cache.

However, the patch was buggy because both read and write commands are
issued with IOCB_NOWAIT, this broke tmpfs-based backstores because tmpfs
doesn't accept write commands with IOCB_NOWAIT.

Fix this bug by restricting IOCB_NOWAIT to read commands only.

Fixes: 50a909db36f2 ("nvmet: use IOCB_NOWAIT for file-ns buffered I/O")

Signed-off-by: Maurizio Lombardi <mlombard at redhat.com>
---
 drivers/nvme/target/io-cmd-file.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/nvme/target/io-cmd-file.c b/drivers/nvme/target/io-cmd-file.c
index 6aa30f30b572..1d9b41190583 100644
--- a/drivers/nvme/target/io-cmd-file.c
+++ b/drivers/nvme/target/io-cmd-file.c
@@ -266,6 +266,7 @@ static void nvmet_file_execute_rw(struct nvmet_req *req)
 
 	if (req->ns->buffered_io) {
 		if (likely(!req->f.mpool_alloc) &&
+				req->cmd->rw.opcode == nvme_cmd_read &&
 				nvmet_file_execute_io(req, IOCB_NOWAIT))
 			return;
 		nvmet_file_submit_buffered_io(req);
-- 
2.27.0




More information about the Linux-nvme mailing list