From owner-freebsd-bugs@FreeBSD.ORG Thu Nov 1 04:10:01 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 C95324A0 for ; Thu, 1 Nov 2012 04:10:01 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:1900:2254:206c::16:87]) by mx1.freebsd.org (Postfix) with ESMTP id 9D3D88FC0C for ; Thu, 1 Nov 2012 04:10:01 +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 qA14A1ID007912 for ; Thu, 1 Nov 2012 04:10:01 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.5/8.14.5/Submit) id qA14A1Lx007911; Thu, 1 Nov 2012 04:10:01 GMT (envelope-from gnats) Resent-Date: Thu, 1 Nov 2012 04:10:01 GMT Resent-Message-Id: <201211010410.qA14A1Lx007911@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 69FFF464 for ; Thu, 1 Nov 2012 04:07:21 +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 515F78FC0C for ; Thu, 1 Nov 2012 04:07:21 +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 qA147KZ0003456 for ; Thu, 1 Nov 2012 04:07:20 GMT (envelope-from nobody@red.freebsd.org) Received: (from nobody@localhost) by red.freebsd.org (8.14.5/8.14.5/Submit) id qA147KLd003455; Thu, 1 Nov 2012 04:07:20 GMT (envelope-from nobody) Message-Id: <201211010407.qA147KLd003455@red.freebsd.org> Date: Thu, 1 Nov 2012 04:07:20 GMT From: Steven Hartland To: freebsd-gnats-submit@FreeBSD.org X-Send-Pr-Version: www-3.1 Subject: misc/173254: Upgrade requests used in ZFS trim map based on ashift (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: Thu, 01 Nov 2012 04:10:01 -0000 >Number: 173254 >Category: misc >Synopsis: Upgrade requests used in ZFS trim map based on ashift (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: Thu Nov 01 04:10:01 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: Upgrades trim free request sizes before inserting them into to free map, making range consolidation much more effective particularly for small deletes. This reduces memory used by the free map as well as reducing the number of bio requests down to geom required to process all deletes. In tests this achieved a factor of 10 reduction of trim ranges / geom call downs. >How-To-Repeat: N/A >Fix: Apply the attached patch Patch attached with submission follows: Upgrades trim free request sizes before inserting them into to free map, making range consolidation much more effective particularly for small deletes. This reduces memory used by the free map as well as reducing the number of bio requests down to geom required to process all deletes. In tests this achieved a factor of 10 reduction of trim ranges / geom call downs. --- sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zio.c 2012-10-25 13:01:17.556311206 +0000 +++ sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zio.c 2012-10-25 13:48:39.280408543 +0000 @@ -2324,7 +2324,7 @@ /* * ========================================================================== - * Read and write to physical devices + * Read, write and delete to physical devices * ========================================================================== */ static int --- sys/cddl/contrib/opensolaris/uts/common/fs/zfs/trim_map.c 2012-10-25 13:01:17.544310799 +0000 +++ sys/cddl/contrib/opensolaris/uts/common/fs/zfs/trim_map.c 2012-10-25 14:41:49.391313700 +0000 @@ -263,14 +263,27 @@ void trim_map_free(zio_t *zio) { + uint64_t size, align; vdev_t *vd = zio->io_vd; trim_map_t *tm = vd->vdev_trimmap; if (zfs_notrim || vd->vdev_notrim || tm == NULL) return; + /* + * Upgrade size based on ashift which would be done by + * zio_vdev_io_start later anyway. + * + * This makes free range consolidation much more effective + * than it would otherwise be. + */ + size = zio->io_size; + align = 1ULL << vd->vdev_top->vdev_ashift; + if (P2PHASE(size, align) != 0) + size = P2ROUNDUP(size, align); + mutex_enter(&tm->tm_lock); - trim_map_free_locked(tm, zio->io_offset, zio->io_offset + zio->io_size, + trim_map_free_locked(tm, zio->io_offset, zio->io_offset + size, vd->vdev_spa->spa_syncing_txg); mutex_exit(&tm->tm_lock); } @@ -282,13 +295,25 @@ trim_map_t *tm = vd->vdev_trimmap; trim_seg_t tsearch, *ts; boolean_t left_over, right_over; - uint64_t start, end; + uint64_t start, end, align, size; if (zfs_notrim || vd->vdev_notrim || tm == NULL) return (B_TRUE); + /* + * Upgrade size based on ashift which would be done by + * zio_vdev_io_start later anyway. + * + * This ensures that entire blocks are invalidated by + * writes + */ + align = 1ULL << vd->vdev_top->vdev_ashift; + size = zio->io_size; + if (P2PHASE(size, align) != 0) + size = P2ROUNDUP(size, align); + start = zio->io_offset; - end = start + zio->io_size; + end = start + size; tsearch.ts_start = start; tsearch.ts_end = end; >Release-Note: >Audit-Trail: >Unformatted: