diff options
author | Kent Overstreet <kent.overstreet@gmail.com> | 2021-04-07 21:04:04 -0400 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@linux.dev> | 2023-10-22 17:08:59 -0400 |
commit | b1bd955ba5693f18a091a5cfe3a21ab3bee74edf (patch) | |
tree | 6e498750ef46d6a8aaabed5623f84fa49e49ddf0 /fs/bcachefs/alloc_background.c | |
parent | 3a14d58e7b330f3526509917bb6a38b55a1feef5 (diff) |
bcachefs: Don't wait for ALLOC_SCAN_BATCH buckets in allocator
It used to be necessary for the allocator thread to batch up
invalidating buckets when possible - but since we added the btree key
cache that hasn't been a concern, and now it's causing the allocator
thread to livelock when the filesystem is nearly full.
Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Diffstat (limited to 'fs/bcachefs/alloc_background.c')
-rw-r--r-- | fs/bcachefs/alloc_background.c | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/fs/bcachefs/alloc_background.c b/fs/bcachefs/alloc_background.c index be86e36e816a..a8a59140efbe 100644 --- a/fs/bcachefs/alloc_background.c +++ b/fs/bcachefs/alloc_background.c @@ -1071,7 +1071,7 @@ static int bch2_allocator_thread(void *arg) pr_debug("free_inc now empty"); - do { + while (1) { cond_resched(); /* * Find some buckets that we can invalidate, either @@ -1095,22 +1095,21 @@ static int bch2_allocator_thread(void *arg) wake_up_process(c->gc_thread); } + if (nr) + break; + /* * If we found any buckets, we have to invalidate them * before we scan for more - but if we didn't find very * many we may want to wait on more buckets being * available so we don't spin: */ - if (!nr || - (nr < ALLOC_SCAN_BATCH(ca) && - !fifo_empty(&ca->free[RESERVE_NONE]))) { - ret = wait_buckets_available(c, ca); - if (ret) { - up_read(&c->gc_lock); - goto stop; - } + ret = wait_buckets_available(c, ca); + if (ret) { + up_read(&c->gc_lock); + goto stop; } - } while (!nr); + } up_read(&c->gc_lock); |