[Devel,RHEL7,COMMIT] ms/fuse: fsync() does not return IO errors

Submitted by Konstantin Khorenko on July 19, 2016, 9:20 a.m.

Details

Message ID 201607190920.u6J9K7Po016068@finist_cl7.x64_64.work.ct
State New
Series "ms/fuse: fsync() does not return IO errors"
Headers show

Commit Message

Konstantin Khorenko July 19, 2016, 9:20 a.m.
The commit is pushed to "branch-rh7-3.10.0-327.18.2.vz7.15.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-327.18.2.vz7.14.27
------>
commit 2e8a93df0e035c066a8558e184af6c32cbe2207e
Author: Alexey Kuznetsov <kuznet@virtuozzo.com>
Date:   Tue Jul 19 13:20:00 2016 +0400

    ms/fuse: fsync() does not return IO errors
    
    Two bugs: one is trivial misprint, another is more serious:
    due to implementation of fuse writeback filemap_write_and_wait_range()
    does not catch errors. We have to do this directly after fuse_sync_writes()
    
    https://jira.sw.ru/browse/PSBM-49821
    #VSTOR-670
    
    Signed-off-by: Alexey Kuznetsov <kuznet@virtuozzo.com>
    Acked-by: Maxim Patlasov <mpatlasov@virtuozzo.com>
---
 fs/fuse/file.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

Patch hide | download patch | download mbox

diff --git a/fs/fuse/file.c b/fs/fuse/file.c
index 9889e26..0ef7fe1 100644
--- a/fs/fuse/file.c
+++ b/fs/fuse/file.c
@@ -667,9 +667,19 @@  int fuse_fsync_common(struct file *file, loff_t start, loff_t end,
 
 	fuse_sync_writes(inode);
 
+	/* Due to implementation of fuse writeback filemap_write_and_wait_range()
+	 * does not catch errors. We have to do this directly after fuse_sync_writes()
+	 */
+	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)
+		goto out;
+
 	if (test_bit(FUSE_I_MTIME_UPDATED,
 		     &get_fuse_inode(inode)->state)) {
-		int err = fuse_flush_mtime(file, false);
+		err = fuse_flush_mtime(file, false);
 		if (err)
 			goto out;
 	}