diff mbox series

[07/11] btrfs: zero out temporary superblock buffer header

Message ID 5f0d31d6299aacfce2df98e338afee2c20dbdb51.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
We use HEADER_FLAG_V2 to determine different offsets into the buffer, so
we need to make sure that we clear the header of the temporary
extent_buffer we allocate to read the super block in, otherwise we could
have this flag set and do the wrong math for the different item helpers.

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

Patch

diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
index 1be7cb2f955f..fc2d3db8e539 100644
--- a/fs/btrfs/volumes.c
+++ b/fs/btrfs/volumes.c
@@ -7403,6 +7403,8 @@  int btrfs_read_sys_array(struct btrfs_fs_info *fs_info)
 	if (IS_ERR(sb))
 		return PTR_ERR(sb);
 	set_extent_buffer_uptodate(sb);
+	memzero_extent_buffer(sb, 0, sizeof(struct btrfs_header));
+
 	/*
 	 * The sb extent buffer is artificial and just used to read the system array.
 	 * set_extent_buffer_uptodate() call does not properly mark all it's