From nobody@FreeBSD.org  Fri Oct 26 08:41:02 2012
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52])
	by hub.freebsd.org (Postfix) with ESMTP id 0662940E
	for <freebsd-gnats-submit@FreeBSD.org>; 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 <freebsd-gnats-submit@FreeBSD.org>; 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 <freebsd-gnats-submit@FreeBSD.org>; 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 <steven.hartland@multiplay.co.uk>
To: freebsd-gnats-submit@FreeBSD.org
Subject: Add sysctl to enable / disable ZFS device full trim on init (patch included)
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>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:    smh
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Fri Oct 26 08:50:02 UTC 2012
>Closed-Date:    Thu Dec 13 17:39:35 UTC 2012
>Last-Modified:  Thu Dec 13 17:39:35 UTC 2012
>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 <sys/trim_map.h>
 #include <sys/fs/zfs.h>
 
+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:
Responsible-Changed-From-To: freebsd-bugs->smh 
Responsible-Changed-By: smh 
Responsible-Changed-When: Tue Dec 11 14:08:56 UTC 2012 
Responsible-Changed-Why:  
I'll take it. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=173116 
State-Changed-From-To: open->closed 
State-Changed-By: smh 
State-Changed-When: Thu Dec 13 17:39:34 UTC 2012 
State-Changed-Why:  
patched in head/ with r244188 

http://www.freebsd.org/cgi/query-pr.cgi?pr=173116 
>Unformatted:
