From owner-svn-src-all@freebsd.org Sat Feb 25 20:01:18 2017 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 9E997CED3A2; Sat, 25 Feb 2017 20:01:18 +0000 (UTC) (envelope-from jpaetzel@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 769CB9A5; Sat, 25 Feb 2017 20:01:18 +0000 (UTC) (envelope-from jpaetzel@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v1PK1He3012092; Sat, 25 Feb 2017 20:01:17 GMT (envelope-from jpaetzel@FreeBSD.org) Received: (from jpaetzel@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v1PK1HMG012091; Sat, 25 Feb 2017 20:01:17 GMT (envelope-from jpaetzel@FreeBSD.org) Message-Id: <201702252001.v1PK1HMG012091@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jpaetzel set sender to jpaetzel@FreeBSD.org using -f From: Josh Paetzel Date: Sat, 25 Feb 2017 20:01:17 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r314280 - head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 25 Feb 2017 20:01:18 -0000 Author: jpaetzel Date: Sat Feb 25 20:01:17 2017 New Revision: 314280 URL: https://svnweb.freebsd.org/changeset/base/314280 Log: MFV 314276 7570 tunable to allow zvol SCSI unmap to return on commit of txn to ZIL illumos/illumos-gate@1c9272b861cd640a8342f4407da026ed98615517 https://github.com/illumos/illumos-gate/commit/1c9272b861cd640a8342f4407da026ed98615517 https://www.illumos.org/issues/7570 Based on the discovery that every unmap waits for the commit of the txn to the ZIL, introducing a very high latency to unmap commands, this behavior was made into a tunable zvol_unmap_sync_enabled and set to false. The net impact of this change is that by default SCSI unmap commands will result in space being freed within the zvol (today they are ignored and returned with good status). However, unlike the code today, instead of 18+ms per unmap, they take about 30us. With the testing done on NTFS against a Win2k12 target, the new behavior should work seamlessly. Files on the zvol that have already been set with the zfree application will continue to write 0's when deleted, and any new files created since zvol creation will send unmap commands when deleted. This behavior exists today, but with this change the unmap commands will be processed and result in reclaim of space. Author: Stephen Blinick Reviewed by: Dan Kimmel Reviewed by: Matt Ahrens Reviewed by: Steve Gonczi Reviewed by: Pavel Zakharov Reviewed by: Saso Kiselkov Reviewed by: Yuri Pankov Approved by: Robert Mustacchi Modified: head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zvol.c Directory Properties: head/sys/cddl/contrib/opensolaris/ (props changed) Modified: head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zvol.c ============================================================================== --- head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zvol.c Sat Feb 25 19:39:58 2017 (r314279) +++ head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zvol.c Sat Feb 25 20:01:17 2017 (r314280) @@ -27,7 +27,7 @@ * Portions Copyright 2010 Robert Milkowski * * Copyright 2011 Nexenta Systems, Inc. All rights reserved. - * Copyright (c) 2012, 2014 by Delphix. All rights reserved. + * Copyright (c) 2012, 2016 by Delphix. All rights reserved. * Copyright (c) 2013, Joyent, Inc. All rights reserved. * Copyright (c) 2014 Integros [integros.com] */ @@ -202,11 +202,22 @@ int zvol_maxphys = DMU_MAX_ACCESS/2; * Toggle unmap functionality. */ boolean_t zvol_unmap_enabled = B_TRUE; + +/* + * If true, unmaps requested as synchronous are executed synchronously, + * otherwise all unmaps are asynchronous. + */ +boolean_t zvol_unmap_sync_enabled = B_FALSE; + #ifndef illumos SYSCTL_INT(_vfs_zfs_vol, OID_AUTO, unmap_enabled, CTLFLAG_RWTUN, &zvol_unmap_enabled, 0, "Enable UNMAP functionality"); +SYSCTL_INT(_vfs_zfs_vol, OID_AUTO, unmap_sync_enabled, CTLFLAG_RWTUN, + &zvol_unmap_sync_enabled, 0, + "UNMAPs requested as sync are executed synchronously"); + static d_open_t zvol_d_open; static d_close_t zvol_d_close; static d_read_t zvol_read; @@ -2268,26 +2279,21 @@ zvol_ioctl(dev_t dev, int cmd, intptr_t zfs_range_unlock(rl); - if (error == 0) { - /* - * If the write-cache is disabled or 'sync' property - * is set to 'always' then treat this as a synchronous - * operation (i.e. commit to zil). - */ - if (!(zv->zv_flags & ZVOL_WCE) || - (zv->zv_objset->os_sync == ZFS_SYNC_ALWAYS)) - zil_commit(zv->zv_zilog, ZVOL_OBJ); - - /* - * If the caller really wants synchronous writes, and - * can't wait for them, don't return until the write - * is done. - */ - if (df.df_flags & DF_WAIT_SYNC) { - txg_wait_synced( - dmu_objset_pool(zv->zv_objset), 0); - } + /* + * If the write-cache is disabled, 'sync' property + * is set to 'always', or if the caller is asking for + * a synchronous free, commit this operation to the zil. + * This will sync any previous uncommitted writes to the + * zvol object. + * Can be overridden by the zvol_unmap_sync_enabled tunable. + */ + if ((error == 0) && zvol_unmap_sync_enabled && + (!(zv->zv_flags & ZVOL_WCE) || + (zv->zv_objset->os_sync == ZFS_SYNC_ALWAYS) || + (df.df_flags & DF_WAIT_SYNC))) { + zil_commit(zv->zv_zilog, ZVOL_OBJ); } + return (error); }