summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@linux.dev>2025-05-07 13:32:15 -0400
committerKent Overstreet <kent.overstreet@linux.dev>2025-05-07 17:10:10 -0400
commit8e4d28036c293241b312b1fceafb32b994f80fcc (patch)
tree6736216a95acfea3299f8d140cc25270e7e8e892
parentda18dabc3784663a088943e613c36cd17aeb52d3 (diff)
bcachefs: Don't aggressively discard the journal
We frequently use 'bcachefs list_journal -a' for debugging, as it provides a record of all btree transactions, and a history of what happened. But it's not so useful if we immediately discard journal buckets right after they're no longer dirty. This tweaks journal reclaim to only discard when we're low on space, keeping the journal mostly un-discarded. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
-rw-r--r--fs/bcachefs/journal_reclaim.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/fs/bcachefs/journal_reclaim.c b/fs/bcachefs/journal_reclaim.c
index ea670c3c43d8..976464d8a695 100644
--- a/fs/bcachefs/journal_reclaim.c
+++ b/fs/bcachefs/journal_reclaim.c
@@ -266,10 +266,11 @@ out:
static bool should_discard_bucket(struct journal *j, struct journal_device *ja)
{
- bool ret;
-
spin_lock(&j->lock);
- ret = ja->discard_idx != ja->dirty_idx_ondisk;
+ unsigned min_free = max(4, ja->nr / 8);
+
+ bool ret = bch2_journal_dev_buckets_available(j, ja, journal_space_discarded) < min_free &&
+ ja->discard_idx != ja->dirty_idx_ondisk;
spin_unlock(&j->lock);
return ret;