Btrfs: report error after failure inlining extent in compressed write path
authorFilipe Manana <fdmanana@suse.com>
Fri, 10 Oct 2014 09:45:12 +0000 (10:45 +0100)
committerChris Mason <clm@fb.com>
Fri, 21 Nov 2014 01:14:28 +0000 (17:14 -0800)
If cow_file_range_inline() failed, when called from compress_file_range(),
we were tagging the locked page for writeback, end its writeback and unlock it,
but not marking it with an error nor setting AS_EIO in inode's mapping flags.

This made it impossible for a caller of filemap_fdatawrite_range (writepages)
or filemap_fdatawait_range() to know that an error happened. And the return
value of compress_file_range() is useless because it's returned to a workqueue
task and not to the task calling filemap_fdatawrite_range (writepages).

This change applies on top of the previous patchset starting at the patch
titled:

    "[1/5] Btrfs: set page and mapping error on compressed write failure"

Which changed extent_clear_unlock_delalloc() to use SetPageError and
mapping_set_error().

Signed-off-by: Filipe Manana <fdmanana@suse.com>
Signed-off-by: Chris Mason <clm@fb.com>
fs/btrfs/inode.c

index 95f06936bc6e2c5afb312e4ab15e2f7a11b380dd..cb5978a4a2773c62bb11a7d60030c813ba027a27 100644 (file)
@@ -527,7 +527,10 @@ cont:
                if (ret <= 0) {
                        unsigned long clear_flags = EXTENT_DELALLOC |
                                EXTENT_DEFRAG;
+                       unsigned long page_error_op;
+
                        clear_flags |= (ret < 0) ? EXTENT_DO_ACCOUNTING : 0;
+                       page_error_op = ret < 0 ? PAGE_SET_ERROR : 0;
 
                        /*
                         * inline extent creation worked or returned error,
@@ -538,6 +541,7 @@ cont:
                                                     clear_flags, PAGE_UNLOCK |
                                                     PAGE_CLEAR_DIRTY |
                                                     PAGE_SET_WRITEBACK |
+                                                    page_error_op |
                                                     PAGE_END_WRITEBACK);
                        goto free_pages_out;
                }