[Zrouter-src-freebsd] ZRouter.org: push to FreeBSD HEAD tree

zrouter-src-freebsd at zrouter.org zrouter-src-freebsd at zrouter.org
Wed Feb 1 10:56:49 UTC 2012


details:   http://zrouter.org/hg/FreeBSD/head//rev/304c0fd1146a
changeset: 317:304c0fd1146a
user:      ray at terran.dlink.ua
date:      Wed Feb 01 11:52:48 2012 +0200
description:
Update sys/cddl

diffstat:

 head/sys/cddl/compat/opensolaris/sys/kmem.h                         |   6 +-
 head/sys/cddl/compat/opensolaris/sys/sid.h                          |   8 +-
 head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dnode.c         |   2 +-
 head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/metaslab.c      |   4 +-
 head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa.c           |  19 +++--
 head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/vdev.h      |   3 +-
 head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/vdev_impl.h |   1 +
 head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zfs_ioctl.h |   3 +-
 head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev.c          |  20 ++++-
 head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_fm.c        |   8 ++
 head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ioctl.c     |  13 +++-
 head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zio.c           |  32 +++++++--
 12 files changed, 81 insertions(+), 38 deletions(-)

diffs (431 lines):

diff -r 2c7e9f76c40e -r 304c0fd1146a head/sys/cddl/compat/opensolaris/sys/kmem.h
--- a/head/sys/cddl/compat/opensolaris/sys/kmem.h	Wed Feb 01 11:52:38 2012 +0200
+++ b/head/sys/cddl/compat/opensolaris/sys/kmem.h	Wed Feb 01 11:52:48 2012 +0200
@@ -23,7 +23,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $FreeBSD$
+ * $FreeBSD: head/sys/cddl/compat/opensolaris/sys/kmem.h 230623 2012-01-27 20:18:31Z kmacy $
  */
 
 #ifndef _OPENSOLARIS_SYS_KMEM_H_
@@ -45,7 +45,9 @@
 #define	KM_SLEEP		M_WAITOK
 #define	KM_PUSHPAGE		M_WAITOK
 #define	KM_NOSLEEP		M_NOWAIT
-#define	KMC_NODEBUG		0
+#define	KM_ZERO			M_ZERO
+#define	KM_NODEBUG		M_NODUMP
+#define	KMC_NODEBUG		UMA_ZONE_NODUMP
 #define	KMC_NOTOUCH		0
 
 typedef struct kmem_cache {
diff -r 2c7e9f76c40e -r 304c0fd1146a head/sys/cddl/compat/opensolaris/sys/sid.h
--- a/head/sys/cddl/compat/opensolaris/sys/sid.h	Wed Feb 01 11:52:38 2012 +0200
+++ b/head/sys/cddl/compat/opensolaris/sys/sid.h	Wed Feb 01 11:52:48 2012 +0200
@@ -23,14 +23,14 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $FreeBSD$
+ * $FreeBSD: head/sys/cddl/compat/opensolaris/sys/sid.h 230454 2012-01-22 10:58:17Z pjd $
  */
 
 #ifndef _OPENSOLARIS_SYS_SID_H_
 #define	_OPENSOLARIS_SYS_SID_H_
 
 typedef struct ksiddomain {
-	char	kd_name[16];	/* Domain part of SID */
+	char	kd_name[1];	/* Domain part of SID */
 } ksiddomain_t;
 typedef void	ksid_t;
 
@@ -39,8 +39,8 @@
 {
 	ksiddomain_t *kd;
 
-	kd = kmem_alloc(sizeof(*kd), KM_SLEEP);
-	strlcpy(kd->kd_name, "FreeBSD", sizeof(kd->kd_name));
+	kd = kmem_alloc(sizeof(*kd) + strlen(domain), KM_SLEEP);
+	strcpy(kd->kd_name, domain);
 	return (kd);
 }
 
diff -r 2c7e9f76c40e -r 304c0fd1146a head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dnode.c
--- a/head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dnode.c	Wed Feb 01 11:52:38 2012 +0200
+++ b/head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dnode.c	Wed Feb 01 11:52:48 2012 +0200
@@ -1077,7 +1077,7 @@
 	if (children_dnodes == NULL) {
 		int i;
 		dnode_children_t *winner;
-		children_dnodes = kmem_alloc(sizeof (dnode_children_t) +
+		children_dnodes = kmem_zalloc(sizeof (dnode_children_t) +
 		    (epb - 1) * sizeof (dnode_handle_t), KM_SLEEP);
 		children_dnodes->dnc_count = epb;
 		dnh = &children_dnodes->dnc_children[0];
diff -r 2c7e9f76c40e -r 304c0fd1146a head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/metaslab.c
--- a/head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/metaslab.c	Wed Feb 01 11:52:38 2012 +0200
+++ b/head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/metaslab.c	Wed Feb 01 11:52:48 2012 +0200
@@ -20,7 +20,7 @@
  */
 /*
  * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
- * Copyright (c) 2011 by Delphix. All rights reserved.
+ * Copyright (c) 2012 by Delphix. All rights reserved.
  */
 
 #include <sys/zfs_context.h>
@@ -36,7 +36,7 @@
  * avoid having to load lots of space_maps in a given txg. There are,
  * however, some cases where we want to avoid "fast" ganging and instead
  * we want to do an exhaustive search of all metaslabs on this device.
- * Currently we don't allow any gang or dump device related allocations
+ * Currently we don't allow any gang, zil, or dump device related allocations
  * to "fast" gang.
  */
 #define	CAN_FASTGANG(flags) \
diff -r 2c7e9f76c40e -r 304c0fd1146a head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa.c
--- a/head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa.c	Wed Feb 01 11:52:38 2012 +0200
+++ b/head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa.c	Wed Feb 01 11:52:48 2012 +0200
@@ -1073,8 +1073,10 @@
 	}
 	spa->spa_spares.sav_count = 0;
 
-	for (i = 0; i < spa->spa_l2cache.sav_count; i++)
+	for (i = 0; i < spa->spa_l2cache.sav_count; i++) {
+		vdev_clear_stats(spa->spa_l2cache.sav_vdevs[i]);
 		vdev_free(spa->spa_l2cache.sav_vdevs[i]);
+	}
 	if (spa->spa_l2cache.sav_vdevs) {
 		kmem_free(spa->spa_l2cache.sav_vdevs,
 		    spa->spa_l2cache.sav_count * sizeof (void *));
@@ -1302,11 +1304,13 @@
 
 		vd = oldvdevs[i];
 		if (vd != NULL) {
+			ASSERT(vd->vdev_isl2cache);
+
 			if (spa_l2cache_exists(vd->vdev_guid, &pool) &&
 			    pool != 0ULL && l2arc_vdev_present(vd))
 				l2arc_remove_vdev(vd);
-			(void) vdev_close(vd);
-			spa_l2cache_remove(vd);
+			vdev_clear_stats(vd);
+			vdev_free(vd);
 		}
 	}
 
@@ -1949,7 +1953,7 @@
 	 */
 	if (type != SPA_IMPORT_ASSEMBLE) {
 		spa_config_enter(spa, SCL_ALL, FTAG, RW_WRITER);
-		error = vdev_validate(rvd);
+		error = vdev_validate(rvd, mosconfig);
 		spa_config_exit(spa, SCL_ALL, FTAG);
 
 		if (error != 0)
@@ -2818,6 +2822,7 @@
 		if ((strcmp(config, ZPOOL_CONFIG_L2CACHE) == 0) &&
 		    strcmp(vd->vdev_ops->vdev_op_type, VDEV_TYPE_DISK) != 0) {
 			error = ENOTBLK;
+			vdev_free(vd);
 			goto out;
 		}
 #endif
@@ -2927,10 +2932,6 @@
 		if (spa_l2cache_exists(vd->vdev_guid, &pool) &&
 		    pool != 0ULL && l2arc_vdev_present(vd))
 			l2arc_remove_vdev(vd);
-		if (vd->vdev_isl2cache)
-			spa_l2cache_remove(vd);
-		vdev_clear_stats(vd);
-		(void) vdev_close(vd);
 	}
 }
 
@@ -3929,7 +3930,7 @@
 	pvd = oldvd->vdev_parent;
 
 	if ((error = spa_config_parse(spa, &newrootvd, nvroot, NULL, 0,
-	    VDEV_ALLOC_ADD)) != 0)
+	    VDEV_ALLOC_ATTACH)) != 0)
 		return (spa_vdev_exit(spa, NULL, txg, EINVAL));
 
 	if (newrootvd->vdev_children != 1)
diff -r 2c7e9f76c40e -r 304c0fd1146a head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/vdev.h
--- a/head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/vdev.h	Wed Feb 01 11:52:38 2012 +0200
+++ b/head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/vdev.h	Wed Feb 01 11:52:48 2012 +0200
@@ -20,6 +20,7 @@
  */
 /*
  * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012 by Delphix. All rights reserved.
  */
 
 #ifndef _SYS_VDEV_H
@@ -48,7 +49,7 @@
 extern int vdev_open(vdev_t *);
 extern void vdev_open_children(vdev_t *);
 extern boolean_t vdev_uses_zvols(vdev_t *);
-extern int vdev_validate(vdev_t *);
+extern int vdev_validate(vdev_t *, boolean_t);
 extern void vdev_close(vdev_t *);
 extern int vdev_create(vdev_t *, uint64_t txg, boolean_t isreplace);
 extern void vdev_reopen(vdev_t *);
diff -r 2c7e9f76c40e -r 304c0fd1146a head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/vdev_impl.h
--- a/head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/vdev_impl.h	Wed Feb 01 11:52:38 2012 +0200
+++ b/head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/vdev_impl.h	Wed Feb 01 11:52:48 2012 +0200
@@ -261,6 +261,7 @@
 #define	VDEV_ALLOC_L2CACHE	3
 #define	VDEV_ALLOC_ROOTPOOL	4
 #define	VDEV_ALLOC_SPLIT	5
+#define	VDEV_ALLOC_ATTACH	6
 
 /*
  * Allocate or free a vdev
diff -r 2c7e9f76c40e -r 304c0fd1146a head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zfs_ioctl.h
--- a/head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zfs_ioctl.h	Wed Feb 01 11:52:38 2012 +0200
+++ b/head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zfs_ioctl.h	Wed Feb 01 11:52:48 2012 +0200
@@ -300,7 +300,8 @@
 	boolean_t	zc_temphold;
 	uint64_t	zc_action_handle;
 	int		zc_cleanup_fd;
-	uint8_t		zc_pad[4];		/* alignment */
+	uint8_t		zc_simple;
+	uint8_t		zc_pad[3];		/* alignment */
 	uint64_t	zc_sendobj;
 	uint64_t	zc_fromobj;
 	uint64_t	zc_createtxg;
diff -r 2c7e9f76c40e -r 304c0fd1146a head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev.c
--- a/head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev.c	Wed Feb 01 11:52:38 2012 +0200
+++ b/head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev.c	Wed Feb 01 11:52:48 2012 +0200
@@ -499,7 +499,7 @@
 		    &vd->vdev_removing);
 	}
 
-	if (parent && !parent->vdev_parent) {
+	if (parent && !parent->vdev_parent && alloctype != VDEV_ALLOC_ATTACH) {
 		ASSERT(alloctype == VDEV_ALLOC_LOAD ||
 		    alloctype == VDEV_ALLOC_ADD ||
 		    alloctype == VDEV_ALLOC_SPLIT ||
@@ -675,6 +675,8 @@
 	svd->vdev_ms_shift = 0;
 	svd->vdev_ms_count = 0;
 
+	if (tvd->vdev_mg)
+		ASSERT3P(tvd->vdev_mg, ==, svd->vdev_mg);
 	tvd->vdev_mg = svd->vdev_mg;
 	tvd->vdev_ms = svd->vdev_ms;
 
@@ -1294,13 +1296,18 @@
  * contents.  This needs to be done before vdev_load() so that we don't
  * inadvertently do repair I/Os to the wrong device.
  *
+ * If 'strict' is false ignore the spa guid check. This is necessary because
+ * if the machine crashed during a re-guid the new guid might have been written
+ * to all of the vdev labels, but not the cached config. The strict check
+ * will be performed when the pool is opened again using the mos config.
+ *
  * This function will only return failure if one of the vdevs indicates that it
  * has since been destroyed or exported.  This is only possible if
  * /etc/zfs/zpool.cache was readonly at the time.  Otherwise, the vdev state
  * will be updated but the function will return 0.
  */
 int
-vdev_validate(vdev_t *vd)
+vdev_validate(vdev_t *vd, boolean_t strict)
 {
 	spa_t *spa = vd->vdev_spa;
 	nvlist_t *label;
@@ -1308,7 +1315,7 @@
 	uint64_t state;
 
 	for (int c = 0; c < vd->vdev_children; c++)
-		if (vdev_validate(vd->vdev_child[c]) != 0)
+		if (vdev_validate(vd->vdev_child[c], strict) != 0)
 			return (EBADF);
 
 	/*
@@ -1338,8 +1345,9 @@
 			return (0);
 		}
 
-		if (nvlist_lookup_uint64(label, ZPOOL_CONFIG_POOL_GUID,
-		    &guid) != 0 || guid != spa_guid(spa)) {
+		if (strict && (nvlist_lookup_uint64(label,
+		    ZPOOL_CONFIG_POOL_GUID, &guid) != 0 ||
+		    guid != spa_guid(spa))) {
 			vdev_set_state(vd, B_FALSE, VDEV_STATE_CANT_OPEN,
 			    VDEV_AUX_CORRUPT_DATA);
 			nvlist_free(label);
@@ -1501,7 +1509,7 @@
 		    !l2arc_vdev_present(vd))
 			l2arc_add_vdev(spa, vd);
 	} else {
-		(void) vdev_validate(vd);
+		(void) vdev_validate(vd, B_TRUE);
 	}
 
 	/*
diff -r 2c7e9f76c40e -r 304c0fd1146a head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_fm.c
--- a/head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_fm.c	Wed Feb 01 11:52:38 2012 +0200
+++ b/head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_fm.c	Wed Feb 01 11:52:48 2012 +0200
@@ -23,6 +23,10 @@
  * Use is subject to license terms.
  */
 
+/*
+ * Copyright (c) 2012 by Delphix. All rights reserved.
+ */
+
 #include <sys/spa.h>
 #include <sys/spa_impl.h>
 #include <sys/vdev.h>
@@ -709,6 +713,10 @@
 
 	if (report->zcr_ereport == NULL) {
 		report->zcr_free(report->zcr_cbdata, report->zcr_cbinfo);
+		if (report->zcr_ckinfo != NULL) {
+			kmem_free(report->zcr_ckinfo,
+			    sizeof (*report->zcr_ckinfo));
+		}
 		kmem_free(report, sizeof (*report));
 		return;
 	}
diff -r 2c7e9f76c40e -r 304c0fd1146a head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ioctl.c
--- a/head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ioctl.c	Wed Feb 01 11:52:38 2012 +0200
+++ b/head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ioctl.c	Wed Feb 01 11:52:48 2012 +0200
@@ -20,7 +20,7 @@
  */
 /*
  * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
- * Copyright (c) 2011 Pawel Jakub Dawidek <pawel at dawidek.net>.
+ * Copyright (c) 2011-2012 Pawel Jakub Dawidek <pawel at dawidek.net>.
  * All rights reserved.
  * Portions Copyright 2011 Martin Matuska <mm at FreeBSD.org>
  * Copyright 2011 Nexenta Systems, Inc.  All rights reserved.
@@ -81,6 +81,12 @@
 
 CTASSERT(sizeof(zfs_cmd_t) < IOCPARM_MAX);
 
+static int snapshot_list_prefetch;
+SYSCTL_DECL(_vfs_zfs);
+TUNABLE_INT("vfs.zfs.snapshot_list_prefetch", &snapshot_list_prefetch);
+SYSCTL_INT(_vfs_zfs, OID_AUTO, snapshot_list_prefetch, CTLFLAG_RW,
+    &snapshot_list_prefetch, 0, "Prefetch data when listing snapshots");
+
 static struct cdev *zfsdev;
 
 extern void zfs_init(void);
@@ -2030,6 +2036,7 @@
  * zc_name		name of filesystem
  * zc_cookie		zap cursor
  * zc_nvlist_dst_size	size of buffer for property nvlist
+ * zc_simple		when set, only name is requested
  *
  * outputs:
  * zc_name		name of next snapshot
@@ -2044,7 +2051,7 @@
 	int error;
 
 top:
-	if (zc->zc_cookie == 0)
+	if (snapshot_list_prefetch && zc->zc_cookie == 0 && !zc->zc_simple)
 		(void) dmu_objset_find(zc->zc_name, dmu_objset_prefetch,
 		    NULL, DS_FIND_SNAPSHOTS);
 
@@ -2066,7 +2073,7 @@
 	    zc->zc_name + strlen(zc->zc_name), &zc->zc_obj, &zc->zc_cookie,
 	    NULL);
 
-	if (error == 0) {
+	if (error == 0 && !zc->zc_simple) {
 		dsl_dataset_t *ds;
 		dsl_pool_t *dp = os->os_dsl_dataset->ds_dir->dd_pool;
 
diff -r 2c7e9f76c40e -r 304c0fd1146a head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zio.c
--- a/head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zio.c	Wed Feb 01 11:52:38 2012 +0200
+++ b/head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zio.c	Wed Feb 01 11:52:48 2012 +0200
@@ -20,7 +20,7 @@
  */
 /*
  * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
- * Copyright (c) 2011 by Delphix. All rights reserved.
+ * Copyright (c) 2012 by Delphix. All rights reserved.
  */
 
 #include <sys/zfs_context.h>
@@ -42,6 +42,10 @@
 TUNABLE_INT("vfs.zfs.zio.use_uma", &zio_use_uma);
 SYSCTL_INT(_vfs_zfs_zio, OID_AUTO, use_uma, CTLFLAG_RDTUN, &zio_use_uma, 0,
     "Use uma(9) for ZIO allocations");
+static int zio_exclude_metadata = 0;
+TUNABLE_INT("vfs.zfs.zio.exclude_metadata", &zio_exclude_metadata);
+SYSCTL_INT(_vfs_zfs_zio, OID_AUTO, exclude_metadata, CTLFLAG_RDTUN, &zio_exclude_metadata, 0,
+    "Exclude metadata buffers from dumps as well");
 
 /*
  * ==========================================================================
@@ -148,7 +152,7 @@
 			(void) sprintf(name, "zio_data_buf_%lu", (ulong_t)size);
 			zio_data_buf_cache[c] = kmem_cache_create(name, size,
 			    align, NULL, NULL, NULL, NULL, NULL,
-			    cflags | KMC_NOTOUCH);
+			    cflags | KMC_NOTOUCH | KMC_NODEBUG);
 		}
 	}
 
@@ -217,13 +221,14 @@
 zio_buf_alloc(size_t size)
 {
 	size_t c = (size - 1) >> SPA_MINBLOCKSHIFT;
+	int flags = zio_exclude_metadata ? KM_NODEBUG : 0;
 
 	ASSERT(c < SPA_MAXBLOCKSIZE >> SPA_MINBLOCKSHIFT);
 
 	if (zio_use_uma)
 		return (kmem_cache_alloc(zio_buf_cache[c], KM_PUSHPAGE));
 	else
-		return (kmem_alloc(size, KM_SLEEP));
+		return (kmem_alloc(size, KM_SLEEP|flags));
 }
 
 /*
@@ -242,7 +247,7 @@
 	if (zio_use_uma)
 		return (kmem_cache_alloc(zio_data_buf_cache[c], KM_PUSHPAGE));
 	else
-		return (kmem_alloc(size, KM_SLEEP));
+		return (kmem_alloc(size, KM_SLEEP | KM_NODEBUG));
 }
 
 void
@@ -2235,13 +2240,22 @@
 
 	ASSERT(txg > spa_syncing_txg(spa));
 
-	if (use_slog)
+	/*
+	 * ZIL blocks are always contiguous (i.e. not gang blocks) so we
+	 * set the METASLAB_GANG_AVOID flag so that they don't "fast gang"
+	 * when allocating them.
+	 */
+	if (use_slog) {
 		error = metaslab_alloc(spa, spa_log_class(spa), size,
-		    new_bp, 1, txg, old_bp, METASLAB_HINTBP_AVOID);
-
-	if (error)
+		    new_bp, 1, txg, old_bp,
+		    METASLAB_HINTBP_AVOID | METASLAB_GANG_AVOID);
+	}
+
+	if (error) {
 		error = metaslab_alloc(spa, spa_normal_class(spa), size,
-		    new_bp, 1, txg, old_bp, METASLAB_HINTBP_AVOID);
+		    new_bp, 1, txg, old_bp,
+		    METASLAB_HINTBP_AVOID | METASLAB_GANG_AVOID);
+	}
 
 	if (error == 0) {
 		BP_SET_LSIZE(new_bp, size);


More information about the Zrouter-src-freebsd mailing list