forked from Mirrors/btrfs-progs
btrfs-restore: deal with NULL returns from read_node_slot
Signed-off-by: Chris Mason <chris.mason@fusionio.com>master
parent
8b5d89be6d
commit
194aa4a1bd
|
@ -152,9 +152,11 @@ int next_leaf(struct btrfs_root *root, struct btrfs_path *path)
|
||||||
{
|
{
|
||||||
int slot;
|
int slot;
|
||||||
int level = 1;
|
int level = 1;
|
||||||
|
int offset = 1;
|
||||||
struct extent_buffer *c;
|
struct extent_buffer *c;
|
||||||
struct extent_buffer *next = NULL;
|
struct extent_buffer *next = NULL;
|
||||||
|
|
||||||
|
again:
|
||||||
for (; level < BTRFS_MAX_LEVEL; level++) {
|
for (; level < BTRFS_MAX_LEVEL; level++) {
|
||||||
if (path->nodes[level])
|
if (path->nodes[level])
|
||||||
break;
|
break;
|
||||||
|
@ -169,7 +171,7 @@ int next_leaf(struct btrfs_root *root, struct btrfs_path *path)
|
||||||
if (!path->nodes[level])
|
if (!path->nodes[level])
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
slot = path->slots[level] + 1;
|
slot = path->slots[level] + offset;
|
||||||
c = path->nodes[level];
|
c = path->nodes[level];
|
||||||
if (slot >= btrfs_header_nritems(c)) {
|
if (slot >= btrfs_header_nritems(c)) {
|
||||||
level++;
|
level++;
|
||||||
|
@ -182,7 +184,9 @@ int next_leaf(struct btrfs_root *root, struct btrfs_path *path)
|
||||||
reada_for_search(root, path, level, slot, 0);
|
reada_for_search(root, path, level, slot, 0);
|
||||||
|
|
||||||
next = read_node_slot(root, c, slot);
|
next = read_node_slot(root, c, slot);
|
||||||
break;
|
if (next)
|
||||||
|
break;
|
||||||
|
offset++;
|
||||||
}
|
}
|
||||||
path->slots[level] = slot;
|
path->slots[level] = slot;
|
||||||
while(1) {
|
while(1) {
|
||||||
|
@ -196,6 +200,8 @@ int next_leaf(struct btrfs_root *root, struct btrfs_path *path)
|
||||||
if (path->reada)
|
if (path->reada)
|
||||||
reada_for_search(root, path, level, 0, 0);
|
reada_for_search(root, path, level, 0, 0);
|
||||||
next = read_node_slot(root, next, 0);
|
next = read_node_slot(root, next, 0);
|
||||||
|
if (!next)
|
||||||
|
goto again;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
3
ctree.c
3
ctree.c
|
@ -797,7 +797,8 @@ struct extent_buffer *read_node_slot(struct btrfs_root *root,
|
||||||
if (slot >= btrfs_header_nritems(parent))
|
if (slot >= btrfs_header_nritems(parent))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
BUG_ON(level == 0);
|
if (level == 0)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
return read_tree_block(root, btrfs_node_blockptr(parent, slot),
|
return read_tree_block(root, btrfs_node_blockptr(parent, slot),
|
||||||
btrfs_level_size(root, level - 1),
|
btrfs_level_size(root, level - 1),
|
||||||
|
|
Loading…
Reference in New Issue