bcachefs: disallow ever going rw if nochanges or noreplay
authorKent Overstreet <kent.overstreet@gmail.com>
Fri, 5 Apr 2019 04:18:52 +0000 (00:18 -0400)
committerKent Overstreet <kent.overstreet@linux.dev>
Sun, 22 Oct 2023 21:08:20 +0000 (17:08 -0400)
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
fs/bcachefs/super.c

index 27eacb1cd14481306ae3f59f3333f567bd941b79..85a9400a47fc302d590db7d437bfb25c031f5e5c 100644 (file)
@@ -378,6 +378,10 @@ int __bch2_fs_read_write(struct bch_fs *c, bool early)
        if (test_bit(BCH_FS_RW, &c->flags))
                return 0;
 
+       if (c->opts.nochanges ||
+           c->opts.noreplay)
+               return -EINVAL;
+
        ret = bch2_fs_mark_dirty(c);
        if (ret)
                goto err;
@@ -684,6 +688,7 @@ static struct bch_fs *bch2_fs_alloc(struct bch_sb *sb, struct bch_opts opts)
 
        c->opts.nochanges       |= c->opts.noreplay;
        c->opts.read_only       |= c->opts.nochanges;
+       c->opts.read_only       |= c->opts.noreplay;
 
        if (bch2_fs_init_fault("fs_alloc"))
                goto err;