aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/volumes.c
diff options
context:
space:
mode:
authorMiao Xie <miaox@cn.fujitsu.com>2013-05-15 03:48:19 -0400
committerJosef Bacik <jbacik@fusionio.com>2013-06-14 11:29:37 -0400
commitcb517eabba4f109810dba2e5f37b0dcf22103065 (patch)
tree5c553813bf6fdc41df3912a1146828cba64d3b17 /fs/btrfs/volumes.c
parentbabbf170c781f24095336c82ebf18ad272ddb773 (diff)
Btrfs: cleanup the similar code of the fs root read
There are several functions whose code is similar, such as btrfs_find_last_root() btrfs_read_fs_root_no_radix() Besides that, some functions are invoked twice, it is unnecessary, for example, we are sure that all roots which is found in btrfs_find_orphan_roots() have their orphan items, so it is unnecessary to check the orphan item again. So cleanup it. Signed-off-by: Miao Xie <miaox@cn.fujitsu.com> Signed-off-by: Josef Bacik <jbacik@fusionio.com>
Diffstat (limited to 'fs/btrfs/volumes.c')
-rw-r--r--fs/btrfs/volumes.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
index 24940085cdac..440de708f9eb 100644
--- a/fs/btrfs/volumes.c
+++ b/fs/btrfs/volumes.c
@@ -5367,7 +5367,6 @@ static struct btrfs_device *add_missing_dev(struct btrfs_root *root,
5367 return NULL; 5367 return NULL;
5368 list_add(&device->dev_list, 5368 list_add(&device->dev_list,
5369 &fs_devices->devices); 5369 &fs_devices->devices);
5370 device->dev_root = root->fs_info->dev_root;
5371 device->devid = devid; 5370 device->devid = devid;
5372 device->work.func = pending_bios_fn; 5371 device->work.func = pending_bios_fn;
5373 device->fs_devices = fs_devices; 5372 device->fs_devices = fs_devices;
@@ -5593,7 +5592,6 @@ static int read_one_dev(struct btrfs_root *root,
5593 } 5592 }
5594 5593
5595 fill_device_from_item(leaf, dev_item, device); 5594 fill_device_from_item(leaf, dev_item, device);
5596 device->dev_root = root->fs_info->dev_root;
5597 device->in_fs_metadata = 1; 5595 device->in_fs_metadata = 1;
5598 if (device->writeable && !device->is_tgtdev_for_dev_replace) { 5596 if (device->writeable && !device->is_tgtdev_for_dev_replace) {
5599 device->fs_devices->total_rw_bytes += device->total_bytes; 5597 device->fs_devices->total_rw_bytes += device->total_bytes;
@@ -5751,6 +5749,17 @@ error:
5751 return ret; 5749 return ret;
5752} 5750}
5753 5751
5752void btrfs_init_devices_late(struct btrfs_fs_info *fs_info)
5753{
5754 struct btrfs_fs_devices *fs_devices = fs_info->fs_devices;
5755 struct btrfs_device *device;
5756
5757 mutex_lock(&fs_devices->device_list_mutex);
5758 list_for_each_entry(device, &fs_devices->devices, dev_list)
5759 device->dev_root = fs_info->dev_root;
5760 mutex_unlock(&fs_devices->device_list_mutex);
5761}
5762
5754static void __btrfs_reset_dev_stats(struct btrfs_device *dev) 5763static void __btrfs_reset_dev_stats(struct btrfs_device *dev)
5755{ 5764{
5756 int i; 5765 int i;