Skip to content

Commit eb5b64f

Browse files
dennisszhoukdave
authored andcommitted
btrfs: adjust dirty_metadata_bytes after writeback failure of extent buffer
Before, if a eb failed to write out, we would end up triggering a BUG_ON(). As of f434062 ("btrfs: extent_io: Move the BUG_ON() in flush_write_bio() one level up"), we no longer BUG_ON(), so we should make life consistent and add back the unwritten bytes to dirty_metadata_bytes. Fixes: f434062 ("btrfs: extent_io: Move the BUG_ON() in flush_write_bio() one level up") CC: [email protected] # 5.2+ Reviewed-by: Filipe Manana <[email protected]> Signed-off-by: Dennis Zhou <[email protected]> Signed-off-by: David Sterba <[email protected]>
1 parent 9f7fec0 commit eb5b64f

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

fs/btrfs/extent_io.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3728,11 +3728,20 @@ static void end_extent_buffer_writeback(struct extent_buffer *eb)
37283728
static void set_btree_ioerr(struct page *page)
37293729
{
37303730
struct extent_buffer *eb = (struct extent_buffer *)page->private;
3731+
struct btrfs_fs_info *fs_info;
37313732

37323733
SetPageError(page);
37333734
if (test_and_set_bit(EXTENT_BUFFER_WRITE_ERR, &eb->bflags))
37343735
return;
37353736

3737+
/*
3738+
* If we error out, we should add back the dirty_metadata_bytes
3739+
* to make it consistent.
3740+
*/
3741+
fs_info = eb->fs_info;
3742+
percpu_counter_add_batch(&fs_info->dirty_metadata_bytes,
3743+
eb->len, fs_info->dirty_metadata_batch);
3744+
37363745
/*
37373746
* If writeback for a btree extent that doesn't belong to a log tree
37383747
* failed, increment the counter transaction->eb_write_errors.

0 commit comments

Comments
 (0)