]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
btrfs: initialize fs_devices->fs_info earlier in btrfs_init_devices_late()
authorAnand Jain <anand.jain@oracle.com>
Wed, 1 Jan 2025 18:06:30 +0000 (02:06 +0800)
committerDavid Sterba <dsterba@suse.com>
Mon, 13 Jan 2025 13:53:20 +0000 (14:53 +0100)
Currently, fs_devices->fs_info is initialized in btrfs_init_devices_late(),
but this occurs too late for find_live_mirror(), which is invoked by
load_super_root() much earlier than btrfs_init_devices_late().

Fix this by moving the initialization to open_ctree(), before load_super_root().

Reviewed-by: Naohiro Aota <naohiro.aota@wdc.com>
Signed-off-by: Anand Jain <anand.jain@oracle.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/disk-io.c
fs/btrfs/volumes.c

index 04d68f253940ca5bfe5c10d700d87dcf12ff6f6e..4928bf2cd07fe0d941bbc080e44286d90382f82f 100644 (file)
@@ -3388,6 +3388,7 @@ int __cold open_ctree(struct super_block *sb, struct btrfs_fs_devices *fs_device
        fs_info->sectors_per_page = (PAGE_SIZE >> fs_info->sectorsize_bits);
        fs_info->csums_per_leaf = BTRFS_MAX_ITEM_SIZE(fs_info) / fs_info->csum_size;
        fs_info->stripesize = stripesize;
+       fs_info->fs_devices->fs_info = fs_info;
 
        /*
         * Handle the space caching options appropriately now that we have the
index ccbfea163390b7eb96064ceae3396845f5e2ac44..e5d5cfb2d23965b27165a130cdbc9bc62e51b01c 100644 (file)
@@ -7515,8 +7515,6 @@ int btrfs_init_devices_late(struct btrfs_fs_info *fs_info)
        struct btrfs_device *device;
        int ret = 0;
 
-       fs_devices->fs_info = fs_info;
-
        mutex_lock(&fs_devices->device_list_mutex);
        list_for_each_entry(device, &fs_devices->devices, dev_list)
                device->fs_info = fs_info;