svn commit: r326401 - head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs
Alan Somers
asomers at FreeBSD.org
Thu Nov 30 15:36:07 UTC 2017
Author: asomers
Date: Thu Nov 30 15:36:06 2017
New Revision: 326401
URL: https://svnweb.freebsd.org/changeset/base/326401
Log:
Fix assertion when ZFS fails to open certain devices
"panic: vdev_geom_close_locked: cp->private is NULL"
This panic will result if ZFS fails to open a device due to either of the
following reasons:
1) The device's sector size is greater than 8KB.
2) ZFS wants to open the device RW, but it can't be opened for writing.
The solution is to change the initialization order to ensure that the
assertion will be satisfied.
PR: 221066
Reported by: David NewHamlet <wheelcomplex at gmail.com>
Reviewed by: avg
MFC after: 3 weeks
Sponsored by: Spectra Logic Corp
Differential Revision: https://reviews.freebsd.org/D13278
Modified:
head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_geom.c
Modified: head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_geom.c
==============================================================================
--- head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_geom.c Thu Nov 30 15:34:55 2017 (r326400)
+++ head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_geom.c Thu Nov 30 15:36:06 2017 (r326401)
@@ -851,35 +851,10 @@ vdev_geom_open(vdev_t *vd, uint64_t *psize, uint64_t *
if (cp == NULL) {
ZFS_LOG(1, "Vdev %s not found.", vd->vdev_path);
error = ENOENT;
- } else if (cp->provider->sectorsize > VDEV_PAD_SIZE ||
- !ISP2(cp->provider->sectorsize)) {
- ZFS_LOG(1, "Provider %s has unsupported sectorsize.",
- cp->provider->name);
-
- vdev_geom_close_locked(vd);
- error = EINVAL;
- cp = NULL;
- } else if (cp->acw == 0 && (spa_mode(vd->vdev_spa) & FWRITE) != 0) {
- int i;
-
- for (i = 0; i < 5; i++) {
- error = g_access(cp, 0, 1, 0);
- if (error == 0)
- break;
- g_topology_unlock();
- tsleep(vd, 0, "vdev", hz / 2);
- g_topology_lock();
- }
- if (error != 0) {
- printf("ZFS WARNING: Unable to open %s for writing (error=%d).\n",
- cp->provider->name, error);
- vdev_geom_close_locked(vd);
- cp = NULL;
- }
- }
- if (cp != NULL) {
+ } else {
struct consumer_priv_t *priv;
struct consumer_vdev_elem *elem;
+ int spamode;
priv = (struct consumer_priv_t*)&cp->private;
if (cp->private == NULL)
@@ -887,6 +862,34 @@ vdev_geom_open(vdev_t *vd, uint64_t *psize, uint64_t *
elem = g_malloc(sizeof(*elem), M_WAITOK|M_ZERO);
elem->vd = vd;
SLIST_INSERT_HEAD(priv, elem, elems);
+
+ spamode = spa_mode(vd->vdev_spa);
+ if (cp->provider->sectorsize > VDEV_PAD_SIZE ||
+ !ISP2(cp->provider->sectorsize)) {
+ ZFS_LOG(1, "Provider %s has unsupported sectorsize.",
+ cp->provider->name);
+
+ vdev_geom_close_locked(vd);
+ error = EINVAL;
+ cp = NULL;
+ } else if (cp->acw == 0 && (spamode & FWRITE) != 0) {
+ int i;
+
+ for (i = 0; i < 5; i++) {
+ error = g_access(cp, 0, 1, 0);
+ if (error == 0)
+ break;
+ g_topology_unlock();
+ tsleep(vd, 0, "vdev", hz / 2);
+ g_topology_lock();
+ }
+ if (error != 0) {
+ printf("ZFS WARNING: Unable to open %s for writing (error=%d).\n",
+ cp->provider->name, error);
+ vdev_geom_close_locked(vd);
+ cp = NULL;
+ }
+ }
}
/* Fetch initial physical path information for this device. */
More information about the svn-src-head
mailing list