From 2458067d8d55173ad68caac8c0460d46bf8106a1 Mon Sep 17 00:00:00 2001 From: Jian Yu Date: Fri, 15 Jul 2016 00:11:45 -0700 Subject: [PATCH] LU-8311 mount: fix lmd_parse() to parse colon as NID delimiter In multi-rail and failover configurations, colon is a valid delimiter in LNET nid list to separate different hosts. This patch fixes lmd_parse()->lmd_parse_nidlist() to handle both comma and colon as delimiters. Signed-off-by: Jian Yu Change-Id: I287e08c22c82c2143fe9aba185473a672e8f1429 Reviewed-on: http://review.whamcloud.com/21329 Tested-by: Jenkins Tested-by: Maloo Reviewed-by: Bob Glossman Reviewed-by: Niu Yawei Reviewed-by: Oleg Drokin --- lustre/obdclass/obd_mount.c | 32 ++++++++++++++++---------------- lustre/tests/conf-sanity.sh | 8 +++----- 2 files changed, 19 insertions(+), 21 deletions(-) diff --git a/lustre/obdclass/obd_mount.c b/lustre/obdclass/obd_mount.c index 3908e1e..fba6e8e 100644 --- a/lustre/obdclass/obd_mount.c +++ b/lustre/obdclass/obd_mount.c @@ -1046,18 +1046,18 @@ static int lmd_parse_mgs(struct lustre_mount_data *lmd, char **ptr) } /** - * Find the first comma delimiter from the specified \a buf and make \a *endh - * point to the string starting with the comma. The commas in expression list - * [...] will be skipped. + * Find the first delimiter (comma or colon) from the specified \a buf and + * make \a *endh point to the string starting with the delimiter. The commas + * in expression list [...] will be skipped. * - * \param[in] buf a comma-separated string + * \param[in] buf a delimiter-separated string * \param[in] endh a pointer to a pointer that will point to the string - * starting with the comma + * starting with the delimiter * - * \retval 0 if comma delimiter is found - * \retval 1 if comma delimiter is not found + * \retval 0 if delimiter is found + * \retval 1 if delimiter is not found */ -static int lmd_find_comma(char *buf, char **endh) +static int lmd_find_delimiter(char *buf, char **endh) { char *c = buf; int skip = 0; @@ -1071,7 +1071,7 @@ static int lmd_find_comma(char *buf, char **endh) else if (*c == ']') skip--; - if (*c == ',' && skip == 0) { + if ((*c == ',' || *c == ':') && skip == 0) { if (endh != NULL) *endh = c; return 0; @@ -1084,13 +1084,13 @@ static int lmd_find_comma(char *buf, char **endh) } /** - * Find the first valid string delimited by comma from the specified \a buf - # and parse it to see whether it's a valid nid list. If yes, \a *endh will - * point to the next string starting with the comma. + * Find the first valid string delimited by comma or colon from the specified + * \a buf and parse it to see whether it's a valid nid list. If yes, \a *endh + * will point to the next string starting with the delimiter. * - * \param[in] buf a comma-separated string + * \param[in] buf a delimiter-separated string * \param[in] endh a pointer to a pointer that will point to the string - * starting with the comma + * starting with the delimiter * * \retval 0 if the string is a valid nid list * \retval 1 if the string is not a valid nid list @@ -1109,7 +1109,7 @@ static int lmd_parse_nidlist(char *buf, char **endh) if (*buf == ' ' || *buf == '/' || *buf == '\0') return 1; - if (lmd_find_comma(buf, &endp) != 0) + if (lmd_find_delimiter(buf, &endp) != 0) endp = buf + strlen(buf); tmp = *endp; @@ -1248,7 +1248,7 @@ static int lmd_parse(char *options, struct lustre_mount_data *lmd) } else if (strncmp(s1, "param=", 6) == 0) { size_t length, params_length; char *tail = s1; - if (lmd_find_comma(s1 + 6, &tail) != 0) + if (lmd_find_delimiter(s1 + 6, &tail) != 0) length = strlen(s1); else { char *param_str = tail + 1; diff --git a/lustre/tests/conf-sanity.sh b/lustre/tests/conf-sanity.sh index 1bd8cff..89a945b 100755 --- a/lustre/tests/conf-sanity.sh +++ b/lustre/tests/conf-sanity.sh @@ -5150,10 +5150,8 @@ run_test 76c "verify changelog_mask is applied with set_param -P" test_77() { # LU-3445 local server_version=$(lustre_version_code $SINGLEMDS) - - [[ $server_version -ge $(version_code 2.2.60) ]] && - [[ $server_version -le $(version_code 2.4.0) ]] && - skip "Need MDS version < 2.2.60 or > 2.4.0" && return + [[ $server_version -ge $(version_code 2.8.55) ]] || + { skip "Need MDS version 2.8.55+ "; return; } if [[ -z "$fs2ost_DEV" || -z "$fs2mds_DEV" ]]; then is_blkdev $SINGLEMDS $(mdsdevname ${SINGLEMDS//mds/}) && @@ -5174,7 +5172,7 @@ test_77() { # LU-3445 error "start fs2mds failed" mgsnid=$(do_facet fs2mds $LCTL list_nids | xargs | tr ' ' ,) - [[ $mgsnid = *,* ]] || mgsnid+=",$mgsnid" + mgsnid="$mgsnid,$mgsnid:$mgsnid" add fs2ost $(mkfs_opts ost1 $fs2ostdev) --mgsnode=$mgsnid \ --failnode=$failnid --fsname=$fsname \ -- 1.8.3.1