Skip to content

Commit a66ff26

Browse files
author
Kent Overstreet
committed
bcachefs: Close journal entry if necessary when flushing all pins
Since outstanding journal buffers hold a journal pin, when flushing all pins we need to close the current journal entry if necessary so its pin can be released. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
1 parent 4a147af commit a66ff26

4 files changed

Lines changed: 9 additions & 4 deletions

File tree

fs/bcachefs/journal.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ static bool journal_entry_want_write(struct journal *j)
249249
return ret;
250250
}
251251

252-
static bool journal_entry_close(struct journal *j)
252+
bool bch2_journal_entry_close(struct journal *j)
253253
{
254254
bool ret;
255255

@@ -383,7 +383,7 @@ static bool journal_quiesced(struct journal *j)
383383
bool ret = atomic64_read(&j->seq) == j->seq_ondisk;
384384

385385
if (!ret)
386-
journal_entry_close(j);
386+
bch2_journal_entry_close(j);
387387
return ret;
388388
}
389389

@@ -436,7 +436,7 @@ static int __journal_res_get(struct journal *j, struct journal_res *res,
436436

437437
/*
438438
* Recheck after taking the lock, so we don't race with another thread
439-
* that just did journal_entry_open() and call journal_entry_close()
439+
* that just did journal_entry_open() and call bch2_journal_entry_close()
440440
* unnecessarily
441441
*/
442442
if (journal_res_get_fast(j, res, flags)) {
@@ -1041,7 +1041,7 @@ void bch2_fs_journal_stop(struct journal *j)
10411041
bch2_journal_reclaim_stop(j);
10421042
bch2_journal_flush_all_pins(j);
10431043

1044-
wait_event(j->wait, journal_entry_close(j));
1044+
wait_event(j->wait, bch2_journal_entry_close(j));
10451045

10461046
/*
10471047
* Always write a new journal entry, to make sure the clock hands are up

fs/bcachefs/journal.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,7 @@ static inline union journal_res_state journal_state_buf_put(struct journal *j, u
266266
return s;
267267
}
268268

269+
bool bch2_journal_entry_close(struct journal *);
269270
void bch2_journal_buf_put_final(struct journal *, u64, bool);
270271

271272
static inline void __bch2_journal_buf_put(struct journal *j, unsigned idx, u64 seq)

fs/bcachefs/journal_io.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1599,6 +1599,7 @@ static CLOSURE_CALLBACK(journal_write_done)
15991599
} while ((v = atomic64_cmpxchg(&j->reservations.counter,
16001600
old.v, new.v)) != old.v);
16011601

1602+
bch2_journal_reclaim_fast(j);
16021603
bch2_journal_space_available(j);
16031604

16041605
closure_wake_up(&w->wait);

fs/bcachefs/journal_reclaim.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -776,6 +776,9 @@ static int journal_flush_done(struct journal *j, u64 seq_to_flush,
776776
(1U << JOURNAL_PIN_btree), 0, 0, 0))
777777
*did_work = true;
778778

779+
if (seq_to_flush > journal_cur_seq(j))
780+
bch2_journal_entry_close(j);
781+
779782
spin_lock(&j->lock);
780783
/*
781784
* If journal replay hasn't completed, the unreplayed journal entries

0 commit comments

Comments
 (0)