[PATCH] NFS: flag files as supporting FMODE_NOWAIT

Arik Rinberg posted 1 patch 1 month, 3 weeks ago
fs/nfs/file.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[PATCH] NFS: flag files as supporting FMODE_NOWAIT
Posted by Arik Rinberg 1 month, 3 weeks ago
When opening a file in NFS, set FMODE_NOWAIT in filp->f_mode.

Without this flag, asynchronous I/O frameworks like io_uring assume
that the file system does not support non-blocking I/O. This causes
io_uring to punt all I/O operations to background io-wq worker threads
to avoid blocking the main ring. This results in performance
degredation.

By setting FMODE_NOWAIT, we inform the VFS that NFS supports
asynchronous I/O natively, keeping execution on the fast path and
restoring performance.

Link: https://github.com/axboe/liburing/issues/1499

Signed-off-by: Arik Rinberg <ArikRinberg@google.com>
---
 fs/nfs/file.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/nfs/file.c b/fs/nfs/file.c
index 5d08b6409c28..8e2100550f10 100644
--- a/fs/nfs/file.c
+++ b/fs/nfs/file.c
@@ -73,7 +73,7 @@ nfs_file_open(struct inode *inode, struct file *filp)
 
 	res = nfs_open(inode, filp);
 	if (res == 0)
-		filp->f_mode |= FMODE_CAN_ODIRECT;
+		filp->f_mode |= FMODE_CAN_ODIRECT | FMODE_NOWAIT;
 	return res;
 }
 
-- 
2.54.0.rc1.555.g9c883467ad-goog