@@ -2340,13 +2340,18 @@ static inline int btrfs_next_tree_block(struct btrfs_root *root,
return btrfs_next_leaf(root, path);
}
+static inline int btrfs_next_slot(struct btrfs_root *root,
+ struct btrfs_path *p, int level)
+{
+ ++p->slots[level];
+ if (p->slots[level] >= btrfs_header_nritems(p->nodes[level]))
+ return btrfs_next_tree_block(root, p);
+ return 0;
+}
static inline int btrfs_next_item(struct btrfs_root *root,
struct btrfs_path *p)
{
- ++p->slots[0];
- if (p->slots[0] >= btrfs_header_nritems(p->nodes[0]))
- return btrfs_next_leaf(root, p);
- return 0;
+ return btrfs_next_slot(root, p, 0);
}
int btrfs_prev_leaf(struct btrfs_root *root, struct btrfs_path *path);
This will help a lot in level by level iteration. Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com> --- ctree.h | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-)