List Info

Thread: Use 'mpatha' for user_friendly_names option




Use 'mpatha' for user_friendly_names option
country flaguser name
Germany
2008-04-30 04:03:29
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 <haresuse.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] = '';
+	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 != '' && *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 %sn", id,
wwid);
+
+	i = format_devname(buf, id, LINE_MAX);
+	c = buf + i;
+	snprintf(c,LINE_MAX - i, " %sn", wwid);
 	buf[LINE_MAX - 1] = '';
 
 	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

--
dm-devel mailing list
dm-develredhat.com
http
s://www.redhat.com/mailman/listinfo/dm-devel

Re: Use 'mpatha' for user_friendly_names option
user name
2008-05-06 14:35:39
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

--
dm-devel mailing list
dm-develredhat.com
http
s://www.redhat.com/mailman/listinfo/dm-devel

Re: Use 'mpatha' for user_friendly_names option
country flaguser name
Germany
2008-05-07 01:19:24
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
haresuse.de			      +49 911 74053 688
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: Markus Rex, HRB 16746 (AG Nürnberg)

--
dm-devel mailing list
dm-develredhat.com
http
s://www.redhat.com/mailman/listinfo/dm-devel

[1-3]

about | contact  Other archives ( Real Estate discussion Medical topics )