]> git.baikalelectronics.ru Git - kernel.git/commitdiff
NFSv4: Add FMODE_CAN_ODIRECT after successful open of a NFS4.x file
authorDave Wysochanski <dwysocha@redhat.com>
Fri, 10 Jun 2022 00:46:29 +0000 (20:46 -0400)
committerAnna Schumaker <Anna.Schumaker@Netapp.com>
Wed, 15 Jun 2022 19:03:12 +0000 (15:03 -0400)
Commit 2705bb11ba80 ("VFS: add FMODE_CAN_ODIRECT file flag")
added the FMODE_CAN_ODIRECT flag for NFSv3 but neglected to add
it for NFSv4.x.  This causes direct io on NFSv4.x to fail open
with EINVAL:
  mount -o vers=4.2 127.0.0.1:/export /mnt/nfs4
  dd if=/dev/zero of=/mnt/nfs4/file.bin bs=128k count=1 oflag=direct
  dd: failed to open '/mnt/nfs4/file.bin': Invalid argument
  dd of=/dev/null if=/mnt/nfs4/file.bin bs=128k count=1 iflag=direct
  dd: failed to open '/mnt/dir1/file1.bin': Invalid argument

Fixes: 2705bb11ba80 ("VFS: add FMODE_CAN_ODIRECT file flag")
Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>
Signed-off-by: Anna Schumaker <Anna.Schumaker@Netapp.com>
fs/nfs/dir.c
fs/nfs/nfs4file.c

index a8ecdd527662cc95ded7e074cc9cd6123377d950..0c4e8dd6aa968717d68a829540c14ac1b3972b51 100644 (file)
@@ -2124,6 +2124,7 @@ int nfs_atomic_open(struct inode *dir, struct dentry *dentry,
                }
                goto out;
        }
+       file->f_mode |= FMODE_CAN_ODIRECT;
 
        err = nfs_finish_open(ctx, ctx->dentry, file, open_flags);
        trace_nfs_atomic_open_exit(dir, ctx, open_flags, err);
index 03d3a270eff4f128843c8ddd516f5142e4326fad..e88f6b18445ece3b51ea0781861575908c393893 100644 (file)
@@ -93,6 +93,7 @@ nfs4_file_open(struct inode *inode, struct file *filp)
        nfs_file_set_open_context(filp, ctx);
        nfs_fscache_open_file(inode, filp);
        err = 0;
+       filp->f_mode |= FMODE_CAN_ODIRECT;
 
 out_put_ctx:
        put_nfs_open_context(ctx);