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;
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,
bch2_trans_iter_exit(trans, &iter);
if (ret) {
- bch_err(c, "%s: error looking up alloc key: %s", __func__, bch2_err_str(ret));
+ bch_err_msg(c, ret, "looking up alloc key");
goto err;
}
ret = bch2_btree_write_buffer_flush(trans);
if (ret) {
- bch_err(c, "%s: error flushing btree write buffer: %s", __func__, bch2_err_str(ret));
+ bch_err_msg(c, ret, "flushing btree write buffer");
goto err;
}
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:
bch2_trans_exit(&trans);
if (ret)
- bch_err(c, "error in %s(): %s", __func__, bch2_err_str(ret));
+ bch_err_fn(c, ret);
bch2_btree_interior_updates_flush(c);
mutex_unlock(&c->sb_lock);
}
+ if (ret)
+ bch_err_fn(c, ret);
return ret;
}