Skip to content

Commit 50564b6

Browse files
fdmananakdave
authored andcommitted
btrfs: abort transaction on generation mismatch when marking eb as dirty
When marking an extent buffer as dirty, at btrfs_mark_buffer_dirty(), we check if its generation matches the running transaction and if not we just print a warning. Such mismatch is an indicator that something really went wrong and only printing a warning message (and stack trace) is not enough to prevent a corruption. Allowing a transaction to commit with such an extent buffer will trigger an error if we ever try to read it from disk due to a generation mismatch with its parent generation. So abort the current transaction with -EUCLEAN if we notice a generation mismatch. For this we need to pass a transaction handle to btrfs_mark_buffer_dirty() which is always available except in test code, in which case we can pass NULL since it operates on dummy extent buffers and all test roots have a single node/leaf (root node at level 0). Signed-off-by: Filipe Manana <[email protected]> Reviewed-by: David Sterba <[email protected]> Signed-off-by: David Sterba <[email protected]>
1 parent bc27d6f commit 50564b6

25 files changed

+205
-169
lines changed

fs/btrfs/block-group.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2601,7 +2601,7 @@ static int insert_dev_extent(struct btrfs_trans_handle *trans,
26012601
btrfs_set_dev_extent_chunk_offset(leaf, extent, chunk_offset);
26022602

26032603
btrfs_set_dev_extent_length(leaf, extent, num_bytes);
2604-
btrfs_mark_buffer_dirty(leaf);
2604+
btrfs_mark_buffer_dirty(trans, leaf);
26052605
out:
26062606
btrfs_free_path(path);
26072607
return ret;
@@ -3025,7 +3025,7 @@ static int update_block_group_item(struct btrfs_trans_handle *trans,
30253025
cache->global_root_id);
30263026
btrfs_set_stack_block_group_flags(&bgi, cache->flags);
30273027
write_extent_buffer(leaf, &bgi, bi, sizeof(bgi));
3028-
btrfs_mark_buffer_dirty(leaf);
3028+
btrfs_mark_buffer_dirty(trans, leaf);
30293029
fail:
30303030
btrfs_release_path(path);
30313031
/*

0 commit comments

Comments
 (0)