svn commit: r242230 - stable/9/sys/boot/zfs

Andriy Gapon avg at FreeBSD.org
Sun Oct 28 15:47:57 UTC 2012


Author: avg
Date: Sun Oct 28 15:47:56 2012
New Revision: 242230
URL: http://svn.freebsd.org/changeset/base/242230

Log:
  MFC r241289: boot/zfs: call zfs_spa_init for all found pools

Modified:
  stable/9/sys/boot/zfs/zfs.c
  stable/9/sys/boot/zfs/zfsimpl.c
Directory Properties:
  stable/9/sys/   (props changed)
  stable/9/sys/boot/   (props changed)

Modified: stable/9/sys/boot/zfs/zfs.c
==============================================================================
--- stable/9/sys/boot/zfs/zfs.c	Sun Oct 28 15:45:18 2012	(r242229)
+++ stable/9/sys/boot/zfs/zfs.c	Sun Oct 28 15:47:56 2012	(r242230)
@@ -369,10 +369,28 @@ vdev_read(vdev_t *vdev, void *priv, off_
 static int
 zfs_dev_init(void)
 {
+	spa_t *spa;
+	spa_t *next;
+	spa_t *prev;
+
 	zfs_init();
 	if (archsw.arch_zfs_probe == NULL)
 		return (ENXIO);
 	archsw.arch_zfs_probe();
+
+	prev = NULL;
+	spa = STAILQ_FIRST(&zfs_pools);
+	while (spa != NULL) {
+		next = STAILQ_NEXT(spa, spa_link);
+		if (zfs_spa_init(spa)) {
+			if (prev == NULL)
+				STAILQ_REMOVE_HEAD(&zfs_pools, spa_link);
+			else
+				STAILQ_REMOVE_AFTER(&zfs_pools, prev, spa_link);
+		} else
+			prev = spa;
+		spa = next;
+	}
 	return (0);
 }
 
@@ -435,9 +453,6 @@ zfs_dev_open(struct open_file *f, ...)
 		spa = spa_find_by_guid(dev->pool_guid);
 	if (!spa)
 		return (ENXIO);
-	rv = zfs_spa_init(spa);
-	if (rv != 0)
-		return (rv);
 	mount = malloc(sizeof(*mount));
 	rv = zfs_mount(spa, dev->root_guid, mount);
 	if (rv != 0) {
@@ -517,9 +532,6 @@ zfs_parsedev(struct zfs_devdesc *dev, co
 	spa = spa_find_by_name(poolname);
 	if (!spa)
 		return (ENXIO);
-	rv = zfs_spa_init(spa);
-	if (rv != 0)
-		return (rv);
 	dev->pool_guid = spa->spa_guid;
 	if (rootname[0] != '\0') {
 		rv = zfs_lookup_dataset(spa, rootname, &dev->root_guid);
@@ -554,10 +566,6 @@ zfs_fmtdev(void *vdev)
 		printf("ZFS: can't find pool by guid\n");
 		return (buf);
 	}
-	if (zfs_spa_init(spa) != 0) {
-		printf("ZFS: can't init pool\n");
-		return (buf);
-	}
 	if (dev->root_guid == 0 && zfs_get_root(spa, &dev->root_guid)) {
 		printf("ZFS: can't find root filesystem\n");
 		return (buf);
@@ -597,9 +605,6 @@ zfs_list(const char *name)
 	spa = spa_find_by_name(poolname);
 	if (!spa)
 		return (ENXIO);
-	rv = zfs_spa_init(spa);
-	if (rv != 0)
-		return (rv);
 	if (dsname != NULL)
 		rv = zfs_lookup_dataset(spa, dsname, &objid);
 	else

Modified: stable/9/sys/boot/zfs/zfsimpl.c
==============================================================================
--- stable/9/sys/boot/zfs/zfsimpl.c	Sun Oct 28 15:45:18 2012	(r242229)
+++ stable/9/sys/boot/zfs/zfsimpl.c	Sun Oct 28 15:47:56 2012	(r242230)
@@ -1826,13 +1826,14 @@ static int
 zfs_spa_init(spa_t *spa)
 {
 
-	if (spa->spa_inited)
-		return (0);
 	if (zio_read(spa, &spa->spa_uberblock.ub_rootbp, &spa->spa_mos)) {
 		printf("ZFS: can't read MOS of pool %s\n", spa->spa_name);
 		return (EIO);
 	}
-	spa->spa_inited = 1;
+	if (spa->spa_mos.os_type != DMU_OST_META) {
+		printf("ZFS: corrupted MOS of pool %s\n", spa->spa_name);
+		return (EIO);
+	}
 	return (0);
 }
 


More information about the svn-src-stable-9 mailing list