Skip to content

Commit

Permalink
btrfs: Handle btrfs_set_extent_delalloc failure in fixup worker
Browse files Browse the repository at this point in the history
This function was introduced by 247e743 ("Btrfs: Use async helpers
to deal with pages that have been improperly dirtied") and it didn't do
any error handling then. This function might very well fail in ENOMEM
situation, yet it's not handled, this could lead to inconsistent state.
So let's handle the failure by setting the mapping error bit.

Cc: [email protected]
Signed-off-by: Nikolay Borisov <[email protected]>
Reviewed-by: Qu Wenruo <[email protected]>
Reviewed-by: David Sterba <[email protected]>
Signed-off-by: David Sterba <[email protected]>
  • Loading branch information
lorddoskias authored and kdave committed Jan 22, 2018
1 parent ad8bc4d commit f3038ee
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions fs/btrfs/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -2116,8 +2116,15 @@ static void btrfs_writepage_fixup_worker(struct btrfs_work *work)
goto out;
}

btrfs_set_extent_delalloc(inode, page_start, page_end, 0, &cached_state,
0);
ret = btrfs_set_extent_delalloc(inode, page_start, page_end, 0,
&cached_state, 0);
if (ret) {
mapping_set_error(page->mapping, ret);
end_extent_writepage(page, ret, page_start, page_end);
ClearPageChecked(page);
goto out;
}

ClearPageChecked(page);
set_page_dirty(page);
btrfs_delalloc_release_extents(BTRFS_I(inode), PAGE_SIZE);
Expand Down

0 comments on commit f3038ee

Please sign in to comment.