bcachefs: trans_for_each_path_with_node() no longer uses path->idx
authorKent Overstreet <kent.overstreet@linux.dev>
Mon, 11 Dec 2023 04:57:50 +0000 (23:57 -0500)
committerKent Overstreet <kent.overstreet@linux.dev>
Mon, 1 Jan 2024 16:47:43 +0000 (11:47 -0500)
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
fs/bcachefs/btree_iter.c
fs/bcachefs/btree_iter.h
fs/bcachefs/btree_locking.h
fs/bcachefs/btree_update_interior.c

index 7723c03ec5538a80702a6d92c938809b82012b1e..f69b84711cc275483ec9ea54ec181d29ccc49023 100644 (file)
@@ -418,8 +418,9 @@ void bch2_btree_path_fix_key_modified(struct btree_trans *trans,
                                      struct bkey_packed *where)
 {
        struct btree_path *path;
+       unsigned i;
 
-       trans_for_each_path_with_node(trans, b, path) {
+       trans_for_each_path_with_node(trans, b, path, i) {
                __bch2_btree_path_fix_key_modified(path, b, where);
                bch2_btree_path_verify_level(trans, path, b->c.level);
        }
@@ -526,6 +527,7 @@ void bch2_btree_node_iter_fix(struct btree_trans *trans,
 {
        struct bset_tree *t = bch2_bkey_to_bset_inlined(b, where);
        struct btree_path *linked;
+       unsigned i;
 
        if (node_iter != &path->l[b->c.level].iter) {
                __bch2_btree_node_iter_fix(path, b, node_iter, t,
@@ -535,7 +537,7 @@ void bch2_btree_node_iter_fix(struct btree_trans *trans,
                        bch2_btree_node_iter_verify(node_iter, b);
        }
 
-       trans_for_each_path_with_node(trans, b, linked) {
+       trans_for_each_path_with_node(trans, b, linked, i) {
                __bch2_btree_node_iter_fix(linked, b,
                                           &linked->l[b->c.level].iter, t,
                                           where, clobber_u64s, new_u64s);
@@ -714,8 +716,9 @@ void bch2_trans_node_add(struct btree_trans *trans,
 void bch2_trans_node_reinit_iter(struct btree_trans *trans, struct btree *b)
 {
        struct btree_path *path;
+       unsigned i;
 
-       trans_for_each_path_with_node(trans, b, path)
+       trans_for_each_path_with_node(trans, b, path, i)
                __btree_path_level_init(path, b->c.level);
 
        bch2_trans_revalidate_updates_in_node(trans, b);
index a75d0e7d122ab763f3b68d46081899d9980b962c..eb9aa3930ca2554342bb49c6b32f4f2116239e41 100644 (file)
@@ -151,22 +151,21 @@ static inline bool __path_has_node(const struct btree_path *path,
 
 static inline struct btree_path *
 __trans_next_path_with_node(struct btree_trans *trans, struct btree *b,
-                           unsigned idx)
+                           unsigned *idx)
 {
-       struct btree_path *path = __trans_next_path(trans, &idx);
+       struct btree_path *path;
 
-       while ((path = __trans_next_path(trans, &idx)) &&
+       while ((path = __trans_next_path(trans, idx)) &&
                !__path_has_node(path, b))
-              idx++;
+              (*idx)++;
 
        return path;
 }
 
-#define trans_for_each_path_with_node(_trans, _b, _path)               \
-       for (_path = __trans_next_path_with_node((_trans), (_b), 1);    \
-            (_path);                                                   \
-            _path = __trans_next_path_with_node((_trans), (_b),        \
-                                                (_path)->idx + 1))
+#define trans_for_each_path_with_node(_trans, _b, _path, _iter)                \
+       for (_iter = 1;                                                 \
+            (_path = __trans_next_path_with_node((_trans), (_b), &_iter));\
+            _iter++)
 
 btree_path_idx_t __bch2_btree_path_make_mut(struct btree_trans *, btree_path_idx_t,
                                            bool, unsigned long);
index e9056fc3337d25fe234a4374d01f0d3a9c0e3a74..fc92781e97ba9cd5c5ca504c02821ff86228894e 100644 (file)
@@ -175,6 +175,7 @@ bch2_btree_node_unlock_write_inlined(struct btree_trans *trans, struct btree_pat
                                     struct btree *b)
 {
        struct btree_path *linked;
+       unsigned i;
 
        EBUG_ON(path->l[b->c.level].b != b);
        EBUG_ON(path->l[b->c.level].lock_seq != six_lock_seq(&b->c.lock));
@@ -182,7 +183,7 @@ bch2_btree_node_unlock_write_inlined(struct btree_trans *trans, struct btree_pat
 
        mark_btree_node_locked_noreset(path, b->c.level, BTREE_NODE_INTENT_LOCKED);
 
-       trans_for_each_path_with_node(trans, b, linked)
+       trans_for_each_path_with_node(trans, b, linked, i)
                linked->l[b->c.level].lock_seq++;
 
        six_unlock_write(&b->c.lock);
index 83cb363837f840fd75b1e5b5c602d5b3872cc06e..0649c219df3305c5c4f9ff4cebc48fea7ed1dea2 100644 (file)
@@ -1646,13 +1646,14 @@ bch2_btree_insert_keys_interior(struct btree_update *as,
                                struct keylist *keys)
 {
        struct btree_path *linked;
+       unsigned i;
 
        __bch2_btree_insert_keys_interior(as, trans, path, b,
                                          path->l[b->c.level].iter, keys);
 
        btree_update_updated_node(as, b);
 
-       trans_for_each_path_with_node(trans, b, linked)
+       trans_for_each_path_with_node(trans, b, linked, i)
                bch2_btree_node_iter_peek(&linked->l[b->c.level].iter, b);
 
        bch2_trans_verify_paths(trans);