diff mbox series

[06/11] btrfs: zero dummy extent buffers

Message ID bd193c475fc99e6e14a12dc40938ed22609220d6.1646692474.git.josef@toxicpanda.com (mailing list archive)
State New, archived
Headers show
Series btrfs: add snapshot_id to btrfs_header and root_item | expand

Commit Message

Josef Bacik March 7, 2022, 10:36 p.m. UTC
Our self tests allocate dummy extent buffers to test a variety of
things, however these eb's are very lightly initialized.  This causes
problems with the extent tree v2 stuff as we will read the header flags
and could have the V2 flag set and thus do the wrong thing.  Fix this by
zero'ing out the header of any dummy extent buffers we allocate.

Signed-off-by: Josef Bacik <josef@toxicpanda.com>
---
 fs/btrfs/extent_io.c | 1 +
 1 file changed, 1 insertion(+)
diff mbox series

Patch

diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c
index 951b2e0e0df1..31309aba3344 100644
--- a/fs/btrfs/extent_io.c
+++ b/fs/btrfs/extent_io.c
@@ -5960,6 +5960,7 @@  struct extent_buffer *__alloc_dummy_extent_buffer(struct btrfs_fs_info *fs_info,
 	set_extent_buffer_uptodate(eb);
 	btrfs_set_header_nritems(eb, 0);
 	set_bit(EXTENT_BUFFER_UNMAPPED, &eb->bflags);
+	memzero_extent_buffer(eb, 0, sizeof(struct btrfs_header));
 
 	return eb;
 err: