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

bcachefs: Make sure opts.read_only gets propagated back to VFS



If we think we're read-only but the VFS doesn't, fun will ensue.

And now that we know we have to be able to do this safely, just make
nochanges imply ro.

Reported-by: default avatar <syzbot+a7d6ceaba099cc21dee4@syzkaller.appspotmail.com>
Signed-off-by: default avatarKent Overstreet <kent.overstreet@linux.dev>
parent 0acb385e
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -2490,6 +2490,14 @@ static int bch2_fs_get_tree(struct fs_context *fc)
	if (ret)
		goto err_stop_fs;

	/*
	 * We might be doing a RO mount because other options required it, or we
	 * have no alloc info and it's a small image with no room to regenerate
	 * it
	 */
	if (c->opts.read_only)
		fc->sb_flags |= SB_RDONLY;

	sb = sget(fc->fs_type, NULL, bch2_set_super, fc->sb_flags|SB_NOSEC, c);
	ret = PTR_ERR_OR_ZERO(sb);
	if (ret)
+3 −1
Original line number Diff line number Diff line
@@ -752,9 +752,11 @@ int bch2_fs_recovery(struct bch_fs *c)
			? min(c->opts.recovery_pass_last, BCH_RECOVERY_PASS_snapshots_read)
			: BCH_RECOVERY_PASS_snapshots_read;
		c->opts.nochanges = true;
		c->opts.read_only = true;
	}

	if (c->opts.nochanges)
		c->opts.read_only = true;

	mutex_lock(&c->sb_lock);
	struct bch_sb_field_ext *ext = bch2_sb_field_get(c->disk_sb.sb, ext);
	bool write_sb = false;