mirror of
https://github.com/koverstreet/bcachefs-tools.git
synced 2025-02-02 00:00:03 +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);
|
||||
break;
|
||||
case 'v':
|
||||
opt_set(opts, verbose_recovery, true);
|
||||
opt_set(opts, verbose, true);
|
||||
break;
|
||||
case 'h':
|
||||
list_keys_usage();
|
||||
|
@ -45,7 +45,7 @@ int cmd_fsck(int argc, char *argv[])
|
||||
/* force check, even if filesystem marked clean: */
|
||||
break;
|
||||
case 'v':
|
||||
opt_set(opts, verbose_recovery, true);
|
||||
opt_set(opts, verbose, true);
|
||||
break;
|
||||
case 'h':
|
||||
usage();
|
||||
|
@ -227,13 +227,13 @@
|
||||
|
||||
#define bch_verbose(c, fmt, ...) \
|
||||
do { \
|
||||
if ((c)->opts.verbose_recovery) \
|
||||
if ((c)->opts.verbose) \
|
||||
bch_info(c, fmt, ##__VA_ARGS__); \
|
||||
} while (0)
|
||||
|
||||
#define pr_verbose_init(opts, fmt, ...) \
|
||||
do { \
|
||||
if (opt_get(opts, verbose_init)) \
|
||||
if (opt_get(opts, verbose)) \
|
||||
pr_info(fmt, ##__VA_ARGS__); \
|
||||
} while (0)
|
||||
|
||||
|
@ -103,19 +103,6 @@ static int bch2_ioc_fsgetxattr(struct bch_inode_info *inode,
|
||||
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,
|
||||
struct bch_inode_unpacked *bi,
|
||||
void *p)
|
||||
@ -123,11 +110,7 @@ static int fssetxattr_inode_update_fn(struct bch_inode_info *inode,
|
||||
struct flags_set *s = p;
|
||||
|
||||
if (s->projid != bi->bi_project) {
|
||||
if (s->projid)
|
||||
bi->bi_fields_set |= 1U << Inode_opt_project;
|
||||
else
|
||||
bi->bi_fields_set &= ~(1U << Inode_opt_project);
|
||||
|
||||
bi->bi_fields_set |= 1U << Inode_opt_project;
|
||||
bi->bi_project = s->projid;
|
||||
}
|
||||
|
||||
@ -150,7 +133,10 @@ static int bch2_ioc_fssetxattr(struct bch_fs *c,
|
||||
if (fa.fsx_xflags)
|
||||
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);
|
||||
if (ret)
|
||||
@ -163,7 +149,7 @@ static int bch2_ioc_fssetxattr(struct bch_fs *c,
|
||||
}
|
||||
|
||||
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)
|
||||
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];
|
||||
u64 v = bch2_opt_get_by_id(&c->opts, i);
|
||||
|
||||
if (opt->mode < OPT_MOUNT)
|
||||
if (!(opt->mode & OPT_MOUNT))
|
||||
continue;
|
||||
|
||||
if (v == bch2_opt_get_by_id(&bch2_opts_default, i))
|
||||
|
@ -104,6 +104,19 @@ int bch2_fs_quota_transfer(struct bch_fs *,
|
||||
unsigned,
|
||||
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);
|
||||
|
||||
/* 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 closure cl;
|
||||
struct rcu_head rcu;
|
||||
u64 start_time;
|
||||
|
||||
struct rhash_head hash;
|
||||
@ -999,7 +1000,7 @@ static void promote_free(struct bch_fs *c, struct promote_op *op)
|
||||
bch_promote_params);
|
||||
BUG_ON(ret);
|
||||
percpu_ref_put(&c->writes);
|
||||
kfree(op);
|
||||
kfree_rcu(op, rcu);
|
||||
}
|
||||
|
||||
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 &&
|
||||
ja->bucket_seq[ja->cur_idx] >
|
||||
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;
|
||||
|
||||
|
@ -74,22 +74,22 @@ const char * const bch2_dev_state[] = {
|
||||
|
||||
void bch2_opts_apply(struct bch_opts *dst, struct bch_opts src)
|
||||
{
|
||||
#define BCH_OPT(_name, ...) \
|
||||
#define x(_name, ...) \
|
||||
if (opt_defined(src, _name)) \
|
||||
opt_set(*dst, _name, src._name);
|
||||
|
||||
BCH_OPTS()
|
||||
#undef BCH_OPT
|
||||
#undef x
|
||||
}
|
||||
|
||||
bool bch2_opt_defined_by_id(const struct bch_opts *opts, enum bch_opt_id id)
|
||||
{
|
||||
switch (id) {
|
||||
#define BCH_OPT(_name, ...) \
|
||||
#define x(_name, ...) \
|
||||
case Opt_##_name: \
|
||||
return opt_defined(*opts, _name);
|
||||
BCH_OPTS()
|
||||
#undef BCH_OPT
|
||||
#undef x
|
||||
default:
|
||||
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)
|
||||
{
|
||||
switch (id) {
|
||||
#define BCH_OPT(_name, ...) \
|
||||
#define x(_name, ...) \
|
||||
case Opt_##_name: \
|
||||
return opts->_name;
|
||||
BCH_OPTS()
|
||||
#undef BCH_OPT
|
||||
#undef x
|
||||
default:
|
||||
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)
|
||||
{
|
||||
switch (id) {
|
||||
#define BCH_OPT(_name, ...) \
|
||||
#define x(_name, ...) \
|
||||
case Opt_##_name: \
|
||||
opt_set(*opts, _name, v); \
|
||||
break;
|
||||
BCH_OPTS()
|
||||
#undef BCH_OPT
|
||||
#undef x
|
||||
default:
|
||||
BUG();
|
||||
}
|
||||
@ -130,11 +130,11 @@ struct bch_opts bch2_opts_from_sb(struct bch_sb *sb)
|
||||
{
|
||||
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) \
|
||||
opt_set(opts, _name, _sb_opt(sb));
|
||||
BCH_OPTS()
|
||||
#undef BCH_OPT
|
||||
#undef x
|
||||
|
||||
return opts;
|
||||
}
|
||||
@ -142,24 +142,27 @@ struct bch_opts bch2_opts_from_sb(struct bch_sb *sb)
|
||||
const struct bch_option bch2_opt_table[] = {
|
||||
#define OPT_BOOL() .type = BCH_OPT_BOOL
|
||||
#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_FN(_fn) .type = BCH_OPT_FN, \
|
||||
.parse = _fn##_parse, \
|
||||
.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] = { \
|
||||
.attr = { \
|
||||
.name = #_name, \
|
||||
.mode = _mode == OPT_RUNTIME ? 0644 : 0444, \
|
||||
.mode = (_mode) & OPT_RUNTIME ? 0644 : 0444, \
|
||||
}, \
|
||||
.mode = _mode, \
|
||||
.hint = _hint, \
|
||||
.help = _help, \
|
||||
.set_sb = SET_##_sb_opt, \
|
||||
_type \
|
||||
},
|
||||
|
||||
BCH_OPTS()
|
||||
#undef BCH_OPT
|
||||
#undef x
|
||||
};
|
||||
|
||||
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)
|
||||
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)
|
||||
return -ERANGE;
|
||||
break;
|
||||
@ -255,6 +271,9 @@ void bch2_opt_to_text(struct printbuf *out, struct bch_fs *c,
|
||||
case BCH_OPT_UINT:
|
||||
pr_buf(out, "%lli", v);
|
||||
break;
|
||||
case BCH_OPT_SECTORS:
|
||||
bch2_hprint(out, v);
|
||||
break;
|
||||
case BCH_OPT_STR:
|
||||
if (flags & OPT_SHOW_FULL_LIST)
|
||||
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;
|
||||
}
|
||||
|
||||
if (bch2_opt_table[id].mode < OPT_MOUNT)
|
||||
if (!(bch2_opt_table[id].mode & OPT_MOUNT))
|
||||
goto bad_opt;
|
||||
|
||||
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 */
|
||||
LE64_BITMASK(NO_SB_OPT, struct bch_sb, flags[0], 0, 0);
|
||||
|
||||
/* When can be set: */
|
||||
enum opt_mode {
|
||||
OPT_INTERNAL,
|
||||
OPT_FORMAT,
|
||||
OPT_MOUNT,
|
||||
OPT_RUNTIME,
|
||||
OPT_FORMAT = (1 << 0),
|
||||
OPT_MOUNT = (1 << 1),
|
||||
OPT_RUNTIME = (1 << 2),
|
||||
OPT_INODE = (1 << 3),
|
||||
OPT_DEVICE = (1 << 4),
|
||||
};
|
||||
|
||||
enum opt_type {
|
||||
BCH_OPT_BOOL,
|
||||
BCH_OPT_UINT,
|
||||
BCH_OPT_SECTORS,
|
||||
BCH_OPT_STR,
|
||||
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
|
||||
* member
|
||||
@ -65,147 +68,246 @@ enum opt_type {
|
||||
*/
|
||||
|
||||
#define BCH_OPTS() \
|
||||
BCH_OPT(block_size, u16, OPT_FORMAT, \
|
||||
OPT_UINT(1, 128), \
|
||||
BCH_SB_BLOCK_SIZE, 8) \
|
||||
BCH_OPT(btree_node_size, u16, OPT_FORMAT, \
|
||||
OPT_UINT(1, 128), \
|
||||
BCH_SB_BTREE_NODE_SIZE, 512) \
|
||||
BCH_OPT(errors, u8, OPT_RUNTIME, \
|
||||
OPT_STR(bch2_error_actions), \
|
||||
BCH_SB_ERROR_ACTION, BCH_ON_ERROR_RO) \
|
||||
BCH_OPT(metadata_replicas, u8, OPT_RUNTIME, \
|
||||
OPT_UINT(1, BCH_REPLICAS_MAX), \
|
||||
BCH_SB_META_REPLICAS_WANT, 1) \
|
||||
BCH_OPT(data_replicas, u8, OPT_RUNTIME, \
|
||||
OPT_UINT(1, BCH_REPLICAS_MAX), \
|
||||
BCH_SB_DATA_REPLICAS_WANT, 1) \
|
||||
BCH_OPT(metadata_replicas_required, u8, OPT_MOUNT, \
|
||||
OPT_UINT(1, BCH_REPLICAS_MAX), \
|
||||
BCH_SB_META_REPLICAS_REQ, 1) \
|
||||
BCH_OPT(data_replicas_required, u8, OPT_MOUNT, \
|
||||
OPT_UINT(1, BCH_REPLICAS_MAX), \
|
||||
BCH_SB_DATA_REPLICAS_REQ, 1) \
|
||||
BCH_OPT(metadata_checksum, u8, OPT_RUNTIME, \
|
||||
OPT_STR(bch2_csum_types), \
|
||||
BCH_SB_META_CSUM_TYPE, BCH_CSUM_OPT_CRC32C) \
|
||||
BCH_OPT(data_checksum, u8, OPT_RUNTIME, \
|
||||
OPT_STR(bch2_csum_types), \
|
||||
BCH_SB_DATA_CSUM_TYPE, BCH_CSUM_OPT_CRC32C) \
|
||||
BCH_OPT(compression, u8, OPT_RUNTIME, \
|
||||
OPT_STR(bch2_compression_types), \
|
||||
BCH_SB_COMPRESSION_TYPE, BCH_COMPRESSION_OPT_NONE)\
|
||||
BCH_OPT(background_compression, u8, OPT_RUNTIME, \
|
||||
OPT_STR(bch2_compression_types), \
|
||||
BCH_SB_BACKGROUND_COMPRESSION_TYPE,BCH_COMPRESSION_OPT_NONE)\
|
||||
BCH_OPT(str_hash, u8, OPT_RUNTIME, \
|
||||
OPT_STR(bch2_str_hash_types), \
|
||||
BCH_SB_STR_HASH_TYPE, BCH_STR_HASH_SIPHASH) \
|
||||
BCH_OPT(foreground_target, u16, OPT_RUNTIME, \
|
||||
OPT_FN(bch2_opt_target), \
|
||||
BCH_SB_FOREGROUND_TARGET, 0) \
|
||||
BCH_OPT(background_target, u16, OPT_RUNTIME, \
|
||||
OPT_FN(bch2_opt_target), \
|
||||
BCH_SB_BACKGROUND_TARGET, 0) \
|
||||
BCH_OPT(promote_target, u16, OPT_RUNTIME, \
|
||||
OPT_FN(bch2_opt_target), \
|
||||
BCH_SB_PROMOTE_TARGET, 0) \
|
||||
BCH_OPT(erasure_code, u16, OPT_RUNTIME, \
|
||||
OPT_BOOL(), \
|
||||
BCH_SB_ERASURE_CODE, false) \
|
||||
BCH_OPT(inodes_32bit, u8, OPT_RUNTIME, \
|
||||
OPT_BOOL(), \
|
||||
BCH_SB_INODE_32BIT, false) \
|
||||
BCH_OPT(gc_reserve_percent, u8, OPT_RUNTIME, \
|
||||
OPT_UINT(5, 21), \
|
||||
BCH_SB_GC_RESERVE, 8) \
|
||||
BCH_OPT(gc_reserve_bytes, u64, OPT_RUNTIME, \
|
||||
OPT_UINT(0, U64_MAX), \
|
||||
BCH_SB_GC_RESERVE_BYTES, 0) \
|
||||
BCH_OPT(root_reserve_percent, u8, OPT_MOUNT, \
|
||||
OPT_UINT(0, 100), \
|
||||
BCH_SB_ROOT_RESERVE, 0) \
|
||||
BCH_OPT(wide_macs, u8, OPT_RUNTIME, \
|
||||
OPT_BOOL(), \
|
||||
BCH_SB_128_BIT_MACS, false) \
|
||||
BCH_OPT(acl, u8, OPT_MOUNT, \
|
||||
OPT_BOOL(), \
|
||||
BCH_SB_POSIX_ACL, true) \
|
||||
BCH_OPT(usrquota, u8, OPT_MOUNT, \
|
||||
OPT_BOOL(), \
|
||||
BCH_SB_USRQUOTA, false) \
|
||||
BCH_OPT(grpquota, u8, OPT_MOUNT, \
|
||||
OPT_BOOL(), \
|
||||
BCH_SB_GRPQUOTA, false) \
|
||||
BCH_OPT(prjquota, u8, OPT_MOUNT, \
|
||||
OPT_BOOL(), \
|
||||
BCH_SB_PRJQUOTA, false) \
|
||||
BCH_OPT(degraded, u8, OPT_MOUNT, \
|
||||
OPT_BOOL(), \
|
||||
NO_SB_OPT, false) \
|
||||
BCH_OPT(discard, u8, OPT_MOUNT, \
|
||||
OPT_BOOL(), \
|
||||
NO_SB_OPT, false) \
|
||||
BCH_OPT(verbose_recovery, u8, OPT_MOUNT, \
|
||||
OPT_BOOL(), \
|
||||
NO_SB_OPT, false) \
|
||||
BCH_OPT(verbose_init, u8, OPT_MOUNT, \
|
||||
OPT_BOOL(), \
|
||||
NO_SB_OPT, false) \
|
||||
BCH_OPT(journal_flush_disabled, u8, OPT_RUNTIME, \
|
||||
OPT_BOOL(), \
|
||||
NO_SB_OPT, false) \
|
||||
BCH_OPT(fsck, u8, OPT_MOUNT, \
|
||||
OPT_BOOL(), \
|
||||
NO_SB_OPT, true) \
|
||||
BCH_OPT(fix_errors, u8, OPT_MOUNT, \
|
||||
OPT_BOOL(), \
|
||||
NO_SB_OPT, false) \
|
||||
BCH_OPT(nochanges, u8, OPT_MOUNT, \
|
||||
OPT_BOOL(), \
|
||||
NO_SB_OPT, false) \
|
||||
BCH_OPT(noreplay, u8, OPT_MOUNT, \
|
||||
OPT_BOOL(), \
|
||||
NO_SB_OPT, false) \
|
||||
BCH_OPT(norecovery, u8, OPT_MOUNT, \
|
||||
OPT_BOOL(), \
|
||||
NO_SB_OPT, false) \
|
||||
BCH_OPT(noexcl, u8, OPT_MOUNT, \
|
||||
OPT_BOOL(), \
|
||||
NO_SB_OPT, false) \
|
||||
BCH_OPT(sb, u64, OPT_MOUNT, \
|
||||
OPT_UINT(0, S64_MAX), \
|
||||
NO_SB_OPT, BCH_SB_SECTOR) \
|
||||
BCH_OPT(read_only, u8, OPT_INTERNAL, \
|
||||
OPT_BOOL(), \
|
||||
NO_SB_OPT, false) \
|
||||
BCH_OPT(nostart, u8, OPT_INTERNAL, \
|
||||
OPT_BOOL(), \
|
||||
NO_SB_OPT, false) \
|
||||
BCH_OPT(version_upgrade, u8, OPT_MOUNT, \
|
||||
OPT_BOOL(), \
|
||||
NO_SB_OPT, false) \
|
||||
BCH_OPT(project, u8, OPT_INTERNAL, \
|
||||
OPT_BOOL(), \
|
||||
NO_SB_OPT, false) \
|
||||
x(block_size, u16, \
|
||||
OPT_FORMAT, \
|
||||
OPT_SECTORS(1, 128), \
|
||||
BCH_SB_BLOCK_SIZE, 8, \
|
||||
"size", NULL) \
|
||||
x(btree_node_size, u16, \
|
||||
OPT_FORMAT, \
|
||||
OPT_SECTORS(1, 128), \
|
||||
BCH_SB_BTREE_NODE_SIZE, 512, \
|
||||
"size", "Btree node size, default 256k") \
|
||||
x(errors, u8, \
|
||||
OPT_FORMAT|OPT_MOUNT|OPT_RUNTIME, \
|
||||
OPT_STR(bch2_error_actions), \
|
||||
BCH_SB_ERROR_ACTION, BCH_ON_ERROR_RO, \
|
||||
NULL, "Action to take on filesystem error") \
|
||||
x(metadata_replicas, u8, \
|
||||
OPT_FORMAT|OPT_MOUNT|OPT_RUNTIME, \
|
||||
OPT_UINT(1, BCH_REPLICAS_MAX), \
|
||||
BCH_SB_META_REPLICAS_WANT, 1, \
|
||||
"#", "Number of metadata replicas") \
|
||||
x(data_replicas, u8, \
|
||||
OPT_FORMAT|OPT_MOUNT|OPT_RUNTIME|OPT_INODE, \
|
||||
OPT_UINT(1, BCH_REPLICAS_MAX), \
|
||||
BCH_SB_DATA_REPLICAS_WANT, 1, \
|
||||
"#", "Number of data replicas") \
|
||||
x(metadata_replicas_required, u8, \
|
||||
OPT_FORMAT|OPT_MOUNT, \
|
||||
OPT_UINT(1, BCH_REPLICAS_MAX), \
|
||||
BCH_SB_META_REPLICAS_REQ, 1, \
|
||||
"#", NULL) \
|
||||
x(data_replicas_required, u8, \
|
||||
OPT_FORMAT|OPT_MOUNT, \
|
||||
OPT_UINT(1, BCH_REPLICAS_MAX), \
|
||||
BCH_SB_DATA_REPLICAS_REQ, 1, \
|
||||
"#", NULL) \
|
||||
x(metadata_checksum, u8, \
|
||||
OPT_FORMAT|OPT_MOUNT|OPT_RUNTIME, \
|
||||
OPT_STR(bch2_csum_types), \
|
||||
BCH_SB_META_CSUM_TYPE, BCH_CSUM_OPT_CRC32C, \
|
||||
NULL, NULL) \
|
||||
x(data_checksum, u8, \
|
||||
OPT_FORMAT|OPT_MOUNT|OPT_RUNTIME|OPT_INODE, \
|
||||
OPT_STR(bch2_csum_types), \
|
||||
BCH_SB_DATA_CSUM_TYPE, BCH_CSUM_OPT_CRC32C, \
|
||||
NULL, NULL) \
|
||||
x(compression, u8, \
|
||||
OPT_FORMAT|OPT_MOUNT|OPT_RUNTIME|OPT_INODE, \
|
||||
OPT_STR(bch2_compression_types), \
|
||||
BCH_SB_COMPRESSION_TYPE, BCH_COMPRESSION_OPT_NONE, \
|
||||
NULL, NULL) \
|
||||
x(background_compression, u8, \
|
||||
OPT_FORMAT|OPT_MOUNT|OPT_RUNTIME|OPT_INODE, \
|
||||
OPT_STR(bch2_compression_types), \
|
||||
BCH_SB_BACKGROUND_COMPRESSION_TYPE,BCH_COMPRESSION_OPT_NONE, \
|
||||
NULL, NULL) \
|
||||
x(str_hash, u8, \
|
||||
OPT_FORMAT|OPT_MOUNT|OPT_RUNTIME, \
|
||||
OPT_STR(bch2_str_hash_types), \
|
||||
BCH_SB_STR_HASH_TYPE, BCH_STR_HASH_SIPHASH, \
|
||||
NULL, "Hash function for directory entries and xattrs")\
|
||||
x(foreground_target, u16, \
|
||||
OPT_FORMAT|OPT_MOUNT|OPT_RUNTIME|OPT_INODE, \
|
||||
OPT_FN(bch2_opt_target), \
|
||||
BCH_SB_FOREGROUND_TARGET, 0, \
|
||||
"(target)", "Device or disk group for foreground writes") \
|
||||
x(background_target, u16, \
|
||||
OPT_FORMAT|OPT_MOUNT|OPT_RUNTIME|OPT_INODE, \
|
||||
OPT_FN(bch2_opt_target), \
|
||||
BCH_SB_BACKGROUND_TARGET, 0, \
|
||||
"(target)", "Device or disk group to move data to in the background")\
|
||||
x(promote_target, u16, \
|
||||
OPT_FORMAT|OPT_MOUNT|OPT_RUNTIME|OPT_INODE, \
|
||||
OPT_FN(bch2_opt_target), \
|
||||
BCH_SB_PROMOTE_TARGET, 0, \
|
||||
"(target)", "Device or disk group to promote data to on read")\
|
||||
x(erasure_code, u16, \
|
||||
OPT_FORMAT|OPT_MOUNT|OPT_RUNTIME|OPT_INODE, \
|
||||
OPT_BOOL(), \
|
||||
BCH_SB_ERASURE_CODE, false, \
|
||||
NULL, "Enable erasure coding (DO NOT USE YET)") \
|
||||
x(inodes_32bit, u8, \
|
||||
OPT_FORMAT|OPT_MOUNT|OPT_RUNTIME, \
|
||||
OPT_BOOL(), \
|
||||
BCH_SB_INODE_32BIT, false, \
|
||||
NULL, "Constrain inode numbers to 32 bits") \
|
||||
x(gc_reserve_percent, u8, \
|
||||
OPT_FORMAT|OPT_MOUNT|OPT_RUNTIME, \
|
||||
OPT_UINT(5, 21), \
|
||||
BCH_SB_GC_RESERVE, 8, \
|
||||
"%", "Percentage of disk space to reserve for copygc")\
|
||||
x(gc_reserve_bytes, u64, \
|
||||
OPT_FORMAT|OPT_MOUNT|OPT_RUNTIME, \
|
||||
OPT_SECTORS(0, U64_MAX), \
|
||||
BCH_SB_GC_RESERVE_BYTES, 0, \
|
||||
"%", "Amount of disk space to reserve for copygc\n" \
|
||||
"Takes precedence over gc_reserve_percent if set")\
|
||||
x(root_reserve_percent, u8, \
|
||||
OPT_FORMAT|OPT_MOUNT, \
|
||||
OPT_UINT(0, 100), \
|
||||
BCH_SB_ROOT_RESERVE, 0, \
|
||||
"%", "Percentage of disk space to reserve for superuser")\
|
||||
x(wide_macs, u8, \
|
||||
OPT_FORMAT|OPT_MOUNT|OPT_RUNTIME, \
|
||||
OPT_BOOL(), \
|
||||
BCH_SB_128_BIT_MACS, false, \
|
||||
NULL, "Store full 128 bits of cryptographic MACs, instead of 80")\
|
||||
x(acl, u8, \
|
||||
OPT_FORMAT|OPT_MOUNT, \
|
||||
OPT_BOOL(), \
|
||||
BCH_SB_POSIX_ACL, true, \
|
||||
NULL, "Enable POSIX acls") \
|
||||
x(usrquota, u8, \
|
||||
OPT_FORMAT|OPT_MOUNT, \
|
||||
OPT_BOOL(), \
|
||||
BCH_SB_USRQUOTA, false, \
|
||||
NULL, "Enable user quotas") \
|
||||
x(grpquota, u8, \
|
||||
OPT_FORMAT|OPT_MOUNT, \
|
||||
OPT_BOOL(), \
|
||||
BCH_SB_GRPQUOTA, false, \
|
||||
NULL, "Enable group quotas") \
|
||||
x(prjquota, u8, \
|
||||
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 {
|
||||
#define BCH_OPT(_name, _bits, ...) unsigned _name##_defined:1;
|
||||
#define x(_name, _bits, ...) unsigned _name##_defined:1;
|
||||
BCH_OPTS()
|
||||
#undef BCH_OPT
|
||||
#undef x
|
||||
|
||||
#define BCH_OPT(_name, _bits, ...) _bits _name;
|
||||
#define x(_name, _bits, ...) _bits _name;
|
||||
BCH_OPTS()
|
||||
#undef BCH_OPT
|
||||
#undef x
|
||||
};
|
||||
|
||||
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 = _default, \
|
||||
|
||||
BCH_OPTS()
|
||||
#undef BCH_OPT
|
||||
#undef x
|
||||
};
|
||||
|
||||
#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);
|
||||
|
||||
enum bch_opt_id {
|
||||
#define BCH_OPT(_name, ...) Opt_##_name,
|
||||
#define x(_name, ...) Opt_##_name,
|
||||
BCH_OPTS()
|
||||
#undef BCH_OPT
|
||||
#undef x
|
||||
bch2_opts_nr
|
||||
};
|
||||
|
||||
@ -255,6 +357,9 @@ struct bch_option {
|
||||
};
|
||||
};
|
||||
|
||||
const char *hint;
|
||||
const char *help;
|
||||
|
||||
};
|
||||
|
||||
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) {
|
||||
.q[QTYP_USR] = u->bi_uid,
|
||||
.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,
|
||||
struct bch_qid dst,
|
||||
struct bch_qid src, u64 space)
|
||||
struct bch_qid src, u64 space,
|
||||
enum quota_acct_mode mode)
|
||||
{
|
||||
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);
|
||||
char h1[21], h2[21];
|
||||
|
||||
bch2_hprint(h1, w.dev_most_full_work << 9);
|
||||
bch2_hprint(h2, w.dev_most_full_capacity << 9);
|
||||
bch2_hprint(&PBUF(h1), w.dev_most_full_work << 9);
|
||||
bch2_hprint(&PBUF(h2), w.dev_most_full_capacity << 9);
|
||||
pr_buf(&out, "fullest_dev (%i):\t%s/%s\n",
|
||||
w.dev_most_full_idx, h1, h2);
|
||||
|
||||
bch2_hprint(h1, w.total_work << 9);
|
||||
bch2_hprint(h2, c->capacity << 9);
|
||||
bch2_hprint(&PBUF(h1), w.total_work << 9);
|
||||
bch2_hprint(&PBUF(h2), c->capacity << 9);
|
||||
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);
|
||||
@ -278,7 +278,7 @@ ssize_t bch2_rebalance_work_show(struct bch_fs *c, char *buf)
|
||||
pr_buf(&out, "waiting\n");
|
||||
break;
|
||||
case REBALANCE_THROTTLED:
|
||||
bch2_hprint(h1,
|
||||
bch2_hprint(&PBUF(h1),
|
||||
(r->throttled_until_iotime -
|
||||
atomic_long_read(&c->io_clock[WRITE].now)) << 9);
|
||||
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);
|
||||
return 0;
|
||||
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);
|
||||
mutex_unlock(&c->state_lock);
|
||||
return ret;
|
||||
|
@ -72,9 +72,10 @@ do { \
|
||||
#define sysfs_hprint(file, val) \
|
||||
do { \
|
||||
if (attr == &sysfs_ ## file) { \
|
||||
ssize_t ret = bch2_hprint(buf, val); \
|
||||
strcat(buf, "\n"); \
|
||||
return ret + 1; \
|
||||
struct printbuf out = _PBUF(buf, PAGE_SIZE); \
|
||||
bch2_hprint(&out, val); \
|
||||
pr_buf(&out, "\n"); \
|
||||
return out.pos - buf; \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
@ -657,7 +658,7 @@ int bch2_opts_create_sysfs_files(struct kobject *kobj)
|
||||
for (i = bch2_opt_table;
|
||||
i < bch2_opt_table + bch2_opts_nr;
|
||||
i++) {
|
||||
if (i->mode == OPT_INTERNAL)
|
||||
if (!(i->mode & (OPT_FORMAT|OPT_MOUNT|OPT_RUNTIME)))
|
||||
continue;
|
||||
|
||||
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;
|
||||
|
||||
scnprintf(name_buf, sizeof(name_buf), "%s:", testname);
|
||||
bch2_hprint(nr_buf, nr);
|
||||
bch2_hprint(per_sec_buf, nr * NSEC_PER_SEC / time);
|
||||
bch2_hprint(&PBUF(nr_buf), nr);
|
||||
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",
|
||||
name_buf, nr_buf, nr_threads,
|
||||
time / NSEC_PER_SEC,
|
||||
|
@ -99,10 +99,10 @@ STRTO_H(strtoint, int)
|
||||
STRTO_H(strtouint, unsigned int)
|
||||
STRTO_H(strtoll, 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;
|
||||
|
||||
for (u = 0; v >= 1024 || v <= -1024; u++) {
|
||||
@ -110,17 +110,16 @@ ssize_t bch2_hprint(char *buf, s64 v)
|
||||
v >>= 10;
|
||||
}
|
||||
|
||||
if (!u)
|
||||
return sprintf(buf, "%lli", v);
|
||||
pr_buf(buf, "%lli", v);
|
||||
|
||||
/*
|
||||
* 103 is magic: t is in the range [-1023, 1023] and we want
|
||||
* to turn it into [-9, 9]
|
||||
*/
|
||||
if (v < 100 && v > -100)
|
||||
scnprintf(dec, sizeof(dec), ".%i", t / 103);
|
||||
|
||||
return sprintf(buf, "%lli%s%c", v, dec, si_units[u]);
|
||||
if (u && v < 100 && v > -100)
|
||||
pr_buf(buf, ".%i", t / 103);
|
||||
if (u)
|
||||
pr_buf(buf, "%c", si_units[u]);
|
||||
}
|
||||
|
||||
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];
|
||||
s64 next_io;
|
||||
|
||||
bch2_hprint(rate, pd->rate.rate);
|
||||
bch2_hprint(actual, pd->last_actual);
|
||||
bch2_hprint(target, pd->last_target);
|
||||
bch2_hprint(proportional, pd->last_proportional);
|
||||
bch2_hprint(derivative, pd->last_derivative);
|
||||
bch2_hprint(change, pd->last_change);
|
||||
bch2_hprint(&PBUF(rate), pd->rate.rate);
|
||||
bch2_hprint(&PBUF(actual), pd->last_actual);
|
||||
bch2_hprint(&PBUF(target), pd->last_target);
|
||||
bch2_hprint(&PBUF(proportional), pd->last_proportional);
|
||||
bch2_hprint(&PBUF(derivative), pd->last_derivative);
|
||||
bch2_hprint(&PBUF(change), pd->last_change);
|
||||
|
||||
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_strtoll_h(const char *, 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)
|
||||
{
|
||||
@ -351,7 +352,7 @@ static inline int bch2_strtoul_h(const char *cp, long *res)
|
||||
: type_is(var, char *) ? "%s\n" \
|
||||
: "%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);
|
||||
|
||||
|
@ -512,7 +512,14 @@ static int bch2_xattr_bcachefs_set(const struct xattr_handler *handler,
|
||||
}
|
||||
|
||||
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);
|
||||
err:
|
||||
mutex_unlock(&inode->ei_update_lock);
|
||||
|
||||
if (value &&
|
||||
|
Loading…
Reference in New Issue
Block a user