7004852 After installing use the x86 Auto install, the newly installed machine fails to boot Build155
authorJan Damborsky <dambi@opensolaris.org>
Thu, 09 Dec 2010 09:31:10 +0100
changeset 956 4e40790503b0
parent 955 000af470aa07
child 957 25c41214990e
child 963 2085421690db
7004852 After installing use the x86 Auto install, the newly installed machine fails to boot
usr/src/cmd/text-install/osol_install/text_install/ti_install.py
usr/src/lib/liborchestrator/perform_slim_install.c
usr/src/lib/libti/ti_bem.c
--- a/usr/src/cmd/text-install/osol_install/text_install/ti_install.py	Mon Dec 06 09:34:22 2010 -0700
+++ b/usr/src/cmd/text-install/osol_install/text_install/ti_install.py	Thu Dec 09 09:31:10 2010 +0100
@@ -502,7 +502,7 @@
     '''
     # reset_zfs_mount_property
     # Setup mountpoint property back to "/" from "/a" for
-    # /, /opt, /export, /export/home
+    # /, /export, /export/home
 
     # make sure we are not in the alternate root.
     # Otherwise, be_unmount() fails
@@ -510,12 +510,31 @@
 
     # since be_unmount() can not currently handle shared filesystems,
     # it's necesary to manually set their mountpoint to the appropriate value
-    for fs in ZFS_SHARED_FS:
-        exec_cmd(["/usr/sbin/zfs", "unmount", rootpool_name + fs],
-                 "unmount " + rootpool_name + fs)
-        exec_cmd(["/usr/sbin/zfs", "set", "mountpoint=" + fs,
-                 rootpool_name + fs], "change mount point for " +
-                 rootpool_name + fs)
+
+    # Limitations of current implementation:
+    #
+    # Following assumptions have to be met with respect to structure of
+    # shared filesystems:
+    #
+    #  - list of shared filesystems is ordered hierarchically AND
+    #  - it contains only one stream of hierarchy.
+    #
+    # List of shared datasets is currently hardcoded and meets those
+    # assumptions. The implementation has to be revisited once creating more
+    # complex structures of ZFS datasets is supported.
+
+    # Unmount the oldest ancestor dataset.
+    # It also unmounts all children datasets.
+    exec_cmd(["/usr/sbin/zfs", "unmount", rootpool_name + ZFS_SHARED_FS[-1]],
+                 "unmount " + rootpool_name + ZFS_SHARED_FS[-1])
+
+    # Reset mountpoint just for ancestor dataset. Child datasets inherit
+    # mounpoint from their ancestors.
+
+
+    exec_cmd(["/usr/sbin/zfs", "set", "mountpoint=" + ZFS_SHARED_FS[-1],
+                 rootpool_name + ZFS_SHARED_FS[-1]], "change mount point for " +
+                 rootpool_name + ZFS_SHARED_FS[-1])
 
     # Transfer the log file
     final_log_loc = INSTALLED_ROOT_DIR + install_profile.log_final
--- a/usr/src/lib/liborchestrator/perform_slim_install.c	Mon Dec 06 09:34:22 2010 -0700
+++ b/usr/src/lib/liborchestrator/perform_slim_install.c	Thu Dec 09 09:31:10 2010 +0100
@@ -2232,13 +2232,21 @@
 
 /*
  * Setup mountpoint property back to "/" from "/a" for
- * /, /opt, /export, /export/home
+ * /, /export, /export/home
+ *
+ * Following assumptions have to be met:
+ *  - list of shared filesystems is ordered hierarchically AND
+ *  - it contains only one stream of hierarchy.
+ *
+ * List of shared datasets is currently hardcoded and meets those assumptions.
+ * The implementation has to be revisited once creating more complex structures
+ * of ZFS datasets is supported.
  */
 static int
 reset_zfs_mount_property(char *target, int transfer_mode)
 {
 	char 		cmd[MAXPATHLEN];
-	int		i, ret;
+	int		ret;
 
 	if (target == NULL) {
 		return (OM_FAILURE);
@@ -2255,37 +2263,45 @@
 
 	/*
 	 * Since be_unmount() can't currently handle shared filesystems,
-	 * it is necessary to manually set their mountpoint to the
+	 * it is necessary to manually reset their mountpoint to the
 	 * appropriate value.
 	 */
 
-	for (i = l_zfs_shared_fs_num - 1; i >= 0; i--) {
-		(void) snprintf(cmd, sizeof (cmd),
-		    "/usr/sbin/zfs unmount %s%s",
-		    ROOTPOOL_NAME, zfs_shared_fs_names[i]);
-
-		om_log_print("%s\n", cmd);
-		ret = td_safe_system(cmd, B_TRUE);
-
-		if ((ret == -1) || WEXITSTATUS(ret) != 0) {
-			om_debug_print(OM_DBGLVL_ERR,
-			    "Couldn't unmount %s%s, err=%d\n", ROOTPOOL_NAME,
-			    zfs_shared_fs_names[i], ret);
-		}
-
-		(void) snprintf(cmd, sizeof (cmd),
-		    "/usr/sbin/zfs set mountpoint=%s %s%s",
-		    zfs_shared_fs_names[i], ROOTPOOL_NAME,
-		    zfs_shared_fs_names[i]);
-
-		om_log_print("%s\n", cmd);
-		ret = td_safe_system(cmd, B_TRUE);
-
-		if ((ret == -1) || WEXITSTATUS(ret) != 0) {
-			om_debug_print(OM_DBGLVL_ERR,
-			    "Couldn't change mountpoint for %s%s, err=%d\n",
-			    ROOTPOOL_NAME, zfs_shared_fs_names[i], ret);
-		}
+	/*
+	 * Unmount the oldest ancestor dataset.
+	 * It also unmounts all children datasets.
+	 */
+
+	(void) snprintf(cmd, sizeof (cmd),
+	    "/usr/sbin/zfs unmount %s%s",
+	    ROOTPOOL_NAME, zfs_shared_fs_names[0]);
+
+	om_log_print("%s\n", cmd);
+	ret = td_safe_system(cmd, B_TRUE);
+
+	if ((ret == -1) || WEXITSTATUS(ret) != 0) {
+		om_debug_print(OM_DBGLVL_ERR,
+		    "Couldn't unmount %s%s, err=%d\n", ROOTPOOL_NAME,
+		    zfs_shared_fs_names[0], ret);
+	}
+
+	/*
+	 * Reset mountpoint just for ancestor dataset. Children datasets inherit
+	 * mounpoint from their ancestors.
+	 */
+
+	(void) snprintf(cmd, sizeof (cmd),
+	    "/usr/sbin/zfs set mountpoint=%s %s%s",
+	    zfs_shared_fs_names[0], ROOTPOOL_NAME,
+	    zfs_shared_fs_names[0]);
+
+	om_log_print("%s\n", cmd);
+	ret = td_safe_system(cmd, B_TRUE);
+
+	if ((ret == -1) || WEXITSTATUS(ret) != 0) {
+		om_debug_print(OM_DBGLVL_ERR,
+		    "Couldn't change mountpoint for %s%s, err=%d\n",
+		    ROOTPOOL_NAME, zfs_shared_fs_names[0], ret);
 	}
 
 	/*
--- a/usr/src/lib/libti/ti_bem.c	Mon Dec 06 09:34:22 2010 -0700
+++ b/usr/src/lib/libti/ti_bem.c	Thu Dec 09 09:31:10 2010 +0100
@@ -19,8 +19,7 @@
  * CDDL HEADER END
  */
 /*
- * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
- * Use is subject to license terms.
+ * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
  */
 
 #include <assert.h>
@@ -123,6 +122,18 @@
  *		IBEM_E_ATTR_INVALID - invalid set of attributes passed
  *		IBEM_E_RPOOL_NOT_EXIST - root pool doesn't exist
  *		IBEM_E_BE_CREATE_FAILED - be_init() failed
+ *
+ * Limitations of current implementation:
+ *
+ * Following assumptions have to be met with respect to structure of
+ * shared filesystems to be created:
+ *
+ *  - list of shared filesystems to be created is ordered hierarchically AND
+ *  - it contains only one stream of hierarchy.
+ *
+ * List of shared datasets is currently hardcoded and meets those assumptions.
+ * The implementation has to be revisited once creating more complex structures
+ * of ZFS datasets is supported.
  */
 
 ibem_errno_t
@@ -355,21 +366,44 @@
 	 * mount shared filesystems on alternate root
 	 */
 
-	for (i = 0; i < fs_shared_num; i++) {
+	/*
+	 * First make sure that children datasets inherit mountpoint
+	 * from their ancestors.
+	 */
+
+	for (i = 1; i < fs_shared_num; i++) {
 		(void) snprintf(cmd, sizeof (cmd),
-		    "/usr/sbin/zfs set mountpoint=%s%s %s%s", be_mountpoint,
-		    fs_shared_names[i], rpool_name, fs_shared_names[i]);
+		    "/usr/sbin/zfs inherit mountpoint %s%s",
+		    rpool_name, fs_shared_names[i]);
 
 		if (ibem_system(cmd) == -1)
 			return (IBEM_E_BE_MOUNT_FAILED);
 
-		(void) snprintf(cmd, sizeof (cmd),
-		    "/usr/sbin/zfs mount %s%s",
-		    rpool_name, fs_shared_names[i]);
+	}
+
+	/*
+	 * Now set target mountpoint for the oldest ancestor.
+	 * Children datasets inherit it.
+	 */
+
+	(void) snprintf(cmd, sizeof (cmd),
+	    "/usr/sbin/zfs set mountpoint=%s%s %s%s", be_mountpoint,
+	    fs_shared_names[0], rpool_name, fs_shared_names[0]);
 
-		if (ibem_system(cmd) == -1)
-			return (IBEM_E_BE_MOUNT_FAILED);
-	}
+	if (ibem_system(cmd) == -1)
+		return (IBEM_E_BE_MOUNT_FAILED);
+
+	/*
+	 * Finally mount the last child dataset. That forces all ancestor
+	 * datasets to be also mounted.
+	 */
+
+	(void) snprintf(cmd, sizeof (cmd),
+	    "/usr/sbin/zfs mount %s%s",
+	    rpool_name, fs_shared_names[fs_shared_num - 1]);
+
+	if (ibem_system(cmd) == -1)
+		return (IBEM_E_BE_MOUNT_FAILED);
 
 	return (IBEM_E_SUCCESS);
 }