From: Mr NeilBrown Date: Thu, 12 May 2022 04:39:16 +0000 (+1000) Subject: LU-13340 lustre: Support large nids in LCFG_ADD_UUID X-Git-Tag: 2.15.57~98 X-Git-Url: https://git.whamcloud.com/?a=commitdiff_plain;ds=sidebyside;h=e7cf1fc1f274484dbd31e227652153fd4118aeef;p=fs%2Flustre-release.git LU-13340 lustre: Support large nids in LCFG_ADD_UUID 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 Change-Id: If08477df677f26e0ff450803e79dde707becde0f Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/50096 Tested-by: jenkins Tested-by: Maloo Reviewed-by: James Simmons Reviewed-by: Oleg Drokin Reviewed-by: Andreas Dilger --- diff --git a/lustre/include/uapi/linux/lustre/lustre_cfg.h b/lustre/include/uapi/linux/lustre/lustre_cfg.h index a82932b..760b1f9 100644 --- a/lustre/include/uapi/linux/lustre/lustre_cfg.h +++ b/lustre/include/uapi/linux/lustre/lustre_cfg.h @@ -174,7 +174,7 @@ static struct lcfg_type_data lcfg_data_table[] = { { 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" } }, diff --git a/lustre/mgs/mgs_llog.c b/lustre/mgs/mgs_llog.c index 4a3b64e..e334dd0 100644 --- a/lustre/mgs/mgs_llog.c +++ b/lustre/mgs/mgs_llog.c @@ -1091,11 +1091,15 @@ static inline int record_add_uuid(const struct lu_env *env, struct llog_handle *llh, struct lnet_nid *nid, char *uuid) { + lnet_nid_t nid4 = 0; + char *cfg2 = NULL; + if (nid_is_nid4(nid)) - 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, @@ -2214,6 +2218,17 @@ static int mgs_steal_client_llog_handler(const struct lu_env *env, 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 diff --git a/lustre/obdclass/obd_config.c b/lustre/obdclass/obd_config.c index 431d0a5..e397312 100644 --- a/lustre/obdclass/obd_config.c +++ b/lustre/obdclass/obd_config.c @@ -1398,8 +1398,19 @@ int class_process_config(struct lustre_cfg *lcfg) 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: { diff --git a/lustre/obdclass/obd_mount.c b/lustre/obdclass/obd_mount.c index e96ca5f..a43a659 100644 --- a/lustre/obdclass/obd_mount.c +++ b/lustre/obdclass/obd_mount.c @@ -183,10 +183,14 @@ static int do_lcfg(char *cfgname, lnet_nid_t nid, int cmd, static int do_lcfg_nid(char *cfgname, struct lnet_nid *nid, int cmd, char *s1) { + lnet_nid_t nid4 = 0; + char *nidstr = NULL; + if (nid_is_nid4(nid)) - 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); } /** diff --git a/lustre/target/tgt_mount.c b/lustre/target/tgt_mount.c index 7e4aaa8..ee7120e 100644 --- a/lustre/target/tgt_mount.c +++ b/lustre/target/tgt_mount.c @@ -644,7 +644,13 @@ static int lustre_lwp_setup(struct lustre_cfg *lcfg, struct lustre_sb_info *lsi, int rc; ENTRY; - 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); @@ -872,8 +878,15 @@ static int client_lwp_config_process(const struct lu_env *env, } 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); diff --git a/lustre/utils/lustre_cfg.c b/lustre/utils/lustre_cfg.c index 44571e1..180f37c 100644 --- a/lustre/utils/lustre_cfg.c +++ b/lustre/utils/lustre_cfg.c @@ -244,22 +244,30 @@ int jt_obd_cleanup(int argc, char **argv) } static -int do_add_uuid(char *func, char *uuid, lnet_nid_t nid) +int do_add_uuid(char *func, char *uuid, struct lnet_nid *nid) { int rc; + 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); + 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->lcfg_nid = nid; + 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); @@ -271,25 +279,24 @@ int do_add_uuid(char *func, char *uuid, lnet_nid_t nid) } if (uuid) - 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) { - lnet_nid_t nid; + struct lnet_nid nid; 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); } - 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)