Skip to content

Commit 7efa287

Browse files
author
Kent Overstreet
committed
bcachefs: Fix bch2_journal_noflush_seq()
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 <[email protected]>
1 parent 79162e8 commit 7efa287

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

fs/bcachefs/journal.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -716,7 +716,7 @@ int bch2_journal_flush_seq_async(struct journal *j, u64 seq,
716716
return ret;
717717

718718
seq = res.seq;
719-
buf = j->buf + (seq & JOURNAL_BUF_MASK);
719+
buf = journal_seq_to_buf(j, seq);
720720
buf->must_flush = true;
721721

722722
if (!buf->flush_time) {
@@ -734,8 +734,8 @@ int bch2_journal_flush_seq_async(struct journal *j, u64 seq,
734734
}
735735

736736
/*
737-
* if write was kicked off without a flush, flush the next sequence
738-
* number instead
737+
* if write was kicked off without a flush, or if we promised it
738+
* wouldn't be a flush, flush the next sequence number instead
739739
*/
740740
buf = journal_seq_to_buf(j, seq);
741741
if (buf->noflush) {
@@ -813,8 +813,8 @@ bool bch2_journal_noflush_seq(struct journal *j, u64 seq)
813813
unwritten_seq++) {
814814
struct journal_buf *buf = journal_seq_to_buf(j, unwritten_seq);
815815

816-
/* journal write is already in flight, and was a flush write: */
817-
if (unwritten_seq == journal_last_unwritten_seq(j) && !buf->noflush)
816+
/* journal flush already in flight, or flush requseted */
817+
if (buf->must_flush)
818818
goto out;
819819

820820
buf->noflush = true;

fs/bcachefs/journal_io.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1936,6 +1936,7 @@ static int bch2_journal_write_pick_flush(struct journal *j, struct journal_buf *
19361936

19371937
j->nr_noflush_writes++;
19381938
} else {
1939+
w->must_flush = true;
19391940
j->last_flush_write = jiffies;
19401941
j->nr_flush_writes++;
19411942
clear_bit(JOURNAL_NEED_FLUSH_WRITE, &j->flags);

0 commit comments

Comments
 (0)