]> git.kernelconcepts.de Git - karo-tx-linux.git/blobdiff - fs/btrfs/file.c
Merge tag 'for-linus-v4.13-2' of git://git.kernel.org/pub/scm/linux/kernel/git/jlayto...
[karo-tx-linux.git] / fs / btrfs / file.c
index 24338702ea5bbbe3911f3e3341bfa21804f51590..a85d7903fbdd3b697fb79748191ef754a1bedad1 100644 (file)
@@ -2032,7 +2032,7 @@ int btrfs_sync_file(struct file *file, loff_t start, loff_t end, int datasync)
        struct btrfs_root *root = BTRFS_I(inode)->root;
        struct btrfs_trans_handle *trans;
        struct btrfs_log_ctx ctx;
-       int ret = 0;
+       int ret = 0, err;
        bool full_sync = 0;
        u64 len;
 
@@ -2051,7 +2051,7 @@ int btrfs_sync_file(struct file *file, loff_t start, loff_t end, int datasync)
         */
        ret = start_ordered_ops(inode, start, end);
        if (ret)
-               return ret;
+               goto out;
 
        inode_lock(inode);
        atomic_inc(&root->log_batch);
@@ -2156,10 +2156,10 @@ int btrfs_sync_file(struct file *file, loff_t start, loff_t end, int datasync)
                 * An ordered extent might have started before and completed
                 * already with io errors, in which case the inode was not
                 * updated and we end up here. So check the inode's mapping
-                * flags for any errors that might have happened while doing
-                * writeback of file data.
+                * for any errors that might have happened since we last
+                * checked called fsync.
                 */
-               ret = filemap_check_errors(inode->i_mapping);
+               ret = filemap_check_wb_err(inode->i_mapping, file->f_wb_err);
                inode_unlock(inode);
                goto out;
        }
@@ -2248,6 +2248,9 @@ int btrfs_sync_file(struct file *file, loff_t start, loff_t end, int datasync)
                ret = btrfs_end_transaction(trans);
        }
 out:
+       err = file_check_and_advance_wb_err(file);
+       if (!ret)
+               ret = err;
        return ret > 0 ? -EIO : ret;
 }