Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 14 Mar 2018 21:21:03 +0000 (UTC)
From:      Steven Hartland <smh@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r330950 - head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs
Message-ID:  <201803142121.w2ELL3XX088649@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: smh
Date: Wed Mar 14 21:21:03 2018
New Revision: 330950
URL: https://svnweb.freebsd.org/changeset/base/330950

Log:
  Prevent ZFS TRIM breaking VTOC8 partitions
  
  Update the ZFS TRIM code to ensure it respects VTOC8 partition headers as
  documented by the ZFS On-Disk Specification section 1.3
  
  Before this a zpool create on a VTOC8 partitioned device would overwrite the
  partition metadata.
  
  Reported by:	marius
  Reviewed by:	marius agv
  MFC after:	1 week
  Sponsored by:	Multiplay

Modified:
  head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_label.c

Modified: head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_label.c
==============================================================================
--- head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_label.c	Wed Mar 14 21:11:41 2018	(r330949)
+++ head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_label.c	Wed Mar 14 21:21:03 2018	(r330950)
@@ -802,7 +802,9 @@ vdev_label_init(vdev_t *vd, uint64_t crtxg, vdev_label
 	}
 
 	/*
-	 * TRIM the whole thing so that we start with a clean slate.
+	 * TRIM the whole thing, excluding the blank space and boot header
+	 * as specified by ZFS On-Disk Specification (section 1.3), so that
+	 * we start with a clean slate.
 	 * It's just an optimization, so we don't care if it fails.
 	 * Don't TRIM if removing so that we don't interfere with zpool
 	 * disaster recovery.
@@ -810,7 +812,8 @@ vdev_label_init(vdev_t *vd, uint64_t crtxg, vdev_label
 	if (zfs_trim_enabled && vdev_trim_on_init && !vd->vdev_notrim && 
 	    (reason == VDEV_LABEL_CREATE || reason == VDEV_LABEL_SPARE ||
 	    reason == VDEV_LABEL_L2CACHE))
-		zio_wait(zio_trim(NULL, spa, vd, 0, vd->vdev_psize));
+		zio_wait(zio_trim(NULL, spa, vd, VDEV_SKIP_SIZE,
+		    vd->vdev_psize - VDEV_SKIP_SIZE));
 
 	/*
 	 * Initialize its label.



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201803142121.w2ELL3XX088649>