diff mbox

[2/7] btrfs-progs: Introduce btrfs_next_slot() function to iterate to next slot in given level.

Message ID 1423034213-14018-3-git-send-email-quwenruo@cn.fujitsu.com (mailing list archive)
State New, archived
Headers show

Commit Message

Qu Wenruo Feb. 4, 2015, 7:16 a.m. UTC
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(-)
diff mbox

Patch

diff --git a/ctree.h b/ctree.h
index c52d3de..0dfe733 100644
--- a/ctree.h
+++ b/ctree.h
@@ -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);