Commit c7e78f7b authored by Kent Overstreet's avatar Kent Overstreet
Browse files

bcachefs: Ignore empty btree root journal entries



There's no reason to treat them as errors: just ignore them, and go with
a previous btree root if we had one.

Reported-by: default avatar <syzbot+e22007d6acb9c87c2362@syzkaller.appspotmail.com>
Signed-off-by: default avatarKent Overstreet <kent.overstreet@linux.dev>
parent 90f3683e
Loading
Loading
Loading
Loading
+7 −9
Original line number Diff line number Diff line
@@ -442,7 +442,9 @@ static int journal_replay_entry_early(struct bch_fs *c,

	switch (entry->type) {
	case BCH_JSET_ENTRY_btree_root: {
		struct btree_root *r;

		if (unlikely(!entry->u64s))
			return 0;

		if (fsck_err_on(entry->btree_id >= BTREE_ID_NR_MAX,
				c, invalid_btree_id,
@@ -456,15 +458,11 @@ static int journal_replay_entry_early(struct bch_fs *c,
				return ret;
		}

		r = bch2_btree_id_root(c, entry->btree_id);
		struct btree_root *r = bch2_btree_id_root(c, entry->btree_id);

		if (entry->u64s) {
		r->level = entry->level;
		bkey_copy(&r->key, (struct bkey_i *) entry->start);
		r->error = 0;
		} else {
			r->error = -BCH_ERR_btree_node_read_error;
		}
		r->alive = true;
		break;
	}