Skip to content

Commit f946ce0

Browse files
author
Kent Overstreet
committed
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: [email protected] Signed-off-by: Kent Overstreet <[email protected]>
1 parent 0acb385 commit f946ce0

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

fs/bcachefs/fs.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2490,6 +2490,14 @@ static int bch2_fs_get_tree(struct fs_context *fc)
24902490
if (ret)
24912491
goto err_stop_fs;
24922492

2493+
/*
2494+
* We might be doing a RO mount because other options required it, or we
2495+
* have no alloc info and it's a small image with no room to regenerate
2496+
* it
2497+
*/
2498+
if (c->opts.read_only)
2499+
fc->sb_flags |= SB_RDONLY;
2500+
24932501
sb = sget(fc->fs_type, NULL, bch2_set_super, fc->sb_flags|SB_NOSEC, c);
24942502
ret = PTR_ERR_OR_ZERO(sb);
24952503
if (ret)

fs/bcachefs/recovery.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -752,9 +752,11 @@ int bch2_fs_recovery(struct bch_fs *c)
752752
? min(c->opts.recovery_pass_last, BCH_RECOVERY_PASS_snapshots_read)
753753
: BCH_RECOVERY_PASS_snapshots_read;
754754
c->opts.nochanges = true;
755-
c->opts.read_only = true;
756755
}
757756

757+
if (c->opts.nochanges)
758+
c->opts.read_only = true;
759+
758760
mutex_lock(&c->sb_lock);
759761
struct bch_sb_field_ext *ext = bch2_sb_field_get(c->disk_sb.sb, ext);
760762
bool write_sb = false;

0 commit comments

Comments
 (0)