Btrfs: added helper btrfs_next_item()
authorJan Schmidt <list.btrfs@jan-o-sch.net>
Tue, 22 Nov 2011 14:14:33 +0000 (15:14 +0100)
committerJan Schmidt <list.btrfs@jan-o-sch.net>
Thu, 22 Dec 2011 15:22:26 +0000 (16:22 +0100)
btrfs_next_item() makes the btrfs path point to the next item, crossing leaf
boundaries if needed.

Signed-off-by: Arne Jansen <sensille@gmx.net>
Signed-off-by: Jan Schmidt <list.btrfs@jan-o-sch.net>
fs/btrfs/ctree.h

index 50634abef9b4a51336e95b8bc2aafb4edb7844a0..3e4a07b798179369d0ea7c93393b9b351bba52fd 100644 (file)
@@ -2482,6 +2482,13 @@ static inline int btrfs_insert_empty_item(struct btrfs_trans_handle *trans,
 }
 
 int btrfs_next_leaf(struct btrfs_root *root, struct btrfs_path *path);
+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;
+}
 int btrfs_prev_leaf(struct btrfs_root *root, struct btrfs_path *path);
 int btrfs_leaf_free_space(struct btrfs_root *root, struct extent_buffer *leaf);
 void btrfs_drop_snapshot(struct btrfs_root *root,