Commit dac257f7 authored by Jeff Layton's avatar Jeff Layton

fs: check for writeback errors after syncing out buffers in generic_file_fsync

ext2 currently does a test+clear of the AS_EIO flag, which is
is problematic for some coming changes.

What we really need to do instead is call filemap_check_errors
in __generic_file_fsync after syncing out the buffers. That
will be sufficient for this case, and help other callers detect
these errors properly as well.

With that, we don't need to twiddle it in ext2.
Suggested-by: default avatarJan Kara <jack@suse.cz>
Signed-off-by: default avatarJeff Layton <jlayton@redhat.com>
Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
Reviewed-by: default avatarJan Kara <jack@suse.cz>
Reviewed-by: default avatarMatthew Wilcox <mawilcox@microsoft.com>
parent d945b59d
...@@ -174,15 +174,12 @@ int ext2_fsync(struct file *file, loff_t start, loff_t end, int datasync) ...@@ -174,15 +174,12 @@ int ext2_fsync(struct file *file, loff_t start, loff_t end, int datasync)
{ {
int ret; int ret;
struct super_block *sb = file->f_mapping->host->i_sb; struct super_block *sb = file->f_mapping->host->i_sb;
struct address_space *mapping = sb->s_bdev->bd_inode->i_mapping;
ret = generic_file_fsync(file, start, end, datasync); ret = generic_file_fsync(file, start, end, datasync);
if (ret == -EIO || test_and_clear_bit(AS_EIO, &mapping->flags)) { if (ret == -EIO)
/* We don't really know where the IO error happened... */ /* We don't really know where the IO error happened... */
ext2_error(sb, __func__, ext2_error(sb, __func__,
"detected IO error when writing metadata buffers"); "detected IO error when writing metadata buffers");
ret = -EIO;
}
return ret; return ret;
} }
......
...@@ -991,7 +991,9 @@ int __generic_file_fsync(struct file *file, loff_t start, loff_t end, ...@@ -991,7 +991,9 @@ int __generic_file_fsync(struct file *file, loff_t start, loff_t end,
out: out:
inode_unlock(inode); inode_unlock(inode);
return ret; /* must call this unconditionally as it clears AS_* error flags */
err = filemap_check_errors(inode->i_mapping);
return ret ? ret : err;
} }
EXPORT_SYMBOL(__generic_file_fsync); EXPORT_SYMBOL(__generic_file_fsync);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment