Commit 44ec5990 authored by Kent Overstreet's avatar Kent Overstreet
Browse files

bcachefs: Don't use the new_fs() bucket alloc path on an initialized fs



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: default avatar <syzbot+24a867cb90d8315cccff@syzkaller.appspotmail.com>
Signed-off-by: default avatarKent Overstreet <kent.overstreet@linux.dev>
parent a0bd30e4
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -1095,7 +1095,7 @@ int bch2_set_nr_journal_buckets(struct bch_fs *c, struct bch_dev *ca,
	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;
+1 −1
Original line number Diff line number Diff line
@@ -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 *);
+2 −2
Original line number Diff line number Diff line
@@ -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;