gfs2: Prevent direct-I/O write fallback errors from getting lost
authorAndreas Gruenbacher <agruenba@redhat.com>
Mon, 10 May 2021 10:25:59 +0000 (12:25 +0200)
committerAndreas Gruenbacher <agruenba@redhat.com>
Thu, 20 May 2021 11:31:36 +0000 (13:31 +0200)
When a direct I/O write falls entirely and falls back to buffered I/O and the
buffered I/O fails, the write failed with return value 0 instead of the error
number reported by the buffered I/O. Fix that.

Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com>
fs/gfs2/file.c

index a0b542d84cd9e3404a6ca76435a885c72a07a6fc..493a83e3f59061d59f163abb637e28a614b77e79 100644 (file)
@@ -911,8 +911,11 @@ static ssize_t gfs2_file_write_iter(struct kiocb *iocb, struct iov_iter *from)
                current->backing_dev_info = inode_to_bdi(inode);
                buffered = iomap_file_buffered_write(iocb, from, &gfs2_iomap_ops);
                current->backing_dev_info = NULL;
-               if (unlikely(buffered <= 0))
+               if (unlikely(buffered <= 0)) {
+                       if (!ret)
+                               ret = buffered;
                        goto out_unlock;
+               }
 
                /*
                 * We need to ensure that the page cache pages are written to