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

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

Details

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

Commit Message

Maxim Patlasov July 20, 2016, 12:36 a.m.
fuse_flush() calls filemap_write_and_wait() and checks
its status, 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().

https://jira.sw.ru/browse/PSBM-49821

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

Patch hide | download patch | download mbox

diff --git a/fs/fuse/file.c b/fs/fuse/file.c
index 0ef7fe1..5e73dd0 100644
--- a/fs/fuse/file.c
+++ b/fs/fuse/file.c
@@ -599,6 +599,13 @@  static int fuse_flush(struct file *file, fl_owner_t id)
 	fuse_sync_writes(inode);
 	mutex_unlock(&inode->i_mutex);
 
+	if (test_and_clear_bit(AS_ENOSPC, &file->f_mapping->flags))
+		err = -ENOSPC;
+	if (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;