aboutsummaryrefslogtreecommitdiffstats
path: root/volumes.c
diff options
context:
space:
mode:
authorQu Wenruo <quwenruo@cn.fujitsu.com>2013-06-27 14:25:18 +0800
committerDavid Sterba <dsterba@suse.cz>2013-08-09 14:32:32 +0200
commitbe96777126d283773e4397278a5662d90676ab88 (patch)
tree5808f0a899ef7bfc09f3b7d98508416ac0aecc0e /volumes.c
parent6c10240e4ed096ea028bb0b18d1eb71280329a3c (diff)
downloadbtrfs-progs-be96777126d283773e4397278a5662d90676ab88.tar.gz
btrfs-progs-be96777126d283773e4397278a5662d90676ab88.tar.xz
btrfs-progs-be96777126d283773e4397278a5662d90676ab88.zip
btrfs-progs: Cleanup unneeded extra variant in btrfs_read_sys_array
The btrfs_read_sys_array function uses 3 variants to read data from super block. But the three variants are related to each other, so the patch removes unneeded extra variants and make code a little simpler. Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com> Reviewed-by: Miao Xie <miaox@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.cz> Signed-off-by: Chris Mason <chris.mason@fusionio.com>
Diffstat (limited to 'volumes.c')
-rw-r--r--volumes.c17
1 files changed, 5 insertions, 12 deletions
diff --git a/volumes.c b/volumes.c
index cb7adef..68b4294 100644
--- a/volumes.c
+++ b/volumes.c
@@ -1645,11 +1645,9 @@ int btrfs_read_sys_array(struct btrfs_root *root)
struct btrfs_chunk *chunk;
struct btrfs_key key;
u32 num_stripes;
- u32 array_size;
u32 len = 0;
u8 *ptr;
- unsigned long sb_ptr;
- u32 cur;
+ u8 *array_end;
int ret = 0;
sb = btrfs_find_create_tree_block(root, BTRFS_SUPER_INFO_OFFSET,
@@ -1658,7 +1656,8 @@ int btrfs_read_sys_array(struct btrfs_root *root)
return -ENOMEM;
btrfs_set_buffer_uptodate(sb);
write_extent_buffer(sb, super_copy, 0, sizeof(*super_copy));
- array_size = btrfs_super_sys_array_size(super_copy);
+ array_end = ((u8 *)super_copy->sys_chunk_array) +
+ btrfs_super_sys_array_size(super_copy);
/*
* we do this loop twice, once for the device items and
@@ -1666,20 +1665,16 @@ int btrfs_read_sys_array(struct btrfs_root *root)
* structs filled in for every chunk
*/
ptr = super_copy->sys_chunk_array;
- sb_ptr = offsetof(struct btrfs_super_block, sys_chunk_array);
- cur = 0;
- while (cur < array_size) {
+ while (ptr < array_end) {
disk_key = (struct btrfs_disk_key *)ptr;
btrfs_disk_key_to_cpu(&key, disk_key);
len = sizeof(*disk_key);
ptr += len;
- sb_ptr += len;
- cur += len;
if (key.type == BTRFS_CHUNK_ITEM_KEY) {
- chunk = (struct btrfs_chunk *)sb_ptr;
+ chunk = (struct btrfs_chunk *)(ptr - (u8 *)super_copy);
ret = read_one_chunk(root, &key, sb, chunk);
if (ret)
break;
@@ -1689,8 +1684,6 @@ int btrfs_read_sys_array(struct btrfs_root *root)
BUG();
}
ptr += len;
- sb_ptr += len;
- cur += len;
}
free_extent_buffer(sb);
return ret;