Btrfs: mark mapping with error flag to report errors to userspace
authorLiu Bo <bo.li.liu@oracle.com>
Mon, 12 May 2014 04:47:36 +0000 (12:47 +0800)
committerChris Mason <clm@fb.com>
Tue, 10 Jun 2014 00:20:47 +0000 (17:20 -0700)
According to commit 865ffef3797da2cac85b3354b5b6050dc9660978
(fs: fix fsync() error reporting),
it's not stable to just check error pages because pages can be
truncated or invalidated, we should also mark mapping with error
flag so that a later fsync can catch the error.

Signed-off-by: Liu Bo <bo.li.liu@oracle.com>
Signed-off-by: Chris Mason <clm@fb.com>
fs/btrfs/extent_io.c

index fa31c8d2c095589b379b32f77d469f24366a1763..a55580f4e611252968e44bd6b5563187b5328425 100644 (file)
@@ -2367,6 +2367,8 @@ int end_extent_writepage(struct page *page, int err, u64 start, u64 end)
        if (!uptodate) {
                ClearPageUptodate(page);
                SetPageError(page);
+               ret = ret < 0 ? ret : -EIO;
+               mapping_set_error(page->mapping, ret);
        }
        return 0;
 }