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
This commit is contained in:
parent
b4c951aff5
commit
4890f838a2
@ -802,7 +802,9 @@ vdev_label_init(vdev_t *vd, uint64_t crtxg, vdev_labeltype_t reason)
|
||||
}
|
||||
|
||||
/*
|
||||
* 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_labeltype_t reason)
|
||||
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.
|
||||
|
Loading…
Reference in New Issue
Block a user