]> git.sesse.net Git - bcachefs-tools-debian/blobdiff - libbcachefs/move.c
Update bcachefs sources to 25de2b00dc bcachefs: Change check for invalid key types
[bcachefs-tools-debian] / libbcachefs / move.c
index 37fb3784a2f97fa6e18ac72ab7211cc2341b5adc..05272673901d2ba93cccd69c0b1e9febf4042803 100644 (file)
@@ -632,7 +632,7 @@ int bch2_move_data(struct bch_fs *c,
        bch2_moving_ctxt_init(&ctxt, c, rate, stats, wp, wait_on_copygc);
 
        for (id = start_btree_id;
-            id <= min_t(unsigned, end_btree_id, BTREE_ID_NR - 1);
+            id <= min_t(unsigned, end_btree_id, btree_id_nr_alive(c) - 1);
             id++) {
                stats->btree_id = id;
 
@@ -640,6 +640,9 @@ int bch2_move_data(struct bch_fs *c,
                    id != BTREE_ID_reflink)
                        continue;
 
+               if (!bch2_btree_id_root(c, id)->b)
+                       continue;
+
                ret = __bch2_move_data(&ctxt,
                                       id == start_btree_id ? start_pos : POS_MIN,
                                       id == end_btree_id   ? end_pos   : POS_MAX,
@@ -861,10 +864,13 @@ static int bch2_move_btree(struct bch_fs *c,
        stats->data_type = BCH_DATA_btree;
 
        for (id = start_btree_id;
-            id <= min_t(unsigned, end_btree_id, BTREE_ID_NR - 1);
+            id <= min_t(unsigned, end_btree_id, btree_id_nr_alive(c) - 1);
             id++) {
                stats->btree_id = id;
 
+               if (!bch2_btree_id_root(c, id)->b)
+                       continue;
+
                bch2_trans_node_iter_init(&trans, &iter, id, POS_MIN, 0, 0,
                                          BTREE_ITER_PREFETCH);
 retry: