summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpjd <pjd@FreeBSD.org>2010-03-19 20:14:27 +0000
committerpjd <pjd@FreeBSD.org>2010-03-19 20:14:27 +0000
commit96459d48e9a019676cb6cbcc686ba9d87ad18001 (patch)
tree54f4c48d20199f7638fda5a4c3a38d6cfdd50301
parent102a1f8933fc21bc4d59fefc7cf937a79852efd3 (diff)
downloadFreeBSD-src-96459d48e9a019676cb6cbcc686ba9d87ad18001.zip
FreeBSD-src-96459d48e9a019676cb6cbcc686ba9d87ad18001.tar.gz
The same code is used to import and to create pool.
The order of operations is the following: 1. Try to open vdev by remembered path and guid. 2. If 1 failed, try to find vdev which guid matches and ignore the path. 3. If 2 failed this means either that the vdev we're looking for is gone or that pool is being created and vdev doesn't contain proper guid yet. To be able to handle pool creation we open vdev by path anyway. Because of 3 it is possible that we open wrong vdev on import which can lead to confusions. The solution for this is to check spa_load_state. On pool creation it will be equal to SPA_LOAD_NONE and we can open vdev only by path immediately and if it is not equal to SPA_LOAD_NONE we first open by path+guid and when that fails, we open by guid. We no longer open wrong vdev on import. MFC after: 2 weeks
-rw-r--r--sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_geom.c30
1 files changed, 20 insertions, 10 deletions
diff --git a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_geom.c b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_geom.c
index d5c57e7..819473e 100644
--- a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_geom.c
+++ b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_geom.c
@@ -29,6 +29,7 @@
#include <sys/bio.h>
#include <sys/disk.h>
#include <sys/spa.h>
+#include <sys/spa_impl.h>
#include <sys/vdev_impl.h>
#include <sys/fs/zfs.h>
#include <sys/zio.h>
@@ -505,17 +506,26 @@ vdev_geom_open(vdev_t *vd, uint64_t *psize, uint64_t *ashift)
if ((owned = mtx_owned(&Giant)))
mtx_unlock(&Giant);
error = 0;
- cp = vdev_geom_open_by_path(vd, 1);
- if (cp == NULL) {
- /*
- * The device at vd->vdev_path doesn't have the expected guid.
- * The disks might have merely moved around so try all other
- * geom providers to find one with the right guid.
- */
- cp = vdev_geom_open_by_guid(vd);
- }
- if (cp == NULL)
+
+ /*
+ * If we're creating pool, just find GEOM provider by its name
+ * and ignore GUID mismatches.
+ */
+ if (vd->vdev_spa->spa_load_state == SPA_LOAD_NONE)
cp = vdev_geom_open_by_path(vd, 0);
+ else {
+ cp = vdev_geom_open_by_path(vd, 1);
+ if (cp == NULL) {
+ /*
+ * The device at vd->vdev_path doesn't have the
+ * expected guid. The disks might have merely
+ * moved around so try all other GEOM providers
+ * to find one with the right guid.
+ */
+ cp = vdev_geom_open_by_guid(vd);
+ }
+ }
+
if (cp == NULL) {
ZFS_LOG(1, "Provider %s not found.", vd->vdev_path);
error = ENOENT;
OpenPOWER on IntegriCloud