<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="generator" content="Osso Notes">
<title></title></head>
<body>
<p>I'd rather have others give their feeling on the usefullness of this feature. My own opinion is that user_friendly_names are for people who don't care about naming, alias for those who care. This per-hardware prefix would fill a quite narrow gap in-between ... But some may have more enthusiast feeling, which will matter.
<br>
<br>At least it doesn't change the current behaviour by default.
<br>
<br>Best regards,
<br>cvaroqui
<br>
<br>----- Message d'origine -----
<br>> Any comments??
<br>>
<br>> Malahal Naineni [<a href="mailto:malahal@us.ibm.com">malahal@us.ibm.com</a>] wrote:
<br>> > The current multipath tools use "mpath" prefix for all LUNs when
<br>> > user_friendly_names is set. It would be nice if the names are generated
<br>> > based on the storage subsystem. For example, all EMC LUNs would be
<br>> > named emc_a, emc_b, elm_c etc., and all IBM's SVC LUNs would be named
<br>> > svc_a, svc_b, svc_c. This patch attempts to do that using only
<br>> > multipath.conf. Patches can be added to the internal hardware table,
<br>> > if needed.
<br>> >
<br>> > Signed-off-by: Malahal Naineni (<a href="mailto:malahal@us.ibm.com">malahal@us.ibm.com</a>)
<br>> >
<br>> > diff -r 49b7dc2c9d46 -r b4d519b4bbc6 libmultipath/alias.c
<br>> > --- a/libmultipath/alias.c Tue Jun 15 17:23:49 2010 -0700
<br>> > +++ b/libmultipath/alias.c Tue Jun 22 19:25:24 2010 -0700
<br>> > @@ -180,34 +180,35 @@ fail:
<br>> > }
<br>> >
<br>> > static int
<br>> > -format_devname(char *name, int id, int len)
<br>> > +format_devname(char *name, int id, int len, char *prefix)
<br>> > {
<br>> > int pos;
<br>> > + int prefix_len = strlen(prefix);
<br>> >
<br>> > memset(name,0, len);
<br>> > - strcpy(name,"mpath");
<br>> > - for (pos = len - 1; pos >= 5; pos--) {
<br>> > + strcpy(name, prefix);
<br>> > + for (pos = len - 1; pos >= prefix_len; pos--) {
<br>> > name[pos] = 'a' + id % 26;
<br>> > if (id < 26)
<br>> > break;
<br>> > id /= 26;
<br>> > id--;
<br>> > }
<br>> > - memmove(name + 5, name + pos, len - pos);
<br>> > - name[5 + len - pos] = '\0';
<br>> > - return (5 + len - pos);
<br>> > + memmove(name + prefix_len, name + pos, len - pos);
<br>> > + name[prefix_len + len - pos] = '\0';
<br>> > + return (prefix_len + len - pos);
<br>> > }
<br>> >
<br>> > static int
<br>> > -scan_devname(char *alias)
<br>> > +scan_devname(char *alias, char *prefix)
<br>> > {
<br>> > char *c;
<br>> > int i, n = 0;
<br>> >
<br>> > - if (strncmp(alias, "mpath", 5))
<br>> > + if (!prefix || strncmp(alias, prefix, strlen(prefix)))
<br>> > return -1;
<br>> >
<br>> > - c = alias + 5;
<br>> > + c = alias + strlen(prefix);
<br>> > while (*c != '\0' && *c != ' ' && *c != '\t') {
<br>> > i = *c - 'a';
<br>> > n = ( n * 26 ) + i;
<br>> > @@ -221,7 +222,7 @@ scan_devname(char *alias)
<br>> > }
<br>> >
<br>> > static int
<br>> > -lookup_binding(FILE *f, char *map_wwid, char **map_alias)
<br>> > +lookup_binding(FILE *f, char *map_wwid, char **map_alias, char
<br>> > *prefix) {
<br>> > char buf[LINE_MAX];
<br>> > unsigned int line_nr = 0;
<br>> > @@ -240,7 +241,7 @@ lookup_binding(FILE *f, char *map_wwid,
<br>> > alias = strtok(buf, " \t");
<br>> > if (!alias) /* blank line */
<br>> > continue;
<br>> > - curr_id = scan_devname(alias);
<br>> > + curr_id = scan_devname(alias, prefix);
<br>> > if (curr_id >= id)
<br>> > id = curr_id + 1;
<br>> > wwid = strtok(NULL, "");
<br>> > @@ -284,7 +285,7 @@ rlookup_binding(FILE *f, char **map_wwid
<br>> > alias = strtok(buf, " \t");
<br>> > if (!alias) /* blank line */
<br>> > continue;
<br>> > - curr_id = scan_devname(alias);
<br>> > + curr_id = scan_devname(alias, NULL); /* TBD: Why this call? */
<br>> > if (curr_id >= id)
<br>> > id = curr_id + 1;
<br>> > wwid = strtok(NULL, " \t");
<br>> > @@ -309,7 +310,7 @@ rlookup_binding(FILE *f, char **map_wwid
<br>> > }
<br>> >
<br>> > static char *
<br>> > -allocate_binding(int fd, char *wwid, int id)
<br>> > +allocate_binding(int fd, char *wwid, int id, char *prefix)
<br>> > {
<br>> > char buf[LINE_MAX];
<br>> > off_t offset;
<br>> > @@ -321,7 +322,7 @@ allocate_binding(int fd, char *wwid, int
<br>> > return NULL;
<br>> > }
<br>> >
<br>> > - i = format_devname(buf, id, LINE_MAX);
<br>> > + i = format_devname(buf, id, LINE_MAX, prefix);
<br>> > c = buf + i;
<br>> > snprintf(c,LINE_MAX - i, " %s\n", wwid);
<br>> > buf[LINE_MAX - 1] = '\0';
<br>> > @@ -352,7 +353,7 @@ allocate_binding(int fd, char *wwid, int
<br>> > }
<br>> >
<br>> > char *
<br>> > -get_user_friendly_alias(char *wwid, char *file)
<br>> > +get_user_friendly_alias(char *wwid, char *file, char *prefix)
<br>> > {
<br>> > char *alias;
<br>> > int fd, scan_fd, id;
<br>> > @@ -385,7 +386,7 @@ get_user_friendly_alias(char *wwid, char
<br>> > return NULL;
<br>> > }
<br>> >
<br>> > - id = lookup_binding(f, wwid, &alias);
<br>> > + id = lookup_binding(f, wwid, &alias, prefix);
<br>> > if (id < 0) {
<br>> > fclose(f);
<br>> > close(scan_fd);
<br>> > @@ -394,7 +395,7 @@ get_user_friendly_alias(char *wwid, char
<br>> > }
<br>> >
<br>> > if (!alias && can_write)
<br>> > - alias = allocate_binding(fd, wwid, id);
<br>> > + alias = allocate_binding(fd, wwid, id, prefix);
<br>> >
<br>> > fclose(f);
<br>> > close(scan_fd);
<br>> > diff -r 49b7dc2c9d46 -r b4d519b4bbc6 libmultipath/alias.h
<br>> > --- a/libmultipath/alias.h Tue Jun 15 17:23:49 2010 -0700
<br>> > +++ b/libmultipath/alias.h Tue Jun 22 19:25:24 2010 -0700
<br>> > @@ -8,5 +8,5 @@
<br>> > "# alias wwid\n" \
<br>> > "#\n"
<br>> >
<br>> > -char *get_user_friendly_alias(char *wwid, char *file);
<br>> > +char *get_user_friendly_alias(char *wwid, char *file, char *prefix);
<br>> > char *get_user_friendly_wwid(char *alias, char *file);
<br>> > diff -r 49b7dc2c9d46 -r b4d519b4bbc6 libmultipath/config.c
<br>> > --- a/libmultipath/config.c Tue Jun 15 17:23:49 2010 -0700
<br>> > +++ b/libmultipath/config.c Tue Jun 22 19:25:24 2010 -0700
<br>> > @@ -158,6 +158,9 @@ free_hwe (struct hwentry * hwe)
<br>> > if (hwe->prio_args)
<br>> > FREE(hwe->prio_args);
<br>> >
<br>> > + if (hwe->alias_prefix)
<br>> > + FREE(hwe->alias_prefix);
<br>> > +
<br>> > if (hwe->bl_product)
<br>> > FREE(hwe->bl_product);
<br>> >
<br>> > @@ -282,6 +285,7 @@ merge_hwe (struct hwentry * hwe1, struct
<br>> > merge_str(checker_name);
<br>> > merge_str(prio_name);
<br>> > merge_str(prio_args);
<br>> > + merge_str(alias_prefix);
<br>> > merge_str(bl_product);
<br>> > merge_num(pgpolicy);
<br>> > merge_num(pgfailback);
<br>> > @@ -333,6 +337,9 @@ store_hwe (vector hwtable, struct hwentr
<br>> > if (dhwe->prio_args && !(hwe->prio_args =
<br>> > set_param_str(dhwe->prio_args))) goto out;
<br>> >
<br>> > + if (dhwe->alias_prefix && !(hwe->alias_prefix =
<br>> > set_param_str(dhwe->alias_prefix))) + goto out;
<br>> > +
<br>> > hwe->pgpolicy = dhwe->pgpolicy;
<br>> > hwe->pgfailback = dhwe->pgfailback;
<br>> > hwe->rr_weight = dhwe->rr_weight;
<br>> > @@ -409,6 +416,9 @@ free_config (struct config * conf)
<br>> > if (conf->prio_name)
<br>> > FREE(conf->prio_name);
<br>> >
<br>> > + if (conf->alias_prefix)
<br>> > + FREE(conf->alias_prefix);
<br>> > +
<br>> > if (conf->prio_args)
<br>> > FREE(conf->prio_args);
<br>> >
<br>> > diff -r 49b7dc2c9d46 -r b4d519b4bbc6 libmultipath/config.h
<br>> > --- a/libmultipath/config.h Tue Jun 15 17:23:49 2010 -0700
<br>> > +++ b/libmultipath/config.h Tue Jun 22 19:25:24 2010 -0700
<br>> > @@ -25,6 +25,7 @@ struct hwentry {
<br>> > char * checker_name;
<br>> > char * prio_name;
<br>> > char * prio_args;
<br>> > + char * alias_prefix;
<br>> >
<br>> > int pgpolicy;
<br>> > int pgfailback;
<br>> > @@ -99,6 +100,7 @@ struct config {
<br>> > char * prio_name;
<br>> > char * prio_args;
<br>> > char * checker_name;
<br>> > + char * alias_prefix;
<br>> >
<br>> > vector keywords;
<br>> > vector mptable;
<br>> > diff -r 49b7dc2c9d46 -r b4d519b4bbc6 libmultipath/defaults.h
<br>> > --- a/libmultipath/defaults.h Tue Jun 15 17:23:49 2010 -0700
<br>> > +++ b/libmultipath/defaults.h Tue Jun 22 19:25:24 2010 -0700
<br>> > @@ -2,6 +2,7 @@
<br>> > #define DEFAULT_UDEVDIR "/dev"
<br>> > #define DEFAULT_MULTIPATHDIR "/" LIB_STRING "/multipath"
<br>> > #define DEFAULT_SELECTOR "round-robin 0"
<br>> > +#define DEFAULT_ALIAS_PREFIX "mpath"
<br>> > #define DEFAULT_FEATURES "0"
<br>> > #define DEFAULT_HWHANDLER "0"
<br>> > #define DEFAULT_MINIO 1000
<br>> > diff -r 49b7dc2c9d46 -r b4d519b4bbc6 libmultipath/dict.c
<br>> > --- a/libmultipath/dict.c Tue Jun 15 17:23:49 2010 -0700
<br>> > +++ b/libmultipath/dict.c Tue Jun 22 19:25:24 2010 -0700
<br>> > @@ -148,6 +148,17 @@ def_prio_handler(vector strvec)
<br>> > }
<br>> >
<br>> > static int
<br>> > +def_alias_prefix_handler(vector strvec)
<br>> > +{
<br>> > + conf->alias_prefix = set_value(strvec);
<br>> > +
<br>> > + if (!conf->alias_prefix)
<br>> > + return 1;
<br>> > +
<br>> > + return 0;
<br>> > +}
<br>> > +
<br>> > +static int
<br>> > def_prio_args_handler(vector strvec)
<br>> > {
<br>> > conf->prio_args = set_value(strvec);
<br>> > @@ -831,6 +842,22 @@ hw_prio_handler(vector strvec)
<br>> > }
<br>> >
<br>> > static int
<br>> > +hw_alias_prefix_handler(vector strvec)
<br>> > +{
<br>> > + struct hwentry * hwe = VECTOR_LAST_SLOT(conf->hwtable);
<br>> > +
<br>> > + if (!hwe)
<br>> > + return 1;
<br>> > +
<br>> > + hwe->alias_prefix = set_value(strvec);
<br>> > +
<br>> > + if (!hwe->alias_prefix)
<br>> > + return 1;
<br>> > +
<br>> > + return 0;
<br>> > +}
<br>> > +
<br>> > +static int
<br>> > hw_prio_args_handler(vector strvec)
<br>> > {
<br>> > struct hwentry * hwe = VECTOR_LAST_SLOT(conf->hwtable);
<br>> > @@ -1580,6 +1607,19 @@ snprint_hw_prio (char * buff, int len, v
<br>> > }
<br>> >
<br>> > static int
<br>> > +snprint_hw_alias_prefix (char * buff, int len, void * data)
<br>> > +{
<br>> > + struct hwentry * hwe = (struct hwentry *)data;
<br>> > +
<br>> > + if (!hwe->alias_prefix || (strlen(hwe->alias_prefix) == 0))
<br>> > + return 0;
<br>> > + if (conf->alias_prefix && !strcmp(hwe->alias_prefix,
<br>> > conf->alias_prefix)) + return 0;
<br>> > +
<br>> > + return snprintf(buff, len, "%s", hwe->alias_prefix);
<br>> > +}
<br>> > +
<br>> > +static int
<br>> > snprint_hw_prio_args (char * buff, int len, void * data)
<br>> > {
<br>> > struct hwentry * hwe = (struct hwentry *)data;
<br>> > @@ -2076,6 +2116,16 @@ snprint_def_user_friendly_names (char *
<br>> > }
<br>> >
<br>> > static int
<br>> > +snprint_def_alias_prefix (char * buff, int len, void * data)
<br>> > +{
<br>> > + if (!conf->alias_prefix)
<br>> > + return 0;
<br>> > + if (!strcmp(conf->alias_prefix, DEFAULT_ALIAS_PREFIX))
<br>> > + return 0;
<br>> > + return snprintf(buff, len, conf->alias_prefix);
<br>> > +}
<br>> > +
<br>> > +static int
<br>> > snprint_ble_simple (char * buff, int len, void * data)
<br>> > {
<br>> > struct blentry * ble = (struct blentry *)data;
<br>> > @@ -2117,6 +2167,7 @@ init_keywords(void)
<br>> > install_keyword("features", &def_features_handler,
<br>> > &snprint_def_features); install_keyword("path_checker",
<br>> > &def_path_checker_handler, &snprint_def_path_checker);
<br>> > install_keyword("checker", &def_path_checker_handler,
<br>> > &snprint_def_path_checker); + install_keyword("alias_prefix",
<br>> > &def_alias_prefix_handler, &snprint_def_alias_prefix);
<br>> > install_keyword("failback", &default_failback_handler,
<br>> > &snprint_def_failback); install_keyword("rr_min_io",
<br>> > &def_minio_handler, &snprint_def_rr_min_io);
<br>> > install_keyword("max_fds", &max_fds_handler, &snprint_max_fds); @@
<br>> > -2176,6 +2227,7 @@ init_keywords(void)
<br>> > install_keyword("path_selector", &hw_selector_handler,
<br>> > &snprint_hw_selector); install_keyword("path_checker",
<br>> > &hw_path_checker_handler, &snprint_hw_path_checker);
<br>> > install_keyword("checker", &hw_path_checker_handler,
<br>> > &snprint_hw_path_checker); + install_keyword("alias_prefix",
<br>> > &hw_alias_prefix_handler, &snprint_hw_alias_prefix);
<br>> > install_keyword("features", &hw_features_handler,
<br>> > &snprint_hw_features); install_keyword("hardware_handler",
<br>> > &hw_handler_handler, &snprint_hw_hardware_handler);
<br>> > install_keyword("prio", &hw_prio_handler, &snprint_hw_prio); diff -r
<br>> > 49b7dc2c9d46 -r b4d519b4bbc6 libmultipath/propsel.c ---
<br>> > a/libmultipath/propsel.c Tue Jun 15 17:23:49 2010 -0700 +++
<br>> > b/libmultipath/propsel.c Tue Jun 22 19:25:24 2010 -0700 @@ -215,6
<br>> > +215,26 @@ select_selector (struct multipath * mp) return 0; }
<br>> >
<br>> > +static void
<br>> > +select_alias_prefix (struct multipath * mp)
<br>> > +{
<br>> > + if (mp->hwe && mp->hwe->alias_prefix) {
<br>> > + mp->alias_prefix = mp->hwe->alias_prefix;
<br>> > + condlog(3, "%s: alias_prefix = %s (controller setting)",
<br>> > + mp->wwid, mp->alias_prefix);
<br>> > + return;
<br>> > + }
<br>> > + if (conf->alias_prefix) {
<br>> > + mp->alias_prefix = conf->alias_prefix;
<br>> > + condlog(3, "%s: alias_prefix = %s (config file default)",
<br>> > + mp->wwid, mp->alias_prefix);
<br>> > + return;
<br>> > + }
<br>> > + mp->alias_prefix = set_default(DEFAULT_ALIAS_PREFIX);
<br>> > + condlog(3, "%s: alias_prefix = %s (internal default)",
<br>> > + mp->wwid, mp->alias_prefix);
<br>> > +}
<br>> > +
<br>> > extern int
<br>> > select_alias (struct multipath * mp)
<br>> > {
<br>> > @@ -222,9 +242,11 @@ select_alias (struct multipath * mp)
<br>> > mp->alias = mp->mpe->alias;
<br>> > else {
<br>> > mp->alias = NULL;
<br>> > - if (conf->user_friendly_names)
<br>> > + if (conf->user_friendly_names) {
<br>> > + select_alias_prefix(mp);
<br>> > mp->alias = get_user_friendly_alias(mp->wwid,
<br>> > - conf->bindings_file);
<br>> > + conf->bindings_file, mp->alias_prefix);
<br>> > + }
<br>> > if (mp->alias == NULL){
<br>> > char *alias;
<br>> > if ((alias = MALLOC(WWID_SIZE)) != NULL){
<br>> > diff -r 49b7dc2c9d46 -r b4d519b4bbc6 libmultipath/structs.h
<br>> > --- a/libmultipath/structs.h Tue Jun 15 17:23:49 2010 -0700
<br>> > +++ b/libmultipath/structs.h Tue Jun 22 19:25:24 2010 -0700
<br>> > @@ -186,6 +186,7 @@ struct multipath {
<br>> >
<br>> > /* configlet pointers */
<br>> > char * alias;
<br>> > + char * alias_prefix;
<br>> > char * selector;
<br>> > char * features;
<br>> > char * hwhandler;
<br>> >
<br>> > --
<br>> > dm-devel mailing list
<br>> > <a href="mailto:dm-devel@redhat.com">dm-devel@redhat.com</a>
<br>> > <a href="https://www.redhat.com/mailman/listinfo/dm-devel">https://www.redhat.com/mailman/listinfo/dm-devel</a>
<br>>
<br>> --
<br>> dm-devel mailing list
<br>> <a href="mailto:dm-devel@redhat.com">dm-devel@redhat.com</a>
<br>> <a href="https://www.redhat.com/mailman/listinfo/dm-devel">https://www.redhat.com/mailman/listinfo/dm-devel</a>
<br><br></p>
</body>
</html>