Commit b05c0e93 authored by Kent Overstreet's avatar Kent Overstreet

bcachefs: journal->buf_lock

Add a new lock for synchronizing between journal IO path and btree write
buffer flush.
Signed-off-by: default avatarKent Overstreet <kent.overstreet@linux.dev>
parent 0ba9375a
...@@ -1219,6 +1219,7 @@ int bch2_fs_journal_init(struct journal *j) ...@@ -1219,6 +1219,7 @@ int bch2_fs_journal_init(struct journal *j)
static struct lock_class_key res_key; static struct lock_class_key res_key;
unsigned i; unsigned i;
mutex_init(&j->buf_lock);
spin_lock_init(&j->lock); spin_lock_init(&j->lock);
spin_lock_init(&j->err_lock); spin_lock_init(&j->err_lock);
init_waitqueue_head(&j->wait); init_waitqueue_head(&j->wait);
......
...@@ -1885,9 +1885,11 @@ CLOSURE_CALLBACK(bch2_journal_write) ...@@ -1885,9 +1885,11 @@ CLOSURE_CALLBACK(bch2_journal_write)
if (ret) if (ret)
goto err; goto err;
mutex_lock(&j->buf_lock);
journal_buf_realloc(j, w); journal_buf_realloc(j, w);
ret = bch2_journal_write_prep(j, w); ret = bch2_journal_write_prep(j, w);
mutex_unlock(&j->buf_lock);
if (ret) if (ret)
goto err; goto err;
......
...@@ -181,6 +181,12 @@ struct journal { ...@@ -181,6 +181,12 @@ struct journal {
*/ */
darray_u64 early_journal_entries; darray_u64 early_journal_entries;
/*
* Protects journal_buf->data, when accessing without a jorunal
* reservation: for synchronization between the btree write buffer code
* and the journal write path:
*/
struct mutex buf_lock;
/* /*
* Two journal entries -- one is currently open for new entries, the * Two journal entries -- one is currently open for new entries, the
* other is possibly being written out. * other is possibly being written out.
......
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