Skip to content

Commit 8e4d280

Browse files
author
Kent Overstreet
committed
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>
1 parent da18dab commit 8e4d280

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

fs/bcachefs/journal_reclaim.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -266,10 +266,11 @@ void bch2_journal_space_available(struct journal *j)
266266

267267
static bool should_discard_bucket(struct journal *j, struct journal_device *ja)
268268
{
269-
bool ret;
270-
271269
spin_lock(&j->lock);
272-
ret = ja->discard_idx != ja->dirty_idx_ondisk;
270+
unsigned min_free = max(4, ja->nr / 8);
271+
272+
bool ret = bch2_journal_dev_buckets_available(j, ja, journal_space_discarded) < min_free &&
273+
ja->discard_idx != ja->dirty_idx_ondisk;
273274
spin_unlock(&j->lock);
274275

275276
return ret;

0 commit comments

Comments
 (0)