]> www.infradead.org Git - linux.git/commitdiff
bcachefs: Fix bch2_journal_noflush_seq()
authorKent Overstreet <kent.overstreet@linux.dev>
Thu, 29 Feb 2024 02:56:57 +0000 (21:56 -0500)
committerKent Overstreet <kent.overstreet@linux.dev>
Thu, 14 Mar 2024 01:22:25 +0000 (21:22 -0400)
Improved journal pipelining broke journal_noflush_seq(); it implicitly
assumed only the oldest outstanding journal buf could be in flight, but
that's no longer true.

Make this more straightforward by just setting buf->must_flush whenever
we know a journal buf is going to be flush.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
fs/bcachefs/journal.c
fs/bcachefs/journal_io.c

index 95fd84c08c8c0a17221706a11e13a3802b2bcd4c..9f208fcb95754bf777ede3bb2648021f42988eef 100644 (file)
@@ -716,7 +716,7 @@ recheck_need_open:
                        return ret;
 
                seq = res.seq;
-               buf = j->buf + (seq & JOURNAL_BUF_MASK);
+               buf = journal_seq_to_buf(j, seq);
                buf->must_flush = true;
 
                if (!buf->flush_time) {
@@ -734,8 +734,8 @@ recheck_need_open:
        }
 
        /*
-        * if write was kicked off without a flush, flush the next sequence
-        * number instead
+        * if write was kicked off without a flush, or if we promised it
+        * wouldn't be a flush, flush the next sequence number instead
         */
        buf = journal_seq_to_buf(j, seq);
        if (buf->noflush) {
@@ -813,8 +813,8 @@ bool bch2_journal_noflush_seq(struct journal *j, u64 seq)
             unwritten_seq++) {
                struct journal_buf *buf = journal_seq_to_buf(j, unwritten_seq);
 
-               /* journal write is already in flight, and was a flush write: */
-               if (unwritten_seq == journal_last_unwritten_seq(j) && !buf->noflush)
+               /* journal flush already in flight, or flush requseted */
+               if (buf->must_flush)
                        goto out;
 
                buf->noflush = true;
index 34af25f286aab908a97cce774e1242f1ea694ad2..0b49b2383d8258dd3b63cab6f64d968bcd44d150 100644 (file)
@@ -1936,6 +1936,7 @@ static int bch2_journal_write_pick_flush(struct journal *j, struct journal_buf *
 
                j->nr_noflush_writes++;
        } else {
+               w->must_flush = true;
                j->last_flush_write = jiffies;
                j->nr_flush_writes++;
                clear_bit(JOURNAL_NEED_FLUSH_WRITE, &j->flags);