Skip to content

Commit 5ee3d10

Browse files
DaveWysochanskiRHamschuma-ntap
authored andcommitted
NFSv4: Add FMODE_CAN_ODIRECT after successful open of a NFS4.x file
Commit a2ad63d ("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: a2ad63d ("VFS: add FMODE_CAN_ODIRECT file flag") Signed-off-by: Dave Wysochanski <[email protected]> Signed-off-by: Anna Schumaker <[email protected]>
1 parent 3047912 commit 5ee3d10

File tree

2 files changed

+2
-0
lines changed

2 files changed

+2
-0
lines changed

fs/nfs/dir.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2124,6 +2124,7 @@ int nfs_atomic_open(struct inode *dir, struct dentry *dentry,
21242124
}
21252125
goto out;
21262126
}
2127+
file->f_mode |= FMODE_CAN_ODIRECT;
21272128

21282129
err = nfs_finish_open(ctx, ctx->dentry, file, open_flags);
21292130
trace_nfs_atomic_open_exit(dir, ctx, open_flags, err);

fs/nfs/nfs4file.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ nfs4_file_open(struct inode *inode, struct file *filp)
9393
nfs_file_set_open_context(filp, ctx);
9494
nfs_fscache_open_file(inode, filp);
9595
err = 0;
96+
filp->f_mode |= FMODE_CAN_ODIRECT;
9697

9798
out_put_ctx:
9899
put_nfs_open_context(ctx);

0 commit comments

Comments
 (0)