Skip to content

Commit 073bda7

Browse files
naotakdave
authored andcommitted
btrfs: zoned: add ASSERT and WARN for EXTENT_BUFFER_ZONED_ZEROOUT handling
Add an ASSERT to catch a faulty delayed reference item resulting from prematurely cleared extent buffer. Also, add a WARN to detect if we try to dirty a ZEROOUT buffer again, which is suspicious as its update will be lost. Reviewed-by: Johannes Thumshirn <[email protected]> Signed-off-by: Naohiro Aota <[email protected]> Reviewed-by: David Sterba <[email protected]> Signed-off-by: David Sterba <[email protected]>
1 parent 6887938 commit 073bda7

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

fs/btrfs/extent-tree.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3464,6 +3464,14 @@ void btrfs_free_tree_block(struct btrfs_trans_handle *trans,
34643464
if (root_id != BTRFS_TREE_LOG_OBJECTID) {
34653465
struct btrfs_ref generic_ref = { 0 };
34663466

3467+
/*
3468+
* Assert that the extent buffer is not cleared due to
3469+
* EXTENT_BUFFER_ZONED_ZEROOUT. Please refer
3470+
* btrfs_clear_buffer_dirty() and btree_csum_one_bio() for
3471+
* detail.
3472+
*/
3473+
ASSERT(btrfs_header_bytenr(buf) != 0);
3474+
34673475
btrfs_init_generic_ref(&generic_ref, BTRFS_DROP_DELAYED_REF,
34683476
buf->start, buf->len, parent,
34693477
btrfs_header_owner(buf));

fs/btrfs/extent_io.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4193,6 +4193,7 @@ void set_extent_buffer_dirty(struct extent_buffer *eb)
41934193
num_folios = num_extent_folios(eb);
41944194
WARN_ON(atomic_read(&eb->refs) == 0);
41954195
WARN_ON(!test_bit(EXTENT_BUFFER_TREE_REF, &eb->bflags));
4196+
WARN_ON(test_bit(EXTENT_BUFFER_ZONED_ZEROOUT, &eb->bflags));
41964197

41974198
if (!was_dirty) {
41984199
bool subpage = eb->fs_info->nodesize < PAGE_SIZE;

0 commit comments

Comments
 (0)