]> git.sesse.net Git - bcachefs-tools-debian/blobdiff - libbcachefs/super.c
Update bcachefs sources to 44ac32df8e0c bcachefs: Split brain detection
[bcachefs-tools-debian] / libbcachefs / super.c
index e7b81dbda55f332934e4d5c3fb8d0d184d01c2c9..0f189c9d56b5dfe1bc49a5b10bafe8e1f51861de 100644 (file)
@@ -433,16 +433,6 @@ static int __bch2_fs_read_write(struct bch_fs *c, bool early)
        if (test_bit(BCH_FS_rw, &c->flags))
                return 0;
 
-       if (c->opts.norecovery)
-               return -BCH_ERR_erofs_norecovery;
-
-       /*
-        * nochanges is used for fsck -n mode - we have to allow going rw
-        * during recovery for that to work:
-        */
-       if (c->opts.nochanges && (!early || c->opts.read_only))
-               return -BCH_ERR_erofs_nochanges;
-
        bch_info(c, "going read-write");
 
        ret = bch2_sb_members_v2_init(c);
@@ -510,6 +500,12 @@ err:
 
 int bch2_fs_read_write(struct bch_fs *c)
 {
+       if (c->opts.norecovery)
+               return -BCH_ERR_erofs_norecovery;
+
+       if (c->opts.nochanges)
+               return -BCH_ERR_erofs_nochanges;
+
        return __bch2_fs_read_write(c, false);
 }
 
@@ -1033,7 +1029,7 @@ int bch2_fs_start(struct bch_fs *c)
 
        set_bit(BCH_FS_started, &c->flags);
 
-       if (c->opts.read_only || c->opts.nochanges) {
+       if (c->opts.read_only) {
                bch2_fs_read_only(c);
        } else {
                ret = !test_bit(BCH_FS_rw, &c->flags)
@@ -1996,6 +1992,11 @@ struct bch_fs *bch2_fs_open(char * const *devices, unsigned nr_devices,
                BUG_ON(darray_push(&sbs, sb));
        }
 
+       if (opts.nochanges && !opts.read_only) {
+               ret = -BCH_ERR_erofs_nochanges;
+               goto err_print;
+       }
+
        darray_for_each(sbs, sb)
                if (!best || sb_cmp(sb->sb, best->sb) > 0)
                        best = sb;