summaryrefslogtreecommitdiff
path: root/fs/bcachefs/journal_reclaim.c
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@gmail.com>2021-04-16 19:38:14 +0300
committerKent Overstreet <kent.overstreet@linux.dev>2023-10-23 00:09:00 +0300
commit96f399d0eed9a63e706c045407675622f32f5a5d (patch)
tree7d91640610af487781fe217b76a5d9b8ba908ad6 /fs/bcachefs/journal_reclaim.c
parent3e07a7300f0684f7c77485e65a1ae97c7ab2514f (diff)
downloadlinux-96f399d0eed9a63e706c045407675622f32f5a5d.tar.xz
bcachefs: Fix journal reclaim loop
When dirty key cache keys were separated from other journal pins, we broke the loop conditional in __bch2_journal_reclaim() - it's supposed to keep looping as long as there's work to do. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com> Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Diffstat (limited to 'fs/bcachefs/journal_reclaim.c')
-rw-r--r--fs/bcachefs/journal_reclaim.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/fs/bcachefs/journal_reclaim.c b/fs/bcachefs/journal_reclaim.c
index 0d7fe1f99dbf..e2086c76d104 100644
--- a/fs/bcachefs/journal_reclaim.c
+++ b/fs/bcachefs/journal_reclaim.c
@@ -599,7 +599,7 @@ static int __bch2_journal_reclaim(struct journal *j, bool direct)
struct bch_fs *c = container_of(j, struct bch_fs, journal);
bool kthread = (current->flags & PF_KTHREAD) != 0;
u64 seq_to_flush;
- size_t min_nr, nr_flushed;
+ size_t min_nr, min_key_cache, nr_flushed;
unsigned flags;
int ret = 0;
@@ -649,9 +649,10 @@ static int __bch2_journal_reclaim(struct journal *j, bool direct)
atomic_long_read(&c->btree_key_cache.nr_dirty),
atomic_long_read(&c->btree_key_cache.nr_keys));
+ min_key_cache = min(bch2_nr_btree_keys_need_flush(c), 128UL);
+
nr_flushed = journal_flush_pins(j, seq_to_flush,
- min_nr,
- min(bch2_nr_btree_keys_need_flush(c), 128UL));
+ min_nr, min_key_cache);
if (direct)
j->nr_direct_reclaim += nr_flushed;
@@ -661,7 +662,7 @@ static int __bch2_journal_reclaim(struct journal *j, bool direct)
if (nr_flushed)
wake_up(&j->reclaim_wait);
- } while (min_nr && nr_flushed && !direct);
+ } while ((min_nr || min_key_cache) && !direct);
memalloc_noreclaim_restore(flags);