From: Jian Yu Date: Wed, 12 Feb 2014 15:48:58 +0000 (+0800) Subject: LU-4460 mount: fix lmd_parse() to handle comma-separated NIDs X-Git-Tag: 2.5.57~73 X-Git-Url: https://git.whamcloud.com/?a=commitdiff_plain;h=11317196203c26f8c9e4d2a8261859b1c7a76c9d;p=fs%2Flustre-release.git LU-4460 mount: fix lmd_parse() to handle comma-separated NIDs This patch reverts commit 3917e62018878dfffac59ceed70f20b0419945d3, which cannot handle the upgrade situation that old mountdata already contains comma-separated NIDs. The correct way to fix the original issue is to parse comma-separated NIDs in lmd_parse(). The patch also updates disk2_4-ldiskfs.tar.bz2 to make the mountdata of ost contain comma-separated NIDs so as to verify the patch under upgrade situation. Test-Parameters: alwaysuploadlogs \ envdefinitions=SLOW=yes,ENABLE_QUOTA=yes testlist=conf-sanity Signed-off-by: Jian Yu Change-Id: If179618c9c89dc2168f748aeba59384ea31197ff Reviewed-on: http://review.whamcloud.com/8918 Tested-by: Maloo Tested-by: Jenkins Reviewed-by: Niu Yawei Reviewed-by: Bobi Jam Reviewed-by: Sebastien Buisson Reviewed-by: Oleg Drokin --- diff --git a/lustre/obdclass/obd_mount.c b/lustre/obdclass/obd_mount.c index d592459..0f70f44 100644 --- a/lustre/obdclass/obd_mount.c +++ b/lustre/obdclass/obd_mount.c @@ -1047,7 +1047,7 @@ static int lmd_parse_mgs(struct lustre_mount_data *lmd, char **ptr) */ static int lmd_parse(char *options, struct lustre_mount_data *lmd) { - char *s1, *s2, *devname = NULL; + char *s1, *s2, *s3, *devname = NULL; struct lustre_mount_data *raw = (struct lustre_mount_data *)options; int rc = 0; ENTRY; @@ -1083,6 +1083,7 @@ static int lmd_parse(char *options, struct lustre_mount_data *lmd) /* Skip whitespace and extra commas */ while (*s1 == ' ' || *s1 == ',') s1++; + s3 = s1; /* Client options are parsed in ll_options: eg. flock, user_xattr, acl */ @@ -1120,6 +1121,7 @@ static int lmd_parse(char *options, struct lustre_mount_data *lmd) rc = lmd_parse_mgs(lmd, &s2); if (rc) goto invalid; + s3 = s2; clear++; } else if (strncmp(s1, "writeconf", 9) == 0) { lmd->lmd_flags |= LMD_FLG_WRITECONF; @@ -1156,13 +1158,23 @@ static int lmd_parse(char *options, struct lustre_mount_data *lmd) } else if (strncmp(s1, "param=", 6) == 0) { int length; char *tail = strchr(s1 + 6, ','); - if (tail == NULL) + if (tail == NULL) { length = strlen(s1); - else - length = tail - s1; + } else { + lnet_nid_t nid; + char *param_str = tail + 1; + int supplementary = 1; + + while (class_parse_nid_quiet(param_str, &nid, + ¶m_str) == 0) { + supplementary = 0; + } + length = param_str - s1 - supplementary; + } length -= 6; strncat(lmd->lmd_params, s1 + 6, length); strcat(lmd->lmd_params, " "); + s3 = s1 + 6 + length; clear++; } else if (strncmp(s1, "osd=", 4) == 0) { rc = lmd_parse_string(&lmd->lmd_osd_type, s1 + 4); @@ -1180,8 +1192,8 @@ static int lmd_parse(char *options, struct lustre_mount_data *lmd) break; } - /* Find next opt */ - s2 = strchr(s1, ','); + /* Find next opt */ + s2 = strchr(s3, ','); if (s2 == NULL) { if (clear) *s1 = '\0'; diff --git a/lustre/tests/conf-sanity.sh b/lustre/tests/conf-sanity.sh index 6324a5a..546780d 100644 --- a/lustre/tests/conf-sanity.sh +++ b/lustre/tests/conf-sanity.sh @@ -1315,7 +1315,9 @@ test_32newtarball() { count=$(($T32_BLIMIT / 1024 / 2)) chown $T32_QID.$T32_QID $tmp/src/t32_qf_old - formatall + # format ost with comma-separated NIDs to verify LU-4460 + local failnid="$(h2$NETTYPE 1.2.3.4),$(h2$NETTYPE 4.3.2.1)" + MGSNID="$MGSNID,$MGSNID" OSTOPT="--failnode=$failnid" formatall setupall diff --git a/lustre/tests/disk2_4-ldiskfs.tar.bz2 b/lustre/tests/disk2_4-ldiskfs.tar.bz2 index b9fcf38..623c376 100644 Binary files a/lustre/tests/disk2_4-ldiskfs.tar.bz2 and b/lustre/tests/disk2_4-ldiskfs.tar.bz2 differ diff --git a/lustre/utils/mount_utils.c b/lustre/utils/mount_utils.c index 1fca4c7..31cec4a 100644 --- a/lustre/utils/mount_utils.c +++ b/lustre/utils/mount_utils.c @@ -102,31 +102,19 @@ int run_command(char *cmd, int cmdsz) int add_param(char *buf, char *key, char *val) { - char *sub_val = NULL; - int buflen = strlen(buf); - int end = sizeof(((struct lustre_disk_data *)0)->ldd_params); - int start = 0; - int keylen = 0; + int end = sizeof(((struct lustre_disk_data *)0)->ldd_params); + int start = strlen(buf); + int keylen = 0; - if (key != NULL) + if (key) keylen = strlen(key); - - start = buflen; - while ((sub_val = strsep(&val, ",")) != NULL) { - if (*sub_val == 0) - continue; - - if (start + 1 + keylen + strlen(sub_val) >= end) { - fprintf(stderr, "%s: params are too long-\n%s %s%s\n", - progname, buf, key != NULL ? key : "", sub_val); - buf[buflen] = '\0'; - return 1; - } - - sprintf(buf + start, " %s%s", key != NULL ? key : "", sub_val); - start = strlen(buf); + if (start + 1 + keylen + strlen(val) >= end) { + fprintf(stderr, "%s: params are too long-\n%s %s%s\n", + progname, buf, key ? key : "", val); + return 1; } + sprintf(buf + start, " %s%s", key ? key : "", val); return 0; }