mirror of
https://github.com/koverstreet/bcachefs-tools.git
synced 2025-12-11 00:00:12 +03:00
Update bcachefs sources to 2724e115d2 bcachefs: Lots of option handling improvements
This commit is contained in:
parent
f9ba96e165
commit
99ccaf73a8
@ -1 +1 @@
|
|||||||
57ea7773cb4368dc98ec68385c3d0941c246ad70
|
2724e115d243043ee62d78883bec4035651d74ab
|
||||||
|
|||||||
@ -292,7 +292,7 @@ int cmd_list(int argc, char *argv[])
|
|||||||
opt_set(opts, norecovery, false);
|
opt_set(opts, norecovery, false);
|
||||||
break;
|
break;
|
||||||
case 'v':
|
case 'v':
|
||||||
opt_set(opts, verbose_recovery, true);
|
opt_set(opts, verbose, true);
|
||||||
break;
|
break;
|
||||||
case 'h':
|
case 'h':
|
||||||
list_keys_usage();
|
list_keys_usage();
|
||||||
|
|||||||
@ -45,7 +45,7 @@ int cmd_fsck(int argc, char *argv[])
|
|||||||
/* force check, even if filesystem marked clean: */
|
/* force check, even if filesystem marked clean: */
|
||||||
break;
|
break;
|
||||||
case 'v':
|
case 'v':
|
||||||
opt_set(opts, verbose_recovery, true);
|
opt_set(opts, verbose, true);
|
||||||
break;
|
break;
|
||||||
case 'h':
|
case 'h':
|
||||||
usage();
|
usage();
|
||||||
|
|||||||
@ -227,13 +227,13 @@
|
|||||||
|
|
||||||
#define bch_verbose(c, fmt, ...) \
|
#define bch_verbose(c, fmt, ...) \
|
||||||
do { \
|
do { \
|
||||||
if ((c)->opts.verbose_recovery) \
|
if ((c)->opts.verbose) \
|
||||||
bch_info(c, fmt, ##__VA_ARGS__); \
|
bch_info(c, fmt, ##__VA_ARGS__); \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
#define pr_verbose_init(opts, fmt, ...) \
|
#define pr_verbose_init(opts, fmt, ...) \
|
||||||
do { \
|
do { \
|
||||||
if (opt_get(opts, verbose_init)) \
|
if (opt_get(opts, verbose)) \
|
||||||
pr_info(fmt, ##__VA_ARGS__); \
|
pr_info(fmt, ##__VA_ARGS__); \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
|
|||||||
@ -103,19 +103,6 @@ static int bch2_ioc_fsgetxattr(struct bch_inode_info *inode,
|
|||||||
return copy_to_user(arg, &fa, sizeof(fa));
|
return copy_to_user(arg, &fa, sizeof(fa));
|
||||||
}
|
}
|
||||||
|
|
||||||
static int bch2_set_projid(struct bch_fs *c,
|
|
||||||
struct bch_inode_info *inode,
|
|
||||||
u32 projid)
|
|
||||||
{
|
|
||||||
struct bch_qid qid = inode->ei_qid;
|
|
||||||
|
|
||||||
qid.q[QTYP_PRJ] = projid;
|
|
||||||
|
|
||||||
return bch2_fs_quota_transfer(c, inode, qid,
|
|
||||||
1 << QTYP_PRJ,
|
|
||||||
KEY_TYPE_QUOTA_PREALLOC);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int fssetxattr_inode_update_fn(struct bch_inode_info *inode,
|
static int fssetxattr_inode_update_fn(struct bch_inode_info *inode,
|
||||||
struct bch_inode_unpacked *bi,
|
struct bch_inode_unpacked *bi,
|
||||||
void *p)
|
void *p)
|
||||||
@ -123,11 +110,7 @@ static int fssetxattr_inode_update_fn(struct bch_inode_info *inode,
|
|||||||
struct flags_set *s = p;
|
struct flags_set *s = p;
|
||||||
|
|
||||||
if (s->projid != bi->bi_project) {
|
if (s->projid != bi->bi_project) {
|
||||||
if (s->projid)
|
bi->bi_fields_set |= 1U << Inode_opt_project;
|
||||||
bi->bi_fields_set |= 1U << Inode_opt_project;
|
|
||||||
else
|
|
||||||
bi->bi_fields_set &= ~(1U << Inode_opt_project);
|
|
||||||
|
|
||||||
bi->bi_project = s->projid;
|
bi->bi_project = s->projid;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -150,7 +133,10 @@ static int bch2_ioc_fssetxattr(struct bch_fs *c,
|
|||||||
if (fa.fsx_xflags)
|
if (fa.fsx_xflags)
|
||||||
return -EOPNOTSUPP;
|
return -EOPNOTSUPP;
|
||||||
|
|
||||||
s.projid = fa.fsx_projid;
|
if (fa.fsx_projid >= U32_MAX)
|
||||||
|
return -EINVAL;
|
||||||
|
|
||||||
|
s.projid = fa.fsx_projid + 1;
|
||||||
|
|
||||||
ret = mnt_want_write_file(file);
|
ret = mnt_want_write_file(file);
|
||||||
if (ret)
|
if (ret)
|
||||||
@ -163,7 +149,7 @@ static int bch2_ioc_fssetxattr(struct bch_fs *c,
|
|||||||
}
|
}
|
||||||
|
|
||||||
mutex_lock(&inode->ei_update_lock);
|
mutex_lock(&inode->ei_update_lock);
|
||||||
ret = bch2_set_projid(c, inode, fa.fsx_projid);
|
ret = bch2_set_projid(c, inode, s.projid);
|
||||||
if (ret)
|
if (ret)
|
||||||
goto err_unlock;
|
goto err_unlock;
|
||||||
|
|
||||||
|
|||||||
@ -1604,7 +1604,7 @@ static int bch2_show_options(struct seq_file *seq, struct dentry *root)
|
|||||||
const struct bch_option *opt = &bch2_opt_table[i];
|
const struct bch_option *opt = &bch2_opt_table[i];
|
||||||
u64 v = bch2_opt_get_by_id(&c->opts, i);
|
u64 v = bch2_opt_get_by_id(&c->opts, i);
|
||||||
|
|
||||||
if (opt->mode < OPT_MOUNT)
|
if (!(opt->mode & OPT_MOUNT))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (v == bch2_opt_get_by_id(&bch2_opts_default, i))
|
if (v == bch2_opt_get_by_id(&bch2_opts_default, i))
|
||||||
|
|||||||
@ -104,6 +104,19 @@ int bch2_fs_quota_transfer(struct bch_fs *,
|
|||||||
unsigned,
|
unsigned,
|
||||||
enum quota_acct_mode);
|
enum quota_acct_mode);
|
||||||
|
|
||||||
|
static inline int bch2_set_projid(struct bch_fs *c,
|
||||||
|
struct bch_inode_info *inode,
|
||||||
|
u32 projid)
|
||||||
|
{
|
||||||
|
struct bch_qid qid = inode->ei_qid;
|
||||||
|
|
||||||
|
qid.q[QTYP_PRJ] = projid;
|
||||||
|
|
||||||
|
return bch2_fs_quota_transfer(c, inode, qid,
|
||||||
|
1 << QTYP_PRJ,
|
||||||
|
KEY_TYPE_QUOTA_PREALLOC);
|
||||||
|
}
|
||||||
|
|
||||||
struct inode *bch2_vfs_inode_get(struct bch_fs *, u64);
|
struct inode *bch2_vfs_inode_get(struct bch_fs *, u64);
|
||||||
|
|
||||||
/* returns 0 if we want to do the update, or error is passed up */
|
/* returns 0 if we want to do the update, or error is passed up */
|
||||||
|
|||||||
@ -946,6 +946,7 @@ void bch2_write(struct closure *cl)
|
|||||||
|
|
||||||
struct promote_op {
|
struct promote_op {
|
||||||
struct closure cl;
|
struct closure cl;
|
||||||
|
struct rcu_head rcu;
|
||||||
u64 start_time;
|
u64 start_time;
|
||||||
|
|
||||||
struct rhash_head hash;
|
struct rhash_head hash;
|
||||||
@ -999,7 +1000,7 @@ static void promote_free(struct bch_fs *c, struct promote_op *op)
|
|||||||
bch_promote_params);
|
bch_promote_params);
|
||||||
BUG_ON(ret);
|
BUG_ON(ret);
|
||||||
percpu_ref_put(&c->writes);
|
percpu_ref_put(&c->writes);
|
||||||
kfree(op);
|
kfree_rcu(op, rcu);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void promote_done(struct closure *cl)
|
static void promote_done(struct closure *cl)
|
||||||
|
|||||||
@ -584,7 +584,7 @@ static void bch2_journal_read_device(struct closure *cl)
|
|||||||
while (ja->bucket_seq[ja->cur_idx] > min_seq &&
|
while (ja->bucket_seq[ja->cur_idx] > min_seq &&
|
||||||
ja->bucket_seq[ja->cur_idx] >
|
ja->bucket_seq[ja->cur_idx] >
|
||||||
ja->bucket_seq[(ja->cur_idx + 1) % ja->nr])
|
ja->bucket_seq[(ja->cur_idx + 1) % ja->nr])
|
||||||
ja->cur_idx++;
|
ja->cur_idx = (ja->cur_idx + 1) % ja->nr;
|
||||||
|
|
||||||
ja->sectors_free = 0;
|
ja->sectors_free = 0;
|
||||||
|
|
||||||
|
|||||||
@ -74,22 +74,22 @@ const char * const bch2_dev_state[] = {
|
|||||||
|
|
||||||
void bch2_opts_apply(struct bch_opts *dst, struct bch_opts src)
|
void bch2_opts_apply(struct bch_opts *dst, struct bch_opts src)
|
||||||
{
|
{
|
||||||
#define BCH_OPT(_name, ...) \
|
#define x(_name, ...) \
|
||||||
if (opt_defined(src, _name)) \
|
if (opt_defined(src, _name)) \
|
||||||
opt_set(*dst, _name, src._name);
|
opt_set(*dst, _name, src._name);
|
||||||
|
|
||||||
BCH_OPTS()
|
BCH_OPTS()
|
||||||
#undef BCH_OPT
|
#undef x
|
||||||
}
|
}
|
||||||
|
|
||||||
bool bch2_opt_defined_by_id(const struct bch_opts *opts, enum bch_opt_id id)
|
bool bch2_opt_defined_by_id(const struct bch_opts *opts, enum bch_opt_id id)
|
||||||
{
|
{
|
||||||
switch (id) {
|
switch (id) {
|
||||||
#define BCH_OPT(_name, ...) \
|
#define x(_name, ...) \
|
||||||
case Opt_##_name: \
|
case Opt_##_name: \
|
||||||
return opt_defined(*opts, _name);
|
return opt_defined(*opts, _name);
|
||||||
BCH_OPTS()
|
BCH_OPTS()
|
||||||
#undef BCH_OPT
|
#undef x
|
||||||
default:
|
default:
|
||||||
BUG();
|
BUG();
|
||||||
}
|
}
|
||||||
@ -98,11 +98,11 @@ bool bch2_opt_defined_by_id(const struct bch_opts *opts, enum bch_opt_id id)
|
|||||||
u64 bch2_opt_get_by_id(const struct bch_opts *opts, enum bch_opt_id id)
|
u64 bch2_opt_get_by_id(const struct bch_opts *opts, enum bch_opt_id id)
|
||||||
{
|
{
|
||||||
switch (id) {
|
switch (id) {
|
||||||
#define BCH_OPT(_name, ...) \
|
#define x(_name, ...) \
|
||||||
case Opt_##_name: \
|
case Opt_##_name: \
|
||||||
return opts->_name;
|
return opts->_name;
|
||||||
BCH_OPTS()
|
BCH_OPTS()
|
||||||
#undef BCH_OPT
|
#undef x
|
||||||
default:
|
default:
|
||||||
BUG();
|
BUG();
|
||||||
}
|
}
|
||||||
@ -111,12 +111,12 @@ u64 bch2_opt_get_by_id(const struct bch_opts *opts, enum bch_opt_id id)
|
|||||||
void bch2_opt_set_by_id(struct bch_opts *opts, enum bch_opt_id id, u64 v)
|
void bch2_opt_set_by_id(struct bch_opts *opts, enum bch_opt_id id, u64 v)
|
||||||
{
|
{
|
||||||
switch (id) {
|
switch (id) {
|
||||||
#define BCH_OPT(_name, ...) \
|
#define x(_name, ...) \
|
||||||
case Opt_##_name: \
|
case Opt_##_name: \
|
||||||
opt_set(*opts, _name, v); \
|
opt_set(*opts, _name, v); \
|
||||||
break;
|
break;
|
||||||
BCH_OPTS()
|
BCH_OPTS()
|
||||||
#undef BCH_OPT
|
#undef x
|
||||||
default:
|
default:
|
||||||
BUG();
|
BUG();
|
||||||
}
|
}
|
||||||
@ -130,11 +130,11 @@ struct bch_opts bch2_opts_from_sb(struct bch_sb *sb)
|
|||||||
{
|
{
|
||||||
struct bch_opts opts = bch2_opts_empty();
|
struct bch_opts opts = bch2_opts_empty();
|
||||||
|
|
||||||
#define BCH_OPT(_name, _bits, _mode, _type, _sb_opt, _default) \
|
#define x(_name, _bits, _mode, _type, _sb_opt, ...) \
|
||||||
if (_sb_opt != NO_SB_OPT) \
|
if (_sb_opt != NO_SB_OPT) \
|
||||||
opt_set(opts, _name, _sb_opt(sb));
|
opt_set(opts, _name, _sb_opt(sb));
|
||||||
BCH_OPTS()
|
BCH_OPTS()
|
||||||
#undef BCH_OPT
|
#undef x
|
||||||
|
|
||||||
return opts;
|
return opts;
|
||||||
}
|
}
|
||||||
@ -142,24 +142,27 @@ struct bch_opts bch2_opts_from_sb(struct bch_sb *sb)
|
|||||||
const struct bch_option bch2_opt_table[] = {
|
const struct bch_option bch2_opt_table[] = {
|
||||||
#define OPT_BOOL() .type = BCH_OPT_BOOL
|
#define OPT_BOOL() .type = BCH_OPT_BOOL
|
||||||
#define OPT_UINT(_min, _max) .type = BCH_OPT_UINT, .min = _min, .max = _max
|
#define OPT_UINT(_min, _max) .type = BCH_OPT_UINT, .min = _min, .max = _max
|
||||||
|
#define OPT_SECTORS(_min, _max) .type = BCH_OPT_SECTORS, .min = _min, .max = _max
|
||||||
#define OPT_STR(_choices) .type = BCH_OPT_STR, .choices = _choices
|
#define OPT_STR(_choices) .type = BCH_OPT_STR, .choices = _choices
|
||||||
#define OPT_FN(_fn) .type = BCH_OPT_FN, \
|
#define OPT_FN(_fn) .type = BCH_OPT_FN, \
|
||||||
.parse = _fn##_parse, \
|
.parse = _fn##_parse, \
|
||||||
.to_text = _fn##_to_text
|
.to_text = _fn##_to_text
|
||||||
|
|
||||||
#define BCH_OPT(_name, _bits, _mode, _type, _sb_opt, _default) \
|
#define x(_name, _bits, _mode, _type, _sb_opt, _default, _hint, _help) \
|
||||||
[Opt_##_name] = { \
|
[Opt_##_name] = { \
|
||||||
.attr = { \
|
.attr = { \
|
||||||
.name = #_name, \
|
.name = #_name, \
|
||||||
.mode = _mode == OPT_RUNTIME ? 0644 : 0444, \
|
.mode = (_mode) & OPT_RUNTIME ? 0644 : 0444, \
|
||||||
}, \
|
}, \
|
||||||
.mode = _mode, \
|
.mode = _mode, \
|
||||||
|
.hint = _hint, \
|
||||||
|
.help = _help, \
|
||||||
.set_sb = SET_##_sb_opt, \
|
.set_sb = SET_##_sb_opt, \
|
||||||
_type \
|
_type \
|
||||||
},
|
},
|
||||||
|
|
||||||
BCH_OPTS()
|
BCH_OPTS()
|
||||||
#undef BCH_OPT
|
#undef x
|
||||||
};
|
};
|
||||||
|
|
||||||
int bch2_opt_lookup(const char *name)
|
int bch2_opt_lookup(const char *name)
|
||||||
@ -215,6 +218,19 @@ int bch2_opt_parse(struct bch_fs *c, const struct bch_option *opt,
|
|||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
|
if (*res < opt->min || *res >= opt->max)
|
||||||
|
return -ERANGE;
|
||||||
|
break;
|
||||||
|
case BCH_OPT_SECTORS:
|
||||||
|
ret = bch2_strtou64_h(val, res);
|
||||||
|
if (ret < 0)
|
||||||
|
return ret;
|
||||||
|
|
||||||
|
if (*res & 511)
|
||||||
|
return -EINVAL;
|
||||||
|
|
||||||
|
*res >>= 9;
|
||||||
|
|
||||||
if (*res < opt->min || *res >= opt->max)
|
if (*res < opt->min || *res >= opt->max)
|
||||||
return -ERANGE;
|
return -ERANGE;
|
||||||
break;
|
break;
|
||||||
@ -255,6 +271,9 @@ void bch2_opt_to_text(struct printbuf *out, struct bch_fs *c,
|
|||||||
case BCH_OPT_UINT:
|
case BCH_OPT_UINT:
|
||||||
pr_buf(out, "%lli", v);
|
pr_buf(out, "%lli", v);
|
||||||
break;
|
break;
|
||||||
|
case BCH_OPT_SECTORS:
|
||||||
|
bch2_hprint(out, v);
|
||||||
|
break;
|
||||||
case BCH_OPT_STR:
|
case BCH_OPT_STR:
|
||||||
if (flags & OPT_SHOW_FULL_LIST)
|
if (flags & OPT_SHOW_FULL_LIST)
|
||||||
bch2_string_opt_to_text(out, opt->choices, v);
|
bch2_string_opt_to_text(out, opt->choices, v);
|
||||||
@ -344,7 +363,7 @@ int bch2_parse_mount_opts(struct bch_opts *opts, char *options)
|
|||||||
goto no_val;
|
goto no_val;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bch2_opt_table[id].mode < OPT_MOUNT)
|
if (!(bch2_opt_table[id].mode & OPT_MOUNT))
|
||||||
goto bad_opt;
|
goto bad_opt;
|
||||||
|
|
||||||
if (id == Opt_acl &&
|
if (id == Opt_acl &&
|
||||||
|
|||||||
@ -31,22 +31,25 @@ extern const char * const bch2_dev_state[];
|
|||||||
/* dummy option, for options that aren't stored in the superblock */
|
/* dummy option, for options that aren't stored in the superblock */
|
||||||
LE64_BITMASK(NO_SB_OPT, struct bch_sb, flags[0], 0, 0);
|
LE64_BITMASK(NO_SB_OPT, struct bch_sb, flags[0], 0, 0);
|
||||||
|
|
||||||
|
/* When can be set: */
|
||||||
enum opt_mode {
|
enum opt_mode {
|
||||||
OPT_INTERNAL,
|
OPT_FORMAT = (1 << 0),
|
||||||
OPT_FORMAT,
|
OPT_MOUNT = (1 << 1),
|
||||||
OPT_MOUNT,
|
OPT_RUNTIME = (1 << 2),
|
||||||
OPT_RUNTIME,
|
OPT_INODE = (1 << 3),
|
||||||
|
OPT_DEVICE = (1 << 4),
|
||||||
};
|
};
|
||||||
|
|
||||||
enum opt_type {
|
enum opt_type {
|
||||||
BCH_OPT_BOOL,
|
BCH_OPT_BOOL,
|
||||||
BCH_OPT_UINT,
|
BCH_OPT_UINT,
|
||||||
|
BCH_OPT_SECTORS,
|
||||||
BCH_OPT_STR,
|
BCH_OPT_STR,
|
||||||
BCH_OPT_FN,
|
BCH_OPT_FN,
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* BCH_OPT(name, type, in mem type, mode, sb_opt)
|
* x(name, shortopt, type, in mem type, mode, sb_opt)
|
||||||
*
|
*
|
||||||
* @name - name of mount option, sysfs attribute, and struct bch_opts
|
* @name - name of mount option, sysfs attribute, and struct bch_opts
|
||||||
* member
|
* member
|
||||||
@ -65,147 +68,246 @@ enum opt_type {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#define BCH_OPTS() \
|
#define BCH_OPTS() \
|
||||||
BCH_OPT(block_size, u16, OPT_FORMAT, \
|
x(block_size, u16, \
|
||||||
OPT_UINT(1, 128), \
|
OPT_FORMAT, \
|
||||||
BCH_SB_BLOCK_SIZE, 8) \
|
OPT_SECTORS(1, 128), \
|
||||||
BCH_OPT(btree_node_size, u16, OPT_FORMAT, \
|
BCH_SB_BLOCK_SIZE, 8, \
|
||||||
OPT_UINT(1, 128), \
|
"size", NULL) \
|
||||||
BCH_SB_BTREE_NODE_SIZE, 512) \
|
x(btree_node_size, u16, \
|
||||||
BCH_OPT(errors, u8, OPT_RUNTIME, \
|
OPT_FORMAT, \
|
||||||
OPT_STR(bch2_error_actions), \
|
OPT_SECTORS(1, 128), \
|
||||||
BCH_SB_ERROR_ACTION, BCH_ON_ERROR_RO) \
|
BCH_SB_BTREE_NODE_SIZE, 512, \
|
||||||
BCH_OPT(metadata_replicas, u8, OPT_RUNTIME, \
|
"size", "Btree node size, default 256k") \
|
||||||
OPT_UINT(1, BCH_REPLICAS_MAX), \
|
x(errors, u8, \
|
||||||
BCH_SB_META_REPLICAS_WANT, 1) \
|
OPT_FORMAT|OPT_MOUNT|OPT_RUNTIME, \
|
||||||
BCH_OPT(data_replicas, u8, OPT_RUNTIME, \
|
OPT_STR(bch2_error_actions), \
|
||||||
OPT_UINT(1, BCH_REPLICAS_MAX), \
|
BCH_SB_ERROR_ACTION, BCH_ON_ERROR_RO, \
|
||||||
BCH_SB_DATA_REPLICAS_WANT, 1) \
|
NULL, "Action to take on filesystem error") \
|
||||||
BCH_OPT(metadata_replicas_required, u8, OPT_MOUNT, \
|
x(metadata_replicas, u8, \
|
||||||
OPT_UINT(1, BCH_REPLICAS_MAX), \
|
OPT_FORMAT|OPT_MOUNT|OPT_RUNTIME, \
|
||||||
BCH_SB_META_REPLICAS_REQ, 1) \
|
OPT_UINT(1, BCH_REPLICAS_MAX), \
|
||||||
BCH_OPT(data_replicas_required, u8, OPT_MOUNT, \
|
BCH_SB_META_REPLICAS_WANT, 1, \
|
||||||
OPT_UINT(1, BCH_REPLICAS_MAX), \
|
"#", "Number of metadata replicas") \
|
||||||
BCH_SB_DATA_REPLICAS_REQ, 1) \
|
x(data_replicas, u8, \
|
||||||
BCH_OPT(metadata_checksum, u8, OPT_RUNTIME, \
|
OPT_FORMAT|OPT_MOUNT|OPT_RUNTIME|OPT_INODE, \
|
||||||
OPT_STR(bch2_csum_types), \
|
OPT_UINT(1, BCH_REPLICAS_MAX), \
|
||||||
BCH_SB_META_CSUM_TYPE, BCH_CSUM_OPT_CRC32C) \
|
BCH_SB_DATA_REPLICAS_WANT, 1, \
|
||||||
BCH_OPT(data_checksum, u8, OPT_RUNTIME, \
|
"#", "Number of data replicas") \
|
||||||
OPT_STR(bch2_csum_types), \
|
x(metadata_replicas_required, u8, \
|
||||||
BCH_SB_DATA_CSUM_TYPE, BCH_CSUM_OPT_CRC32C) \
|
OPT_FORMAT|OPT_MOUNT, \
|
||||||
BCH_OPT(compression, u8, OPT_RUNTIME, \
|
OPT_UINT(1, BCH_REPLICAS_MAX), \
|
||||||
OPT_STR(bch2_compression_types), \
|
BCH_SB_META_REPLICAS_REQ, 1, \
|
||||||
BCH_SB_COMPRESSION_TYPE, BCH_COMPRESSION_OPT_NONE)\
|
"#", NULL) \
|
||||||
BCH_OPT(background_compression, u8, OPT_RUNTIME, \
|
x(data_replicas_required, u8, \
|
||||||
OPT_STR(bch2_compression_types), \
|
OPT_FORMAT|OPT_MOUNT, \
|
||||||
BCH_SB_BACKGROUND_COMPRESSION_TYPE,BCH_COMPRESSION_OPT_NONE)\
|
OPT_UINT(1, BCH_REPLICAS_MAX), \
|
||||||
BCH_OPT(str_hash, u8, OPT_RUNTIME, \
|
BCH_SB_DATA_REPLICAS_REQ, 1, \
|
||||||
OPT_STR(bch2_str_hash_types), \
|
"#", NULL) \
|
||||||
BCH_SB_STR_HASH_TYPE, BCH_STR_HASH_SIPHASH) \
|
x(metadata_checksum, u8, \
|
||||||
BCH_OPT(foreground_target, u16, OPT_RUNTIME, \
|
OPT_FORMAT|OPT_MOUNT|OPT_RUNTIME, \
|
||||||
OPT_FN(bch2_opt_target), \
|
OPT_STR(bch2_csum_types), \
|
||||||
BCH_SB_FOREGROUND_TARGET, 0) \
|
BCH_SB_META_CSUM_TYPE, BCH_CSUM_OPT_CRC32C, \
|
||||||
BCH_OPT(background_target, u16, OPT_RUNTIME, \
|
NULL, NULL) \
|
||||||
OPT_FN(bch2_opt_target), \
|
x(data_checksum, u8, \
|
||||||
BCH_SB_BACKGROUND_TARGET, 0) \
|
OPT_FORMAT|OPT_MOUNT|OPT_RUNTIME|OPT_INODE, \
|
||||||
BCH_OPT(promote_target, u16, OPT_RUNTIME, \
|
OPT_STR(bch2_csum_types), \
|
||||||
OPT_FN(bch2_opt_target), \
|
BCH_SB_DATA_CSUM_TYPE, BCH_CSUM_OPT_CRC32C, \
|
||||||
BCH_SB_PROMOTE_TARGET, 0) \
|
NULL, NULL) \
|
||||||
BCH_OPT(erasure_code, u16, OPT_RUNTIME, \
|
x(compression, u8, \
|
||||||
OPT_BOOL(), \
|
OPT_FORMAT|OPT_MOUNT|OPT_RUNTIME|OPT_INODE, \
|
||||||
BCH_SB_ERASURE_CODE, false) \
|
OPT_STR(bch2_compression_types), \
|
||||||
BCH_OPT(inodes_32bit, u8, OPT_RUNTIME, \
|
BCH_SB_COMPRESSION_TYPE, BCH_COMPRESSION_OPT_NONE, \
|
||||||
OPT_BOOL(), \
|
NULL, NULL) \
|
||||||
BCH_SB_INODE_32BIT, false) \
|
x(background_compression, u8, \
|
||||||
BCH_OPT(gc_reserve_percent, u8, OPT_RUNTIME, \
|
OPT_FORMAT|OPT_MOUNT|OPT_RUNTIME|OPT_INODE, \
|
||||||
OPT_UINT(5, 21), \
|
OPT_STR(bch2_compression_types), \
|
||||||
BCH_SB_GC_RESERVE, 8) \
|
BCH_SB_BACKGROUND_COMPRESSION_TYPE,BCH_COMPRESSION_OPT_NONE, \
|
||||||
BCH_OPT(gc_reserve_bytes, u64, OPT_RUNTIME, \
|
NULL, NULL) \
|
||||||
OPT_UINT(0, U64_MAX), \
|
x(str_hash, u8, \
|
||||||
BCH_SB_GC_RESERVE_BYTES, 0) \
|
OPT_FORMAT|OPT_MOUNT|OPT_RUNTIME, \
|
||||||
BCH_OPT(root_reserve_percent, u8, OPT_MOUNT, \
|
OPT_STR(bch2_str_hash_types), \
|
||||||
OPT_UINT(0, 100), \
|
BCH_SB_STR_HASH_TYPE, BCH_STR_HASH_SIPHASH, \
|
||||||
BCH_SB_ROOT_RESERVE, 0) \
|
NULL, "Hash function for directory entries and xattrs")\
|
||||||
BCH_OPT(wide_macs, u8, OPT_RUNTIME, \
|
x(foreground_target, u16, \
|
||||||
OPT_BOOL(), \
|
OPT_FORMAT|OPT_MOUNT|OPT_RUNTIME|OPT_INODE, \
|
||||||
BCH_SB_128_BIT_MACS, false) \
|
OPT_FN(bch2_opt_target), \
|
||||||
BCH_OPT(acl, u8, OPT_MOUNT, \
|
BCH_SB_FOREGROUND_TARGET, 0, \
|
||||||
OPT_BOOL(), \
|
"(target)", "Device or disk group for foreground writes") \
|
||||||
BCH_SB_POSIX_ACL, true) \
|
x(background_target, u16, \
|
||||||
BCH_OPT(usrquota, u8, OPT_MOUNT, \
|
OPT_FORMAT|OPT_MOUNT|OPT_RUNTIME|OPT_INODE, \
|
||||||
OPT_BOOL(), \
|
OPT_FN(bch2_opt_target), \
|
||||||
BCH_SB_USRQUOTA, false) \
|
BCH_SB_BACKGROUND_TARGET, 0, \
|
||||||
BCH_OPT(grpquota, u8, OPT_MOUNT, \
|
"(target)", "Device or disk group to move data to in the background")\
|
||||||
OPT_BOOL(), \
|
x(promote_target, u16, \
|
||||||
BCH_SB_GRPQUOTA, false) \
|
OPT_FORMAT|OPT_MOUNT|OPT_RUNTIME|OPT_INODE, \
|
||||||
BCH_OPT(prjquota, u8, OPT_MOUNT, \
|
OPT_FN(bch2_opt_target), \
|
||||||
OPT_BOOL(), \
|
BCH_SB_PROMOTE_TARGET, 0, \
|
||||||
BCH_SB_PRJQUOTA, false) \
|
"(target)", "Device or disk group to promote data to on read")\
|
||||||
BCH_OPT(degraded, u8, OPT_MOUNT, \
|
x(erasure_code, u16, \
|
||||||
OPT_BOOL(), \
|
OPT_FORMAT|OPT_MOUNT|OPT_RUNTIME|OPT_INODE, \
|
||||||
NO_SB_OPT, false) \
|
OPT_BOOL(), \
|
||||||
BCH_OPT(discard, u8, OPT_MOUNT, \
|
BCH_SB_ERASURE_CODE, false, \
|
||||||
OPT_BOOL(), \
|
NULL, "Enable erasure coding (DO NOT USE YET)") \
|
||||||
NO_SB_OPT, false) \
|
x(inodes_32bit, u8, \
|
||||||
BCH_OPT(verbose_recovery, u8, OPT_MOUNT, \
|
OPT_FORMAT|OPT_MOUNT|OPT_RUNTIME, \
|
||||||
OPT_BOOL(), \
|
OPT_BOOL(), \
|
||||||
NO_SB_OPT, false) \
|
BCH_SB_INODE_32BIT, false, \
|
||||||
BCH_OPT(verbose_init, u8, OPT_MOUNT, \
|
NULL, "Constrain inode numbers to 32 bits") \
|
||||||
OPT_BOOL(), \
|
x(gc_reserve_percent, u8, \
|
||||||
NO_SB_OPT, false) \
|
OPT_FORMAT|OPT_MOUNT|OPT_RUNTIME, \
|
||||||
BCH_OPT(journal_flush_disabled, u8, OPT_RUNTIME, \
|
OPT_UINT(5, 21), \
|
||||||
OPT_BOOL(), \
|
BCH_SB_GC_RESERVE, 8, \
|
||||||
NO_SB_OPT, false) \
|
"%", "Percentage of disk space to reserve for copygc")\
|
||||||
BCH_OPT(fsck, u8, OPT_MOUNT, \
|
x(gc_reserve_bytes, u64, \
|
||||||
OPT_BOOL(), \
|
OPT_FORMAT|OPT_MOUNT|OPT_RUNTIME, \
|
||||||
NO_SB_OPT, true) \
|
OPT_SECTORS(0, U64_MAX), \
|
||||||
BCH_OPT(fix_errors, u8, OPT_MOUNT, \
|
BCH_SB_GC_RESERVE_BYTES, 0, \
|
||||||
OPT_BOOL(), \
|
"%", "Amount of disk space to reserve for copygc\n" \
|
||||||
NO_SB_OPT, false) \
|
"Takes precedence over gc_reserve_percent if set")\
|
||||||
BCH_OPT(nochanges, u8, OPT_MOUNT, \
|
x(root_reserve_percent, u8, \
|
||||||
OPT_BOOL(), \
|
OPT_FORMAT|OPT_MOUNT, \
|
||||||
NO_SB_OPT, false) \
|
OPT_UINT(0, 100), \
|
||||||
BCH_OPT(noreplay, u8, OPT_MOUNT, \
|
BCH_SB_ROOT_RESERVE, 0, \
|
||||||
OPT_BOOL(), \
|
"%", "Percentage of disk space to reserve for superuser")\
|
||||||
NO_SB_OPT, false) \
|
x(wide_macs, u8, \
|
||||||
BCH_OPT(norecovery, u8, OPT_MOUNT, \
|
OPT_FORMAT|OPT_MOUNT|OPT_RUNTIME, \
|
||||||
OPT_BOOL(), \
|
OPT_BOOL(), \
|
||||||
NO_SB_OPT, false) \
|
BCH_SB_128_BIT_MACS, false, \
|
||||||
BCH_OPT(noexcl, u8, OPT_MOUNT, \
|
NULL, "Store full 128 bits of cryptographic MACs, instead of 80")\
|
||||||
OPT_BOOL(), \
|
x(acl, u8, \
|
||||||
NO_SB_OPT, false) \
|
OPT_FORMAT|OPT_MOUNT, \
|
||||||
BCH_OPT(sb, u64, OPT_MOUNT, \
|
OPT_BOOL(), \
|
||||||
OPT_UINT(0, S64_MAX), \
|
BCH_SB_POSIX_ACL, true, \
|
||||||
NO_SB_OPT, BCH_SB_SECTOR) \
|
NULL, "Enable POSIX acls") \
|
||||||
BCH_OPT(read_only, u8, OPT_INTERNAL, \
|
x(usrquota, u8, \
|
||||||
OPT_BOOL(), \
|
OPT_FORMAT|OPT_MOUNT, \
|
||||||
NO_SB_OPT, false) \
|
OPT_BOOL(), \
|
||||||
BCH_OPT(nostart, u8, OPT_INTERNAL, \
|
BCH_SB_USRQUOTA, false, \
|
||||||
OPT_BOOL(), \
|
NULL, "Enable user quotas") \
|
||||||
NO_SB_OPT, false) \
|
x(grpquota, u8, \
|
||||||
BCH_OPT(version_upgrade, u8, OPT_MOUNT, \
|
OPT_FORMAT|OPT_MOUNT, \
|
||||||
OPT_BOOL(), \
|
OPT_BOOL(), \
|
||||||
NO_SB_OPT, false) \
|
BCH_SB_GRPQUOTA, false, \
|
||||||
BCH_OPT(project, u8, OPT_INTERNAL, \
|
NULL, "Enable group quotas") \
|
||||||
OPT_BOOL(), \
|
x(prjquota, u8, \
|
||||||
NO_SB_OPT, false) \
|
OPT_FORMAT|OPT_MOUNT, \
|
||||||
|
OPT_BOOL(), \
|
||||||
|
BCH_SB_PRJQUOTA, false, \
|
||||||
|
NULL, "Enable project quotas") \
|
||||||
|
x(degraded, u8, \
|
||||||
|
OPT_MOUNT, \
|
||||||
|
OPT_BOOL(), \
|
||||||
|
NO_SB_OPT, false, \
|
||||||
|
NULL, "Allow mounting in degraded mode") \
|
||||||
|
x(discard, u8, \
|
||||||
|
OPT_MOUNT|OPT_DEVICE, \
|
||||||
|
OPT_BOOL(), \
|
||||||
|
NO_SB_OPT, false, \
|
||||||
|
NULL, "Enable discard/TRIM support") \
|
||||||
|
x(verbose, u8, \
|
||||||
|
OPT_MOUNT, \
|
||||||
|
OPT_BOOL(), \
|
||||||
|
NO_SB_OPT, false, \
|
||||||
|
NULL, "Extra debugging information during mount/recovery")\
|
||||||
|
x(journal_flush_disabled, u8, \
|
||||||
|
OPT_MOUNT|OPT_RUNTIME, \
|
||||||
|
OPT_BOOL(), \
|
||||||
|
NO_SB_OPT, false, \
|
||||||
|
NULL, "Disable journal flush on sync/fsync\n" \
|
||||||
|
"If enabled, writes can be lost, but only since the\n"\
|
||||||
|
"last journal write (default 1 second)") \
|
||||||
|
x(fsck, u8, \
|
||||||
|
OPT_MOUNT, \
|
||||||
|
OPT_BOOL(), \
|
||||||
|
NO_SB_OPT, true, \
|
||||||
|
NULL, "Run fsck on mount") \
|
||||||
|
x(fix_errors, u8, \
|
||||||
|
OPT_MOUNT, \
|
||||||
|
OPT_BOOL(), \
|
||||||
|
NO_SB_OPT, false, \
|
||||||
|
NULL, "Fix errors during fsck without asking") \
|
||||||
|
x(nochanges, u8, \
|
||||||
|
OPT_MOUNT, \
|
||||||
|
OPT_BOOL(), \
|
||||||
|
NO_SB_OPT, false, \
|
||||||
|
NULL, "Super read only mode - no writes at all will be issued,\n"\
|
||||||
|
"even if we have to replay the journal") \
|
||||||
|
x(noreplay, u8, \
|
||||||
|
OPT_MOUNT, \
|
||||||
|
OPT_BOOL(), \
|
||||||
|
NO_SB_OPT, false, \
|
||||||
|
NULL, "Don't replay the journal (only for internal tools)")\
|
||||||
|
x(norecovery, u8, \
|
||||||
|
OPT_MOUNT, \
|
||||||
|
OPT_BOOL(), \
|
||||||
|
NO_SB_OPT, false, \
|
||||||
|
NULL, NULL) \
|
||||||
|
x(noexcl, u8, \
|
||||||
|
OPT_MOUNT, \
|
||||||
|
OPT_BOOL(), \
|
||||||
|
NO_SB_OPT, false, \
|
||||||
|
NULL, "Don't open device in exclusive mode") \
|
||||||
|
x(sb, u64, \
|
||||||
|
OPT_MOUNT, \
|
||||||
|
OPT_UINT(0, S64_MAX), \
|
||||||
|
NO_SB_OPT, BCH_SB_SECTOR, \
|
||||||
|
"offset", "Sector offset of superblock") \
|
||||||
|
x(read_only, u8, \
|
||||||
|
0, \
|
||||||
|
OPT_BOOL(), \
|
||||||
|
NO_SB_OPT, false, \
|
||||||
|
NULL, NULL) \
|
||||||
|
x(nostart, u8, \
|
||||||
|
0, \
|
||||||
|
OPT_BOOL(), \
|
||||||
|
NO_SB_OPT, false, \
|
||||||
|
NULL, "Don\'t start filesystem, only open devices") \
|
||||||
|
x(version_upgrade, u8, \
|
||||||
|
OPT_MOUNT, \
|
||||||
|
OPT_BOOL(), \
|
||||||
|
NO_SB_OPT, false, \
|
||||||
|
NULL, "Set superblock to latest version,\n" \
|
||||||
|
"allowing any new features to be used") \
|
||||||
|
x(project, u8, \
|
||||||
|
OPT_INODE, \
|
||||||
|
OPT_BOOL(), \
|
||||||
|
NO_SB_OPT, false, \
|
||||||
|
NULL, NULL) \
|
||||||
|
x(fs_size, u64, \
|
||||||
|
OPT_DEVICE, \
|
||||||
|
OPT_SECTORS(0, S64_MAX), \
|
||||||
|
NO_SB_OPT, 0, \
|
||||||
|
"size", "Size of filesystem on device") \
|
||||||
|
x(bucket, u32, \
|
||||||
|
OPT_DEVICE, \
|
||||||
|
OPT_SECTORS(0, S64_MAX), \
|
||||||
|
NO_SB_OPT, 0, \
|
||||||
|
"size", "Size of filesystem on device") \
|
||||||
|
x(durability, u8, \
|
||||||
|
OPT_DEVICE, \
|
||||||
|
OPT_UINT(0, BCH_REPLICAS_MAX), \
|
||||||
|
NO_SB_OPT, 1, \
|
||||||
|
"n", "Data written to this device will be considered\n"\
|
||||||
|
"to have already been replicated n times")
|
||||||
|
|
||||||
|
|
||||||
struct bch_opts {
|
struct bch_opts {
|
||||||
#define BCH_OPT(_name, _bits, ...) unsigned _name##_defined:1;
|
#define x(_name, _bits, ...) unsigned _name##_defined:1;
|
||||||
BCH_OPTS()
|
BCH_OPTS()
|
||||||
#undef BCH_OPT
|
#undef x
|
||||||
|
|
||||||
#define BCH_OPT(_name, _bits, ...) _bits _name;
|
#define x(_name, _bits, ...) _bits _name;
|
||||||
BCH_OPTS()
|
BCH_OPTS()
|
||||||
#undef BCH_OPT
|
#undef x
|
||||||
};
|
};
|
||||||
|
|
||||||
static const struct bch_opts bch2_opts_default = {
|
static const struct bch_opts bch2_opts_default = {
|
||||||
#define BCH_OPT(_name, _bits, _mode, _type, _sb_opt, _default) \
|
#define x(_name, _bits, _mode, _type, _sb_opt, _default, ...) \
|
||||||
._name##_defined = true, \
|
._name##_defined = true, \
|
||||||
._name = _default, \
|
._name = _default, \
|
||||||
|
|
||||||
BCH_OPTS()
|
BCH_OPTS()
|
||||||
#undef BCH_OPT
|
#undef x
|
||||||
};
|
};
|
||||||
|
|
||||||
#define opt_defined(_opts, _name) ((_opts)._name##_defined)
|
#define opt_defined(_opts, _name) ((_opts)._name##_defined)
|
||||||
@ -227,9 +329,9 @@ static inline struct bch_opts bch2_opts_empty(void)
|
|||||||
void bch2_opts_apply(struct bch_opts *, struct bch_opts);
|
void bch2_opts_apply(struct bch_opts *, struct bch_opts);
|
||||||
|
|
||||||
enum bch_opt_id {
|
enum bch_opt_id {
|
||||||
#define BCH_OPT(_name, ...) Opt_##_name,
|
#define x(_name, ...) Opt_##_name,
|
||||||
BCH_OPTS()
|
BCH_OPTS()
|
||||||
#undef BCH_OPT
|
#undef x
|
||||||
bch2_opts_nr
|
bch2_opts_nr
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -255,6 +357,9 @@ struct bch_option {
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const char *hint;
|
||||||
|
const char *help;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
extern const struct bch_option bch2_opt_table[];
|
extern const struct bch_option bch2_opt_table[];
|
||||||
|
|||||||
@ -19,7 +19,7 @@ static inline struct bch_qid bch_qid(struct bch_inode_unpacked *u)
|
|||||||
return (struct bch_qid) {
|
return (struct bch_qid) {
|
||||||
.q[QTYP_USR] = u->bi_uid,
|
.q[QTYP_USR] = u->bi_uid,
|
||||||
.q[QTYP_GRP] = u->bi_gid,
|
.q[QTYP_GRP] = u->bi_gid,
|
||||||
.q[QTYP_PRJ] = u->bi_project,
|
.q[QTYP_PRJ] = u->bi_project ? u->bi_project - 1 : 0,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -55,7 +55,8 @@ static inline int bch2_quota_acct(struct bch_fs *c, struct bch_qid qid,
|
|||||||
|
|
||||||
static inline int bch2_quota_transfer(struct bch_fs *c, unsigned qtypes,
|
static inline int bch2_quota_transfer(struct bch_fs *c, unsigned qtypes,
|
||||||
struct bch_qid dst,
|
struct bch_qid dst,
|
||||||
struct bch_qid src, u64 space)
|
struct bch_qid src, u64 space,
|
||||||
|
enum quota_acct_mode mode)
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -262,13 +262,13 @@ ssize_t bch2_rebalance_work_show(struct bch_fs *c, char *buf)
|
|||||||
struct rebalance_work w = rebalance_work(c);
|
struct rebalance_work w = rebalance_work(c);
|
||||||
char h1[21], h2[21];
|
char h1[21], h2[21];
|
||||||
|
|
||||||
bch2_hprint(h1, w.dev_most_full_work << 9);
|
bch2_hprint(&PBUF(h1), w.dev_most_full_work << 9);
|
||||||
bch2_hprint(h2, w.dev_most_full_capacity << 9);
|
bch2_hprint(&PBUF(h2), w.dev_most_full_capacity << 9);
|
||||||
pr_buf(&out, "fullest_dev (%i):\t%s/%s\n",
|
pr_buf(&out, "fullest_dev (%i):\t%s/%s\n",
|
||||||
w.dev_most_full_idx, h1, h2);
|
w.dev_most_full_idx, h1, h2);
|
||||||
|
|
||||||
bch2_hprint(h1, w.total_work << 9);
|
bch2_hprint(&PBUF(h1), w.total_work << 9);
|
||||||
bch2_hprint(h2, c->capacity << 9);
|
bch2_hprint(&PBUF(h2), c->capacity << 9);
|
||||||
pr_buf(&out, "total work:\t\t%s/%s\n", h1, h2);
|
pr_buf(&out, "total work:\t\t%s/%s\n", h1, h2);
|
||||||
|
|
||||||
pr_buf(&out, "rate:\t\t\t%u\n", r->pd.rate.rate);
|
pr_buf(&out, "rate:\t\t\t%u\n", r->pd.rate.rate);
|
||||||
@ -278,7 +278,7 @@ ssize_t bch2_rebalance_work_show(struct bch_fs *c, char *buf)
|
|||||||
pr_buf(&out, "waiting\n");
|
pr_buf(&out, "waiting\n");
|
||||||
break;
|
break;
|
||||||
case REBALANCE_THROTTLED:
|
case REBALANCE_THROTTLED:
|
||||||
bch2_hprint(h1,
|
bch2_hprint(&PBUF(h1),
|
||||||
(r->throttled_until_iotime -
|
(r->throttled_until_iotime -
|
||||||
atomic_long_read(&c->io_clock[WRITE].now)) << 9);
|
atomic_long_read(&c->io_clock[WRITE].now)) << 9);
|
||||||
pr_buf(&out, "throttled for %lu sec or %s io\n",
|
pr_buf(&out, "throttled for %lu sec or %s io\n",
|
||||||
|
|||||||
@ -1344,7 +1344,8 @@ int bch2_dev_remove(struct bch_fs *c, struct bch_dev *ca, int flags)
|
|||||||
mutex_unlock(&c->state_lock);
|
mutex_unlock(&c->state_lock);
|
||||||
return 0;
|
return 0;
|
||||||
err:
|
err:
|
||||||
if (ca->mi.state == BCH_MEMBER_STATE_RW)
|
if (ca->mi.state == BCH_MEMBER_STATE_RW &&
|
||||||
|
!percpu_ref_is_zero(&ca->io_ref))
|
||||||
__bch2_dev_read_write(c, ca);
|
__bch2_dev_read_write(c, ca);
|
||||||
mutex_unlock(&c->state_lock);
|
mutex_unlock(&c->state_lock);
|
||||||
return ret;
|
return ret;
|
||||||
|
|||||||
@ -72,9 +72,10 @@ do { \
|
|||||||
#define sysfs_hprint(file, val) \
|
#define sysfs_hprint(file, val) \
|
||||||
do { \
|
do { \
|
||||||
if (attr == &sysfs_ ## file) { \
|
if (attr == &sysfs_ ## file) { \
|
||||||
ssize_t ret = bch2_hprint(buf, val); \
|
struct printbuf out = _PBUF(buf, PAGE_SIZE); \
|
||||||
strcat(buf, "\n"); \
|
bch2_hprint(&out, val); \
|
||||||
return ret + 1; \
|
pr_buf(&out, "\n"); \
|
||||||
|
return out.pos - buf; \
|
||||||
} \
|
} \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
@ -657,7 +658,7 @@ int bch2_opts_create_sysfs_files(struct kobject *kobj)
|
|||||||
for (i = bch2_opt_table;
|
for (i = bch2_opt_table;
|
||||||
i < bch2_opt_table + bch2_opts_nr;
|
i < bch2_opt_table + bch2_opts_nr;
|
||||||
i++) {
|
i++) {
|
||||||
if (i->mode == OPT_INTERNAL)
|
if (!(i->mode & (OPT_FORMAT|OPT_MOUNT|OPT_RUNTIME)))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
ret = sysfs_create_file(kobj, &i->attr);
|
ret = sysfs_create_file(kobj, &i->attr);
|
||||||
|
|||||||
@ -618,8 +618,8 @@ void bch2_btree_perf_test(struct bch_fs *c, const char *testname,
|
|||||||
time = j.finish - j.start;
|
time = j.finish - j.start;
|
||||||
|
|
||||||
scnprintf(name_buf, sizeof(name_buf), "%s:", testname);
|
scnprintf(name_buf, sizeof(name_buf), "%s:", testname);
|
||||||
bch2_hprint(nr_buf, nr);
|
bch2_hprint(&PBUF(nr_buf), nr);
|
||||||
bch2_hprint(per_sec_buf, nr * NSEC_PER_SEC / time);
|
bch2_hprint(&PBUF(per_sec_buf), nr * NSEC_PER_SEC / time);
|
||||||
printk(KERN_INFO "%-12s %s with %u threads in %5llu sec, %5llu nsec per iter, %5s per sec\n",
|
printk(KERN_INFO "%-12s %s with %u threads in %5llu sec, %5llu nsec per iter, %5s per sec\n",
|
||||||
name_buf, nr_buf, nr_threads,
|
name_buf, nr_buf, nr_threads,
|
||||||
time / NSEC_PER_SEC,
|
time / NSEC_PER_SEC,
|
||||||
|
|||||||
@ -99,10 +99,10 @@ STRTO_H(strtoint, int)
|
|||||||
STRTO_H(strtouint, unsigned int)
|
STRTO_H(strtouint, unsigned int)
|
||||||
STRTO_H(strtoll, long long)
|
STRTO_H(strtoll, long long)
|
||||||
STRTO_H(strtoull, unsigned long long)
|
STRTO_H(strtoull, unsigned long long)
|
||||||
|
STRTO_H(strtou64, u64)
|
||||||
|
|
||||||
ssize_t bch2_hprint(char *buf, s64 v)
|
void bch2_hprint(struct printbuf *buf, s64 v)
|
||||||
{
|
{
|
||||||
char dec[4] = "";
|
|
||||||
int u, t = 0;
|
int u, t = 0;
|
||||||
|
|
||||||
for (u = 0; v >= 1024 || v <= -1024; u++) {
|
for (u = 0; v >= 1024 || v <= -1024; u++) {
|
||||||
@ -110,17 +110,16 @@ ssize_t bch2_hprint(char *buf, s64 v)
|
|||||||
v >>= 10;
|
v >>= 10;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!u)
|
pr_buf(buf, "%lli", v);
|
||||||
return sprintf(buf, "%lli", v);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* 103 is magic: t is in the range [-1023, 1023] and we want
|
* 103 is magic: t is in the range [-1023, 1023] and we want
|
||||||
* to turn it into [-9, 9]
|
* to turn it into [-9, 9]
|
||||||
*/
|
*/
|
||||||
if (v < 100 && v > -100)
|
if (u && v < 100 && v > -100)
|
||||||
scnprintf(dec, sizeof(dec), ".%i", t / 103);
|
pr_buf(buf, ".%i", t / 103);
|
||||||
|
if (u)
|
||||||
return sprintf(buf, "%lli%s%c", v, dec, si_units[u]);
|
pr_buf(buf, "%c", si_units[u]);
|
||||||
}
|
}
|
||||||
|
|
||||||
void bch2_string_opt_to_text(struct printbuf *out,
|
void bch2_string_opt_to_text(struct printbuf *out,
|
||||||
@ -480,12 +479,12 @@ size_t bch2_pd_controller_print_debug(struct bch_pd_controller *pd, char *buf)
|
|||||||
char change[21];
|
char change[21];
|
||||||
s64 next_io;
|
s64 next_io;
|
||||||
|
|
||||||
bch2_hprint(rate, pd->rate.rate);
|
bch2_hprint(&PBUF(rate), pd->rate.rate);
|
||||||
bch2_hprint(actual, pd->last_actual);
|
bch2_hprint(&PBUF(actual), pd->last_actual);
|
||||||
bch2_hprint(target, pd->last_target);
|
bch2_hprint(&PBUF(target), pd->last_target);
|
||||||
bch2_hprint(proportional, pd->last_proportional);
|
bch2_hprint(&PBUF(proportional), pd->last_proportional);
|
||||||
bch2_hprint(derivative, pd->last_derivative);
|
bch2_hprint(&PBUF(derivative), pd->last_derivative);
|
||||||
bch2_hprint(change, pd->last_change);
|
bch2_hprint(&PBUF(change), pd->last_change);
|
||||||
|
|
||||||
next_io = div64_s64(pd->rate.next - local_clock(), NSEC_PER_MSEC);
|
next_io = div64_s64(pd->rate.next - local_clock(), NSEC_PER_MSEC);
|
||||||
|
|
||||||
|
|||||||
@ -283,6 +283,7 @@ int bch2_strtoint_h(const char *, int *);
|
|||||||
int bch2_strtouint_h(const char *, unsigned int *);
|
int bch2_strtouint_h(const char *, unsigned int *);
|
||||||
int bch2_strtoll_h(const char *, long long *);
|
int bch2_strtoll_h(const char *, long long *);
|
||||||
int bch2_strtoull_h(const char *, unsigned long long *);
|
int bch2_strtoull_h(const char *, unsigned long long *);
|
||||||
|
int bch2_strtou64_h(const char *, u64 *);
|
||||||
|
|
||||||
static inline int bch2_strtol_h(const char *cp, long *res)
|
static inline int bch2_strtol_h(const char *cp, long *res)
|
||||||
{
|
{
|
||||||
@ -351,7 +352,7 @@ static inline int bch2_strtoul_h(const char *cp, long *res)
|
|||||||
: type_is(var, char *) ? "%s\n" \
|
: type_is(var, char *) ? "%s\n" \
|
||||||
: "%i\n", var)
|
: "%i\n", var)
|
||||||
|
|
||||||
ssize_t bch2_hprint(char *buf, s64 v);
|
void bch2_hprint(struct printbuf *, s64);
|
||||||
|
|
||||||
bool bch2_is_zero(const void *, size_t);
|
bool bch2_is_zero(const void *, size_t);
|
||||||
|
|
||||||
|
|||||||
@ -512,7 +512,14 @@ static int bch2_xattr_bcachefs_set(const struct xattr_handler *handler,
|
|||||||
}
|
}
|
||||||
|
|
||||||
mutex_lock(&inode->ei_update_lock);
|
mutex_lock(&inode->ei_update_lock);
|
||||||
|
if (inode_opt_id == Inode_opt_project) {
|
||||||
|
ret = bch2_set_projid(c, inode, s.v);
|
||||||
|
if (ret)
|
||||||
|
goto err;
|
||||||
|
}
|
||||||
|
|
||||||
ret = bch2_write_inode(c, inode, inode_opt_set_fn, &s, 0);
|
ret = bch2_write_inode(c, inode, inode_opt_set_fn, &s, 0);
|
||||||
|
err:
|
||||||
mutex_unlock(&inode->ei_update_lock);
|
mutex_unlock(&inode->ei_update_lock);
|
||||||
|
|
||||||
if (value &&
|
if (value &&
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user