Commit f1b58c5a authored by Nathaniel Clark's avatar Nathaniel Clark Committed by Greg Kroah-Hartman

staging/lustre/obdclass: be more careful processing server name

Because whole options line gets passed to exclude processing, don't
search from end of passed in argument to determine fsname at
beginning.

Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-2200
Lustre-change: http://review.whamcloud.com/6197Signed-off-by: default avatarNathaniel Clark <nathaniel.l.clark@intel.com>
Reviewed-by: default avatarAndreas Dilger <andreas.dilger@intel.com>
Reviewed-by: default avatarAlex Zhuravlev <alexey.zhuravlev@intel.com>
Signed-off-by: default avatarPeng Tao <tao.peng@emc.com>
Signed-off-by: default avatarAndreas Dilger <andreas.dilger@intel.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent cdb5f710
...@@ -1426,10 +1426,13 @@ int class_config_llog_handler(const struct lu_env *env, ...@@ -1426,10 +1426,13 @@ int class_config_llog_handler(const struct lu_env *env,
} }
if ((clli->cfg_flags & CFG_F_EXCLUDE) && if (clli->cfg_flags & CFG_F_EXCLUDE) {
(lcfg->lcfg_command == LCFG_LOV_ADD_OBD)) CDEBUG(D_CONFIG, "cmd: %x marked EXCLUDED\n",
lcfg->lcfg_command);
if (lcfg->lcfg_command == LCFG_LOV_ADD_OBD)
/* Add inactive instead */ /* Add inactive instead */
lcfg->lcfg_command = LCFG_LOV_ADD_INA; lcfg->lcfg_command = LCFG_LOV_ADD_INA;
}
lustre_cfg_bufs_init(&bufs, lcfg); lustre_cfg_bufs_init(&bufs, lcfg);
......
...@@ -650,6 +650,15 @@ int lustre_put_lsi(struct super_block *sb) ...@@ -650,6 +650,15 @@ int lustre_put_lsi(struct super_block *sb)
RETURN(0); RETURN(0);
} }
/*** SERVER NAME ***
* <FSNAME><SEPERATOR><TYPE><INDEX>
* FSNAME is between 1 and 8 characters (inclusive).
* Excluded characters are '/' and ':'
* SEPERATOR is either ':' or '-'
* TYPE: "OST", "MDT", etc.
* INDEX: Hex representation of the index
*/
/** Get the fsname ("lustre") from the server name ("lustre-OST003F"). /** Get the fsname ("lustre") from the server name ("lustre-OST003F").
* @param [in] svname server name including type and index * @param [in] svname server name including type and index
* @param [out] fsname Buffer to copy filesystem name prefix into. * @param [out] fsname Buffer to copy filesystem name prefix into.
...@@ -659,22 +668,13 @@ int lustre_put_lsi(struct super_block *sb) ...@@ -659,22 +668,13 @@ int lustre_put_lsi(struct super_block *sb)
*/ */
int server_name2fsname(const char *svname, char *fsname, const char **endptr) int server_name2fsname(const char *svname, char *fsname, const char **endptr)
{ {
const char *dash = strrchr(svname, '-'); const char *dash;
if (!dash) {
dash = strrchr(svname, ':');
if (!dash)
return -EINVAL;
}
/* interpret <fsname>-MDTXXXXX-mdc as mdt, the better way is to pass dash = svname + strnlen(svname, 8); /* max fsname length is 8 */
* in the fsname, then determine the server index */
if (!strcmp(LUSTRE_MDC_NAME, dash + 1)) {
dash--;
for (; dash > svname && *dash != '-' && *dash != ':'; dash--) for (; dash > svname && *dash != '-' && *dash != ':'; dash--)
; ;
if (dash == svname) if (dash == svname)
return -EINVAL; return -EINVAL;
}
if (fsname != NULL) { if (fsname != NULL) {
strncpy(fsname, svname, dash - svname); strncpy(fsname, svname, dash - svname);
...@@ -697,15 +697,15 @@ int server_name2svname(const char *label, char *svname, const char **endptr, ...@@ -697,15 +697,15 @@ int server_name2svname(const char *label, char *svname, const char **endptr,
size_t svsize) size_t svsize)
{ {
int rc; int rc;
const const char *dash; const char *dash;
/* We use server_name2fsname() just for parsing */ /* We use server_name2fsname() just for parsing */
rc = server_name2fsname(label, NULL, &dash); rc = server_name2fsname(label, NULL, &dash);
if (rc != 0) if (rc != 0)
return rc; return rc;
if (*dash != '-') if (endptr != NULL)
return -1; *endptr = dash;
if (strlcpy(svname, dash + 1, svsize) >= svsize) if (strlcpy(svname, dash + 1, svsize) >= svsize)
return -E2BIG; return -E2BIG;
...@@ -730,9 +730,6 @@ int server_name2index(const char *svname, __u32 *idx, const char **endptr) ...@@ -730,9 +730,6 @@ int server_name2index(const char *svname, __u32 *idx, const char **endptr)
if (rc != 0) if (rc != 0)
return rc; return rc;
if (*dash != '-')
return -EINVAL;
dash++; dash++;
if (strncmp(dash, "MDT", 3) == 0) if (strncmp(dash, "MDT", 3) == 0)
...@@ -744,12 +741,21 @@ int server_name2index(const char *svname, __u32 *idx, const char **endptr) ...@@ -744,12 +741,21 @@ int server_name2index(const char *svname, __u32 *idx, const char **endptr)
dash += 3; dash += 3;
if (strcmp(dash, "all") == 0) if (strncmp(dash, "all", 3) == 0) {
if (endptr != NULL)
*endptr = dash + 3;
return rc | LDD_F_SV_ALL; return rc | LDD_F_SV_ALL;
}
index = simple_strtoul(dash, (char **)endptr, 16); index = simple_strtoul(dash, (char **)endptr, 16);
if (idx != NULL)
*idx = index; *idx = index;
/* Account for -mdc after index that is possible when specifying mdt */
if (endptr != NULL && strncmp(LUSTRE_MDC_NAME, *endptr + 1,
sizeof(LUSTRE_MDC_NAME)-1) == 0)
*endptr += sizeof(LUSTRE_MDC_NAME);
return rc; return rc;
} }
EXPORT_SYMBOL(server_name2index); EXPORT_SYMBOL(server_name2index);
...@@ -858,13 +864,15 @@ static int lmd_make_exclusion(struct lustre_mount_data *lmd, const char *ptr) ...@@ -858,13 +864,15 @@ static int lmd_make_exclusion(struct lustre_mount_data *lmd, const char *ptr)
s1++; s1++;
rc = server_name2index(s1, &index, &s2); rc = server_name2index(s1, &index, &s2);
if (rc < 0) { if (rc < 0) {
CERROR("Can't parse server name '%s'\n", s1); CERROR("Can't parse server name '%s': rc = %d\n",
s1, rc);
break; break;
} }
if (rc == LDD_F_SV_TYPE_OST) if (rc == LDD_F_SV_TYPE_OST)
exclude_list[lmd->lmd_exclude_count++] = index; exclude_list[lmd->lmd_exclude_count++] = index;
else else
CDEBUG(D_MOUNT, "ignoring exclude %.7s\n", s1); CDEBUG(D_MOUNT, "ignoring exclude %.*s: type = %#x\n",
(uint)(s2-s1), s1, rc);
s1 = s2; s1 = s2;
/* now we are pointing at ':' (next exclude) /* now we are pointing at ':' (next exclude)
or ',' (end of excludes) */ or ',' (end of excludes) */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment