static int next_leaf(struct btrfs_root *root, struct btrfs_path *path) { int slot; int level = 1; int offset = 1; struct extent_buffer *c; struct extent_buffer *next = NULL; struct btrfs_fs_info *fs_info = root->fs_info; again: for (; level < BTRFS_MAX_LEVEL; level++) { if (path->nodes[level]) break; } if (level >= BTRFS_MAX_LEVEL) return 1; slot = path->slots[level] + 1; while(level < BTRFS_MAX_LEVEL) { if (!path->nodes[level]) return 1; slot = path->slots[level] + offset; c = path->nodes[level]; if (slot >= btrfs_header_nritems(c)) { level++; if (level == BTRFS_MAX_LEVEL) return 1; offset = 1; continue; } if (path->reada) reada_for_search(fs_info, path, level, slot, 0); next = read_node_slot(fs_info, c, slot); if (extent_buffer_uptodate(next)) break; offset++; } path->slots[level] = slot; while(1) { level--; c = path->nodes[level]; free_extent_buffer(c); path->nodes[level] = next; path->slots[level] = 0; if (!level) break; if (path->reada) reada_for_search(fs_info, path, level, 0, 0); next = read_node_slot(fs_info, next, 0); if (!extent_buffer_uptodate(next)) goto again; } return 0; }
int next_leaf(struct btrfs_root *root, struct btrfs_path *path) { int slot; int level = 1; struct extent_buffer *c; struct extent_buffer *next = NULL; for (; level < BTRFS_MAX_LEVEL; level++) { if (path->nodes[level]) break; } if (level == BTRFS_MAX_LEVEL) return 1; slot = path->slots[level] + 1; while(level < BTRFS_MAX_LEVEL) { if (!path->nodes[level]) return 1; slot = path->slots[level] + 1; c = path->nodes[level]; if (slot >= btrfs_header_nritems(c)) { level++; if (level == BTRFS_MAX_LEVEL) return 1; continue; } if (next) free_extent_buffer(next); if (path->reada) reada_for_search(root, path, level, slot, 0); next = read_node_slot(root, c, slot); break; } path->slots[level] = slot; while(1) { level--; c = path->nodes[level]; free_extent_buffer(c); path->nodes[level] = next; path->slots[level] = 0; if (!level) break; if (path->reada) reada_for_search(root, path, level, 0, 0); next = read_node_slot(root, next, 0); } return 0; }