Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

bcachefs: refactor pin put helpers

We have a couple journal pin put helpers to handle cases where the
journal lock is already held or not. Refactor the helpers to lock
and reclaim from the highest level and open code the reclaim from
the one caller of the internal variant. The latter call will be
moved into the journal buf release helper in a later patch.

Signed-off-by: Brian Foster <bfoster@redhat.com>
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>

authored by

Brian Foster and committed by
Kent Overstreet
92b63f5b d67a72bf

+8 -9
+2 -1
fs/bcachefs/journal.c
··· 204 204 buf->data->last_seq = cpu_to_le64(buf->last_seq); 205 205 BUG_ON(buf->last_seq > le64_to_cpu(buf->data->seq)); 206 206 207 - __bch2_journal_pin_put(j, le64_to_cpu(buf->data->seq)); 207 + if (__bch2_journal_pin_put(j, le64_to_cpu(buf->data->seq))) 208 + bch2_journal_reclaim_fast(j); 208 209 209 210 cancel_delayed_work(&j->write_work); 210 211
+4 -7
fs/bcachefs/journal_reclaim.c
··· 290 290 * entry, holding it open to ensure it gets replayed during recovery: 291 291 */ 292 292 293 - static void bch2_journal_reclaim_fast(struct journal *j) 293 + void bch2_journal_reclaim_fast(struct journal *j) 294 294 { 295 295 bool popped = false; 296 296 ··· 310 310 bch2_journal_space_available(j); 311 311 } 312 312 313 - void __bch2_journal_pin_put(struct journal *j, u64 seq) 313 + bool __bch2_journal_pin_put(struct journal *j, u64 seq) 314 314 { 315 315 struct journal_entry_pin_list *pin_list = journal_seq_pin(j, seq); 316 316 317 - if (atomic_dec_and_test(&pin_list->count)) 318 - bch2_journal_reclaim_fast(j); 317 + return atomic_dec_and_test(&pin_list->count); 319 318 } 320 319 321 320 void bch2_journal_pin_put(struct journal *j, u64 seq) 322 321 { 323 - struct journal_entry_pin_list *pin_list = journal_seq_pin(j, seq); 324 - 325 - if (atomic_dec_and_test(&pin_list->count)) { 322 + if (__bch2_journal_pin_put(j, seq)) { 326 323 spin_lock(&j->lock); 327 324 bch2_journal_reclaim_fast(j); 328 325 spin_unlock(&j->lock);
+2 -1
fs/bcachefs/journal_reclaim.h
··· 31 31 return &j->pin.data[seq & j->pin.mask]; 32 32 } 33 33 34 - void __bch2_journal_pin_put(struct journal *, u64); 34 + void bch2_journal_reclaim_fast(struct journal *); 35 + bool __bch2_journal_pin_put(struct journal *, u64); 35 36 void bch2_journal_pin_put(struct journal *, u64); 36 37 void bch2_journal_pin_drop(struct journal *, struct journal_entry_pin *); 37 38