summaryrefslogtreecommitdiff
path: root/fs/bcachefs/buckets_waiting_for_journal.c
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@linux.dev>2025-01-27 01:21:44 -0500
committerKent Overstreet <kent.overstreet@linux.dev>2025-02-06 22:35:11 -0500
commit9e9033522ad1e4bb697c9493aa449630fa2c98d2 (patch)
tree9956331176a7d0fa7eb5ca454c920bfa32b90428 /fs/bcachefs/buckets_waiting_for_journal.c
parent2ef995df0ce592f665d312008dbe1ad1c4bcf87f (diff)
bcachefs: Fix discard path journal flushing
The discard path is supposed to issue journal flushes when there's too many buckets empty buckets that need a journal commit before they can be written to again, but at some point this code seems to have been lost. Bring it back with a new optimization to make sure we don't issue too many journal flushes: the journal now tracks the sequence number of the most recent flush in progress, which the discard path uses when deciding which buckets need a journal flush. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Diffstat (limited to 'fs/bcachefs/buckets_waiting_for_journal.c')
-rw-r--r--fs/bcachefs/buckets_waiting_for_journal.c12
1 files changed, 5 insertions, 7 deletions
diff --git a/fs/bcachefs/buckets_waiting_for_journal.c b/fs/bcachefs/buckets_waiting_for_journal.c
index f9fb150eda70..c8a488e6b7b8 100644
--- a/fs/bcachefs/buckets_waiting_for_journal.c
+++ b/fs/bcachefs/buckets_waiting_for_journal.c
@@ -22,23 +22,21 @@ static void bucket_table_init(struct buckets_waiting_for_journal_table *t, size_
memset(t->d, 0, sizeof(t->d[0]) << t->bits);
}
-bool bch2_bucket_needs_journal_commit(struct buckets_waiting_for_journal *b,
- u64 flushed_seq,
- unsigned dev, u64 bucket)
+u64 bch2_bucket_journal_seq_ready(struct buckets_waiting_for_journal *b,
+ unsigned dev, u64 bucket)
{
struct buckets_waiting_for_journal_table *t;
u64 dev_bucket = (u64) dev << 56 | bucket;
- bool ret = false;
- unsigned i;
+ u64 ret = 0;
mutex_lock(&b->lock);
t = b->t;
- for (i = 0; i < ARRAY_SIZE(t->hash_seeds); i++) {
+ for (unsigned i = 0; i < ARRAY_SIZE(t->hash_seeds); i++) {
struct bucket_hashed *h = bucket_hash(t, i, dev_bucket);
if (h->dev_bucket == dev_bucket) {
- ret = h->journal_seq > flushed_seq;
+ ret = h->journal_seq;
break;
}
}