Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 1 Nov 2012 04:07:20 GMT
From:      Steven Hartland <steven.hartland@multiplay.co.uk>
To:        freebsd-gnats-submit@FreeBSD.org
Subject:   misc/173254: Upgrade requests used in ZFS trim map based on ashift (patch included)
Message-ID:  <201211010407.qA147KLd003455@red.freebsd.org>
Resent-Message-ID: <201211010410.qA14A1Lx007911@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help

>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:



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201211010407.qA147KLd003455>