summaryrefslogtreecommitdiff
path: root/fs/bcachefs/movinggc.c
diff options
context:
space:
mode:
authorDaniel Hill <daniel@gluo.nz>2022-06-16 02:06:43 +1200
committerKent Overstreet <kent.overstreet@linux.dev>2023-10-22 17:09:35 -0400
commitc91996c50a9ad6569cf9cb52e79c171f0d34814d (patch)
tree5676408c15b5ed709c1a551e7e0ac533c21981cf /fs/bcachefs/movinggc.c
parent7f5c5d20f01483ba53233e3e2c54848e0b2d9ecd (diff)
bcachefs: data jobs, including rebalance wait for copygc.
move_ratelimit() now has a bool that specifies whether we want to wait for copygc to finish. When copygc is running, we're probably low on free buckets instead of consuming the remaining buckets, we want to wait for copygc to finish. This should help with performance, and run away bucket fragmentation. Signed-off-by: Daniel Hill <daniel@gluo.nz> Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Diffstat (limited to 'fs/bcachefs/movinggc.c')
-rw-r--r--fs/bcachefs/movinggc.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/fs/bcachefs/movinggc.c b/fs/bcachefs/movinggc.c
index d63b9fea4f05..8b6ad9ec72af 100644
--- a/fs/bcachefs/movinggc.c
+++ b/fs/bcachefs/movinggc.c
@@ -316,7 +316,8 @@ static int bch2_copygc(struct bch_fs *c)
NULL,
writepoint_ptr(&c->copygc_write_point),
copygc_pred, NULL,
- &move_stats);
+ &move_stats,
+ false);
if (ret < 0)
bch_err(c, "error %i from bch2_move_data() in copygc", ret);
if (ret)
@@ -381,10 +382,11 @@ static int bch2_copygc_thread(void *arg)
struct bch_fs *c = arg;
struct io_clock *clock = &c->io_clock[WRITE];
u64 last, wait;
+ int ret = 0;
set_freezable();
- while (!kthread_should_stop()) {
+ while (!ret && !kthread_should_stop()) {
cond_resched();
if (kthread_wait_freezable(c->copy_gc_enabled))
@@ -403,8 +405,11 @@ static int bch2_copygc_thread(void *arg)
c->copygc_wait = 0;
- if (bch2_copygc(c))
- break;
+ c->copygc_running = true;
+ ret = bch2_copygc(c);
+ c->copygc_running = false;
+
+ wake_up(&c->copygc_running_wq);
}
return 0;
@@ -448,4 +453,6 @@ int bch2_copygc_start(struct bch_fs *c)
void bch2_fs_copygc_init(struct bch_fs *c)
{
+ init_waitqueue_head(&c->copygc_running_wq);
+ c->copygc_running = false;
}