changeset 18825:2ed7ea649fe9

loader: zfs_bootfs() needs to use config pool txg for boot device illumos issue #9423
author Toomas Soome <tsoome@me.com>
date Thu, 29 Mar 2018 16:11:54 +0300
parents 4272f05ab956
children 50e32dd26136
files usr/src/boot/Makefile.version usr/src/boot/sys/boot/zfs/zfs.c usr/src/boot/sys/boot/zfs/zfsimpl.c usr/src/boot/sys/cddl/boot/zfs/zfsimpl.h
diffstat 4 files changed, 14 insertions(+), 34 deletions(-) [+]
line wrap: on
line diff
--- a/usr/src/boot/Makefile.version	Tue Mar 13 07:59:41 2018 +0200
+++ b/usr/src/boot/Makefile.version	Thu Mar 29 16:11:54 2018 +0300
@@ -33,4 +33,4 @@
 # Use date like formatting here, YYYY.MM.DD.XX, without leading zeroes.
 # The version is processed from left to right, the version number can only
 # be increased.
-BOOT_VERSION = $(LOADER_VERSION)-2018.2.24.1
+BOOT_VERSION = $(LOADER_VERSION)-2018.3.29.1
--- a/usr/src/boot/sys/boot/zfs/zfs.c	Tue Mar 13 07:59:41 2018 +0200
+++ b/usr/src/boot/sys/boot/zfs/zfs.c	Thu Mar 29 16:11:54 2018 +0300
@@ -704,8 +704,6 @@
 	struct zfs_devdesc	*dev = (struct zfs_devdesc *)zdev;
 	uint64_t		objnum;
 	spa_t			*spa;
-	vdev_t			*vdev;
-	vdev_t			*kid;
 	int			n;
 
 	buf[0] = '\0';
@@ -726,37 +724,14 @@
 		return (buf);
 	}
 
-	STAILQ_FOREACH(vdev, &spa->spa_vdevs, v_childlink) {
-		STAILQ_FOREACH(kid, &vdev->v_children, v_childlink) {
-			/* use this kid? */
-			if (kid->v_state == VDEV_STATE_HEALTHY &&
-			    kid->v_phys_path != NULL) {
-				break;
-			}
-		}
-		if (kid != NULL) {
-			vdev = kid;
-			break;
-		}
-		if (vdev->v_state == VDEV_STATE_HEALTHY &&
-		    vdev->v_phys_path != NULL) {
-			break;
-		}
-	}
-
-	/*
-	 * since this pool was used to read in the kernel and boot archive,
-	 * there has to be at least one healthy vdev, therefore vdev
-	 * can not be NULL.
-	 */
 	/* Set the environment. */
 	snprintf(buf, sizeof (buf), "%s/%llu", spa->spa_name,
 	    (unsigned long long)objnum);
 	setenv("zfs-bootfs", buf, 1);
-	if (vdev->v_phys_path != NULL)
-		setenv("bootpath", vdev->v_phys_path, 1);
-	if (vdev->v_devid != NULL)
-		setenv("diskdevid", vdev->v_devid, 1);
+	if (spa->spa_boot_vdev->v_phys_path != NULL)
+		setenv("bootpath", spa->spa_boot_vdev->v_phys_path, 1);
+	if (spa->spa_boot_vdev->v_devid != NULL)
+		setenv("diskdevid", spa->spa_boot_vdev->v_devid, 1);
 
 	/*
 	 * Build the command line string. Once our kernel will read
@@ -766,14 +741,14 @@
 	snprintf(buf, sizeof(buf), "zfs-bootfs=%s/%llu", spa->spa_name,
 	    (unsigned long long)objnum);
 	n = strlen(buf);
-	if (vdev->v_phys_path != NULL) {
+	if (spa->spa_boot_vdev->v_phys_path != NULL) {
 		snprintf(buf+n, sizeof (buf) - n, ",bootpath=\"%s\"",
-		    vdev->v_phys_path);
+		    spa->spa_boot_vdev->v_phys_path);
 		n = strlen(buf);
 	}
-	if (vdev->v_devid != NULL) {
+	if (spa->spa_boot_vdev->v_devid != NULL) {
 		snprintf(buf+n, sizeof (buf) - n, ",diskdevid=\"%s\"",
-		    vdev->v_devid);
+		    spa->spa_boot_vdev->v_devid);
 	}
 	return (buf);
 }
--- a/usr/src/boot/sys/boot/zfs/zfsimpl.c	Tue Mar 13 07:59:41 2018 +0200
+++ b/usr/src/boot/sys/boot/zfs/zfsimpl.c	Thu Mar 29 16:11:54 2018 +0300
@@ -1108,6 +1108,10 @@
 		return (EIO);
 	}
 
+	/* Record boot vdev for spa. */
+	if (is_newer == 1)
+		spa->spa_boot_vdev = vdev;
+
 	/*
 	 * Re-evaluate top-level vdev state.
 	 */
--- a/usr/src/boot/sys/cddl/boot/zfs/zfsimpl.h	Tue Mar 13 07:59:41 2018 +0200
+++ b/usr/src/boot/sys/cddl/boot/zfs/zfsimpl.h	Thu Mar 29 16:11:54 2018 +0300
@@ -1551,6 +1551,7 @@
 	vdev_list_t	spa_vdevs;	/* list of all toplevel vdevs */
 	objset_phys_t	spa_mos;	/* MOS for this pool */
 	int		spa_inited;	/* initialized */
+	vdev_t		*spa_boot_vdev;	/* boot device for kernel */
 } spa_t;
 
 static void decode_embedded_bp_compressed(const blkptr_t *, void *);