summaryrefslogtreecommitdiff
path: root/fs/bcachefs/journal_io.c
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@gmail.com>2022-02-25 18:28:20 +0300
committerKent Overstreet <kent.overstreet@linux.dev>2023-10-23 00:09:26 +0300
commitfbec3b8800ac8244ce751d0ba5b83d94ee48fc76 (patch)
tree7dc294ade316a64524431c7917c62e79e3185699 /fs/bcachefs/journal_io.c
parent506bac7e59d93cfd883dab0697ed91850f319be6 (diff)
downloadlinux-fbec3b8800ac8244ce751d0ba5b83d94ee48fc76.tar.xz
bcachefs: Kill JOURNAL_NEED_WRITE
This replaces the journal flag JOURNAL_NEED_WRITE with per-journal buf state - more explicit, and solving a race in the old code that would lead to entries being opened and written unnecessarily. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
Diffstat (limited to 'fs/bcachefs/journal_io.c')
-rw-r--r--fs/bcachefs/journal_io.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/fs/bcachefs/journal_io.c b/fs/bcachefs/journal_io.c
index bbec4d85b6bc..724a8bb69978 100644
--- a/fs/bcachefs/journal_io.c
+++ b/fs/bcachefs/journal_io.c
@@ -1403,13 +1403,15 @@ static void journal_write_done(struct closure *cl)
closure_wake_up(&w->wait);
journal_wake(j);
- if (test_bit(JOURNAL_NEED_WRITE, &j->flags))
- mod_delayed_work(c->io_complete_wq, &j->write_work, 0);
- spin_unlock(&j->lock);
+ if (new.unwritten_idx == new.idx) {
+ struct journal_buf *buf = journal_cur_buf(j);
+ long delta = buf->expires - jiffies;
- if (new.unwritten_idx != new.idx &&
- !journal_state_count(new, new.unwritten_idx))
+ mod_delayed_work(c->io_complete_wq, &j->write_work, max(0L, delta));
+ } else if (!journal_state_count(new, new.unwritten_idx))
closure_call(&j->io, bch2_journal_write, c->io_complete_wq, NULL);
+
+ spin_unlock(&j->lock);
}
static void journal_write_endio(struct bio *bio)