summaryrefslogtreecommitdiffstats
path: root/fs/bcachefs/move.c
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@linux.dev>2023-11-22 23:44:47 -0500
committerKent Overstreet <kent.overstreet@linux.dev>2023-11-24 02:10:28 -0500
commit261af2f1c6b668586325a37df02f904c1c273a7d (patch)
tree1aa07653d56d441193b143186bb947c5dce024af /fs/bcachefs/move.c
parent50e029c6390a6795869b742a5fce1e57d6a76c82 (diff)
downloadlinux-stable-261af2f1c6b668586325a37df02f904c1c273a7d.tar.gz
linux-stable-261af2f1c6b668586325a37df02f904c1c273a7d.tar.bz2
linux-stable-261af2f1c6b668586325a37df02f904c1c273a7d.zip
bcachefs: Make sure bch2_move_ratelimit() also waits for move_ops
This adds move_ctxt_wait_event_timeout(), which can sleep for a timeout while also issueing pending moves as reads complete. Co-developed-by: Daniel Hill <daniel@gluo.nz> Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Diffstat (limited to 'fs/bcachefs/move.c')
-rw-r--r--fs/bcachefs/move.c17
1 files changed, 4 insertions, 13 deletions
diff --git a/fs/bcachefs/move.c b/fs/bcachefs/move.c
index 7819ed8d9df9..71f865352816 100644
--- a/fs/bcachefs/move.c
+++ b/fs/bcachefs/move.c
@@ -500,22 +500,13 @@ int bch2_move_ratelimit(struct moving_context *ctxt)
do {
delay = ctxt->rate ? bch2_ratelimit_delay(ctxt->rate) : 0;
-
- if (delay) {
- if (delay > HZ / 10)
- bch2_trans_unlock_long(ctxt->trans);
- else
- bch2_trans_unlock(ctxt->trans);
- set_current_state(TASK_INTERRUPTIBLE);
- }
-
- if ((current->flags & PF_KTHREAD) && kthread_should_stop()) {
- __set_current_state(TASK_RUNNING);
+ if ((current->flags & PF_KTHREAD) && kthread_should_stop())
return 1;
- }
if (delay)
- schedule_timeout(delay);
+ move_ctxt_wait_event_timeout(ctxt,
+ freezing(current) || kthread_should_stop(),
+ delay);
if (unlikely(freezing(current))) {
bch2_moving_ctxt_flush_all(ctxt);