diff options
author | Kent Overstreet <kent.overstreet@gmail.com> | 2022-02-28 19:17:27 -0500 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@linux.dev> | 2023-10-22 17:09:26 -0400 |
commit | 30ef633a0b46e06860f46bf7df0f5a313e6e1a19 (patch) | |
tree | 8b6ffa6870ea55dad13072acc60ac4b0ef08c99d /fs/bcachefs/journal_io.c | |
parent | f0a3a2ccabc5ae1e2c7d588a6a4f77d216b1d4cf (diff) |
bcachefs: Refactor journal code to not use unwritten_idx
It makes the code more readable if we work off of sequence numbers,
instead of direct indexes into the array of journal buffers.
Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
Diffstat (limited to 'fs/bcachefs/journal_io.c')
-rw-r--r-- | fs/bcachefs/journal_io.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/fs/bcachefs/journal_io.c b/fs/bcachefs/journal_io.c index 0d6bede8abfa..7c8298ddad25 100644 --- a/fs/bcachefs/journal_io.c +++ b/fs/bcachefs/journal_io.c @@ -1331,7 +1331,7 @@ static void journal_buf_realloc(struct journal *j, struct journal_buf *buf) static inline struct journal_buf *journal_last_unwritten_buf(struct journal *j) { - return j->buf + j->reservations.unwritten_idx; + return j->buf + (journal_last_unwritten_seq(j) & JOURNAL_BUF_MASK); } static void journal_write_done(struct closure *cl) @@ -1403,12 +1403,13 @@ static void journal_write_done(struct closure *cl) closure_wake_up(&w->wait); journal_wake(j); - if (new.unwritten_idx == new.idx) { + if (journal_last_unwritten_seq(j) == journal_cur_seq(j)) { struct journal_buf *buf = journal_cur_buf(j); long delta = buf->expires - jiffies; mod_delayed_work(c->io_complete_wq, &j->write_work, max(0L, delta)); - } else if (!journal_state_count(new, new.unwritten_idx)) + } else if (journal_last_unwritten_seq(j) < journal_cur_seq(j) && + !journal_state_count(new, new.unwritten_idx)) closure_call(&j->io, bch2_journal_write, c->io_complete_wq, NULL); spin_unlock(&j->lock); |