fuse: fuse_flush must check mapping->flags for errors
authorMaxim Patlasov <mpatlasov@virtuozzo.com>
Wed, 20 Jul 2016 01:12:26 +0000 (18:12 -0700)
committerMiklos Szeredi <mszeredi@redhat.com>
Fri, 29 Jul 2016 12:10:57 +0000 (14:10 +0200)
fuse_flush() calls write_inode_now() that triggers writeback, but actual
writeback will happen later, on fuse_sync_writes(). If an error happens,
fuse_writepage_end() will set error bit in mapping->flags. So, we have to
check mapping->flags after fuse_sync_writes().

Signed-off-by: Maxim Patlasov <mpatlasov@virtuozzo.com>
Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
Fixes: 4d99ff8f12eb ("fuse: Turn writeback cache on")
Cc: <stable@vger.kernel.org> # v3.15+
fs/fuse/file.c

index 2491f388358baa0c44db0b460bfb2e0ac735428f..594fb15fba9b1ba2826815094bd7a6b409d30c87 100644 (file)
@@ -417,6 +417,15 @@ static int fuse_flush(struct file *file, fl_owner_t id)
        fuse_sync_writes(inode);
        inode_unlock(inode);
 
+       if (test_bit(AS_ENOSPC, &file->f_mapping->flags) &&
+           test_and_clear_bit(AS_ENOSPC, &file->f_mapping->flags))
+               err = -ENOSPC;
+       if (test_bit(AS_EIO, &file->f_mapping->flags) &&
+           test_and_clear_bit(AS_EIO, &file->f_mapping->flags))
+               err = -EIO;
+       if (err)
+               return err;
+
        req = fuse_get_req_nofail_nopages(fc, file);
        memset(&inarg, 0, sizeof(inarg));
        inarg.fh = ff->fh;