switch rbd and libceph to p_log-based primitives

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
This commit is contained in:
Al Viro 2019-12-20 23:43:32 -05:00
Родитель 3fbb8d5554
Коммит 2c3f3dc315
2 изменённых файлов: 20 добавлений и 20 удалений

Просмотреть файл

@ -6363,10 +6363,9 @@ static int rbd_parse_param(struct fs_parameter *param,
token = fs_parse(NULL, &rbd_parameters, param, &result); token = fs_parse(NULL, &rbd_parameters, param, &result);
dout("%s fs_parse '%s' token %d\n", __func__, param->key, token); dout("%s fs_parse '%s' token %d\n", __func__, param->key, token);
if (token < 0) { if (token < 0) {
if (token == -ENOPARAM) { if (token == -ENOPARAM)
return invalf(NULL, "rbd: Unknown parameter '%s'", return inval_plog(&log, "Unknown parameter '%s'",
param->key); param->key);
}
return token; return token;
} }
@ -6379,9 +6378,8 @@ static int rbd_parse_param(struct fs_parameter *param,
case Opt_alloc_size: case Opt_alloc_size:
if (result.uint_32 < SECTOR_SIZE) if (result.uint_32 < SECTOR_SIZE)
goto out_of_range; goto out_of_range;
if (!is_power_of_2(result.uint_32)) { if (!is_power_of_2(result.uint_32))
return invalf(NULL, "rbd: alloc_size must be a power of 2"); return inval_plog(&log, "alloc_size must be a power of 2");
}
opt->alloc_size = result.uint_32; opt->alloc_size = result.uint_32;
break; break;
case Opt_lock_timeout: case Opt_lock_timeout:
@ -6417,7 +6415,7 @@ static int rbd_parse_param(struct fs_parameter *param,
return 0; return 0;
out_of_range: out_of_range:
return invalf(NULL, "rbd: %s out of range", param->key); return inval_plog(&log, "%s out of range", param->key);
} }
/* /*

Просмотреть файл

@ -337,7 +337,7 @@ EXPORT_SYMBOL(ceph_destroy_options);
/* get secret from key store */ /* get secret from key store */
static int get_secret(struct ceph_crypto_key *dst, const char *name, static int get_secret(struct ceph_crypto_key *dst, const char *name,
struct fs_context *fc) struct p_log *log)
{ {
struct key *ukey; struct key *ukey;
int key_err; int key_err;
@ -351,19 +351,19 @@ static int get_secret(struct ceph_crypto_key *dst, const char *name,
key_err = PTR_ERR(ukey); key_err = PTR_ERR(ukey);
switch (key_err) { switch (key_err) {
case -ENOKEY: case -ENOKEY:
errorf(fc, "libceph: Failed due to key not found: %s", error_plog(log, "Failed due to key not found: %s",
name); name);
break; break;
case -EKEYEXPIRED: case -EKEYEXPIRED:
errorf(fc, "libceph: Failed due to expired key: %s", error_plog(log, "Failed due to expired key: %s",
name); name);
break; break;
case -EKEYREVOKED: case -EKEYREVOKED:
errorf(fc, "libceph: Failed due to revoked key: %s", error_plog(log, "Failed due to revoked key: %s",
name); name);
break; break;
default: default:
errorf(fc, "libceph: Failed due to key error %d: %s", error_plog(log, "Failed due to key error %d: %s",
key_err, name); key_err, name);
} }
err = -EPERM; err = -EPERM;
@ -385,13 +385,14 @@ out:
int ceph_parse_mon_ips(const char *buf, size_t len, struct ceph_options *opt, int ceph_parse_mon_ips(const char *buf, size_t len, struct ceph_options *opt,
struct fs_context *fc) struct fs_context *fc)
{ {
struct p_log log = {.prefix = "libceph", .log = fc ? fc->log : NULL};
int ret; int ret;
/* ip1[:port1][,ip2[:port2]...] */ /* ip1[:port1][,ip2[:port2]...] */
ret = ceph_parse_ips(buf, buf + len, opt->mon_addr, CEPH_MAX_MON, ret = ceph_parse_ips(buf, buf + len, opt->mon_addr, CEPH_MAX_MON,
&opt->num_mon); &opt->num_mon);
if (ret) { if (ret) {
errorf(fc, "libceph: Failed to parse monitor IPs: %d", ret); error_plog(&log, "Failed to parse monitor IPs: %d", ret);
return ret; return ret;
} }
@ -404,6 +405,7 @@ int ceph_parse_param(struct fs_parameter *param, struct ceph_options *opt,
{ {
struct fs_parse_result result; struct fs_parse_result result;
int token, err; int token, err;
struct p_log log = {.prefix = "libceph", .log = fc ? fc->log : NULL};
token = fs_parse(fc, &ceph_parameters, param, &result); token = fs_parse(fc, &ceph_parameters, param, &result);
dout("%s fs_parse '%s' token %d\n", __func__, param->key, token); dout("%s fs_parse '%s' token %d\n", __func__, param->key, token);
@ -417,7 +419,7 @@ int ceph_parse_param(struct fs_parameter *param, struct ceph_options *opt,
&opt->my_addr, &opt->my_addr,
1, NULL); 1, NULL);
if (err) { if (err) {
errorf(fc, "libceph: Failed to parse ip: %d", err); error_plog(&log, "Failed to parse ip: %d", err);
return err; return err;
} }
opt->flags |= CEPH_OPT_MYIP; opt->flags |= CEPH_OPT_MYIP;
@ -426,7 +428,7 @@ int ceph_parse_param(struct fs_parameter *param, struct ceph_options *opt,
case Opt_fsid: case Opt_fsid:
err = parse_fsid(param->string, &opt->fsid); err = parse_fsid(param->string, &opt->fsid);
if (err) { if (err) {
errorf(fc, "libceph: Failed to parse fsid: %d", err); error_plog(&log, "Failed to parse fsid: %d", err);
return err; return err;
} }
opt->flags |= CEPH_OPT_FSID; opt->flags |= CEPH_OPT_FSID;
@ -445,7 +447,7 @@ int ceph_parse_param(struct fs_parameter *param, struct ceph_options *opt,
return -ENOMEM; return -ENOMEM;
err = ceph_crypto_key_unarmor(opt->key, param->string); err = ceph_crypto_key_unarmor(opt->key, param->string);
if (err) { if (err) {
errorf(fc, "libceph: Failed to parse secret: %d", err); error_plog(&log, "Failed to parse secret: %d", err);
return err; return err;
} }
break; break;
@ -456,10 +458,10 @@ int ceph_parse_param(struct fs_parameter *param, struct ceph_options *opt,
opt->key = kzalloc(sizeof(*opt->key), GFP_KERNEL); opt->key = kzalloc(sizeof(*opt->key), GFP_KERNEL);
if (!opt->key) if (!opt->key)
return -ENOMEM; return -ENOMEM;
return get_secret(opt->key, param->string, fc); return get_secret(opt->key, param->string, &log);
case Opt_osdtimeout: case Opt_osdtimeout:
warnf(fc, "libceph: Ignoring osdtimeout"); warn_plog(&log, "Ignoring osdtimeout");
break; break;
case Opt_osdkeepalivetimeout: case Opt_osdkeepalivetimeout:
/* 0 isn't well defined right now, reject it */ /* 0 isn't well defined right now, reject it */
@ -530,7 +532,7 @@ int ceph_parse_param(struct fs_parameter *param, struct ceph_options *opt,
return 0; return 0;
out_of_range: out_of_range:
return invalf(fc, "libceph: %s out of range", param->key); return inval_plog(&log, "%s out of range", param->key);
} }
EXPORT_SYMBOL(ceph_parse_param); EXPORT_SYMBOL(ceph_parse_param);