- return c ?: ERR_PTR(-ENOENT);
-}
-
-static struct bch_fs *__bch2_open_as_blockdevs(const char *dev_name, char * const *devs,
- unsigned nr_devs, struct bch_opts opts)
-{
- struct bch_fs *c, *c1, *c2;
- size_t i;
-
- if (!nr_devs)
- return ERR_PTR(-EINVAL);
-
- c = bch2_fs_open(devs, nr_devs, opts);
-
- if (IS_ERR(c) && PTR_ERR(c) == -EBUSY) {
- /*
- * Already open?
- * Look up each block device, make sure they all belong to a
- * filesystem and they all belong to the _same_ filesystem
- */
-
- c1 = bch2_path_to_fs(devs[0]);
- if (IS_ERR(c1))
- return c;
-
- for (i = 1; i < nr_devs; i++) {
- c2 = bch2_path_to_fs(devs[i]);
- if (!IS_ERR(c2))
- closure_put(&c2->cl);
-
- if (c1 != c2) {
- closure_put(&c1->cl);
- return c;
- }
- }
-
- c = c1;
- }
-
- if (IS_ERR(c))
- return c;
-
- mutex_lock(&c->state_lock);
-
- if (!test_bit(BCH_FS_STARTED, &c->flags)) {
- mutex_unlock(&c->state_lock);