@@ -905,10 +905,7 @@ ssize_t nfs_file_direct_write(struct kiocb *iocb, struct iov_iter *iter)
dfprintk(FILE, "NFS: direct write(%pD2, %zd@%Ld)\n",
file, iov_iter_count(iter), (long long) iocb->ki_pos);
- result = generic_write_checks(iocb, iter);
- if (result <= 0)
- return result;
- count = result;
+ count = iov_iter_count(iter);
nfs_add_stats(mapping->host, NFSIOS_DIRECTWRITTENBYTES, count);
pos = iocb->ki_pos;
@@ -615,8 +615,12 @@ ssize_t nfs_file_write(struct kiocb *iocb, struct iov_iter *from)
if (result)
return result;
- if (iocb->ki_flags & IOCB_DIRECT)
+ if (iocb->ki_flags & IOCB_DIRECT) {
+ result = generic_write_checks(iocb, from);
+ if (result <= 0)
+ return result;
return nfs_file_direct_write(iocb, from);
+ }
dprintk("NFS: write(%pD2, %zu@%Ld)\n",
file, iov_iter_count(from), (long long) iocb->ki_pos);
generic_write_checks() is not needed for swap-out writes, and fails if they are attempted. nfs_file_direct_write() currently calls generic_write_checks() and is in turn called from: nfs_direct_IO - only for swap-out nfs_file_write - for normal O_DIRECT write So move the generic_write_checks() call into nfs_file_write(). This allows NFS swap-out writes to complete. Fixes: dc617f29dbe5 ("vfs: don't allow writes to swap files") Signed-off-by: NeilBrown <neilb@suse.de> --- fs/nfs/direct.c | 5 +---- fs/nfs/file.c | 6 +++++- 2 files changed, 6 insertions(+), 5 deletions(-)