diff --git a/module/zfs/vdev_label.c b/module/zfs/vdev_label.c index 043ece16c4c4..aeab374b8c4f 100644 --- a/module/zfs/vdev_label.c +++ b/module/zfs/vdev_label.c @@ -695,8 +695,8 @@ vdev_label_init(vdev_t *vd, uint64_t crtxg, vdev_labeltype_t reason) * Don't TRIM if removing so that we don't interfere with zpool * disaster recovery. */ - if (reason == VDEV_LABEL_CREATE || reason == VDEV_LABEL_SPARE - || reason == VDEV_LABEL_L2CACHE) + if (!zfs_notrim && (reason == VDEV_LABEL_CREATE || + reason == VDEV_LABEL_SPARE || reason == VDEV_LABEL_L2CACHE)) zio_wait(zio_trim(NULL, spa, vd, 0, vd->vdev_psize)); /*