* [PATCH] Use 'mpatha' for user_friendly_names option
@ 2008-04-30 9:03 Hannes Reinecke
2008-05-06 19:35 ` Guido Günther
0 siblings, 1 reply; 5+ messages in thread
From: Hannes Reinecke @ 2008-04-30 9:03 UTC (permalink / raw)
To: Christophe Varoqui; +Cc: dm-devel
We really should use 'mpatha' instead of 'mpath0' for the
generated names with the user_friendly_names option.
Otherwise we can't distinguish them from EVMS names.
Signed-off-by: Hannes Reinecke <hare@suse.de>
---
libmultipath/alias.c | 61 +++++++++++++++++++++++++++++++++++++++++++------
1 files changed, 53 insertions(+), 8 deletions(-)
diff --git a/libmultipath/alias.c b/libmultipath/alias.c
index ca434fe..517b055 100644
--- a/libmultipath/alias.c
+++ b/libmultipath/alias.c
@@ -179,6 +179,46 @@ fail:
return -1;
}
+static int
+format_devname(char *name, int id, int len)
+{
+ int pos;
+
+ memset(name,0, len);
+ strcpy(name,"mpath");
+ for (pos = len - 1; pos >= 5; 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);
+}
+
+static int
+scan_devname(char *alias)
+{
+ char *c;
+ int i, n = 0;
+
+ if (strncmp(alias, "mpath", 5))
+ return -1;
+
+ c = alias + 5;
+ while (*c != '\0' && *c != ' ' && *c != '\t') {
+ i = *c - 'a';
+ n = ( n * 26 ) + i;
+ c++;
+ if (*c < 'a' || *c > 'z')
+ break;
+ n++;
+ }
+
+ return n;
+}
static int
lookup_binding(FILE *f, char *map_wwid, char **map_alias)
@@ -200,7 +240,8 @@ lookup_binding(FILE *f, char *map_wwid, char **map_alias)
alias = strtok(buf, " \t");
if (!alias) /* blank line */
continue;
- if (sscanf(alias, "mpath%d", &curr_id) == 1 && curr_id >= id)
+ curr_id = scan_devname(alias);
+ if (curr_id >= id)
id = curr_id + 1;
wwid = strtok(NULL, " \t");
if (!wwid){
@@ -221,7 +262,7 @@ lookup_binding(FILE *f, char *map_wwid, char **map_alias)
}
condlog(3, "No matching wwid [%s] in bindings file.", map_wwid);
return id;
-}
+}
static int
rlookup_binding(FILE *f, char **map_wwid, char *map_alias)
@@ -243,7 +284,8 @@ rlookup_binding(FILE *f, char **map_wwid, char *map_alias)
alias = strtok(buf, " \t");
if (!alias) /* blank line */
continue;
- if (sscanf(alias, "mpath%d", &curr_id) == 1 && curr_id >= id)
+ curr_id = scan_devname(alias);
+ if (curr_id >= id)
id = curr_id + 1;
wwid = strtok(NULL, " \t");
if (!wwid){
@@ -264,7 +306,7 @@ rlookup_binding(FILE *f, char **map_wwid, char *map_alias)
}
condlog(3, "No matching alias [%s] in bindings file.", map_alias);
return id;
-}
+}
static char *
allocate_binding(int fd, char *wwid, int id)
@@ -272,13 +314,16 @@ allocate_binding(int fd, char *wwid, int id)
char buf[LINE_MAX];
off_t offset;
char *alias, *c;
-
+ int i;
+
if (id < 0) {
condlog(0, "Bindings file full. Cannot allocate new binding");
return NULL;
}
-
- snprintf(buf, LINE_MAX, "mpath%d %s\n", id, wwid);
+
+ i = format_devname(buf, id, LINE_MAX);
+ c = buf + i;
+ snprintf(c,LINE_MAX - i, " %s\n", wwid);
buf[LINE_MAX - 1] = '\0';
offset = lseek(fd, 0, SEEK_END);
@@ -304,7 +349,7 @@ allocate_binding(int fd, char *wwid, int id)
condlog(3, "Created new binding [%s] for WWID [%s]", alias,
wwid);
return alias;
-}
+}
char *
get_user_friendly_alias(char *wwid, char *file)
--
1.5.2.4
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] Use 'mpatha' for user_friendly_names option
2008-04-30 9:03 [PATCH] Use 'mpatha' for user_friendly_names option Hannes Reinecke
@ 2008-05-06 19:35 ` Guido Günther
2008-05-07 6:19 ` Hannes Reinecke
0 siblings, 1 reply; 5+ messages in thread
From: Guido Günther @ 2008-05-06 19:35 UTC (permalink / raw)
To: device-mapper development
On Wed, Apr 30, 2008 at 11:03:29AM +0200, Hannes Reinecke wrote:
>
> We really should use 'mpatha' instead of 'mpath0' for the
> generated names with the user_friendly_names option.
> Otherwise we can't distinguish them from EVMS names.
Is this really such a good idea? We shipped at least two upstream
versions with this user friendly names default. Changing this causes
problems and at least debian installer uses this during the installation
phase.
Wouldn't it be nicer to make the user_friendly_names_prefix configurable
so people can choose mpath, npath, mp or whatever they want leaving
mpath as the default? I can cook up a patch in that case.
Cheers,
-- Guido
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] Use 'mpatha' for user_friendly_names option
2008-05-06 19:35 ` Guido Günther
@ 2008-05-07 6:19 ` Hannes Reinecke
2008-05-07 6:37 ` Domenico Viggiani
0 siblings, 1 reply; 5+ messages in thread
From: Hannes Reinecke @ 2008-05-07 6:19 UTC (permalink / raw)
To: device-mapper development
Hi Guido,
Guido Günther wrote:
> On Wed, Apr 30, 2008 at 11:03:29AM +0200, Hannes Reinecke wrote:
>> We really should use 'mpatha' instead of 'mpath0' for the
>> generated names with the user_friendly_names option.
>> Otherwise we can't distinguish them from EVMS names.
>
> Is this really such a good idea? We shipped at least two upstream
> versions with this user friendly names default. Changing this causes
> problems and at least debian installer uses this during the installation
> phase.
> Wouldn't it be nicer to make the user_friendly_names_prefix configurable
> so people can choose mpath, npath, mp or whatever they want leaving
> mpath as the default? I can cook up a patch in that case.
> Cheers,
> -- Guido
>
(I knew someone would choke about this one ...)
Yeah, you're right. It would be nice to have that configurable.
Preferred would be to select a prefix and a naming scheme,
ie either numerical or characters.
Was just to lazy for this ...
Normally I don't use this option much; in fact, I discourage
everyone on using it :-)
I really loath to have external configuration files to get
your filesystem up.
But that's just me. Feel free to do so.
Cheers,
Hannes
--
Dr. Hannes Reinecke zSeries & Storage
hare@suse.de +49 911 74053 688
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: Markus Rex, HRB 16746 (AG Nürnberg)
^ permalink raw reply [flat|nested] 5+ messages in thread
* RE: [PATCH] Use 'mpatha' for user_friendly_names option
2008-05-07 6:19 ` Hannes Reinecke
@ 2008-05-07 6:37 ` Domenico Viggiani
2008-05-07 7:17 ` Hannes Reinecke
0 siblings, 1 reply; 5+ messages in thread
From: Domenico Viggiani @ 2008-05-07 6:37 UTC (permalink / raw)
To: 'device-mapper development'
Hannes Reinecke wrote:
>
> Normally I don't use this option much; in fact, I discourage
> everyone on using it :-) I really loath to have external
> configuration files to get your filesystem up.
In fact, I remember the nasty problem at boot time with bindings file
residing under /var/lib/multipath when this is a filesystem different from
/:
http://kbase.redhat.com/faq/FAQ_96_12017.shtm
--
Domenico Viggiani
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] Use 'mpatha' for user_friendly_names option
2008-05-07 6:37 ` Domenico Viggiani
@ 2008-05-07 7:17 ` Hannes Reinecke
0 siblings, 0 replies; 5+ messages in thread
From: Hannes Reinecke @ 2008-05-07 7:17 UTC (permalink / raw)
To: device-mapper development
Hi Domenico,
Domenico Viggiani wrote:
> Hannes Reinecke wrote:
>> Normally I don't use this option much; in fact, I discourage
>> everyone on using it :-) I really loath to have external
>> configuration files to get your filesystem up.
>
> In fact, I remember the nasty problem at boot time with bindings file
> residing under /var/lib/multipath when this is a filesystem different from
> /:
> http://kbase.redhat.com/faq/FAQ_96_12017.shtm
>
Which is exactly why I don't like it.
And most users normally won't touch the device names anyway,
so I don't have a problem with /dev/disk/by-id/scsi-XXXXX-partY.
Plus it breaks my brilliant seamless-switch-to-multipath scheme :-)
Hmm. Maybe I should write an NAA/IEEE naming decoder to translate
the hex number into something readable :-)
Cheers,
Hannes
--
Dr. Hannes Reinecke zSeries & Storage
hare@suse.de +49 911 74053 688
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: Markus Rex, HRB 16746 (AG Nürnberg)
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2008-05-07 7:17 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-04-30 9:03 [PATCH] Use 'mpatha' for user_friendly_names option Hannes Reinecke
2008-05-06 19:35 ` Guido Günther
2008-05-07 6:19 ` Hannes Reinecke
2008-05-07 6:37 ` Domenico Viggiani
2008-05-07 7:17 ` Hannes Reinecke
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.