From b26fc38d256236b8135fc2fab608a366dbda0f73 Mon Sep 17 00:00:00 2001 From: Chris Horn Date: Fri, 12 Jan 2024 21:50:00 -0600 Subject: [PATCH] LU-10003 lnet: Update lctl ping to work with large NIDs jt_ptl_ping()/lnet_parse_nid() updated to use the large struct lnet_processid. This allows lctl ping to work with large NIDs. If we need to fallback to the old_api then the large lnet_processid is converted to the old struct lnet_process_id. Test-Parameters: trivial Signed-off-by: Chris Horn Change-Id: Ie0fb05ed631d0432e6c6caba0f64fc377f785bc2 Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/53835 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Frank Sehr Reviewed-by: James Simmons Reviewed-by: Neil Brown Reviewed-by: Cyril Bordage Reviewed-by: Oleg Drokin --- lustre/tests/sanity.sh | 8 ++++++-- lustre/utils/portals.c | 23 +++++++++++------------ 2 files changed, 17 insertions(+), 14 deletions(-) diff --git a/lustre/tests/sanity.sh b/lustre/tests/sanity.sh index d261fbb..622a0fb 100755 --- a/lustre/tests/sanity.sh +++ b/lustre/tests/sanity.sh @@ -21163,13 +21163,17 @@ test_217() { # bug 22430 # if hostname matches any NID, use hostname for better testing if [[ -z "$nid" || "$nid" =~ "$node_ip" ]]; then echo "lctl ping node $node@$NETTYPE" - lctl ping $node@$NETTYPE + lctl ping $node@$NETTYPE || + error "ping $node@$NETTYPE failed rc=$?" else # otherwise, at least test 'lctl ping' is working echo "lctl ping nid $(h2nettype $nid)" - lctl ping $(h2nettype $nid) + lctl ping $(h2nettype $nid) || + error "ping $(h2nettype $nid) failed rc=$?" echo "skipping $node (no hyphen detected)" fi done + + return 0 } run_test 217 "check lctl ping for hostnames with embedded hyphen ('-')" diff --git a/lustre/utils/portals.c b/lustre/utils/portals.c index 3f88d63..c29c334 100644 --- a/lustre/utils/portals.c +++ b/lustre/utils/portals.c @@ -227,12 +227,12 @@ lnet_parse_time(time_t *t, char *str) } int -lnet_parse_nid(char *nid_str, struct lnet_process_id *id_ptr) +lnet_parse_nid(char *nid_str, struct lnet_processid *id_ptr) { id_ptr->pid = LNET_PID_ANY; - id_ptr->nid = libcfs_str2nid(nid_str); - if (id_ptr->nid == LNET_NID_ANY) { - fprintf(stderr, "Can't parse nid \"%s\"\n", nid_str); + if (libcfs_strnid(&id_ptr->nid, nid_str) < 0 || + LNET_NID_IS_ANY(&id_ptr->nid)) { + fprintf(stderr, "Invalid NID argument \"%s\"\n", nid_str); return -1; } @@ -1273,7 +1273,7 @@ int jt_ptl_ping(int argc, char **argv) bool done = false, print = true; int rc; int timeout; - struct lnet_process_id id; + struct lnet_processid id; yaml_emitter_t request; yaml_parser_t reply; yaml_event_t event; @@ -1304,11 +1304,10 @@ int jt_ptl_ping(int argc, char **argv) if (rc != 0) return -EINVAL; } else { - id.nid = libcfs_str2nid(sep + 1); - - if (id.nid == LNET_NID_ANY) { + if (libcfs_strnid(&id.nid, (sep + 1)) < 0 || + LNET_NID_IS_ANY(&id.nid)) { fprintf(stderr, - "Can't parse process id \"%s\"\n", + "Invalid PID argument \"%s\"\n", argv[1]); return -EINVAL; } @@ -1419,8 +1418,8 @@ int jt_ptl_ping(int argc, char **argv) /* convert NID to string, in case libcfs_str2nid() did name lookup */ yaml_scalar_event_initialize(&event, NULL, (yaml_char_t *)YAML_STR_TAG, - (yaml_char_t *)libcfs_nid2str(id.nid), - strlen(libcfs_nid2str(id.nid)), 1, 0, + (yaml_char_t *)libcfs_nidstr(&id.nid), + strlen(libcfs_nidstr(&id.nid)), 1, 0, YAML_PLAIN_SCALAR_STYLE); rc = yaml_emitter_emit(&request, &event); if (rc == 0) @@ -1527,7 +1526,7 @@ old_api: LIBCFS_IOC_INIT_V2(ping, ping_hdr); ping.ping_hdr.ioc_len = sizeof(ping); - ping.ping_id = id; + ping.ping_id = lnet_pid_to_pid4(&id); ping.ping_src = LNET_NID_ANY; ping.op_param = timeout; ping.ping_count = maxids; -- 1.8.3.1