path: root/fs
diff options
authorDennis Zhou <>2019-09-13 14:54:07 +0100
committerDavid Sterba <>2019-09-24 14:45:11 +0200
commiteb5b64f142504a597d67e2109d603055ff765e52 (patch)
tree99ea93193a7d7a93d918825912810354a3020a54 /fs
parent9f7fec0ba89108b9385f1b9fb167861224912a4a (diff)
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 f4340622e0226 ("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: f4340622e022 ("btrfs: extent_io: Move the BUG_ON() in flush_write_bio() one level up") CC: # 5.2+ Reviewed-by: Filipe Manana <> Signed-off-by: Dennis Zhou <> Signed-off-by: David Sterba <>
Diffstat (limited to 'fs')
1 files changed, 9 insertions, 0 deletions
diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c
index 4dc5e6939856..67066ece4de3 100644
--- a/fs/btrfs/extent_io.c
+++ b/fs/btrfs/extent_io.c
@@ -3728,12 +3728,21 @@ static void end_extent_buffer_writeback(struct extent_buffer *eb)
static void set_btree_ioerr(struct page *page)
struct extent_buffer *eb = (struct extent_buffer *)page->private;
+ struct btrfs_fs_info *fs_info;
if (test_and_set_bit(EXTENT_BUFFER_WRITE_ERR, &eb->bflags))
+ * If we error out, we should add back the dirty_metadata_bytes
+ * to make it consistent.
+ */
+ fs_info = eb->fs_info;
+ percpu_counter_add_batch(&fs_info->dirty_metadata_bytes,
+ eb->len, fs_info->dirty_metadata_batch);
+ /*
* If writeback for a btree extent that doesn't belong to a log tree
* failed, increment the counter transaction->eb_write_errors.
* We do this because while the transaction is running and before it's