[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:56 UTC 2012


details:   http://zrouter.org/hg/FreeBSD/head//rev/625a24901dfe
changeset: 322:625a24901dfe
user:      ray at terran.dlink.ua
date:      Wed Feb 01 11:55:09 2012 +0200
description:
Update cddl

diffstat:

 head/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/pid/err.D_PROC_CREATEFAIL.many.exe |   2 +-
 head/cddl/contrib/opensolaris/cmd/zfs/zfs_iter.c                                            |  32 +++++++++-
 head/cddl/contrib/opensolaris/cmd/zfs/zfs_iter.h                                            |   2 +
 head/cddl/contrib/opensolaris/cmd/zfs/zfs_main.c                                            |  29 ++++++--
 head/cddl/contrib/opensolaris/lib/libzfs/common/libzfs.h                                    |   4 +-
 head/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_dataset.c                            |  20 +++++-
 head/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_impl.h                               |   2 +-
 head/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_iter.c                               |  25 +++++--
 head/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_sendrecv.c                           |   4 +-
 head/cddl/contrib/opensolaris/lib/libzpool/common/sys/zfs_context.h                         |   1 +
 10 files changed, 96 insertions(+), 25 deletions(-)

diffs (357 lines):

diff -r 1feeeb6fe234 -r 625a24901dfe head/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/pid/err.D_PROC_CREATEFAIL.many.exe
--- a/head/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/pid/err.D_PROC_CREATEFAIL.many.exe	Wed Feb 01 11:54:53 2012 +0200
+++ b/head/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/pid/err.D_PROC_CREATEFAIL.many.exe	Wed Feb 01 11:55:09 2012 +0200
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/bin/sh
 #
 # CDDL HEADER START
 #
diff -r 1feeeb6fe234 -r 625a24901dfe head/cddl/contrib/opensolaris/cmd/zfs/zfs_iter.c
--- a/head/cddl/contrib/opensolaris/cmd/zfs/zfs_iter.c	Wed Feb 01 11:54:53 2012 +0200
+++ b/head/cddl/contrib/opensolaris/cmd/zfs/zfs_iter.c	Wed Feb 01 11:55:09 2012 +0200
@@ -20,6 +20,8 @@
  */
 /*
  * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012 Pawel Jakub Dawidek <pawel at dawidek.net>.
+ * All rights reserved.
  */
 
 #include <libintl.h>
@@ -129,8 +131,11 @@
 		cb->cb_depth++;
 		if (zfs_get_type(zhp) == ZFS_TYPE_FILESYSTEM)
 			(void) zfs_iter_filesystems(zhp, zfs_callback, data);
-		if ((zfs_get_type(zhp) != ZFS_TYPE_SNAPSHOT) && include_snaps)
-			(void) zfs_iter_snapshots(zhp, zfs_callback, data);
+		if ((zfs_get_type(zhp) != ZFS_TYPE_SNAPSHOT) && include_snaps) {
+			(void) zfs_iter_snapshots(zhp,
+			    (cb->cb_flags & ZFS_ITER_SIMPLE) != 0, zfs_callback,
+			    data);
+		}
 		cb->cb_depth--;
 	}
 
@@ -184,6 +189,14 @@
 	}
 }
 
+boolean_t
+zfs_sort_only_by_name(const zfs_sort_column_t *sc)
+{
+
+	return (sc != NULL && sc->sc_next == NULL &&
+	    sc->sc_prop == ZFS_PROP_NAME);
+}
+
 /* ARGSUSED */
 static int
 zfs_compare(const void *larg, const void *rarg, void *unused)
@@ -224,7 +237,13 @@
 			lcreate = zfs_prop_get_int(l, ZFS_PROP_CREATETXG);
 			rcreate = zfs_prop_get_int(r, ZFS_PROP_CREATETXG);
 
-			if (lcreate < rcreate)
+			/*
+			 * Both lcreate and rcreate being 0 means we don't have
+			 * properties and we should compare full name.
+			 */
+			if (lcreate == 0 && rcreate == 0)
+				ret = strcmp(lat + 1, rat + 1);
+			else if (lcreate < rcreate)
 				ret = -1;
 			else if (lcreate > rcreate)
 				ret = 1;
@@ -290,7 +309,14 @@
 			if (rvalid)
 				verify(nvlist_lookup_string(rval,
 				    ZPROP_VALUE, &rstr) == 0);
+		} else if (psc->sc_prop == ZFS_PROP_NAME) {
+			lvalid = rvalid = B_TRUE;
 
+			(void) strlcpy(lbuf, zfs_get_name(l), sizeof(lbuf));
+			(void) strlcpy(rbuf, zfs_get_name(r), sizeof(rbuf));
+
+			lstr = lbuf;
+			rstr = rbuf;
 		} else if (zfs_prop_is_string(psc->sc_prop)) {
 			lvalid = (zfs_prop_get(l, psc->sc_prop, lbuf,
 			    sizeof (lbuf), NULL, NULL, 0, B_TRUE) == 0);
diff -r 1feeeb6fe234 -r 625a24901dfe head/cddl/contrib/opensolaris/cmd/zfs/zfs_iter.h
--- a/head/cddl/contrib/opensolaris/cmd/zfs/zfs_iter.h	Wed Feb 01 11:54:53 2012 +0200
+++ b/head/cddl/contrib/opensolaris/cmd/zfs/zfs_iter.h	Wed Feb 01 11:55:09 2012 +0200
@@ -43,11 +43,13 @@
 #define	ZFS_ITER_PROP_LISTSNAPS    (1 << 2)
 #define	ZFS_ITER_DEPTH_LIMIT	   (1 << 3)
 #define	ZFS_ITER_RECVD_PROPS	   (1 << 4)
+#define	ZFS_ITER_SIMPLE		   (1 << 5)
 
 int zfs_for_each(int, char **, int options, zfs_type_t,
     zfs_sort_column_t *, zprop_list_t **, int, zfs_iter_f, void *);
 int zfs_add_sort_column(zfs_sort_column_t **, const char *, boolean_t);
 void zfs_free_sort_columns(zfs_sort_column_t *);
+boolean_t zfs_sort_only_by_name(const zfs_sort_column_t *);
 
 #ifdef	__cplusplus
 }
diff -r 1feeeb6fe234 -r 625a24901dfe head/cddl/contrib/opensolaris/cmd/zfs/zfs_main.c
--- a/head/cddl/contrib/opensolaris/cmd/zfs/zfs_main.c	Wed Feb 01 11:54:53 2012 +0200
+++ b/head/cddl/contrib/opensolaris/cmd/zfs/zfs_main.c	Wed Feb 01 11:55:09 2012 +0200
@@ -21,9 +21,10 @@
 
 /*
  * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
- * Copyright 2011 Nexenta Systems, Inc. All rights reserved.
+ * Copyright 2012 Nexenta Systems, Inc. All rights reserved.
  * Copyright (c) 2011 by Delphix. 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.
  * Copyright (c) 2011 Martin Matuska <mm at FreeBSD.org>. All rights reserved.
  */
 
@@ -2837,7 +2838,12 @@
 			first = B_FALSE;
 		}
 
-		if (pl->pl_prop != ZPROP_INVAL) {
+		if (pl->pl_prop == ZFS_PROP_NAME) {
+			(void) strlcpy(property, zfs_get_name(zhp),
+			    sizeof(property));
+			propstr = property;
+			right_justify = zfs_prop_align_right(pl->pl_prop);
+		} else if (pl->pl_prop != ZPROP_INVAL) {
 			if (zfs_prop_get(zhp, pl->pl_prop, property,
 			    sizeof (property), NULL, NULL, 0, B_FALSE) != 0)
 				propstr = "-";
@@ -3004,6 +3010,13 @@
 		fields = default_fields;
 
 	/*
+	 * If we are only going to list snapshot names and sort by name,
+	 * then we can use faster version.
+	 */
+	if (strcmp(fields, "name") == 0 && zfs_sort_only_by_name(sortcol))
+		flags |= ZFS_ITER_SIMPLE;
+
+	/*
 	 * If "-o space" and no types were specified, don't display snapshots.
 	 */
 	if (strcmp(fields, "space") == 0 && types_specified == B_FALSE)
@@ -4488,7 +4501,7 @@
 		argc--;
 		argv++;
 		opts->dataset = munge_args(argc, argv, un, 2, &opts->perms);
-	} else if (argc == 1) {
+	} else if (argc == 1 && !un) {
 		opts->prt_perms = B_TRUE;
 		opts->dataset = argv[argc-1];
 	} else {
@@ -4975,9 +4988,9 @@
 	parse_allow_args(argc, argv, un, &opts);
 
 	/* try to open the dataset */
-	if ((zhp = zfs_open(g_zfs, opts.dataset, ZFS_TYPE_FILESYSTEM))
-	    == NULL) {
-		(void) fprintf(stderr, "Failed to open Dataset *%s*\n",
+	if ((zhp = zfs_open(g_zfs, opts.dataset, ZFS_TYPE_FILESYSTEM |
+	    ZFS_TYPE_VOLUME)) == NULL) {
+		(void) fprintf(stderr, "Failed to open dataset: %s\n",
 		    opts.dataset);
 		return (-1);
 	}
@@ -4987,7 +5000,7 @@
 
 	fs_perm_set_init(&fs_perm_set);
 	if (parse_fs_perm_set(&fs_perm_set, perm_nvl) != 0) {
-		(void) fprintf(stderr, "Failed to parse fsacl permissionsn");
+		(void) fprintf(stderr, "Failed to parse fsacl permissions\n");
 		goto cleanup1;
 	}
 
diff -r 1feeeb6fe234 -r 625a24901dfe head/cddl/contrib/opensolaris/lib/libzfs/common/libzfs.h
--- a/head/cddl/contrib/opensolaris/lib/libzfs/common/libzfs.h	Wed Feb 01 11:54:53 2012 +0200
+++ b/head/cddl/contrib/opensolaris/lib/libzfs/common/libzfs.h	Wed Feb 01 11:55:09 2012 +0200
@@ -22,6 +22,8 @@
 /*
  * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
  * Copyright 2011 Nexenta Systems, Inc. All rights reserved.
+ * Copyright (c) 2011 Pawel Jakub Dawidek <pawel at dawidek.net>.
+ * All rights reserved.
  * Copyright (c) 2011 by Delphix. All rights reserved.
  * All rights reserved.
  */
@@ -505,7 +507,7 @@
 extern int zfs_iter_children(zfs_handle_t *, zfs_iter_f, void *);
 extern int zfs_iter_dependents(zfs_handle_t *, boolean_t, zfs_iter_f, void *);
 extern int zfs_iter_filesystems(zfs_handle_t *, zfs_iter_f, void *);
-extern int zfs_iter_snapshots(zfs_handle_t *, zfs_iter_f, void *);
+extern int zfs_iter_snapshots(zfs_handle_t *, boolean_t, zfs_iter_f, void *);
 extern int zfs_iter_snapshots_sorted(zfs_handle_t *, zfs_iter_f, void *);
 extern int zfs_iter_snapspec(zfs_handle_t *, const char *, zfs_iter_f, void *);
 
diff -r 1feeeb6fe234 -r 625a24901dfe head/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_dataset.c
--- a/head/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_dataset.c	Wed Feb 01 11:54:53 2012 +0200
+++ b/head/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_dataset.c	Wed Feb 01 11:55:09 2012 +0200
@@ -23,7 +23,7 @@
  * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
  * Copyright 2010 Nexenta Systems, Inc. All rights reserved.
  * Copyright (c) 2011 by Delphix. 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.
  */
 
@@ -514,6 +514,22 @@
 }
 
 zfs_handle_t *
+make_dataset_simple_handle_zc(zfs_handle_t *pzhp, zfs_cmd_t *zc)
+{
+	zfs_handle_t *zhp = calloc(sizeof (zfs_handle_t), 1);
+
+	if (zhp == NULL)
+		return (NULL);
+
+	zhp->zfs_hdl = pzhp->zfs_hdl;
+	(void) strlcpy(zhp->zfs_name, zc->zc_name, sizeof (zhp->zfs_name));
+	zhp->zfs_head_type = pzhp->zfs_type;
+	zhp->zfs_type = ZFS_TYPE_SNAPSHOT;
+	zhp->zpool_hdl = zpool_handle(zhp);
+	return (zhp);
+}
+
+zfs_handle_t *
 zfs_handle_dup(zfs_handle_t *zhp_orig)
 {
 	zfs_handle_t *zhp = calloc(sizeof (zfs_handle_t), 1);
@@ -4197,7 +4213,7 @@
 
 	(void) strlcpy(zc.zc_name, zhp->zfs_name, ZFS_MAXNAMELEN);
 
-	if (zfs_ioctl(hdl, ZFS_IOC_GET_FSACL, &zc) != 0) {
+	if (ioctl(hdl->libzfs_fd, ZFS_IOC_GET_FSACL, &zc) != 0) {
 		(void) snprintf(errbuf, sizeof (errbuf),
 		    dgettext(TEXT_DOMAIN, "cannot get permissions on '%s'"),
 		    zc.zc_name);
diff -r 1feeeb6fe234 -r 625a24901dfe head/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_impl.h
--- a/head/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_impl.h	Wed Feb 01 11:54:53 2012 +0200
+++ b/head/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_impl.h	Wed Feb 01 11:55:09 2012 +0200
@@ -150,7 +150,7 @@
 int get_dependents(libzfs_handle_t *, boolean_t, const char *, char ***,
     size_t *);
 zfs_handle_t *make_dataset_handle_zc(libzfs_handle_t *, zfs_cmd_t *);
-
+zfs_handle_t *make_dataset_simple_handle_zc(zfs_handle_t *, zfs_cmd_t *);
 
 int zprop_parse_value(libzfs_handle_t *, nvpair_t *, int, zfs_type_t,
     nvlist_t *, char **, uint64_t *, const char *);
diff -r 1feeeb6fe234 -r 625a24901dfe head/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_iter.c
--- a/head/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_iter.c	Wed Feb 01 11:54:53 2012 +0200
+++ b/head/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_iter.c	Wed Feb 01 11:55:09 2012 +0200
@@ -23,6 +23,8 @@
  * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
  * Copyright 2010 Nexenta Systems, Inc. All rights reserved.
  * Copyright (c) 2011 by Delphix. All rights reserved.
+ * Copyright (c) 2012 Pawel Jakub Dawidek <pawel at dawidek.net>.
+ * All rights reserved.
  */
 
 #include <stdio.h>
@@ -137,7 +139,8 @@
  * Iterate over all snapshots
  */
 int
-zfs_iter_snapshots(zfs_handle_t *zhp, zfs_iter_f func, void *data)
+zfs_iter_snapshots(zfs_handle_t *zhp, boolean_t simple, zfs_iter_f func,
+    void *data)
 {
 	zfs_cmd_t zc = { 0 };
 	zfs_handle_t *nzhp;
@@ -146,15 +149,19 @@
 	if (zhp->zfs_type == ZFS_TYPE_SNAPSHOT)
 		return (0);
 
+	zc.zc_simple = simple;
+
 	if (zcmd_alloc_dst_nvlist(zhp->zfs_hdl, &zc, 0) != 0)
 		return (-1);
 	while ((ret = zfs_do_list_ioctl(zhp, ZFS_IOC_SNAPSHOT_LIST_NEXT,
 	    &zc)) == 0) {
 
-		if ((nzhp = make_dataset_handle_zc(zhp->zfs_hdl,
-		    &zc)) == NULL) {
+		if (simple)
+			nzhp = make_dataset_simple_handle_zc(zhp, &zc);
+		else
+			nzhp = make_dataset_handle_zc(zhp->zfs_hdl, &zc);
+		if (nzhp == NULL)
 			continue;
-		}
 
 		if ((ret = func(nzhp, data)) != 0) {
 			zcmd_free_nvlists(&zc);
@@ -234,7 +241,7 @@
 	avl_create(&avl, zfs_snapshot_compare,
 	    sizeof (zfs_node_t), offsetof(zfs_node_t, zn_avlnode));
 
-	ret = zfs_iter_snapshots(zhp, zfs_sort_snaps, &avl);
+	ret = zfs_iter_snapshots(zhp, B_FALSE, zfs_sort_snaps, &avl);
 
 	for (node = avl_first(&avl); node != NULL; node = AVL_NEXT(&avl, node))
 		ret |= callback(node->zn_handle, data);
@@ -378,7 +385,7 @@
 	if ((ret = zfs_iter_filesystems(zhp, func, data)) != 0)
 		return (ret);
 
-	return (zfs_iter_snapshots(zhp, func, data));
+	return (zfs_iter_snapshots(zhp, B_FALSE, func, data));
 }
 
 
@@ -439,8 +446,10 @@
 		isf.next = ida->stack;
 		ida->stack = &isf;
 		err = zfs_iter_filesystems(zhp, iter_dependents_cb, ida);
-		if (err == 0)
-			err = zfs_iter_snapshots(zhp, iter_dependents_cb, ida);
+		if (err == 0) {
+			err = zfs_iter_snapshots(zhp, B_FALSE,
+			    iter_dependents_cb, ida);
+		}
 		ida->stack = isf.next;
 	}
 	if (!first && err == 0)
diff -r 1feeeb6fe234 -r 625a24901dfe head/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_sendrecv.c
--- a/head/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_sendrecv.c	Wed Feb 01 11:54:53 2012 +0200
+++ b/head/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_sendrecv.c	Wed Feb 01 11:55:09 2012 +0200
@@ -22,6 +22,8 @@
 /*
  * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
  * Copyright (c) 2011 by Delphix. All rights reserved.
+ * Copyright (c) 2012 Pawel Jakub Dawidek <pawel at dawidek.net>.
+ * All rights reserved.
  */
 
 #include <assert.h>
@@ -717,7 +719,7 @@
 	sd->parent_fromsnap_guid = 0;
 	VERIFY(0 == nvlist_alloc(&sd->parent_snaps, NV_UNIQUE_NAME, 0));
 	VERIFY(0 == nvlist_alloc(&sd->snapprops, NV_UNIQUE_NAME, 0));
-	(void) zfs_iter_snapshots(zhp, send_iterate_snap, sd);
+	(void) zfs_iter_snapshots(zhp, B_FALSE, send_iterate_snap, sd);
 	VERIFY(0 == nvlist_add_nvlist(nvfs, "snaps", sd->parent_snaps));
 	VERIFY(0 == nvlist_add_nvlist(nvfs, "snapprops", sd->snapprops));
 	nvlist_free(sd->parent_snaps);
diff -r 1feeeb6fe234 -r 625a24901dfe head/cddl/contrib/opensolaris/lib/libzpool/common/sys/zfs_context.h
--- a/head/cddl/contrib/opensolaris/lib/libzpool/common/sys/zfs_context.h	Wed Feb 01 11:54:53 2012 +0200
+++ b/head/cddl/contrib/opensolaris/lib/libzpool/common/sys/zfs_context.h	Wed Feb 01 11:55:09 2012 +0200
@@ -331,6 +331,7 @@
 #define	KM_NOSLEEP		UMEM_DEFAULT
 #define	KMC_NODEBUG		UMC_NODEBUG
 #define	KMC_NOTOUCH		0	/* not needed for userland caches */
+#define	KM_NODEBUG		0
 #define	kmem_alloc(_s, _f)	umem_alloc(_s, _f)
 #define	kmem_zalloc(_s, _f)	umem_zalloc(_s, _f)
 #define	kmem_free(_b, _s)	umem_free(_b, _s)


More information about the Zrouter-src-freebsd mailing list