Commit a4e92339 authored by Kent Overstreet's avatar Kent Overstreet

bcachefs: Avoid setting j->write_work unnecessarily

Signed-off-by: default avatarKent Overstreet <kent.overstreet@linux.dev>
parent 656f05d8
...@@ -416,9 +416,10 @@ static int journal_entry_open(struct journal *j) ...@@ -416,9 +416,10 @@ static int journal_entry_open(struct journal *j)
} while ((v = atomic64_cmpxchg(&j->reservations.counter, } while ((v = atomic64_cmpxchg(&j->reservations.counter,
old.v, new.v)) != old.v); old.v, new.v)) != old.v);
mod_delayed_work(j->wq, if (nr_unwritten_journal_entries(j) == 1)
&j->write_work, mod_delayed_work(j->wq,
msecs_to_jiffies(c->opts.journal_flush_delay)); &j->write_work,
msecs_to_jiffies(c->opts.journal_flush_delay));
journal_wake(j); journal_wake(j);
if (j->early_journal_entries.nr) if (j->early_journal_entries.nr)
...@@ -443,19 +444,16 @@ static void journal_quiesce(struct journal *j) ...@@ -443,19 +444,16 @@ static void journal_quiesce(struct journal *j)
static void journal_write_work(struct work_struct *work) static void journal_write_work(struct work_struct *work)
{ {
struct journal *j = container_of(work, struct journal, write_work.work); struct journal *j = container_of(work, struct journal, write_work.work);
long delta;
spin_lock(&j->lock); spin_lock(&j->lock);
if (!__journal_entry_is_open(j->reservations)) if (__journal_entry_is_open(j->reservations)) {
goto unlock; long delta = journal_cur_buf(j)->expires - jiffies;
delta = journal_cur_buf(j)->expires - jiffies;
if (delta > 0) if (delta > 0)
mod_delayed_work(j->wq, &j->write_work, delta); mod_delayed_work(j->wq, &j->write_work, delta);
else else
__journal_entry_close(j, JOURNAL_ENTRY_CLOSED_VAL, true); __journal_entry_close(j, JOURNAL_ENTRY_CLOSED_VAL, true);
unlock: }
spin_unlock(&j->lock); spin_unlock(&j->lock);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment