struct lustre_cfg contains lcfg_nid which is used only for
LCFG_ADD_UUID. This is not sufficient for large nids.
The LCFG_ADD_UUID config record has room for 4 arbitrary strings only
one of which is used ("node"). So we can use the second string to
store a larger nid.
Specifically: if lcfg_nid is zero, then the second config string
(named "nid") will store the nid in string format. When a nid with
4-byte address is needed, that will always be stored in lcfg_nid,
never in the config string.
Signed-off-by: Mr NeilBrown <neilb@suse.de>
Change-Id: If08477df677f26e0ff450803e79dde707becde0f
Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/50096
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: James Simmons <jsimmons@infradead.org>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
{ LCFG_DETACH, "detach", { "1", "2", "3", "4" } },
{ LCFG_SETUP, "setup", { "UUID", "node", "options", "failout" } },
{ LCFG_CLEANUP, "cleanup", { "1", "2", "3", "4" } },
{ LCFG_DETACH, "detach", { "1", "2", "3", "4" } },
{ LCFG_SETUP, "setup", { "UUID", "node", "options", "failout" } },
{ LCFG_CLEANUP, "cleanup", { "1", "2", "3", "4" } },
- { LCFG_ADD_UUID, "add_uuid", { "node", "2", "3", "4" } },
+ { LCFG_ADD_UUID, "add_uuid", { "node", "nid", "3", "4" } },
{ LCFG_DEL_UUID, "del_uuid", { "1", "2", "3", "4" } },
{ LCFG_MOUNTOPT, "new_profile", { "name", "lov", "lmv", "4" } },
{ LCFG_DEL_MOUNTOPT, "del_mountopt", { "1", "2", "3", "4" } },
{ LCFG_DEL_UUID, "del_uuid", { "1", "2", "3", "4" } },
{ LCFG_MOUNTOPT, "new_profile", { "name", "lov", "lmv", "4" } },
{ LCFG_DEL_MOUNTOPT, "del_mountopt", { "1", "2", "3", "4" } },
struct llog_handle *llh,
struct lnet_nid *nid, char *uuid)
{
struct llog_handle *llh,
struct lnet_nid *nid, char *uuid)
{
+ lnet_nid_t nid4 = 0;
+ char *cfg2 = NULL;
+
- return record_base(env, llh, NULL, lnet_nid_to_nid4(nid),
- LCFG_ADD_UUID, uuid,
- NULL, NULL, NULL);
- return -EINVAL;
+ nid4 = lnet_nid_to_nid4(nid);
+ else
+ cfg2 = libcfs_nidstr(nid);
+ return record_base(env, llh, NULL, nid4, LCFG_ADD_UUID, uuid,
+ cfg2, NULL, NULL);
}
static inline int record_add_conn(const struct lu_env *env,
}
static inline int record_add_conn(const struct lu_env *env,
if (lcfg->lcfg_command == LCFG_ADD_UUID) {
__u64 nodenid = lcfg->lcfg_nid;
if (lcfg->lcfg_command == LCFG_ADD_UUID) {
__u64 nodenid = lcfg->lcfg_nid;
+ if (!nodenid) {
+ char *nidstr = lustre_cfg_buf(lcfg, 2);
+
+ if (nidstr) {
+ struct lnet_nid nid;
+
+ if (libcfs_strnid(&nid, nidstr) == 0 &&
+ nid_is_nid4(&nid))
+ nodenid = lnet_nid_to_nid4(&nid);
+ }
+ }
if (strlen(tmti->mti_uuid) == 0) {
/* target uuid not set, this config record is before
if (strlen(tmti->mti_uuid) == 0) {
/* target uuid not set, this config record is before
lustre_cfg_string(lcfg, 1), lcfg->lcfg_nid,
libcfs_nid2str(lcfg->lcfg_nid));
lustre_cfg_string(lcfg, 1), lcfg->lcfg_nid,
libcfs_nid2str(lcfg->lcfg_nid));
- lnet_nid4_to_nid(lcfg->lcfg_nid, &nid);
- err = class_add_uuid(lustre_cfg_string(lcfg, 1), &nid);
+ err = 0;
+ if (lcfg->lcfg_nid) {
+ lnet_nid4_to_nid(lcfg->lcfg_nid, &nid);
+ } else {
+ char *nidstr = lustre_cfg_string(lcfg, 2);
+
+ if (nidstr)
+ err = libcfs_strnid(&nid, nidstr);
+ else
+ err = -EINVAL;
+ }
+ if (!err)
+ err = class_add_uuid(lustre_cfg_string(lcfg, 1), &nid);
GOTO(out, err);
}
case LCFG_DEL_UUID: {
GOTO(out, err);
}
case LCFG_DEL_UUID: {
static int do_lcfg_nid(char *cfgname, struct lnet_nid *nid, int cmd,
char *s1)
{
static int do_lcfg_nid(char *cfgname, struct lnet_nid *nid, int cmd,
char *s1)
{
+ lnet_nid_t nid4 = 0;
+ char *nidstr = NULL;
+
- return do_lcfg(cfgname, lnet_nid_to_nid4(nid), cmd, s1,
- NULL, NULL, NULL);
- return -EINVAL;
+ nid4 = lnet_nid_to_nid4(nid);
+ else
+ nidstr = libcfs_nidstr(nid);
+ return do_lcfg(cfgname, nid4, cmd, s1, nidstr, NULL, NULL);
- lnet_nid4_to_nid(lcfg->lcfg_nid, &nid);
+ if (lcfg->lcfg_nid)
+ lnet_nid4_to_nid(lcfg->lcfg_nid, &nid);
+ else {
+ rc = libcfs_strnid(&nid, lustre_cfg_string(lcfg, 2));
+ if (rc)
+ RETURN(rc);
+ }
rc = class_add_uuid(lustre_cfg_string(lcfg, 1), &nid);
if (rc != 0) {
CERROR("%s: Can't add uuid: rc =%d\n", lsi->lsi_svname, rc);
rc = class_add_uuid(lustre_cfg_string(lcfg, 1), &nid);
if (rc != 0) {
CERROR("%s: Can't add uuid: rc =%d\n", lsi->lsi_svname, rc);
} else if (cfg->cfg_flags == (CFG_F_MARKER | CFG_F_SKIP)) {
struct lnet_nid nid;
} else if (cfg->cfg_flags == (CFG_F_MARKER | CFG_F_SKIP)) {
struct lnet_nid nid;
- lnet_nid4_to_nid(lcfg->lcfg_nid, &nid);
- rc = class_add_uuid(lustre_cfg_string(lcfg, 1), &nid);
+ rc = 0;
+ if (lcfg->lcfg_nid)
+ lnet_nid4_to_nid(lcfg->lcfg_nid, &nid);
+ else
+ rc = libcfs_strnid(&nid,
+ lustre_cfg_string(lcfg, 2));
+ if (!rc)
+ rc = class_add_uuid(lustre_cfg_string(lcfg, 1),
+ &nid);
if (rc < 0)
CERROR("%s: Fail to add uuid, rc:%d\n",
lsi->lsi_svname, rc);
if (rc < 0)
CERROR("%s: Fail to add uuid, rc:%d\n",
lsi->lsi_svname, rc);
-int do_add_uuid(char *func, char *uuid, lnet_nid_t nid)
+int do_add_uuid(char *func, char *uuid, struct lnet_nid *nid)
+ char nidstr[LNET_NIDSTR_SIZE];
struct lustre_cfg_bufs bufs;
struct lustre_cfg *lcfg;
lustre_cfg_bufs_reset(&bufs, lcfg_devname);
if (uuid)
lustre_cfg_bufs_set_string(&bufs, 1, uuid);
struct lustre_cfg_bufs bufs;
struct lustre_cfg *lcfg;
lustre_cfg_bufs_reset(&bufs, lcfg_devname);
if (uuid)
lustre_cfg_bufs_set_string(&bufs, 1, uuid);
+ if (!nid_is_nid4(nid)) {
+ libcfs_nidstr_r(nid, nidstr, sizeof(nidstr));
+ lustre_cfg_bufs_set_string(&bufs, 2, nidstr);
+ }
lcfg = malloc(lustre_cfg_len(bufs.lcfg_bufcount, bufs.lcfg_buflen));
if (!lcfg) {
rc = -ENOMEM;
} else {
lustre_cfg_init(lcfg, LCFG_ADD_UUID, &bufs);
lcfg = malloc(lustre_cfg_len(bufs.lcfg_bufcount, bufs.lcfg_buflen));
if (!lcfg) {
rc = -ENOMEM;
} else {
lustre_cfg_init(lcfg, LCFG_ADD_UUID, &bufs);
+ if (nid_is_nid4(nid))
+ lcfg->lcfg_nid = lnet_nid_to_nid4(nid);
+ else
+ lcfg->lcfg_nid = 0;
rc = lcfg_ioctl(func, OBD_DEV_ID, lcfg);
free(lcfg);
rc = lcfg_ioctl(func, OBD_DEV_ID, lcfg);
free(lcfg);
- printf("Added uuid %s: %s\n", uuid, libcfs_nid2str(nid));
+ printf("Added uuid %s: %s\n", uuid, libcfs_nidstr(nid));
return 0;
}
int jt_lcfg_add_uuid(int argc, char **argv)
{
return 0;
}
int jt_lcfg_add_uuid(int argc, char **argv)
{
if (argc != 3)
return CMD_HELP;
if (argc != 3)
return CMD_HELP;
- nid = libcfs_str2nid(argv[2]);
- if (nid == LNET_NID_ANY) {
+ if (libcfs_strnid(&nid, argv[2]) < 0) {
fprintf(stderr, "Can't parse NID %s\n", argv[2]);
return (-1);
}
fprintf(stderr, "Can't parse NID %s\n", argv[2]);
return (-1);
}
- return do_add_uuid(argv[0], argv[1], nid);
+ return do_add_uuid(argv[0], argv[1], &nid);
}
int jt_lcfg_del_uuid(int argc, char **argv)
}
int jt_lcfg_del_uuid(int argc, char **argv)