From owner-freebsd-bugs@FreeBSD.ORG Fri Oct 26 08:50:02 2012 Return-Path: Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id AD9CD80E for ; Fri, 26 Oct 2012 08:50:02 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.FreeBSD.org [8.8.178.135]) by mx1.freebsd.org (Postfix) with ESMTP id 835CF8FC1A for ; Fri, 26 Oct 2012 08:50:02 +0000 (UTC) Received: from freefall.freebsd.org (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.5/8.14.5) with ESMTP id q9Q8o2CM082058 for ; Fri, 26 Oct 2012 08:50:02 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.5/8.14.5/Submit) id q9Q8o2uS082057; Fri, 26 Oct 2012 08:50:02 GMT (envelope-from gnats) Resent-Date: Fri, 26 Oct 2012 08:50:02 GMT Resent-Message-Id: <201210260850.q9Q8o2uS082057@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Steven Hartland Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 0662940E for ; Fri, 26 Oct 2012 08:41:02 +0000 (UTC) (envelope-from nobody@FreeBSD.org) Received: from red.freebsd.org (red.freebsd.org [IPv6:2001:4f8:fff6::22]) by mx1.freebsd.org (Postfix) with ESMTP id E1EBC8FC1B for ; Fri, 26 Oct 2012 08:41:01 +0000 (UTC) Received: from red.freebsd.org (localhost [127.0.0.1]) by red.freebsd.org (8.14.5/8.14.5) with ESMTP id q9Q8f1p9086599 for ; Fri, 26 Oct 2012 08:41:01 GMT (envelope-from nobody@red.freebsd.org) Received: (from nobody@localhost) by red.freebsd.org (8.14.5/8.14.5/Submit) id q9Q8f1jG086598; Fri, 26 Oct 2012 08:41:01 GMT (envelope-from nobody) Message-Id: <201210260841.q9Q8f1jG086598@red.freebsd.org> Date: Fri, 26 Oct 2012 08:41:01 GMT From: Steven Hartland To: freebsd-gnats-submit@FreeBSD.org X-Send-Pr-Version: www-3.1 Subject: kern/173116: Add sysctl to enable / disable ZFS device full trim on init (patch included) X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 26 Oct 2012 08:50:02 -0000 >Number: 173116 >Category: kern >Synopsis: Add sysctl to enable / disable ZFS device full trim on init (patch included) >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Fri Oct 26 08:50:02 UTC 2012 >Closed-Date: >Last-Modified: >Originator: Steven Hartland >Release: 8.3-RELEASE >Organization: Multiplay >Environment: FreeBSD dev 8.3-RELEASE-p4 FreeBSD 8.3-RELEASE-p4 #22: Mon Sep 17 17:18:32 UTC 2012 root@dev:/usr/obj/usr/src/sys/MULTIPLAY amd64 >Description: Added vfs.zfs.vdev.trim_on_init sysctl which allows full vdev trim on initialisation to be enabled (1) / disabled (0) defaults to enabled. This is useful for devices which have a slow trim speed and are either new or have otherwise already been wiped e.g. secure erase. >How-To-Repeat: N/A >Fix: Apply the attached patch Patch attached with submission follows: Added vfs.zfs.vdev.trim_on_init sysctl which allows full vdev trim on initialisation to be enabled (1) / disabled (0) defaults to enabled. This is useful for devices which have a slow trim speed and are either new or have otherwise already been wiped e.g. secure erase. --- sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_label.c.orig 2012-10-25 19:30:49.281472955 +0000 +++ sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_label.c 2012-10-25 19:45:31.538099840 +0000 @@ -144,6 +144,11 @@ #include #include +boolean_t vdev_trim_on_init = B_TRUE; +SYSCTL_DECL(_vfs_zfs_vdev); +SYSCTL_INT(_vfs_zfs_vdev, OID_AUTO, trim_on_init, CTLFLAG_RW, + &vdev_trim_on_init, 0, "Enable/disable full vdev trim on initialisation"); + /* * Basic routines to read and write from a vdev label. * Used throughout the rest of this file. @@ -699,7 +704,7 @@ * Don't TRIM if removing so that we don't interfere with zpool * disaster recovery. */ - if (!zfs_notrim && (reason == VDEV_LABEL_CREATE || + if (!zfs_notrim && vdev_trim_on_init && (reason == VDEV_LABEL_CREATE || reason == VDEV_LABEL_SPARE || reason == VDEV_LABEL_L2CACHE)) zio_wait(zio_trim(NULL, spa, vd, 0, vd->vdev_psize)); >Release-Note: >Audit-Trail: >Unformatted: