mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-08-05 16:54:27 +00:00
btrfs: factor out loop logic from btrfs_free_extra_devids
This prepares the code to switching seeds devices to a proper list. Reviewed-by: Josef Bacik <josef@toxicpanda.com> Reviewed-by: Anand Jain <anand.jain@oracle.com> Signed-off-by: Nikolay Borisov <nborisov@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
parent
dc0ab488d2
commit
3712ccb7f1
1 changed files with 20 additions and 14 deletions
|
@ -1036,28 +1036,21 @@ error:
|
||||||
return ERR_PTR(ret);
|
return ERR_PTR(ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
static void __btrfs_free_extra_devids(struct btrfs_fs_devices *fs_devices,
|
||||||
* After we have read the system tree and know devids belonging to
|
int step, struct btrfs_device **latest_dev)
|
||||||
* this filesystem, remove the device which does not belong there.
|
|
||||||
*/
|
|
||||||
void btrfs_free_extra_devids(struct btrfs_fs_devices *fs_devices, int step)
|
|
||||||
{
|
{
|
||||||
struct btrfs_device *device, *next;
|
struct btrfs_device *device, *next;
|
||||||
struct btrfs_device *latest_dev = NULL;
|
|
||||||
|
|
||||||
mutex_lock(&uuid_mutex);
|
|
||||||
again:
|
|
||||||
/* This is the initialized path, it is safe to release the devices. */
|
/* This is the initialized path, it is safe to release the devices. */
|
||||||
list_for_each_entry_safe(device, next, &fs_devices->devices, dev_list) {
|
list_for_each_entry_safe(device, next, &fs_devices->devices, dev_list) {
|
||||||
if (test_bit(BTRFS_DEV_STATE_IN_FS_METADATA,
|
if (test_bit(BTRFS_DEV_STATE_IN_FS_METADATA, &device->dev_state)) {
|
||||||
&device->dev_state)) {
|
|
||||||
if (!test_bit(BTRFS_DEV_STATE_REPLACE_TGT,
|
if (!test_bit(BTRFS_DEV_STATE_REPLACE_TGT,
|
||||||
&device->dev_state) &&
|
&device->dev_state) &&
|
||||||
!test_bit(BTRFS_DEV_STATE_MISSING,
|
!test_bit(BTRFS_DEV_STATE_MISSING,
|
||||||
&device->dev_state) &&
|
&device->dev_state) &&
|
||||||
(!latest_dev ||
|
(!*latest_dev ||
|
||||||
device->generation > latest_dev->generation)) {
|
device->generation > (*latest_dev)->generation)) {
|
||||||
latest_dev = device;
|
*latest_dev = device;
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -1095,6 +1088,19 @@ again:
|
||||||
btrfs_free_device(device);
|
btrfs_free_device(device);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* After we have read the system tree and know devids belonging to this
|
||||||
|
* filesystem, remove the device which does not belong there.
|
||||||
|
*/
|
||||||
|
void btrfs_free_extra_devids(struct btrfs_fs_devices *fs_devices, int step)
|
||||||
|
{
|
||||||
|
struct btrfs_device *latest_dev = NULL;
|
||||||
|
|
||||||
|
mutex_lock(&uuid_mutex);
|
||||||
|
again:
|
||||||
|
__btrfs_free_extra_devids(fs_devices, step, &latest_dev);
|
||||||
if (fs_devices->seed) {
|
if (fs_devices->seed) {
|
||||||
fs_devices = fs_devices->seed;
|
fs_devices = fs_devices->seed;
|
||||||
goto again;
|
goto again;
|
||||||
|
|
Loading…
Add table
Reference in a new issue