]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
bcachefs: Fix bch2_journal_meta()
authorKent Overstreet <kent.overstreet@gmail.com>
Sat, 25 Dec 2021 23:40:15 +0000 (18:40 -0500)
committerKent Overstreet <kent.overstreet@linux.dev>
Sun, 22 Oct 2023 21:09:19 +0000 (17:09 -0400)
This patch ensures that the journal entry written gets written as flush
entry, which is important for the shutdown path - the last entry written
needs to be a flush entry.

Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
fs/bcachefs/journal.c
fs/bcachefs/journal_io.c
fs/bcachefs/sysfs.c

index 020c7b0a3469bbb61f1a8db64b4718c01d577891..d27d65a17e43ad4ea15aa4c978d8ab9dba696d52 100644 (file)
@@ -641,6 +641,7 @@ int bch2_journal_flush_seq(struct journal *j, u64 seq)
 
 int bch2_journal_meta(struct journal *j)
 {
+       struct journal_buf *buf;
        struct journal_res res;
        int ret;
 
@@ -650,6 +651,10 @@ int bch2_journal_meta(struct journal *j)
        if (ret)
                return ret;
 
+       buf = j->buf + (res.seq & JOURNAL_BUF_MASK);
+       buf->must_flush = true;
+       set_bit(JOURNAL_NEED_WRITE, &j->flags);
+
        bch2_journal_res_put(j, &res);
 
        return bch2_journal_flush_seq(j, res.seq);
index ae28cee127e34ebc27dc6ac239bad185a7faae10..bda60509582504a4c9e2e926e3f366f06fcfccaa 100644 (file)
@@ -1445,7 +1445,7 @@ void bch2_journal_write(struct closure *cl)
        SET_JSET_BIG_ENDIAN(jset, CPU_BIG_ENDIAN);
        SET_JSET_CSUM_TYPE(jset, bch2_meta_checksum_type(c));
 
-       if (journal_entry_empty(jset))
+       if (!JSET_NO_FLUSH(jset) && journal_entry_empty(jset))
                j->last_empty_seq = le64_to_cpu(jset->seq);
 
        if (bch2_csum_type_is_encryption(JSET_CSUM_TYPE(jset)))
index 341ba3fdd6fcc36c6f5eca66ce7f8af441d8eb89..1d1e2c6fc2e2963f036be1eb4495c1559e07d21b 100644 (file)
@@ -131,7 +131,6 @@ do {                                                                        \
                return strtoi_h(buf, &var) ?: (ssize_t) size;           \
 } while (0)
 
-write_attribute(trigger_journal_flush);
 write_attribute(trigger_gc);
 write_attribute(prune_cache);
 rw_attribute(btree_gc_periodic);
@@ -482,9 +481,6 @@ STORE(bch2_fs)
 
        /* Debugging: */
 
-       if (attr == &sysfs_trigger_journal_flush)
-               bch2_journal_meta(&c->journal);
-
        if (attr == &sysfs_trigger_gc) {
                /*
                 * Full gc is currently incompatible with btree key cache:
@@ -574,7 +570,6 @@ struct attribute *bch2_fs_internal_files[] = {
        &sysfs_io_timers_read,
        &sysfs_io_timers_write,
 
-       &sysfs_trigger_journal_flush,
        &sysfs_trigger_gc,
        &sysfs_prune_cache,