mirror of
https://github.com/torvalds/linux.git
synced 2026-05-31 18:43:33 +02:00
bcachefs: bch2_fs_open() now takes a darray
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
This commit is contained in:
parent
cf95296295
commit
a349868b5e
|
|
@ -21,6 +21,7 @@ struct { \
|
|||
|
||||
typedef DARRAY(char) darray_char;
|
||||
typedef DARRAY(char *) darray_str;
|
||||
typedef DARRAY(const char *) darray_const_str;
|
||||
|
||||
typedef DARRAY(u8) darray_u8;
|
||||
typedef DARRAY(u16) darray_u16;
|
||||
|
|
|
|||
|
|
@ -2441,7 +2441,7 @@ static int bch2_fs_get_tree(struct fs_context *fc)
|
|||
struct inode *vinode;
|
||||
struct bch2_opts_parse *opts_parse = fc->fs_private;
|
||||
struct bch_opts opts = opts_parse->opts;
|
||||
darray_str devs;
|
||||
darray_const_str devs;
|
||||
darray_fs devs_to_fs = {};
|
||||
int ret;
|
||||
|
||||
|
|
@ -2465,7 +2465,7 @@ static int bch2_fs_get_tree(struct fs_context *fc)
|
|||
if (!IS_ERR(sb))
|
||||
goto got_sb;
|
||||
|
||||
c = bch2_fs_open(devs.data, devs.nr, opts);
|
||||
c = bch2_fs_open(&devs, &opts);
|
||||
ret = PTR_ERR_OR_ZERO(c);
|
||||
if (ret)
|
||||
goto err;
|
||||
|
|
|
|||
|
|
@ -3059,7 +3059,7 @@ long bch2_ioctl_fsck_offline(struct bch_ioctl_fsck_offline __user *user_arg)
|
|||
{
|
||||
struct bch_ioctl_fsck_offline arg;
|
||||
struct fsck_thread *thr = NULL;
|
||||
darray_str(devs) = {};
|
||||
darray_const_str devs = {};
|
||||
long ret = 0;
|
||||
|
||||
if (copy_from_user(&arg, user_arg, sizeof(arg)))
|
||||
|
|
@ -3117,7 +3117,7 @@ long bch2_ioctl_fsck_offline(struct bch_ioctl_fsck_offline __user *user_arg)
|
|||
|
||||
bch2_thread_with_stdio_init(&thr->thr, &bch2_offline_fsck_ops);
|
||||
|
||||
thr->c = bch2_fs_open(devs.data, arg.nr_devs, thr->opts);
|
||||
thr->c = bch2_fs_open(&devs, &thr->opts);
|
||||
|
||||
if (!IS_ERR(thr->c) &&
|
||||
thr->c->opts.errors == BCH_ON_ERROR_panic)
|
||||
|
|
|
|||
|
|
@ -807,7 +807,7 @@ static int bch2_fs_init_rw(struct bch_fs *c)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static struct bch_fs *bch2_fs_alloc(struct bch_sb *sb, struct bch_opts opts,
|
||||
static struct bch_fs *bch2_fs_alloc(struct bch_sb *sb, struct bch_opts *opts,
|
||||
bch_sb_handles *sbs)
|
||||
{
|
||||
struct bch_fs *c;
|
||||
|
|
@ -821,7 +821,7 @@ static struct bch_fs *bch2_fs_alloc(struct bch_sb *sb, struct bch_opts opts,
|
|||
goto out;
|
||||
}
|
||||
|
||||
c->stdio = (void *)(unsigned long) opts.stdio;
|
||||
c->stdio = (void *)(unsigned long) opts->stdio;
|
||||
|
||||
__module_get(THIS_MODULE);
|
||||
|
||||
|
|
@ -921,7 +921,7 @@ static struct bch_fs *bch2_fs_alloc(struct bch_sb *sb, struct bch_opts opts,
|
|||
if (ret)
|
||||
goto err;
|
||||
|
||||
bch2_opts_apply(&c->opts, opts);
|
||||
bch2_opts_apply(&c->opts, *opts);
|
||||
|
||||
c->btree_key_cache_btrees |= 1U << BTREE_ID_alloc;
|
||||
if (c->opts.inodes_use_key_cache)
|
||||
|
|
@ -2273,8 +2273,8 @@ static inline int sb_cmp(struct bch_sb *l, struct bch_sb *r)
|
|||
cmp_int(le64_to_cpu(l->write_time), le64_to_cpu(r->write_time));
|
||||
}
|
||||
|
||||
struct bch_fs *bch2_fs_open(char * const *devices, unsigned nr_devices,
|
||||
struct bch_opts opts)
|
||||
struct bch_fs *bch2_fs_open(darray_const_str *devices,
|
||||
struct bch_opts *opts)
|
||||
{
|
||||
bch_sb_handles sbs = {};
|
||||
struct bch_fs *c = NULL;
|
||||
|
|
@ -2285,26 +2285,26 @@ struct bch_fs *bch2_fs_open(char * const *devices, unsigned nr_devices,
|
|||
if (!try_module_get(THIS_MODULE))
|
||||
return ERR_PTR(-ENODEV);
|
||||
|
||||
if (!nr_devices) {
|
||||
if (!devices->nr) {
|
||||
ret = -EINVAL;
|
||||
goto err;
|
||||
}
|
||||
|
||||
ret = darray_make_room(&sbs, nr_devices);
|
||||
ret = darray_make_room(&sbs, devices->nr);
|
||||
if (ret)
|
||||
goto err;
|
||||
|
||||
for (unsigned i = 0; i < nr_devices; i++) {
|
||||
darray_for_each(*devices, i) {
|
||||
struct bch_sb_handle sb = { NULL };
|
||||
|
||||
ret = bch2_read_super(devices[i], &opts, &sb);
|
||||
ret = bch2_read_super(*i, opts, &sb);
|
||||
if (ret)
|
||||
goto err;
|
||||
|
||||
BUG_ON(darray_push(&sbs, sb));
|
||||
}
|
||||
|
||||
if (opts.nochanges && !opts.read_only) {
|
||||
if (opts->nochanges && !opts->read_only) {
|
||||
ret = -BCH_ERR_erofs_nochanges;
|
||||
goto err_print;
|
||||
}
|
||||
|
|
@ -2314,7 +2314,7 @@ struct bch_fs *bch2_fs_open(char * const *devices, unsigned nr_devices,
|
|||
best = sb;
|
||||
|
||||
darray_for_each_reverse(sbs, sb) {
|
||||
ret = bch2_dev_in_fs(best, sb, &opts);
|
||||
ret = bch2_dev_in_fs(best, sb, opts);
|
||||
|
||||
if (ret == -BCH_ERR_device_has_been_removed ||
|
||||
ret == -BCH_ERR_device_splitbrain) {
|
||||
|
|
@ -2358,7 +2358,7 @@ struct bch_fs *bch2_fs_open(char * const *devices, unsigned nr_devices,
|
|||
return c;
|
||||
err_print:
|
||||
pr_err("bch_fs_open err opening %s: %s",
|
||||
devices[0], bch2_err_str(ret));
|
||||
devices->data[0], bch2_err_str(ret));
|
||||
err:
|
||||
if (!IS_ERR_OR_NULL(c))
|
||||
bch2_fs_stop(c);
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@ void bch2_fs_free(struct bch_fs *);
|
|||
void bch2_fs_stop(struct bch_fs *);
|
||||
|
||||
int bch2_fs_start(struct bch_fs *);
|
||||
struct bch_fs *bch2_fs_open(char * const *, unsigned, struct bch_opts);
|
||||
struct bch_fs *bch2_fs_open(darray_const_str *, struct bch_opts *);
|
||||
|
||||
extern const struct blk_holder_ops bch2_sb_handle_bdev_ops;
|
||||
|
||||
|
|
|
|||
|
|
@ -1016,14 +1016,14 @@ u64 *bch2_acc_percpu_u64s(u64 __percpu *p, unsigned nr)
|
|||
return ret;
|
||||
}
|
||||
|
||||
void bch2_darray_str_exit(darray_str *d)
|
||||
void bch2_darray_str_exit(darray_const_str *d)
|
||||
{
|
||||
darray_for_each(*d, i)
|
||||
kfree(*i);
|
||||
darray_exit(d);
|
||||
}
|
||||
|
||||
int bch2_split_devs(const char *_dev_name, darray_str *ret)
|
||||
int bch2_split_devs(const char *_dev_name, darray_const_str *ret)
|
||||
{
|
||||
darray_init(ret);
|
||||
|
||||
|
|
|
|||
|
|
@ -690,8 +690,8 @@ static inline bool qstr_eq(const struct qstr l, const struct qstr r)
|
|||
return l.len == r.len && !memcmp(l.name, r.name, l.len);
|
||||
}
|
||||
|
||||
void bch2_darray_str_exit(darray_str *);
|
||||
int bch2_split_devs(const char *, darray_str *);
|
||||
void bch2_darray_str_exit(darray_const_str *);
|
||||
int bch2_split_devs(const char *, darray_const_str *);
|
||||
|
||||
#ifdef __KERNEL__
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user