]> git.sesse.net Git - bcachefs-tools-debian/blobdiff - libbcachefs/snapshot.c
Update bcachefs sources to 841a95c29f4c bcachefs: fix userspace build errors
[bcachefs-tools-debian] / libbcachefs / snapshot.c
index b2d216fa71824e8666dfac76226726251fe555bd..8d1800ef22b568648f7fa21c742aa3bd06bc33f3 100644 (file)
@@ -123,7 +123,7 @@ bool __bch2_snapshot_is_ancestor(struct bch_fs *c, u32 id, u32 ancestor)
        struct snapshot_table *t;
        bool ret;
 
-       EBUG_ON(c->curr_recovery_pass <= BCH_RECOVERY_PASS_check_snapshots);
+       EBUG_ON(c->recovery_pass_done <= BCH_RECOVERY_PASS_check_snapshots);
 
        rcu_read_lock();
        t = rcu_dereference(c->snapshots);
@@ -1402,27 +1402,24 @@ int bch2_delete_dead_snapshots(struct bch_fs *c)
                goto err;
        }
 
-       ret = for_each_btree_key2(trans, iter, BTREE_ID_snapshots,
-                                 POS_MIN, 0, k,
+       ret = for_each_btree_key(trans, iter, BTREE_ID_snapshots,
+                                POS_MIN, 0, k,
                bch2_snapshot_set_equiv(trans, k));
        if (ret) {
                bch_err_msg(c, ret, "in bch2_snapshots_set_equiv");
                goto err;
        }
 
-       for_each_btree_key(trans, iter, BTREE_ID_snapshots,
-                          POS_MIN, 0, k, ret) {
+       ret = for_each_btree_key(trans, iter, BTREE_ID_snapshots,
+                                POS_MIN, 0, k, ({
                if (k.k->type != KEY_TYPE_snapshot)
                        continue;
 
                snap = bkey_s_c_to_snapshot(k);
-               if (BCH_SNAPSHOT_DELETED(snap.v)) {
-                       ret = snapshot_list_add(c, &deleted, k.k->p.offset);
-                       if (ret)
-                               break;
-               }
-       }
-       bch2_trans_iter_exit(trans, &iter);
+               BCH_SNAPSHOT_DELETED(snap.v)
+                       ? snapshot_list_add(c, &deleted, k.k->p.offset)
+                       : 0;
+       }));
 
        if (ret) {
                bch_err_msg(c, ret, "walking snapshots");
@@ -1469,18 +1466,20 @@ int bch2_delete_dead_snapshots(struct bch_fs *c)
        bch2_trans_unlock(trans);
        down_write(&c->snapshot_create_lock);
 
-       for_each_btree_key(trans, iter, BTREE_ID_snapshots,
-                          POS_MIN, 0, k, ret) {
+       ret = for_each_btree_key(trans, iter, BTREE_ID_snapshots,
+                                POS_MIN, 0, k, ({
                u32 snapshot = k.k->p.offset;
                u32 equiv = bch2_snapshot_equiv(c, snapshot);
 
-               if (equiv != snapshot)
-                       snapshot_list_add(c, &deleted_interior, snapshot);
-       }
-       bch2_trans_iter_exit(trans, &iter);
+               equiv != snapshot
+                       ? snapshot_list_add(c, &deleted_interior, snapshot)
+                       : 0;
+       }));
 
-       if (ret)
+       if (ret) {
+               bch_err_msg(c, ret, "walking snapshots");
                goto err_create_lock;
+       }
 
        /*
         * Fixing children of deleted snapshots can't be done completely
@@ -1694,13 +1693,13 @@ int bch2_snapshots_read(struct bch_fs *c)
        int ret = 0;
 
        ret = bch2_trans_run(c,
-               for_each_btree_key2(trans, iter, BTREE_ID_snapshots,
-                          POS_MIN, 0, k,
+               for_each_btree_key(trans, iter, BTREE_ID_snapshots,
+                                  POS_MIN, 0, k,
                        bch2_mark_snapshot(trans, BTREE_ID_snapshots, 0, bkey_s_c_null, k, 0) ?:
                        bch2_snapshot_set_equiv(trans, k) ?:
                        bch2_check_snapshot_needs_deletion(trans, k)) ?:
-               for_each_btree_key2(trans, iter, BTREE_ID_snapshots,
-                          POS_MIN, 0, k,
+               for_each_btree_key(trans, iter, BTREE_ID_snapshots,
+                                  POS_MIN, 0, k,
                           (set_is_ancestor_bitmap(c, k.k->p.offset), 0)));
        if (ret)
                bch_err_fn(c, ret);