[Devel,v2] fuse: fuse_flush must check mapping->flags for errors

Submitted by Maxim Patlasov on July 20, 2016, 1:12 a.m.

Details

Message ID 20160720011135.7038.47635.stgit@maxim-thinkpad
State New
Series "fuse: fuse_flush must check mapping->flags for errors"
Headers show

Commit Message

Maxim Patlasov July 20, 2016, 1:12 a.m.
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().

Changed in v2:
 - fixed silly type: check must be *after* fuse_sync_writes()

Signed-off-by: Maxim Patlasov <mpatlasov@virtuozzo.com>
---
 fs/fuse/file.c |    9 +++++++++
 1 file changed, 9 insertions(+)

Patch hide | download patch | download mbox

diff --git a/fs/fuse/file.c b/fs/fuse/file.c
index ad1da83..6cac3dc 100644
--- a/fs/fuse/file.c
+++ b/fs/fuse/file.c
@@ -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;

Comments

Miklos Szeredi July 21, 2016, 10:28 a.m.
On Wed, Jul 20, 2016 at 3:12 AM, Maxim Patlasov <mpatlasov@virtuozzo.com> wrote:
> 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().
>
> Changed in v2:
>  - fixed silly type: check must be *after* fuse_sync_writes()

I applied both with a cleanup patch at the end to use the
filemap_check_errors() helper, which does exactly this.

Thanks,
Miklos