Message ID | 20191212110132.11063-7-Damenly_Su@gmx.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | btrfs: metadata uuid fixes and enhancements | expand |
On 12.12.19 г. 13:01 ч., damenly.su@gmail.com wrote: > From: Su Yue <Damenly_Su@gmx.com> > > The partly logic can be moved into find_fsid_inprogress() to > make code for fs_devices finding looks more elegant. > > Signed-off-by: Su Yue <Damenly_Su@gmx.com> Code-wise the change is correct, on the other hand it's overloading what find_fsid_inprogress handles. I did this to make it explicitly clear what functions are called in what case as this code is somewhat tricky. David, do you think this change is worth it. > --- > fs/btrfs/volumes.c | 16 ++++------------ > 1 file changed, 4 insertions(+), 12 deletions(-) > > diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c > index b21ab45e76a0..7e05f96b1575 100644 > --- a/fs/btrfs/volumes.c > +++ b/fs/btrfs/volumes.c > @@ -636,6 +636,7 @@ static int btrfs_open_one_device(struct btrfs_fs_devices *fs_devices, > /* > * Handle scanned device having its CHANGING_FSID_V2 flag set and the fs_devices > * being created with a disk that has already completed its fsid change. > + * Or it might belong to fs with no UUID changes in effect, handle both. > */ > static struct btrfs_fs_devices *find_fsid_inprogress( > struct btrfs_super_block *disk_super) > @@ -651,7 +652,7 @@ static struct btrfs_fs_devices *find_fsid_inprogress( > } > } > > - return NULL; > + return find_fsid(disk_super->fsid, NULL); > } > > static struct btrfs_fs_devices *find_fsid_changed( > @@ -795,19 +796,10 @@ static noinline struct btrfs_device *device_list_add(const char *path, > *new_device_added = false; > > if (fsid_change_in_progress) { > - if (!has_metadata_uuid) { > - /* > - * When we have an image which has CHANGING_FSID_V2 set > - * it might belong to either a filesystem which has > - * disks with completed fsid change or it might belong > - * to fs with no UUID changes in effect, handle both. > - */ > + if (!has_metadata_uuid) > fs_devices = find_fsid_inprogress(disk_super); > - if (!fs_devices) > - fs_devices = find_fsid(disk_super->fsid, NULL); > - } else { > + else > fs_devices = find_fsid_changed(disk_super); > - } > } else if (has_metadata_uuid) { > fs_devices = find_fsid_changing_metada_uuid(disk_super); > } else { >
diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c index b21ab45e76a0..7e05f96b1575 100644 --- a/fs/btrfs/volumes.c +++ b/fs/btrfs/volumes.c @@ -636,6 +636,7 @@ static int btrfs_open_one_device(struct btrfs_fs_devices *fs_devices, /* * Handle scanned device having its CHANGING_FSID_V2 flag set and the fs_devices * being created with a disk that has already completed its fsid change. + * Or it might belong to fs with no UUID changes in effect, handle both. */ static struct btrfs_fs_devices *find_fsid_inprogress( struct btrfs_super_block *disk_super) @@ -651,7 +652,7 @@ static struct btrfs_fs_devices *find_fsid_inprogress( } } - return NULL; + return find_fsid(disk_super->fsid, NULL); } static struct btrfs_fs_devices *find_fsid_changed( @@ -795,19 +796,10 @@ static noinline struct btrfs_device *device_list_add(const char *path, *new_device_added = false; if (fsid_change_in_progress) { - if (!has_metadata_uuid) { - /* - * When we have an image which has CHANGING_FSID_V2 set - * it might belong to either a filesystem which has - * disks with completed fsid change or it might belong - * to fs with no UUID changes in effect, handle both. - */ + if (!has_metadata_uuid) fs_devices = find_fsid_inprogress(disk_super); - if (!fs_devices) - fs_devices = find_fsid(disk_super->fsid, NULL); - } else { + else fs_devices = find_fsid_changed(disk_super); - } } else if (has_metadata_uuid) { fs_devices = find_fsid_changing_metada_uuid(disk_super); } else {