NFS: Fix error reporting in nfs_file_write()
authorTrond Myklebust <trond.myklebust@primarydata.com>
Sat, 3 Sep 2016 16:05:31 +0000 (12:05 -0400)
committerTrond Myklebust <trond.myklebust@primarydata.com>
Sat, 3 Sep 2016 16:10:36 +0000 (12:10 -0400)
When doing O_DSYNC writes, the actual write errors are reported through
generic_write_sync(), so we must test the result.

Reported-by: J. R. Okajima <hooanon05g@gmail.com>
Fixes: 18290650b1c8 ("NFS: Move buffered I/O locking into nfs_file_write()")
Signed-off-by: Trond Myklebust <trond.myklebust@primarydata.com>
fs/nfs/file.c

index 7d620970f2e1addfbd447dc7b4a0bd1233bc9ec6..ca699ddc11c10e2e012f200d37213c90739af286 100644 (file)
@@ -657,7 +657,10 @@ ssize_t nfs_file_write(struct kiocb *iocb, struct iov_iter *from)
        if (result <= 0)
                goto out;
 
-       written = generic_write_sync(iocb, result);
+       result = generic_write_sync(iocb, result);
+       if (result < 0)
+               goto out;
+       written = result;
        iocb->ki_pos += written;
 
        /* Return error values */