]> git.sesse.net Git - bcachefs-tools-debian/blobdiff - libbcachefs/movinggc.c
Update bcachefs sources to bca25b802d fixup! bcachefs: Fix bch2_check_discard_freespa...
[bcachefs-tools-debian] / libbcachefs / movinggc.c
index d13a120da267a04d4075c197818335cbe5c403a7..6750767276f29ca1edfd1328e60fc99b6494036b 100644 (file)
@@ -24,8 +24,8 @@
 #include "move.h"
 #include "movinggc.h"
 #include "super-io.h"
+#include "trace.h"
 
-#include <trace/events/bcachefs.h>
 #include <linux/bsearch.h>
 #include <linux/freezer.h>
 #include <linux/kthread.h>
@@ -91,12 +91,9 @@ static int bch2_bucket_is_movable(struct btree_trans *trans,
                                b->k.bucket.offset))
                return 0;
 
-       bch2_trans_iter_init(trans, &iter, BTREE_ID_alloc,
-                            b->k.bucket, BTREE_ITER_CACHED);
-       k = bch2_btree_iter_peek_slot(&iter);
+       k = bch2_bkey_get_iter(trans, &iter, BTREE_ID_alloc,
+                              b->k.bucket, BTREE_ITER_CACHED);
        ret = bkey_err(k);
-       bch2_trans_iter_exit(trans, &iter);
-
        if (ret)
                return ret;
 
@@ -108,14 +105,7 @@ static int bch2_bucket_is_movable(struct btree_trans *trans,
                a->fragmentation_lru &&
                a->fragmentation_lru <= time;
 
-       if (!ret) {
-               struct printbuf buf = PRINTBUF;
-
-               bch2_bkey_val_to_text(&buf, trans->c, k);
-               pr_debug("%s", buf.buf);
-               printbuf_exit(&buf);
-       }
-
+       bch2_trans_iter_exit(trans, &iter);
        return ret;
 }
 
@@ -134,13 +124,6 @@ static void move_buckets_wait(struct btree_trans *trans,
                if (atomic_read(&i->count))
                        break;
 
-               /*
-                * moving_ctxt_exit calls bch2_write as it flushes pending
-                * reads, which inits another btree_trans; this one must be
-                * unlocked:
-                */
-               bch2_verify_bucket_evacuated(trans, i->bucket.k.bucket, i->bucket.k.gen);
-
                list->first = i->next;
                if (!list->first)
                        list->last = NULL;
@@ -212,6 +195,7 @@ static int bch2_copygc_get_buckets(struct btree_trans *trans,
        return ret < 0 ? ret : 0;
 }
 
+noinline
 static int bch2_copygc(struct btree_trans *trans,
                       struct moving_context *ctxt,
                       struct buckets_in_flight *buckets_in_flight)
@@ -252,7 +236,7 @@ err:
        darray_exit(&buckets);
 
        /* no entries in LRU btree found, or got to end: */
-       if (ret == -ENOENT)
+       if (bch2_err_matches(ret, ENOENT))
                ret = 0;
 
        if (ret < 0 && !bch2_err_matches(ret, EROFS))