btrfs-progs: Introduce btrfs_close_all_devices helper

If there is more than one fs_devices in fs_uuids list (like mkfs.btrfs
does), we need close them all before exit. Add a helper for that.

Signed-off-by: Zhao Lei <zhaolei@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
master
Zhao Lei 2015-08-24 16:45:02 +08:00 committed by David Sterba
parent 004eabb1ad
commit b0f760c91a
2 changed files with 12 additions and 0 deletions

View File

@ -198,6 +198,17 @@ again:
return 0;
}
void btrfs_close_all_devices(void)
{
struct btrfs_fs_devices *fs_devices;
while (!list_empty(&fs_uuids)) {
fs_devices = list_entry(fs_uuids.next, struct btrfs_fs_devices,
list);
btrfs_close_devices(fs_devices);
}
}
int btrfs_open_devices(struct btrfs_fs_devices *fs_devices, int flags)
{
int fd;

View File

@ -187,6 +187,7 @@ int btrfs_add_device(struct btrfs_trans_handle *trans,
int btrfs_open_devices(struct btrfs_fs_devices *fs_devices,
int flags);
int btrfs_close_devices(struct btrfs_fs_devices *fs_devices);
void btrfs_close_all_devices(void);
int btrfs_add_device(struct btrfs_trans_handle *trans,
struct btrfs_root *root,
struct btrfs_device *device);