{
        struct btrfs_inode *inode = async_chunk->inode;
        struct btrfs_fs_info *fs_info = inode->root->fs_info;
+       struct address_space *mapping = inode->vfs_inode.i_mapping;
        u64 blocksize = fs_info->sectorsize;
        u64 start = async_chunk->start;
        u64 end = async_chunk->end;
                /* Compression level is applied here and only here */
                ret = btrfs_compress_pages(
                        compress_type | (fs_info->compress_level << 4),
-                                          inode->vfs_inode.i_mapping, start,
+                                          mapping, start,
                                           pages,
                                           &nr_pages,
                                           &total_in,
                        unsigned long clear_flags = EXTENT_DELALLOC |
                                EXTENT_DELALLOC_NEW | EXTENT_DEFRAG |
                                EXTENT_DO_ACCOUNTING;
-                       unsigned long page_error_op;
 
-                       page_error_op = ret < 0 ? PAGE_SET_ERROR : 0;
+                       if (ret < 0)
+                               mapping_set_error(mapping, -EIO);
 
                        /*
                         * inline extent creation worked or returned error,
                                                     clear_flags,
                                                     PAGE_UNLOCK |
                                                     PAGE_START_WRITEBACK |
-                                                    page_error_op |
                                                     PAGE_END_WRITEBACK);
 
                        /*
        btrfs_dec_block_group_reservations(fs_info, ins.objectid);
        btrfs_free_reserved_extent(fs_info, ins.objectid, ins.offset, 1);
 out_free:
+       mapping_set_error(inode->vfs_inode.i_mapping, -EIO);
        extent_clear_unlock_delalloc(inode, start, end,
                                     NULL, EXTENT_LOCKED | EXTENT_DELALLOC |
                                     EXTENT_DELALLOC_NEW |
                                     EXTENT_DEFRAG | EXTENT_DO_ACCOUNTING,
                                     PAGE_UNLOCK | PAGE_START_WRITEBACK |
-                                    PAGE_END_WRITEBACK | PAGE_SET_ERROR);
+                                    PAGE_END_WRITEBACK);
        free_async_extent_pages(async_extent);
        goto done;
 }