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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This will help a lot in level by level iteration.

Signed-off-by: Qu Wenruo <quwenruo@xxxxxxxxxxxxxx>
---
 ctree.h | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

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);
-- 
2.2.2

--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Filesystem Development]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux