]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commitdiff
bcachefs: journal->buf_lock
authorKent Overstreet <kent.overstreet@linux.dev>
Fri, 3 Nov 2023 01:06:52 +0000 (21:06 -0400)
committerKent Overstreet <kent.overstreet@linux.dev>
Mon, 1 Jan 2024 16:47:41 +0000 (11:47 -0500)
Add a new lock for synchronizing between journal IO path and btree write
buffer flush.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
fs/bcachefs/journal.c
fs/bcachefs/journal_io.c
fs/bcachefs/journal_types.h

index fb983061af4a23a1204636928ecb69beab24d297..6d56a71243bdaaf2515e6cea1dd8c189e8f8c542 100644 (file)
@@ -1219,6 +1219,7 @@ int bch2_fs_journal_init(struct journal *j)
        static struct lock_class_key res_key;
        unsigned i;
 
+       mutex_init(&j->buf_lock);
        spin_lock_init(&j->lock);
        spin_lock_init(&j->err_lock);
        init_waitqueue_head(&j->wait);
index f2e038116b0fdb07a6eced6c489e0002354d4a0d..afcb2a435956baba2494d21eb65e055d61db1007 100644 (file)
@@ -1885,9 +1885,11 @@ CLOSURE_CALLBACK(bch2_journal_write)
        if (ret)
                goto err;
 
+       mutex_lock(&j->buf_lock);
        journal_buf_realloc(j, w);
 
        ret = bch2_journal_write_prep(j, w);
+       mutex_unlock(&j->buf_lock);
        if (ret)
                goto err;
 
index 4ffae252e01ed6fd79e3e7a35692e35c66f961b1..5c8d3a8ec4df6513659172273c8c9e337adeeceb 100644 (file)
@@ -181,6 +181,12 @@ struct journal {
         */
        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
         * other is possibly being written out.