Skip to contentSkip to conversation

nvmet: use IOCB_NOWAIT only if the filesystem supports it.

PATCH Applied Maurizio Lombardi 4 participants 5 messages Nov 22, 2021 – Nov 23, 2021

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 nvmet: use IOCB_NOWAIT only if the filesystem supports it.

Submit I/O requests with the IOCB_NOWAIT flag set only if the underlying filesystem supports it.

Fixes 50a909db36f2 ("nvmet: use IOCB_NOWAIT for file-ns buffered I/O")
---
 drivers/nvme/target/io-cmd-file.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/nvme/target/io-cmd-file.c +2 -0
index 6aa30f30b572..136b14853ed7 100644
@@ -8,6 +8,7 @@
 #include <linux/uio.h>
 #include <linux/falloc.h>
 #include <linux/file.h>
+#include <linux/fs.h>
 #include "nvmet.h"
 
 #define NVMET_MAX_MPOOL_BVEC		16
@@ -266,6 +267,7 @@ static void nvmet_file_execute_rw(struct nvmet_req *req)
 
 	if (req->ns->buffered_io) {
 		if (likely(!req->f.mpool_alloc) &&
+				req->ns->file->f_mode & FMODE_NOWAIT &&
 				nvmet_file_execute_io(req, IOCB_NOWAIT))
 			return;
 		nvmet_file_submit_buffered_io(req);
Signature · 1 line
2.27.0
maintainer
#1 lore raw
Quoted 23 lines · Maurizio Lombardi

Submit I/O requests with the IOCB_NOWAIT flag set only if the underlying filesystem supports it.

Fixes 50a909db36f2 ("nvmet: use IOCB_NOWAIT for file-ns buffered I/O")
---
  drivers/nvme/target/io-cmd-file.c | 2 ++
  1 file changed, 2 insertions(+)
drivers/nvme/target/io-cmd-file.c +1 -0
index 6aa30f30b572..136b14853ed7 100644
@@ -8,6 +8,7 @@
  #include <linux/uio.h>
  #include <linux/falloc.h>
  #include <linux/file.h>
+#include <linux/fs.h>
  #include "nvmet.h"
 
  #define NVMET_MAX_MPOOL_BVEC		16

drivers/nvme/target/io-cmd-file.c static void nvmet_file_execute_rw(struct nvmet_req *req) · line 271

Quoted 5 lines
drivers/nvme/target/io-cmd-file.c +1 -0
@@ -266,6 +267,7 @@ static void nvmet_file_execute_rw(struct nvmet_req *req)
 
  	if (req->ns->buffered_io) {
  		if (likely(!req->f.mpool_alloc) &&
+				req->ns->file->f_mode & FMODE_NOWAIT &&
  				nvmet_file_execute_io(req, IOCB_NOWAIT))

I'd suggest to fix the alignment if we are touching this.
if (likely(!req->f.mpool_alloc) &&

		    req->ns->file->f_mode & FMODE_NOWAIT &&

nvmet_file_execute_io(req, IOCB_NOWAIT))

Quoted 3 lines
drivers/nvme/target/io-cmd-file.c +0 -0
  			return;
  		nvmet_file_submit_buffered_io(req);
#2 lore raw
Quoted 4 lines · Sagi Grimberg

I'd suggest to fix the alignment if we are touching this.
if (likely(!req->f.mpool_alloc) &&

		    req->ns->file->f_mode & FMODE_NOWAIT &&

nvmet_file_execute_io(req, IOCB_NOWAIT))

I had the same though and wil fix this up when applying the patch.

Reviewed-by on v1 1/1
#3 lore raw
In reply to Maurizio Lombardi
Quoted 10 lines · Maurizio Lombardi

External email: Use caution opening links or attachments

Submit I/O requests with the IOCB_NOWAIT flag set only if the underlying filesystem supports it.

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

---

With Sagi's comment, looks good.