diff mbox series

[v2,2/7] btrfs-progs: set eb->fs_info properly

Message ID 20211005062305.549871-3-naohiro.aota@wdc.com (mailing list archive)
State New, archived
Headers show
Series btrfs-progs: use direct-IO for zoned device | expand

Commit Message

Naohiro Aota Oct. 5, 2021, 6:23 a.m. UTC
Several extent_buffer initialization misses fs_info setting. This is OK
before the following patch ("btrfs-progs: use direct-io for zoned device")
as eb->fs_info is not always necessary. But, after that patch, we will use
fs_info to determine it is zoned or not and that causes segfault in such
cases.

Properly set fs_info when initializing extent_buffers to fix the issue.

Signed-off-by: Naohiro Aota <naohiro.aota@wdc.com>
---
 convert/main.c          | 1 +
 kernel-shared/volumes.c | 2 ++
 mkfs/rootdir.c          | 1 +
 3 files changed, 4 insertions(+)
diff mbox series

Patch

diff --git a/convert/main.c b/convert/main.c
index b705946b1312..223eebad2e72 100644
--- a/convert/main.c
+++ b/convert/main.c
@@ -397,6 +397,7 @@  static int migrate_one_reserved_range(struct btrfs_trans_handle *trans,
 		}
 		eb->start = key.objectid;
 		eb->len = key.offset;
+		eb->fs_info = root->fs_info;
 
 		/* Write the data */
 		ret = write_and_map_eb(root->fs_info, eb);
diff --git a/kernel-shared/volumes.c b/kernel-shared/volumes.c
index b2a6b04f8e3d..2ef2a8618d1f 100644
--- a/kernel-shared/volumes.c
+++ b/kernel-shared/volumes.c
@@ -2567,6 +2567,7 @@  static int split_eb_for_raid56(struct btrfs_fs_info *info,
 		eb->flags = 0;
 		eb->fd = -1;
 		eb->dev_bytenr = (u64)-1;
+		eb->fs_info = info;
 
 		this_eb_start = raid_map[i];
 
@@ -2638,6 +2639,7 @@  int write_raid56_with_parity(struct btrfs_fs_info *info,
 		new_eb->fd = multi->stripes[i].dev->fd;
 		multi->stripes[i].dev->total_ios++;
 		new_eb->len = stripe_len;
+		new_eb->fs_info = info;
 
 		if (raid_map[i] == BTRFS_RAID5_P_STRIPE)
 			p_eb = new_eb;
diff --git a/mkfs/rootdir.c b/mkfs/rootdir.c
index c2e14daf6663..16ff257ac408 100644
--- a/mkfs/rootdir.c
+++ b/mkfs/rootdir.c
@@ -397,6 +397,7 @@  again:
 
 		eb->start = first_block + bytes_read;
 		eb->len = sectorsize;
+		eb->fs_info = root->fs_info;
 
 		/*
 		 * we're doing the csum before we record the extent, but