svn commit: r244187 - head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs

Steven Hartland smh at FreeBSD.org
Thu Dec 13 17:06:39 UTC 2012


Author: smh
Date: Thu Dec 13 17:06:38 2012
New Revision: 244187
URL: http://svnweb.freebsd.org/changeset/base/244187

Log:
  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.
  
  While I'm here correct the description of zio_vdev_io_start.
  
  PR:		kern/173254
  Submitted by:	Steven Hartland
  Approved by:	pjd (mentor)

Modified:
  head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/trim_map.c
  head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zio.c

Modified: head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/trim_map.c
==============================================================================
--- head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/trim_map.c	Thu Dec 13 15:19:37 2012	(r244186)
+++ head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/trim_map.c	Thu Dec 13 17:06:38 2012	(r244187)
@@ -28,6 +28,17 @@
 #include <sys/vdev_impl.h>
 #include <sys/trim_map.h>
 
+/*
+ * Calculate the zio end, upgrading based on ashift which would be
+ * done by zio_vdev_io_start.
+ *
+ * This makes free range consolidation much more effective
+ * than it would otherwise be as well as ensuring that entire
+ * blocks are invalidated by writes.
+ */
+#define	TRIM_ZIO_END(zio)	((zio)->io_offset +		\
+ 	P2ROUNDUP((zio)->io_size, 1ULL << (zio)->io_vd->vdev_top->vdev_ashift))
+
 typedef struct trim_map {
 	list_t		tm_head;		/* List of segments sorted by txg. */
 	avl_tree_t	tm_queued_frees;	/* AVL tree of segments waiting for TRIM. */
@@ -270,7 +281,7 @@ trim_map_free(zio_t *zio)
 		return;
 
 	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, TRIM_ZIO_END(zio),
 	    vd->vdev_spa->spa_syncing_txg);
 	mutex_exit(&tm->tm_lock);
 }
@@ -288,7 +299,7 @@ trim_map_write_start(zio_t *zio)
 		return (B_TRUE);
 
 	start = zio->io_offset;
-	end = start + zio->io_size;
+	end = TRIM_ZIO_END(zio);
 	tsearch.ts_start = start;
 	tsearch.ts_end = end;
 

Modified: head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zio.c
==============================================================================
--- head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zio.c	Thu Dec 13 15:19:37 2012	(r244186)
+++ head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zio.c	Thu Dec 13 17:06:38 2012	(r244187)
@@ -2448,7 +2448,7 @@ zio_free_zil(spa_t *spa, uint64_t txg, b
 
 /*
  * ==========================================================================
- * Read and write to physical devices
+ * Read, write and delete to physical devices
  * ==========================================================================
  */
 static int


More information about the svn-src-all mailing list