]> www.infradead.org Git - users/willy/xarray.git/commitdiff
bcachefs: Don't use the new_fs() bucket alloc path on an initialized fs
authorKent Overstreet <kent.overstreet@linux.dev>
Fri, 28 Jun 2024 23:47:31 +0000 (19:47 -0400)
committerKent Overstreet <kent.overstreet@linux.dev>
Fri, 28 Jun 2024 23:47:31 +0000 (19:47 -0400)
On a new filesystem or device we have to allocate the journal with a
bump allocator, because allocation info isn't ready yet - but when
hot-adding a device that doesn't have a journal, we don't want to use
that path.

Reported-by: syzbot+24a867cb90d8315cccff@syzkaller.appspotmail.com
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
fs/bcachefs/journal.c
fs/bcachefs/journal.h
fs/bcachefs/super.c

index 51c2fa09d951e128f3a7a8b74cb327b0a265e3f1..0f4ad9e64ad193907cfa1fc881b37a6993de7429 100644 (file)
@@ -1095,7 +1095,7 @@ unlock:
        return ret;
 }
 
-int bch2_dev_journal_alloc(struct bch_dev *ca)
+int bch2_dev_journal_alloc(struct bch_dev *ca, bool new_fs)
 {
        unsigned nr;
        int ret;
@@ -1117,7 +1117,7 @@ int bch2_dev_journal_alloc(struct bch_dev *ca)
                     min(1 << 13,
                         (1 << 24) / ca->mi.bucket_size));
 
-       ret = __bch2_set_nr_journal_buckets(ca, nr, true, NULL);
+       ret = __bch2_set_nr_journal_buckets(ca, nr, new_fs, NULL);
 err:
        bch_err_fn(ca, ret);
        return ret;
@@ -1129,7 +1129,7 @@ int bch2_fs_journal_alloc(struct bch_fs *c)
                if (ca->journal.nr)
                        continue;
 
-               int ret = bch2_dev_journal_alloc(ca);
+               int ret = bch2_dev_journal_alloc(ca, true);
                if (ret) {
                        percpu_ref_put(&ca->io_ref);
                        return ret;
index fd1f7cdaa8bc62d9f156ab4371628cc75f0a3d12..bc6b9c39dcb4c6a079debe6f602cce0586aa85bd 100644 (file)
@@ -433,7 +433,7 @@ bool bch2_journal_seq_pins_to_text(struct printbuf *, struct journal *, u64 *);
 
 int bch2_set_nr_journal_buckets(struct bch_fs *, struct bch_dev *,
                                unsigned nr);
-int bch2_dev_journal_alloc(struct bch_dev *);
+int bch2_dev_journal_alloc(struct bch_dev *, bool);
 int bch2_fs_journal_alloc(struct bch_fs *);
 
 void bch2_dev_journal_stop(struct journal *, struct bch_dev *);
index 24953cd9bbbcc78b47d804201aafc12748826adc..da735608d47c83cd504a9906c08ac97241877672 100644 (file)
@@ -1772,7 +1772,7 @@ int bch2_dev_add(struct bch_fs *c, const char *path)
        if (ret)
                goto err;
 
-       ret = bch2_dev_journal_alloc(ca);
+       ret = bch2_dev_journal_alloc(ca, true);
        bch_err_msg(c, ret, "allocating journal");
        if (ret)
                goto err;
@@ -1932,7 +1932,7 @@ int bch2_dev_online(struct bch_fs *c, const char *path)
        }
 
        if (!ca->journal.nr) {
-               ret = bch2_dev_journal_alloc(ca);
+               ret = bch2_dev_journal_alloc(ca, false);
                bch_err_msg(ca, ret, "allocating journal");
                if (ret)
                        goto err;