Module Name:    src
Committed By:   hannken
Date:           Sun May 26 10:22:59 UTC 2019

Modified Files:
        src/external/cddl/osnet/dist/uts/common/fs/zfs: vdev_disk.c

Log Message:
upport wedges as vdevs, use DIOCGWEDGEINFO before DIOCGPARTINFO.

PR kern/54219 zpool create pool dk5 causes kernel panic


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 \
    src/external/cddl/osnet/dist/uts/common/fs/zfs/vdev_disk.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/external/cddl/osnet/dist/uts/common/fs/zfs/vdev_disk.c
diff -u src/external/cddl/osnet/dist/uts/common/fs/zfs/vdev_disk.c:1.8 src/external/cddl/osnet/dist/uts/common/fs/zfs/vdev_disk.c:1.9
--- src/external/cddl/osnet/dist/uts/common/fs/zfs/vdev_disk.c:1.8	Mon Sep  3 16:29:22 2018
+++ src/external/cddl/osnet/dist/uts/common/fs/zfs/vdev_disk.c	Sun May 26 10:22:59 2019
@@ -34,6 +34,7 @@
 #include <sys/zio.h>
 #include <sys/sunldi.h>
 #include <sys/fm/fs/zfs.h>
+#include <sys/disk.h>
 #include <sys/disklabel.h>
 #include <sys/dkio.h>
 #include <sys/workqueue.h>
@@ -146,6 +147,8 @@ vdev_disk_open(vdev_t *vd, uint64_t *psi
 	spa_t *spa = vd->vdev_spa;
 	vdev_disk_t *dvd;
 	vnode_t *vp;
+	struct dkwedge_info dkw;
+	struct disk *pdk;
 	int error, cmd;
 	struct partinfo pinfo;
 
@@ -235,9 +238,20 @@ vdev_disk_open(vdev_t *vd, uint64_t *psi
 skip_open:
 	/*
 	 * Determine the actual size of the device.
-	 * XXXNETBSD wedges.
+	 * Try wedge info first as it supports larger disks.
 	 */
-	error = VOP_IOCTL(vp, DIOCGPARTINFO, &pinfo, FREAD|FWRITE, kcred);
+	error = VOP_IOCTL(vp, DIOCGWEDGEINFO, &dkw, FREAD, NOCRED);
+	if (error == 0) {
+		pdk = disk_find(dkw.dkw_parent);
+		if (pdk) {
+			pinfo.pi_secsize = (1 << pdk->dk_byteshift);
+			pinfo.pi_size = dkw.dkw_size;
+			pinfo.pi_offset = dkw.dkw_offset;
+		} else	
+			error = ENODEV;
+	}
+	if (error)
+		error = VOP_IOCTL(vp, DIOCGPARTINFO, &pinfo, FREAD, kcred);
 	if (error != 0) {
 		vd->vdev_stat.vs_aux = VDEV_AUX_OPEN_FAILED;
 		return (SET_ERROR(error));

Reply via email to