]> git.sesse.net Git - bcachefs-tools-debian/blobdiff - libbcache/fs.c
cmd_migrate
[bcachefs-tools-debian] / libbcache / fs.c
index ab0d9728bc0d8b51f5be9d1f81a37c449f2b4b49..ec70a3e39f75cae65ae278a2ed99056b7e165a27 100644 (file)
@@ -1257,13 +1257,17 @@ static struct cache_set *bch_open_as_blockdevs(const char *_dev_name,
                if (!c)
                        goto err_unlock;
 
-               if (!test_bit(BCH_FS_RUNNING, &c->flags)) {
+               mutex_lock(&c->state_lock);
+
+               if (!bch_fs_running(c)) {
+                       mutex_unlock(&c->state_lock);
                        err = "incomplete cache set";
                        c = NULL;
                        goto err_unlock;
                }
 
                closure_get(&c->cl);
+               mutex_unlock(&c->state_lock);
                mutex_unlock(&bch_register_lock);
        }
 
@@ -1291,22 +1295,19 @@ static int bch_remount(struct super_block *sb, int *flags, char *data)
        if (ret)
                return ret;
 
-       mutex_lock(&bch_register_lock);
-
        if (opts.read_only >= 0 &&
            opts.read_only != c->opts.read_only) {
                const char *err = NULL;
 
                if (opts.read_only) {
-                       bch_fs_read_only_sync(c);
+                       bch_fs_read_only(c);
 
                        sb->s_flags |= MS_RDONLY;
                } else {
                        err = bch_fs_read_write(c);
                        if (err) {
                                bch_err(c, "error going rw: %s", err);
-                               ret = -EINVAL;
-                               goto unlock;
+                               return -EINVAL;
                        }
 
                        sb->s_flags &= ~MS_RDONLY;
@@ -1318,9 +1319,6 @@ static int bch_remount(struct super_block *sb, int *flags, char *data)
        if (opts.errors >= 0)
                c->opts.errors = opts.errors;
 
-unlock:
-       mutex_unlock(&bch_register_lock);
-
        return ret;
 }
 
@@ -1449,7 +1447,7 @@ static void bch_kill_sb(struct super_block *sb)
        generic_shutdown_super(sb);
 
        if (test_bit(BCH_FS_BDEV_MOUNTED, &c->flags))
-               bch_fs_stop_sync(c);
+               bch_fs_stop(c);
        else
                closure_put(&c->cl);
 }
@@ -1464,7 +1462,7 @@ static struct file_system_type bcache_fs_type = {
 
 MODULE_ALIAS_FS("bcache");
 
-void bch_fs_exit(void)
+void bch_vfs_exit(void)
 {
        unregister_filesystem(&bcache_fs_type);
        if (bch_dio_write_bioset)
@@ -1477,7 +1475,7 @@ void bch_fs_exit(void)
                kmem_cache_destroy(bch_inode_cache);
 }
 
-int __init bch_fs_init(void)
+int __init bch_vfs_init(void)
 {
        int ret = -ENOMEM;
 
@@ -1504,6 +1502,6 @@ int __init bch_fs_init(void)
 
        return 0;
 err:
-       bch_fs_exit();
+       bch_vfs_exit();
        return ret;
 }