Add alias_prefix to get multipath names based on storage type
RFC PATCH 1/1 Add alias_prefix to get multipath names based on storage type
The current multipath tools use "mpath" prefix for all LUNs when user_friendly_names is set. It would be nice if the names are generated based on the storage subsystem. For example, all EMC LUNs would be named emc_a, emc_b, elm_c etc., and all IBM's SVC LUNs would be named svc_a, svc_b, svc_c. This patch attempts to do that using only multipath.conf. Patches can be added to the internal hardware table, if needed.
libmultipath/alias.c +18 -17
@@ -180,34 +180,35 @@ fail: }static int -format_devname (char *name,int id,int len) +format_devname (char *name,int id,int len,char *prefix) {int pos; +int prefix_len =strlen (prefix);memset (name,0 , len); -strcpy (name,"mpath" ); -for (pos = len -1 ; pos >=5 ; pos--) { +strcpy (name, prefix); +for (pos = len -1 ; pos >= prefix_len; pos--) { name[pos] ='a' + id %26 ;if (id <26 )break ; id /=26 ; id--; } -memmove (name +5 , name + pos, len - pos); - name[5 + len - pos] ='\0' ; -return (5 + len - pos); +memmove (name + prefix_len, name + pos, len - pos); + name[prefix_len + len - pos] ='\0' ; +return (prefix_len + len - pos); }static int -scan_devname (char *alias) +scan_devname (char *alias,char *prefix) {char *c;int i, n =0 ; -if (strncmp (alias,"mpath" ,5 )) +if (!prefix ||strncmp (alias, prefix,strlen (prefix)))return -1 ; - c = alias +5 ; + c = alias +strlen (prefix);while (*c !='\0' && *c !=' ' && *c !='\t' ) { i = *c -'a' ; n = ( n *26 ) + i;
@@ -221,7 +222,7 @@ scan_devname(char *alias) }static int -lookup_binding (FILE *f,char *map_wwid,char **map_alias) +lookup_binding (FILE *f,char *map_wwid,char **map_alias,char *prefix) {char buf[LINE_MAX ];unsigned int line_nr =0 ;
@@ -240,7 +241,7 @@ lookup_binding(FILE *f, char *map_wwid, alias =strtok (buf," \t" );if (!alias)/* blank line */ continue ; - curr_id =scan_devname (alias); + curr_id =scan_devname (alias, prefix);if (curr_id >= id) id = curr_id +1 ; wwid =strtok (NULL ,"" );
@@ -284,7 +285,7 @@ rlookup_binding(FILE *f, char **map_wwid alias =strtok (buf," \t" );if (!alias)/* blank line */ continue ; - curr_id =scan_devname (alias); + curr_id =scan_devname (alias,NULL );/* TBD: Why this call? */ if (curr_id >= id) id = curr_id +1 ; wwid =strtok (NULL ," \t" );
@@ -309,7 +310,7 @@ rlookup_binding(FILE *f, char **map_wwid }static char * -allocate_binding (int fd,char *wwid,int id) +allocate_binding (int fd,char *wwid,int id,char *prefix) {char buf[LINE_MAX ];off_t offset;
@@ -321,7 +322,7 @@ allocate_binding(int fd, char *wwid, intreturn NULL ; } - i =format_devname (buf, id,LINE_MAX ); + i =format_devname (buf, id,LINE_MAX , prefix); c = buf + i;snprintf (c,LINE_MAX - i," %s\n" , wwid); buf[LINE_MAX -1 ] ='\0' ;
@@ -352,7 +353,7 @@ allocate_binding(int fd, char *wwid, int }char * -get_user_friendly_alias (char *wwid,char *file) +get_user_friendly_alias (char *wwid,char *file,char *prefix) {char *alias;int fd, scan_fd, id;
@@ -385,7 +386,7 @@ get_user_friendly_alias(char *wwid, charreturn NULL ; } - id =lookup_binding (f, wwid, &alias); + id =lookup_binding (f, wwid, &alias, prefix);if (id <0 ) {fclose (f);close (scan_fd);
@@ -394,7 +395,7 @@ get_user_friendly_alias(char *wwid, char }if (!alias && can_write) - alias =allocate_binding (fd, wwid, id); + alias =allocate_binding (fd, wwid, id, prefix);fclose (f);close (scan_fd);
libmultipath/alias.h +1 -1
@@ -8,5 +8,5 @@"# alias wwid\n" \"#\n" -char *get_user_friendly_alias (char *wwid, char *file); +char *get_user_friendly_alias (char *wwid, char *file, char *prefix);char *get_user_friendly_wwid (char *alias,char *file);
libmultipath/config.c +10 -0
@@ -158,6 +158,9 @@ free_hwe (struct hwentry * hwe)if (hwe->prio_args)FREE (hwe->prio_args); +if (hwe->alias_prefix) +FREE (hwe->alias_prefix); +if (hwe->bl_product)FREE (hwe->bl_product);
@@ -282,6 +285,7 @@ merge_hwe (struct hwentry * hwe1, structmerge_str (checker_name);merge_str (prio_name);merge_str (prio_args); +merge_str (alias_prefix);merge_str (bl_product);merge_num (pgpolicy);merge_num (pgfailback);
@@ -333,6 +337,9 @@ store_hwe (vector hwtable, struct hwentrif (dhwe->prio_args && !(hwe->prio_args =set_param_str (dhwe->prio_args))) goto out; +if (dhwe->alias_prefix && !(hwe->alias_prefix =set_param_str (dhwe->alias_prefix))) + goto out; + hwe->pgpolicy = dhwe->pgpolicy; hwe->pgfailback = dhwe->pgfailback; hwe->rr_weight = dhwe->rr_weight;
@@ -409,6 +416,9 @@ free_config (struct config * conf)if (conf->prio_name)FREE (conf->prio_name); +if (conf->alias_prefix) +FREE (conf->alias_prefix); +if (conf->prio_args)FREE (conf->prio_args);
libmultipath/config.h +2 -0
@@ -25,6 +25,7 @@ struct hwentry {char * checker_name;char * prio_name;char * prio_args; +char * alias_prefix;int pgpolicy;int pgfailback;
@@ -99,6 +100,7 @@ struct config {char * prio_name;char * prio_args;char * checker_name; +char * alias_prefix;vector keywords;vector mptable;
libmultipath/defaults.h +1 -0
@@ -2,6 +2,7 @@#define DEFAULT_UDEVDIR "/dev"#define DEFAULT_MULTIPATHDIR "/" LIB_STRING "/multipath"#define DEFAULT_SELECTOR "round-robin 0" +#define DEFAULT_ALIAS_PREFIX "mpath"#define DEFAULT_FEATURES "0"#define DEFAULT_HWHANDLER "0"#define DEFAULT_MINIO 1000
libmultipath/dict.c +52 -0
88 lines not on this page · raw message
libmultipath/propsel.c +24 -2
@@ -215,6 +215,26 @@ select_selector (struct multipath * mp)return 0 ; } +static void +select_alias_prefix (struct multipath * mp) +{ +if (mp->hwe && mp->hwe->alias_prefix) { + mp->alias_prefix = mp->hwe->alias_prefix; +condlog (3 ,"%s: alias_prefix = %s (controller setting)" , + mp->wwid, mp->alias_prefix); +return ; + } +if (conf->alias_prefix) { + mp->alias_prefix = conf->alias_prefix; +condlog (3 ,"%s: alias_prefix = %s (config file default)" , + mp->wwid, mp->alias_prefix); +return ; + } + mp->alias_prefix =set_default (DEFAULT_ALIAS_PREFIX ); +condlog (3 ,"%s: alias_prefix = %s (internal default)" , + mp->wwid, mp->alias_prefix); +} +extern int select_alias (struct multipath * mp) {
@@ -222,9 +242,11 @@ select_alias (struct multipath * mp) mp->alias = mp->mpe->alias; else { mp->alias =NULL ; -if (conf->user_friendly_names) +if (conf->user_friendly_names) { +select_alias_prefix (mp); mp->alias =get_user_friendly_alias (mp->wwid, - conf->bindings_file); + conf->bindings_file, mp->alias_prefix); + }if (mp->alias ==NULL ){char *alias;if ((alias =MALLOC (WWID_SIZE )) !=NULL ){
libmultipath/structs.h +1 -0
@@ -186,6 +186,7 @@ struct multipath {/* configlet pointers */ char * alias; +char * alias_prefix;char * selector;char * features;char * hwhandler;
Any comments??
Quoted 367 lines · Malahal Naineni [[email protected]] wrote:
The current multipath tools use "mpath" prefix for all LUNs when
user_friendly_namesis set. It would be nice if the names are generated based on the storage subsystem. For example, all EMC LUNs would be namedemc_a,emc_b,elm_cetc., and all IBM's SVC LUNs would be namedsvc_a,svc_b,svc_c. This patch attempts to do that using only multipath.conf. Patches can be added to the internal hardware table, if needed.Signed-off-by Malahal Naineni ([email protected])diff -r
49b7dc2c9d46-rb4d519b4bbc6libmultipath/alias.clibmultipath/alias.c +18
-17@@ -180,34 +180,35 @@ fail: }static int -format_devname (char *name,int id,int len) +format_devname (char *name,int id,int len,char *prefix) {int pos; +int prefix_len =strlen (prefix);memset (name,0 , len); -strcpy (name,"mpath" ); -for (pos = len -1 ; pos >=5 ; pos--) { +strcpy (name, prefix); +for (pos = len -1 ; pos >= prefix_len; pos--) { name[pos] ='a' + id %26 ;if (id <26 )break ; id /=26 ; id--; } -memmove (name +5 , name + pos, len - pos); - name[5 + len - pos] ='\0' ; -return (5 + len - pos); +memmove (name + prefix_len, name + pos, len - pos); + name[prefix_len + len - pos] ='\0' ; +return (prefix_len + len - pos); }static int -scan_devname (char *alias) +scan_devname (char *alias,char *prefix) {char *c;int i, n =0 ; -if (strncmp (alias,"mpath" ,5 )) +if (!prefix ||strncmp (alias, prefix,strlen (prefix)))return -1 ; - c = alias +5 ; + c = alias +strlen (prefix);while (*c !='\0' && *c !=' ' && *c !='\t' ) { i = *c -'a' ; n = ( n *26 ) + i;@@ -221,7 +222,7 @@ scan_devname(char *alias) }static int -lookup_binding (FILE *f,char *map_wwid,char **map_alias) +lookup_binding (FILE *f,char *map_wwid,char **map_alias,char *prefix) {char buf[LINE_MAX ];unsigned int line_nr =0 ;@@ -240,7 +241,7 @@ lookup_binding(FILE *f, char *map_wwid, alias =strtok (buf," \t" );if (!alias)/* blank line */ continue ; - curr_id =scan_devname (alias); + curr_id =scan_devname (alias, prefix);if (curr_id >= id) id = curr_id +1 ; wwid =strtok (NULL ,"" );@@ -284,7 +285,7 @@ rlookup_binding(FILE *f, char **map_wwid alias =strtok (buf," \t" );if (!alias)/* blank line */ continue ; - curr_id =scan_devname (alias); + curr_id =scan_devname (alias,NULL );/* TBD: Why this call? */ if (curr_id >= id) id = curr_id +1 ; wwid =strtok (NULL ," \t" );@@ -309,7 +310,7 @@ rlookup_binding(FILE *f, char **map_wwid }static char * -allocate_binding (int fd,char *wwid,int id) +allocate_binding (int fd,char *wwid,int id,char *prefix) {char buf[LINE_MAX ];off_t offset;@@ -321,7 +322,7 @@ allocate_binding(int fd, char *wwid, intreturn NULL ; } - i =format_devname (buf, id,LINE_MAX ); + i =format_devname (buf, id,LINE_MAX , prefix); c = buf + i;snprintf (c,LINE_MAX - i," %s\n" , wwid); buf[LINE_MAX -1 ] ='\0' ;@@ -352,7 +353,7 @@ allocate_binding(int fd, char *wwid, int }char * -get_user_friendly_alias (char *wwid,char *file) +get_user_friendly_alias (char *wwid,char *file,char *prefix) {char *alias;int fd, scan_fd, id;@@ -385,7 +386,7 @@ get_user_friendly_alias(char *wwid, charreturn NULL ; } - id =lookup_binding (f, wwid, &alias); + id =lookup_binding (f, wwid, &alias, prefix);if (id <0 ) {fclose (f);close (scan_fd);@@ -394,7 +395,7 @@ get_user_friendly_alias(char *wwid, char }if (!alias && can_write) - alias =allocate_binding (fd, wwid, id); + alias =allocate_binding (fd, wwid, id, prefix);fclose (f);close (scan_fd);diff -r
49b7dc2c9d46-rb4d519b4bbc6libmultipath/alias.hlibmultipath/alias.h +1
-1@@ -8,5 +8,5 @@"# alias wwid\n" \"#\n" -char *get_user_friendly_alias (char *wwid, char *file); +char *get_user_friendly_alias (char *wwid, char *file, char *prefix);char *get_user_friendly_wwid (char *alias,char *file);diff -r
49b7dc2c9d46-rb4d519b4bbc6libmultipath/config.clibmultipath/config.c +10
-0@@ -158,6 +158,9 @@ free_hwe (struct hwentry * hwe)if (hwe->prio_args)FREE (hwe->prio_args); +if (hwe->alias_prefix) +FREE (hwe->alias_prefix); +if (hwe->bl_product)FREE (hwe->bl_product);@@ -282,6 +285,7 @@ merge_hwe (struct hwentry * hwe1, structmerge_str (checker_name);merge_str (prio_name);merge_str (prio_args); +merge_str (alias_prefix);merge_str (bl_product);merge_num (pgpolicy);merge_num (pgfailback);@@ -333,6 +337,9 @@ store_hwe (vector hwtable, struct hwentrif (dhwe->prio_args && !(hwe->prio_args =set_param_str (dhwe->prio_args))) goto out; +if (dhwe->alias_prefix && !(hwe->alias_prefix =set_param_str (dhwe->alias_prefix))) + goto out; + hwe->pgpolicy = dhwe->pgpolicy; hwe->pgfailback = dhwe->pgfailback; hwe->rr_weight = dhwe->rr_weight;@@ -409,6 +416,9 @@ free_config (struct config * conf)if (conf->prio_name)FREE (conf->prio_name); +if (conf->alias_prefix) +FREE (conf->alias_prefix); +if (conf->prio_args)FREE (conf->prio_args);diff -r
49b7dc2c9d46-rb4d519b4bbc6libmultipath/config.hlibmultipath/config.h +2
-0@@ -25,6 +25,7 @@ struct hwentry {char * checker_name;char * prio_name;char * prio_args; +char * alias_prefix;int pgpolicy;int pgfailback;@@ -99,6 +100,7 @@ struct config {char * prio_name;char * prio_args;char * checker_name; +char * alias_prefix;vector keywords;vector mptable;diff -r
49b7dc2c9d46-rb4d519b4bbc6libmultipath/defaults.hlibmultipath/defaults.h +1
-0@@ -2,6 +2,7 @@#define DEFAULT_UDEVDIR "/dev"#define DEFAULT_MULTIPATHDIR "/" LIB_STRING "/multipath"#define DEFAULT_SELECTOR "round-robin 0" +#define DEFAULT_ALIAS_PREFIX "mpath"#define DEFAULT_FEATURES "0"#define DEFAULT_HWHANDLER "0"#define DEFAULT_MINIO 1000diff -r
49b7dc2c9d46-rb4d519b4bbc6libmultipath/dict.clibmultipath/dict.c +52
-0@@ -148,6 +148,17 @@ def_prio_handler(vector strvec) }static int +def_alias_prefix_handler (vector strvec) +{ + conf->alias_prefix =set_value (strvec); + +if (!conf->alias_prefix) +return 1 ; + +return 0 ; +} + +static int def_prio_args_handler (vector strvec) { conf->prio_args =set_value (strvec);@@ -831,6 +842,22 @@ hw_prio_handler(vector strvec) }static int +hw_alias_prefix_handler (vector strvec) +{ +struct hwentry * hwe =VECTOR_LAST_SLOT (conf->hwtable); + +if (!hwe) +return 1 ; + + hwe->alias_prefix =set_value (strvec); + +if (!hwe->alias_prefix) +return 1 ; + +return 0 ; +} + +static int hw_prio_args_handler (vector strvec) {struct hwentry * hwe =VECTOR_LAST_SLOT (conf->hwtable);@@ -1580,6 +1607,19 @@ snprint_hw_prio (char * buff, int len, v }static int +snprint_hw_alias_prefix (char * buff,int len,void * data) +{ +struct hwentry * hwe = (struct hwentry *)data; + +if (!hwe->alias_prefix || (strlen (hwe->alias_prefix) ==0 )) +return 0 ; +if (conf->alias_prefix && !strcmp (hwe->alias_prefix, conf->alias_prefix)) +return 0 ; + +return snprintf (buff, len,"%s" , hwe->alias_prefix); +} + +static int snprint_hw_prio_args (char * buff,int len,void * data) {struct hwentry * hwe = (struct hwentry *)data;@@ -2076,6 +2116,16 @@ snprint_def_user_friendly_names (char * }static int +snprint_def_alias_prefix (char * buff,int len,void * data) +{ +if (!conf->alias_prefix) +return 0 ; +if (!strcmp (conf->alias_prefix,DEFAULT_ALIAS_PREFIX )) +return 0 ; +return snprintf (buff, len, conf->alias_prefix); +} + +static int snprint_ble_simple (char * buff,int len,void * data) {struct blentry * ble = (struct blentry *)data;@@ -2117,6 +2167,7 @@ init_keywords(void)install_keyword ("features" , &def_features_handler, &snprint_def_features);install_keyword ("path_checker" , &def_path_checker_handler, &snprint_def_path_checker);install_keyword ("checker" , &def_path_checker_handler, &snprint_def_path_checker); +install_keyword ("alias_prefix" , &def_alias_prefix_handler, &snprint_def_alias_prefix);install_keyword ("failback" , &default_failback_handler, &snprint_def_failback);install_keyword ("rr_min_io" , &def_minio_handler, &snprint_def_rr_min_io);install_keyword ("max_fds" , &max_fds_handler, &snprint_max_fds);@@ -2176,6 +2227,7 @@ init_keywords(void)install_keyword ("path_selector" , &hw_selector_handler, &snprint_hw_selector);install_keyword ("path_checker" , &hw_path_checker_handler, &snprint_hw_path_checker);install_keyword ("checker" , &hw_path_checker_handler, &snprint_hw_path_checker); +install_keyword ("alias_prefix" , &hw_alias_prefix_handler, &snprint_hw_alias_prefix);install_keyword ("features" , &hw_features_handler, &snprint_hw_features);install_keyword ("hardware_handler" , &hw_handler_handler, &snprint_hw_hardware_handler);install_keyword ("prio" , &hw_prio_handler, &snprint_hw_prio);diff -r
49b7dc2c9d46-rb4d519b4bbc6libmultipath/propsel.clibmultipath/propsel.c +24
-2@@ -215,6 +215,26 @@ select_selector (struct multipath * mp)return 0 ; } +static void +select_alias_prefix (struct multipath * mp) +{ +if (mp->hwe && mp->hwe->alias_prefix) { + mp->alias_prefix = mp->hwe->alias_prefix; +condlog (3 ,"%s: alias_prefix = %s (controller setting)" , + mp->wwid, mp->alias_prefix); +return ; + } +if (conf->alias_prefix) { + mp->alias_prefix = conf->alias_prefix; +condlog (3 ,"%s: alias_prefix = %s (config file default)" , + mp->wwid, mp->alias_prefix); +return ; + } + mp->alias_prefix =set_default (DEFAULT_ALIAS_PREFIX ); +condlog (3 ,"%s: alias_prefix = %s (internal default)" , + mp->wwid, mp->alias_prefix); +} +extern int select_alias (struct multipath * mp) {@@ -222,9 +242,11 @@ select_alias (struct multipath * mp) mp->alias = mp->mpe->alias; else { mp->alias =NULL ; -if (conf->user_friendly_names) +if (conf->user_friendly_names) { +select_alias_prefix (mp); mp->alias =get_user_friendly_alias (mp->wwid, - conf->bindings_file); + conf->bindings_file, mp->alias_prefix); + }if (mp->alias ==NULL ){char *alias;if ((alias =MALLOC (WWID_SIZE )) !=NULL ){diff -r
49b7dc2c9d46-rb4d519b4bbc6libmultipath/structs.hlibmultipath/structs.h +1
-1@@ -186,6 +186,7 @@ struct multipath {/* configlet pointers */ char * alias; +char * alias_prefix;char * selector;char * features;char * hwhandler; --dm-devel mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/dm-devel
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.
At least it doesn't change the current behaviour by default.
Best regards,
cvaroqui
----- Message d'origine -----
Quoted 380 lines
Any comments??
Quoted 369 lines · Malahal Naineni [[email protected]] wrote:
The current multipath tools use "mpath" prefix for all LUNs when
user_friendly_namesis set. It would be nice if the names are generated based on the storage subsystem. For example, all EMC LUNs would be namedemc_a,emc_b,elm_cetc., and all IBM's SVC LUNs would be namedsvc_a,svc_b,svc_c. This patch attempts to do that using only multipath.conf. Patches can be added to the internal hardware table, if needed.Signed-off-by Malahal Naineni ([email protected])diff -r
49b7dc2c9d46-rb4d519b4bbc6libmultipath/alias.clibmultipath/alias.c Tue Jun 22 19:25:24 2010 -0700 renamed from libmultipath/alias.c Tue Jun 15 17:23:49 2010 -0700 +0
-0@@ -180,34 +180,35 @@ fail: }static int
libmultipath/alias.c Tue Jun 22 19:25:24 2010 -0700 renamed from libmultipath/alias.c Tue Jun 15 17:23:49 2010 -0700 +1
-1-format_devname(char *name, int id, int len) +format_devname(char *name, int id, int len, char *prefix){
int pos;
+ intprefix_len= strlen(prefix);
memset(name,0, len);
-strcpy(name,"mpath");
- for (pos = len - 1; pos >= 5; pos--) {
+strcpy(name, prefix);
+ for (pos = len - 1; pos >=prefix_len; pos--) { name[pos] = 'a' + id % 26;
if (id < 26)
break;
id /= 26;
id--;
}
-memmove(name + 5, name + pos, len - pos); - name[5 + len - pos] = '\0';
- return (5 + len - pos);
+memmove(name + prefix_len, name + pos, len - pos); + name[prefix_len + len - pos] = '\0';
+ return (prefix_len+ len - pos);
}static int
libmultipath/alias.c Tue Jun 22 19:25:24 2010 -0700 renamed from libmultipath/alias.c Tue Jun 15 17:23:49 2010 -0700 +1
-1-scan_devname(char *alias) +scan_devname(char *alias, char *prefix){
char *c;
int i, n = 0;- if (
strncmp(alias, "mpath", 5))
+ if (!prefix ||strncmp(alias, prefix, strlen(prefix))) return -1;- c = alias + 5;
+ c = alias + strlen(prefix);
while (*c != '\0' && *c != ' ' && *c != '\t') { i = *c - 'a';
n = ( n * 26 ) + i;libmultipath/alias.c Tue Jun 22 19:25:24 2010 -0700 renamed from libmultipath/alias.c Tue Jun 15 17:23:49 2010 -0700 +0
-0@@ -221,7 +222,7 @@ scan_devname(char *alias) }static int
libmultipath/alias.c Tue Jun 22 19:25:24 2010 -0700 renamed from libmultipath/alias.c Tue Jun 15 17:23:49 2010 -0700 +1
-1-lookup_binding(FILE *f, char *map_wwid, char **map_alias) +lookup_binding(FILE *f, char *map_wwid, char **map_alias, char*prefix) {
char buf[LINE_MAX];
unsigned intline_nr= 0;libmultipath/alias.c Tue Jun 22 19:25:24 2010 -0700 renamed from libmultipath/alias.c Tue Jun 15 17:23:49 2010 -0700 +0
-0@@ -240,7 +241,7 @@ lookup_binding(FILE *f, char *map_wwid, alias = strtok(buf, " \t");if (!alias) /* blank line */
continue;
-curr_id=scan_devname(alias);
+curr_id=scan_devname(alias, prefix);
if (curr_id>= id)
id =curr_id+ 1;
wwid =strtok(NULL, "");libmultipath/alias.c Tue Jun 22 19:25:24 2010 -0700 renamed from libmultipath/alias.c Tue Jun 15 17:23:49 2010 -0700 +0
-0@@ -284,7 +285,7 @@ rlookup_binding(FILE *f, char **map_wwid alias = strtok(buf, " \t");if (!alias) /* blank line */
continue;
-curr_id=scan_devname(alias);
+curr_id=scan_devname(alias, NULL); /* TBD: Why this call? */ if (curr_id>= id)
id =curr_id+ 1;
wwid =strtok(NULL, " \t");libmultipath/alias.c Tue Jun 22 19:25:24 2010 -0700 renamed from libmultipath/alias.c Tue Jun 15 17:23:49 2010 -0700 +0
-0@@ -309,7 +310,7 @@ rlookup_binding(FILE *f, char **map_wwid }static char *
libmultipath/alias.c Tue Jun 22 19:25:24 2010 -0700 renamed from libmultipath/alias.c Tue Jun 15 17:23:49 2010 -0700 +1
-1-allocate_binding(int fd, char *wwid, int id) +allocate_binding(int fd, char *wwid, int id, char *prefix){
char buf[LINE_MAX];
off_toffset;libmultipath/alias.c Tue Jun 22 19:25:24 2010 -0700 renamed from libmultipath/alias.c Tue Jun 15 17:23:49 2010 -0700 +1
-1@@ -321,7 +322,7 @@ allocate_binding(int fd, char *wwid, int return NULL; } - i = format_devname(buf, id, LINE_MAX); + i = format_devname(buf, id, LINE_MAX, prefix); c = buf + i; snprintf(c,LINE_MAX - i, " %s\n", wwid); buf[LINE_MAX - 1] = '\0';@@ -352,7 +353,7 @@ allocate_binding(int fd, char *wwid, int }char *
libmultipath/alias.c Tue Jun 22 19:25:24 2010 -0700 renamed from libmultipath/alias.c Tue Jun 15 17:23:49 2010 -0700 +1
-1-get_user_friendly_alias(char *wwid, char *file) +get_user_friendly_alias(char *wwid, char *file, char *prefix){
char *alias;
int fd,scan_fd, id;libmultipath/alias.c Tue Jun 22 19:25:24 2010 -0700 renamed from libmultipath/alias.c Tue Jun 15 17:23:49 2010 -0700 +2
-2@@ -385,7 +386,7 @@ get_user_friendly_alias(char *wwid, char return NULL; } - id = lookup_binding(f, wwid, &alias); + id = lookup_binding(f, wwid, &alias, prefix); if (id < 0) { fclose(f); close(scan_fd);@@ -394,7 +395,7 @@ get_user_friendly_alias(char *wwid, char } if (!alias && can_write) - alias = allocate_binding(fd, wwid, id); + alias = allocate_binding(fd, wwid, id, prefix); fclose(f); close(scan_fd);diff -r
49b7dc2c9d46-rb4d519b4bbc6libmultipath/alias.hlibmultipath/alias.h Tue Jun 22 19:25:24 2010 -0700 renamed from libmultipath/alias.h Tue Jun 15 17:23:49 2010 -0700 +0
-0@@ -8,5 +8,5 @@ "# alias wwid\n" \"#\n"
libmultipath/alias.h Tue Jun 22 19:25:24 2010 -0700 renamed from libmultipath/alias.h Tue Jun 15 17:23:49 2010 -0700 +1
-1-char *get_user_friendly_alias(char *wwid, char *file); +char *get_user_friendly_alias(char *wwid, char *file, char *prefix);char *get_user_friendly_wwid(char *alias, char *file); diff -r
49b7dc2c9d46-rb4d519b4bbc6libmultipath/config.clibmultipath/config.c Tue Jun 22 19:25:24 2010 -0700 renamed from libmultipath/config.c Tue Jun 15 17:23:49 2010 -0700 +4
-0@@ -158,6 +158,9 @@ free_hwe (struct hwentry * hwe) if (hwe->prio_args) FREE(hwe->prio_args); + if (hwe->alias_prefix) + FREE(hwe->alias_prefix); + if (hwe->bl_product) FREE(hwe->bl_product);@@ -282,6 +285,7 @@ merge_hwe (struct hwentry * hwe1, struct merge_str(checker_name); merge_str(prio_name); merge_str(prio_args); + merge_str(alias_prefix); merge_str(bl_product); merge_num(pgpolicy); merge_num(pgfailback);@@ -333,6 +337,9 @@ store_hwe (vector hwtable, struct hwentrif (
dhwe->prio_args&& !(hwe->prio_args =
set_param_str(dhwe->prio_args))) goto out;+ if (
dhwe->alias_prefix&& !(hwe->alias_prefix =set_param_str(dhwe->alias_prefix))) + goto out; +
hwe->pgpolicy=dhwe->pgpolicy;hwe->pgfailback=dhwe->pgfailback;hwe->rr_weight=dhwe->rr_weight;libmultipath/config.c Tue Jun 22 19:25:24 2010 -0700 renamed from libmultipath/config.c Tue Jun 15 17:23:49 2010 -0700 +3
-0@@ -409,6 +416,9 @@ free_config (struct config * conf) if (conf->prio_name) FREE(conf->prio_name); + if (conf->alias_prefix) + FREE(conf->alias_prefix); + if (conf->prio_args) FREE(conf->prio_args);diff -r
49b7dc2c9d46-rb4d519b4bbc6libmultipath/config.hlibmultipath/config.h Tue Jun 22 19:25:24 2010 -0700 renamed from libmultipath/config.h Tue Jun 15 17:23:49 2010 -0700 +2
-0@@ -25,6 +25,7 @@ struct hwentry { char * checker_name; char * prio_name; char * prio_args; + char * alias_prefix; int pgpolicy; int pgfailback;@@ -99,6 +100,7 @@ struct config { char * prio_name; char * prio_args; char * checker_name; + char * alias_prefix; vector keywords; vector mptable;diff -r
49b7dc2c9d46-rb4d519b4bbc6libmultipath/defaults.hlibmultipath/defaults.h Tue Jun 22 19:25:24 2010 -0700 renamed from libmultipath/defaults.h Tue Jun 15 17:23:49 2010 -0700 +1
-0@@ -2,6 +2,7 @@ #define DEFAULT_UDEVDIR "/dev" #define DEFAULT_MULTIPATHDIR "/" LIB_STRING "/multipath" #define DEFAULT_SELECTOR "round-robin 0" +#define DEFAULT_ALIAS_PREFIX "mpath" #define DEFAULT_FEATURES "0" #define DEFAULT_HWHANDLER "0" #define DEFAULT_MINIO 1000diff -r
49b7dc2c9d46-rb4d519b4bbc6libmultipath/dict.clibmultipath/dict.c Tue Jun 22 19:25:24 2010 -0700 renamed from libmultipath/dict.c Tue Jun 15 17:23:49 2010 -0700 +0
-0@@ -148,6 +148,17 @@ def_prio_handler(vector strvec) }static int
libmultipath/dict.c Tue Jun 22 19:25:24 2010 -0700 renamed from libmultipath/dict.c Tue Jun 15 17:23:49 2010 -0700 +11
-0+def_alias_prefix_handler(vector strvec) +{ + conf->alias_prefix = set_value(strvec); + + if (!conf->alias_prefix) + return 1; + + return 0; +} + +static int
def_prio_args_handler(vector strvec)
{
conf->prio_args=set_value(strvec);libmultipath/dict.c Tue Jun 22 19:25:24 2010 -0700 renamed from libmultipath/dict.c Tue Jun 15 17:23:49 2010 -0700 +0
-0@@ -831,6 +842,22 @@ hw_prio_handler(vector strvec) }static int
libmultipath/dict.c Tue Jun 22 19:25:24 2010 -0700 renamed from libmultipath/dict.c Tue Jun 15 17:23:49 2010 -0700 +16
-0+hw_alias_prefix_handler(vector strvec) +{ + struct hwentry * hwe = VECTOR_LAST_SLOT(conf->hwtable); + + if (!hwe) + return 1; + + hwe->alias_prefix = set_value(strvec); + + if (!hwe->alias_prefix) + return 1; + + return 0; +} + +static int
hw_prio_args_handler(vector strvec)
{
struct hwentry * hwe =VECTOR_LAST_SLOT(conf->hwtable);libmultipath/dict.c Tue Jun 22 19:25:24 2010 -0700 renamed from libmultipath/dict.c Tue Jun 15 17:23:49 2010 -0700 +0
-0@@ -1580,6 +1607,19 @@ snprint_hw_prio (char * buff, int len, v }static int
libmultipath/dict.c Tue Jun 22 19:25:24 2010 -0700 renamed from libmultipath/dict.c Tue Jun 15 17:23:49 2010 -0700 +7
-0+snprint_hw_alias_prefix (char * buff, int len, void * data) +{ + struct hwentry * hwe = (struct hwentry *)data; + + if (!hwe->alias_prefix || (strlen(hwe->alias_prefix) == 0)) + return 0; + if (conf->alias_prefix && !strcmp(hwe->alias_prefix,
conf->alias_prefix)) + return 0;libmultipath/dict.c Tue Jun 22 19:25:24 2010 -0700 renamed from libmultipath/dict.c Tue Jun 15 17:23:49 2010 -0700 +5
-0+ + return snprintf(buff, len, "%s", hwe->alias_prefix); +} + +static int
snprint_hw_prio_args(char * buff, int len, void * data) {
struct hwentry * hwe = (struct hwentry *)data;libmultipath/dict.c Tue Jun 22 19:25:24 2010 -0700 renamed from libmultipath/dict.c Tue Jun 15 17:23:49 2010 -0700 +0
-0@@ -2076,6 +2116,16 @@ snprint_def_user_friendly_names (char * }static int
libmultipath/dict.c Tue Jun 22 19:25:24 2010 -0700 renamed from libmultipath/dict.c Tue Jun 15 17:23:49 2010 -0700 +10
-0+snprint_def_alias_prefix (char * buff, int len, void * data) +{ + if (!conf->alias_prefix) + return 0; + if (!strcmp(conf->alias_prefix, DEFAULT_ALIAS_PREFIX)) + return 0; + return snprintf(buff, len, conf->alias_prefix); +} + +static int
snprint_ble_simple(char * buff, int len, void * data) {
struct blentry * ble = (struct blentry *)data;libmultipath/dict.c Tue Jun 22 19:25:24 2010 -0700 renamed from libmultipath/dict.c Tue Jun 15 17:23:49 2010 -0700 +0
-0@@ -2117,6 +2167,7 @@ init_keywords(void) install_keyword("features", &def_features_handler, &snprint_def_features); install_keyword("path_checker", &def_path_checker_handler, &snprint_def_path_checker); install_keyword("checker", &def_path_checker_handler, &snprint_def_path_checker); + install_keyword("alias_prefix", &def_alias_prefix_handler, &snprint_def_alias_prefix);
install_keyword("failback", &default_failback_handler, &snprint_def_failback);install_keyword("rr_min_io", &def_minio_handler, &snprint_def_rr_min_io);install_keyword("max_fds", &max_fds_handler, &snprint_max_fds); @@ -2176,6 +2227,7 @@init_keywords(void)install_keyword("path_selector", &hw_selector_handler, &snprint_hw_selector);install_keyword("path_checker", &hw_path_checker_handler, &snprint_hw_path_checker);install_keyword("checker", &hw_path_checker_handler, &snprint_hw_path_checker); +install_keyword("alias_prefix", &hw_alias_prefix_handler, &snprint_hw_alias_prefix);install_keyword("features", &hw_features_handler, &snprint_hw_features);install_keyword("hardware_handler", &hw_handler_handler, &snprint_hw_hardware_handler);install_keyword("prio", &hw_prio_handler, &snprint_hw_prio); diff -r49b7dc2c9d46-rb4d519b4bbc6libmultipath/propsel.c--- a/libmultipath/propsel.c Tue Jun 15 17:23:49 2010 -0700 +++ b/libmultipath/propsel.c Tue Jun 22 19:25:24 2010 -0700 @@ -215,6 +215,26 @@select_selector(struct multipath * mp) return 0; }libmultipath/dict.c Tue Jun 22 19:25:24 2010 -0700 renamed from libmultipath/dict.c Tue Jun 15 17:23:49 2010 -0700 +20
-0+static void +select_alias_prefix (struct multipath * mp) +{ + if (mp->hwe && mp->hwe->alias_prefix) { + mp->alias_prefix = mp->hwe->alias_prefix; + condlog(3, "%s: alias_prefix = %s (controller setting)", + mp->wwid, mp->alias_prefix); + return; + } + if (conf->alias_prefix) { + mp->alias_prefix = conf->alias_prefix; + condlog(3, "%s: alias_prefix = %s (config file default)", + mp->wwid, mp->alias_prefix); + return; + } + mp->alias_prefix = set_default(DEFAULT_ALIAS_PREFIX); + condlog(3, "%s: alias_prefix = %s (internal default)", + mp->wwid, mp->alias_prefix); +} +extern int
select_alias(struct multipath * mp)
{libmultipath/dict.c Tue Jun 22 19:25:24 2010 -0700 renamed from libmultipath/dict.c Tue Jun 15 17:23:49 2010 -0700 +4
-2@@ -222,9 +242,11 @@ select_alias (struct multipath * mp) mp->alias = mp->mpe->alias; else { mp->alias = NULL; - if (conf->user_friendly_names) + if (conf->user_friendly_names) { + select_alias_prefix(mp); mp->alias = get_user_friendly_alias(mp->wwid, - conf->bindings_file); + conf->bindings_file, mp->alias_prefix); + } if (mp->alias == NULL){ char *alias; if ((alias = MALLOC(WWID_SIZE)) != NULL){diff -r
49b7dc2c9d46-rb4d519b4bbc6libmultipath/structs.hlibmultipath/structs.h Tue Jun 22 19:25:24 2010 -0700 renamed from libmultipath/structs.h Tue Jun 15 17:23:49 2010 -0700 +1
-1@@ -186,6 +186,7 @@ struct multipath { /* configlet pointers */ char * alias; + char * alias_prefix; char * selector; char * features; char * hwhandler; --Quoted 3 lines
dm-devel mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/dm-devel--
dm-devel mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/dm-devel
Hannes Reinecke
Acked-byQuoted 10 lines · Malahal Naineni
Any comments??
Quoted 7 lines · Malahal Naineni [[email protected]] wrote:
The current multipath tools use "mpath" prefix for all LUNs when
user_friendly_namesis set. It would be nice if the names are generated based on the storage subsystem. For example, all EMC LUNs would be namedemc_a,emc_b,elm_cetc., and all IBM's SVC LUNs would be namedsvc_a,svc_b,svc_c. This patch attempts to do that using only multipath.conf. Patches can be added to the internal hardware table, if needed.
I like it. Having an option to modify the alias prefix is something I always wanted to have.
You could update the manpage, though.
Cheers,
Hannes
Signature · 4 lines
Dr. Hannes Reinecke zSeries & Storage [email protected] +49 911 74053 688 SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg GF: Markus Rex, HRB 16746 (AG Nürnberg)
Christophe Varoqui
AppliedQuoted 7 lines · Malahal Naineni
The current multipath tools use "mpath" prefix for all LUNs when
user_friendly_namesis set. It would be nice if the names are generated based on the storage subsystem. For example, all EMC LUNs would be namedemc_a,emc_b,elm_cetc., and all IBM's SVC LUNs would be namedsvc_a,svc_b,svc_c. This patch attempts to do that using only multipath.conf. Patches can be added to the internal hardware table, if needed.
I merged this patch finally. Only Hannes cared to comment, but he sure looked enthusiastic ;)
Thanks for this work.
Regards,
Signature · 2 lines
Christophe Varoqui <[email protected]> OpenSVC