changeset 4150:b39c1d0a6cde

6500051 metattach dXX dYY produces message "metattach: hostname: /dev/md/dsk/dZZ: not a metadevice"
author jmf
date Wed, 02 May 2007 01:39:51 -0700
parents 0a38a68063a9
children ec477fe2405a
files usr/src/lib/lvm/libmeta/common/meta_mirror.c usr/src/lib/lvm/libmeta/common/meta_name.c
diffstat 2 files changed, 25 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/usr/src/lib/lvm/libmeta/common/meta_mirror.c	Tue May 01 17:31:50 2007 -0700
+++ b/usr/src/lib/lvm/libmeta/common/meta_mirror.c	Wed May 02 01:39:51 2007 -0700
@@ -19,7 +19,7 @@
  * CDDL HEADER END
  */
 /*
- * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
+ * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
  * Use is subject to license terms.
  */
 
@@ -300,6 +300,7 @@
 {
 	int		smi;
 	char		*curroot;
+	char		*temproot;
 	mdname_t	*rootnp;
 	md_mirror_t	*mirrorp;
 	md_stripe_t	*stripep;
@@ -308,6 +309,20 @@
 
 	if ((curroot = meta_get_current_root(ep)) == NULL)
 		return (-1);
+
+	/*
+	 * We need to take the canonical name here otherwise the call to
+	 * metaname will add a bad entry to the drivelistp cache and
+	 * things will get nasty later on.
+	 * However we also need to trap the case where we have a logical
+	 * device name and meta_canonicalize returns NULL.
+	 */
+	temproot = meta_canonicalize(sp, curroot);
+	if (temproot != NULL) {
+		curroot = Strdup(temproot);
+		Free(temproot);
+	}
+
 	/*
 	 * Get device name of current root metadevice. If root
 	 * is net mounted as happens if we're part of the
--- a/usr/src/lib/lvm/libmeta/common/meta_name.c	Tue May 01 17:31:50 2007 -0700
+++ b/usr/src/lib/lvm/libmeta/common/meta_name.c	Wed May 02 01:39:51 2007 -0700
@@ -19,7 +19,7 @@
  * CDDL HEADER END
  */
 /*
- * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
+ * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
  * Use is subject to license terms.
  */
 
@@ -2600,6 +2600,14 @@
 	return (NULL);
 }
 
+/*
+ * metaname()
+ *
+ * Wrapper function for metaname_common()
+ * If the second arg is a metadevice name then it is important that this should
+ * be a canonical name (eg d30 rather than /dev/md/dsk/d30). If this is not the
+ * case then a bad entry may be placed into the drivelistp cache.
+ */
 mdname_t *
 metaname(
 	mdsetname_t	**spp,