diff options
author | Josef Bacik <josef@toxicpanda.com> | 2021-10-05 16:12:42 -0400 |
---|---|---|
committer | David Sterba <dsterba@suse.com> | 2021-10-26 19:08:07 +0200 |
commit | 562d7b1512f7369a19bca2883e2e8672d78f0481 (patch) | |
tree | e123f03b2136f2cf5fa7d35f96b86a22549c7ce6 /fs/btrfs/volumes.h | |
parent | 8b41393fe7c3b180abadc26856fb653014733bb9 (diff) | |
download | lwn-562d7b1512f7369a19bca2883e2e8672d78f0481.tar.gz lwn-562d7b1512f7369a19bca2883e2e8672d78f0481.zip |
btrfs: handle device lookup with btrfs_dev_lookup_args
We have a lot of device lookup functions that all do something slightly
different. Clean this up by adding a struct to hold the different
lookup criteria, and then pass this around to btrfs_find_device() so it
can do the proper matching based on the lookup criteria.
Reviewed-by: Anand Jain <anand.jain@oracle.com>
Signed-off-by: Josef Bacik <josef@toxicpanda.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Diffstat (limited to 'fs/btrfs/volumes.h')
-rw-r--r-- | fs/btrfs/volumes.h | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/fs/btrfs/volumes.h b/fs/btrfs/volumes.h index 874406f51b86..bdcf7641e0bb 100644 --- a/fs/btrfs/volumes.h +++ b/fs/btrfs/volumes.h @@ -451,6 +451,22 @@ struct btrfs_balance_control { struct btrfs_balance_progress stat; }; +/* + * Search for a given device by the set parameters + */ +struct btrfs_dev_lookup_args { + u64 devid; + u8 *uuid; + u8 *fsid; + bool missing; +}; + +/* We have to initialize to -1 because BTRFS_DEV_REPLACE_DEVID is 0 */ +#define BTRFS_DEV_LOOKUP_ARGS_INIT { .devid = (u64)-1 } + +#define BTRFS_DEV_LOOKUP_ARGS(name) \ + struct btrfs_dev_lookup_args name = BTRFS_DEV_LOOKUP_ARGS_INIT + enum btrfs_map_op { BTRFS_MAP_READ, BTRFS_MAP_WRITE, @@ -515,8 +531,8 @@ void __exit btrfs_cleanup_fs_uuids(void); int btrfs_num_copies(struct btrfs_fs_info *fs_info, u64 logical, u64 len); int btrfs_grow_device(struct btrfs_trans_handle *trans, struct btrfs_device *device, u64 new_size); -struct btrfs_device *btrfs_find_device(struct btrfs_fs_devices *fs_devices, - u64 devid, u8 *uuid, u8 *fsid); +struct btrfs_device *btrfs_find_device(const struct btrfs_fs_devices *fs_devices, + const struct btrfs_dev_lookup_args *args); int btrfs_shrink_device(struct btrfs_device *device, u64 new_size); int btrfs_init_new_device(struct btrfs_fs_info *fs_info, const char *path); int btrfs_balance(struct btrfs_fs_info *fs_info, |