The attached patch causes ZFS to base the minimum transfer size for a
new vdev on the GEOM provider's stripesize (physical sector size) rather
than sectorsize (logical sector size), provided that stripesize is a
power of two larger than sectorsize and smaller than or equal to
VDEV_PAD_SIZE.  This should eliminate the need for ivoras@'s gnop trick
when creating ZFS pools on Advanced Format drives.

DES
-- 
Dag-Erling Smørgrav - d...@des.no

Index: sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_geom.c
===================================================================
--- sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_geom.c	(revision 253138)
+++ sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_geom.c	(working copy)
@@ -578,6 +578,7 @@
 {
 	struct g_provider *pp;
 	struct g_consumer *cp;
+	u_int sectorsize;
 	size_t bufsize;
 	int error;
 
@@ -661,8 +662,21 @@
 
 	/*
 	 * Determine the device's minimum transfer size.
+	 *
+	 * This is a bit of a hack.  For performance reasons, we would
+	 * prefer to use the physical sector size (reported by GEOM as
+	 * stripesize) as minimum transfer size.  However, doing so
+	 * unconditionally would break existing vdevs.  Therefore, we
+	 * compute ashift based on stripesize when the vdev isn't already
+	 * part of a pool (vdev_asize == 0), and sectorsize otherwise.
 	 */
-	*ashift = highbit(MAX(pp->sectorsize, SPA_MINBLOCKSIZE)) - 1;
+	if (vd->vdev_asize == 0 && pp->stripesize > pp->sectorsize &&
+	    ISP2(pp->stripesize) && pp->stripesize <= VDEV_PAD_SIZE) {
+		sectorsize = pp->stripesize;
+	} else {
+		sectorsize = pp->sectorsize;
+	}
+	*ashift = highbit(MAX(sectorsize, SPA_MINBLOCKSIZE)) - 1;
 
 	/*
 	 * Clear the nowritecache settings, so that on a vdev_reopen()
_______________________________________________
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "freebsd-hackers-unsubscr...@freebsd.org"

Reply via email to