mirror of
https://github.com/torvalds/linux.git
synced 2024-11-10 14:11:52 +00:00
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>
This commit is contained in:
parent
d67a72bfc9
commit
92b63f5bf0
@ -204,7 +204,8 @@ static void __journal_entry_close(struct journal *j, unsigned closed_val)
|
||||
buf->data->last_seq = cpu_to_le64(buf->last_seq);
|
||||
BUG_ON(buf->last_seq > le64_to_cpu(buf->data->seq));
|
||||
|
||||
__bch2_journal_pin_put(j, le64_to_cpu(buf->data->seq));
|
||||
if (__bch2_journal_pin_put(j, le64_to_cpu(buf->data->seq)))
|
||||
bch2_journal_reclaim_fast(j);
|
||||
|
||||
cancel_delayed_work(&j->write_work);
|
||||
|
||||
|
@ -290,7 +290,7 @@ void bch2_journal_do_discards(struct journal *j)
|
||||
* entry, holding it open to ensure it gets replayed during recovery:
|
||||
*/
|
||||
|
||||
static void bch2_journal_reclaim_fast(struct journal *j)
|
||||
void bch2_journal_reclaim_fast(struct journal *j)
|
||||
{
|
||||
bool popped = false;
|
||||
|
||||
@ -310,19 +310,16 @@ static void bch2_journal_reclaim_fast(struct journal *j)
|
||||
bch2_journal_space_available(j);
|
||||
}
|
||||
|
||||
void __bch2_journal_pin_put(struct journal *j, u64 seq)
|
||||
bool __bch2_journal_pin_put(struct journal *j, u64 seq)
|
||||
{
|
||||
struct journal_entry_pin_list *pin_list = journal_seq_pin(j, seq);
|
||||
|
||||
if (atomic_dec_and_test(&pin_list->count))
|
||||
bch2_journal_reclaim_fast(j);
|
||||
return atomic_dec_and_test(&pin_list->count);
|
||||
}
|
||||
|
||||
void bch2_journal_pin_put(struct journal *j, u64 seq)
|
||||
{
|
||||
struct journal_entry_pin_list *pin_list = journal_seq_pin(j, seq);
|
||||
|
||||
if (atomic_dec_and_test(&pin_list->count)) {
|
||||
if (__bch2_journal_pin_put(j, seq)) {
|
||||
spin_lock(&j->lock);
|
||||
bch2_journal_reclaim_fast(j);
|
||||
spin_unlock(&j->lock);
|
||||
|
@ -31,7 +31,8 @@ journal_seq_pin(struct journal *j, u64 seq)
|
||||
return &j->pin.data[seq & j->pin.mask];
|
||||
}
|
||||
|
||||
void __bch2_journal_pin_put(struct journal *, u64);
|
||||
void bch2_journal_reclaim_fast(struct journal *);
|
||||
bool __bch2_journal_pin_put(struct journal *, u64);
|
||||
void bch2_journal_pin_put(struct journal *, u64);
|
||||
void bch2_journal_pin_drop(struct journal *, struct journal_entry_pin *);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user