summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@gmail.com>2022-06-20 16:05:21 -0400
committerKent Overstreet <kent.overstreet@gmail.com>2022-07-12 08:52:52 -0400
commitf0b47a501cb36a3ad135a4cb9d229aadb76e5331 (patch)
tree43ec6f210390f46f398145f0f36626ad25b1e8f2
parent4db6446ff8c41d09a0b908decd0162eebd884805 (diff)
bcachefs: Pipeline copygc across multiple buckets
This tweaks the copygc path to keep the same moving_ctxt across multiple evacuate bucket calls, meaning we can pipeline across buckets - should be a nice performance boost. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
-rw-r--r--fs/bcachefs/movinggc.c29
1 files changed, 15 insertions, 14 deletions
diff --git a/fs/bcachefs/movinggc.c b/fs/bcachefs/movinggc.c
index e184159abdb3..f9ad4cb26905 100644
--- a/fs/bcachefs/movinggc.c
+++ b/fs/bcachefs/movinggc.c
@@ -95,10 +95,11 @@ static int bch2_copygc(struct bch_fs *c)
struct bch_dev *ca;
unsigned dev_idx;
size_t heap_size = 0;
+ struct moving_context ctxt;
struct data_update_opts data_opts = {
.btree_insert_flags = BTREE_INSERT_USE_RESERVE|JOURNAL_WATERMARK_copygc,
};
- int ret;
+ int ret = 0;
bch_move_stats_init(&move_stats, "copygc");
@@ -147,22 +148,22 @@ static int bch2_copygc(struct bch_fs *c)
heap_resort(h, fragmentation_cmp, NULL);
- while (h->used) {
+ bch2_moving_ctxt_init(&ctxt, c, NULL, &move_stats,
+ writepoint_ptr(&c->copygc_write_point),
+ false);
+
+ /* not correct w.r.t. device removal */
+ while (h->used && !ret) {
BUG_ON(!heap_pop(h, e, -fragmentation_cmp, NULL));
- /* not correct w.r.t. device removal */
-
- ret = bch2_evacuate_bucket(c, POS(e.dev, e.bucket), e.gen,
- &data_opts,
- NULL,
- &move_stats,
- writepoint_ptr(&c->copygc_write_point),
- false);
- if (ret < 0)
- bch_err(c, "error %i from bch2_move_data() in copygc", ret);
- if (ret)
- return ret;
+ ret = __bch2_evacuate_bucket(&ctxt, POS(e.dev, e.bucket), e.gen,
+ data_opts);
}
+ bch2_moving_ctxt_exit(&ctxt);
+
+ if (ret < 0)
+ bch_err(c, "error %i from bch2_move_data() in copygc", ret);
+
trace_copygc(c, atomic64_read(&move_stats.sectors_moved), 0, 0, 0);
return ret;
}