bcachefs: bch2_journal_noflush_seq() now takes [start, end)

Harder to screw up if we're explicit about the range, and more correct
as journal reservations can be outstanding on multiple journal entries
simultaneously.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
This commit is contained in:
Kent Overstreet 2024-12-08 00:28:16 -05:00
parent f3b4692b79
commit c106801642
3 changed files with 10 additions and 7 deletions

View File

@ -953,7 +953,9 @@ int bch2_trigger_alloc(struct btree_trans *trans,
*/
if (is_empty_delta > 0) {
if (new_a->journal_seq == transaction_seq ||
bch2_journal_noflush_seq(&c->journal, new_a->journal_seq))
bch2_journal_noflush_seq(&c->journal,
new_a->journal_seq,
transaction_seq))
new_a->journal_seq = 0;
else {
new_a->journal_seq = transaction_seq;

View File

@ -807,10 +807,11 @@ int bch2_journal_flush(struct journal *j)
}
/*
* bch2_journal_noflush_seq - tell the journal not to issue any flushes before
* bch2_journal_noflush_seq - ask the journal not to issue any flushes in the
* range [start, end)
* @seq
*/
bool bch2_journal_noflush_seq(struct journal *j, u64 seq)
bool bch2_journal_noflush_seq(struct journal *j, u64 start, u64 end)
{
struct bch_fs *c = container_of(j, struct bch_fs, journal);
u64 unwritten_seq;
@ -819,15 +820,15 @@ bool bch2_journal_noflush_seq(struct journal *j, u64 seq)
if (!(c->sb.features & (1ULL << BCH_FEATURE_journal_no_flush)))
return false;
if (seq <= c->journal.flushed_seq_ondisk)
if (c->journal.flushed_seq_ondisk >= start)
return false;
spin_lock(&j->lock);
if (seq <= c->journal.flushed_seq_ondisk)
if (c->journal.flushed_seq_ondisk >= start)
goto out;
for (unwritten_seq = journal_last_unwritten_seq(j);
unwritten_seq < seq;
unwritten_seq < end;
unwritten_seq++) {
struct journal_buf *buf = journal_seq_to_buf(j, unwritten_seq);

View File

@ -404,7 +404,7 @@ void bch2_journal_flush_async(struct journal *, struct closure *);
int bch2_journal_flush_seq(struct journal *, u64, unsigned);
int bch2_journal_flush(struct journal *);
bool bch2_journal_noflush_seq(struct journal *, u64);
bool bch2_journal_noflush_seq(struct journal *, u64, u64);
int bch2_journal_meta(struct journal *);
void bch2_journal_halt(struct journal *);