summaryrefslogtreecommitdiff
path: root/fs/btrfs/volumes.c
diff options
context:
space:
mode:
authorChris Mason <chris.mason@oracle.com>2008-04-25 09:04:37 -0400
committerChris Mason <chris.mason@oracle.com>2008-09-25 11:04:02 -0400
commit84eed90fac1b927a2657ff3bb7a0f18b9cb688f7 (patch)
tree651362117230506a34fcc9d07421faa5b14dda8b /fs/btrfs/volumes.c
parent004fb5750615bb3cf53e2aa50f6ef1ea57d97df9 (diff)
downloadlwn-84eed90fac1b927a2657ff3bb7a0f18b9cb688f7.tar.gz
lwn-84eed90fac1b927a2657ff3bb7a0f18b9cb688f7.zip
Btrfs: Add failure handling for read_sys_array
Signed-off-by: Chris Mason <chris.mason@oracle.com>
Diffstat (limited to 'fs/btrfs/volumes.c')
-rw-r--r--fs/btrfs/volumes.c16
1 files changed, 9 insertions, 7 deletions
diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
index bccb5566fd84..c63a982e31d0 100644
--- a/fs/btrfs/volumes.c
+++ b/fs/btrfs/volumes.c
@@ -1365,14 +1365,14 @@ int btrfs_read_sys_array(struct btrfs_root *root)
struct extent_buffer *sb = root->fs_info->sb_buffer;
struct btrfs_disk_key *disk_key;
struct btrfs_chunk *chunk;
- struct btrfs_key key;
+ u8 *ptr;
+ unsigned long sb_ptr;
+ int ret = 0;
u32 num_stripes;
u32 array_size;
u32 len = 0;
- u8 *ptr;
- unsigned long sb_ptr;
u32 cur;
- int ret;
+ struct btrfs_key key;
array_size = btrfs_super_sys_array_size(super_copy);
@@ -1397,17 +1397,19 @@ int btrfs_read_sys_array(struct btrfs_root *root)
if (key.type == BTRFS_CHUNK_ITEM_KEY) {
chunk = (struct btrfs_chunk *)sb_ptr;
ret = read_one_chunk(root, &key, sb, chunk);
- BUG_ON(ret);
+ if (ret)
+ break;
num_stripes = btrfs_chunk_num_stripes(sb, chunk);
len = btrfs_chunk_item_size(num_stripes);
} else {
- BUG();
+ ret = -EIO;
+ break;
}
ptr += len;
sb_ptr += len;
cur += len;
}
- return 0;
+ return ret;
}
int btrfs_read_chunk_tree(struct btrfs_root *root)