Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 30 Nov 2012 22:38:42 +0000 (UTC)
From:      Martin Matuska <mm@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org
Subject:   svn commit: r243717 - in stable/8: . cddl/contrib/opensolaris/cmd/zdb cddl/contrib/opensolaris/cmd/zfs cddl/contrib/opensolaris/cmd/zhack cddl/contrib/opensolaris/cmd/zinject cddl/contrib/opensolar...
Message-ID:  <201211302238.qAUMcgrS067912@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: mm
Date: Fri Nov 30 22:38:42 2012
New Revision: 243717
URL: http://svnweb.freebsd.org/changeset/base/243717

Log:
  Merge ZFS feature flags support and related bugfixes:
  236884, 237001, 237119, 237458, 237972, 238113, 238391, 238422, 238926,
  238950, 238951, 239389, 239394, 239620, 239774, 239953, 239958, 239967,
  239968, 240063, 240133, 240153, 240303, 240345, 240415, 240955, 241655,
  243014, 243505, 243506
  
  MFC r236884:
  Introduce "feature flags" for ZFS pools (bump SPA version to 5000).
  Add first feature "com.delphix:async_destroy" (asynchronous destroy
  of ZFS datasets).
  Implement features support in ZFS boot code.
  
  Illumos revisions merged:
  13700:2889e2596bd6
  13701:1949b688d5fb
  2619 asynchronous destruction of ZFS file systems
  2747 SPA versioning with zfs feature flags
  
  References:
    https://www.illumos.org/issues/2619
    https://www.illumos.org/issues/2747
  
  MFC r237001:
  Fix ZFS boot with pre-features pools (version <= 28) broken in r236884
  
  MFC r237119 [1]:
  Do not remount ZFS dataset if changing canmount property to "on" and
  dataset is already mounted.
  
  MFC r237458:
  Import Illumos revision 13736:9f1d48e1681f
  2901 ZFS receive fails for exabyte sparse files
  
  References:
    https://www.illumos.org/issues/2901
  
  MFC r237972:
  Expose scrub and resilver tunables.
  This allows the user to tune the priority trade-off between scrub/resilver
  and other ZFS I/O.
  
  MFC r238113 (pjd):
  vdev_io_done stage is not used for ioctls.
  
  MFC r238391:
  Change behavior introduced in r237119 to vendor solution
  
  References:
    https://www.illumos.org/issues/2883
  
  MFC r238422:
  Merge illumos commit 13749:df4cd82e2b60
  
  1796 "ZFS HOLD" should not be used when doing "ZFS SEND" froma read-only pool
  2871 support for __ZFS_POOL_RESTRICT used by ZFS test suite
  2903 zfs destroy -d does not work
  2957 zfs destroy -R/r sometimes fails when removing defer-destroyed snapshot
  
  References:
    https://www.illumos.org/issues/1796
    https://www.illumos.org/issues/2871
    https://www.illumos.org/issues/2903
    https://www.illumos.org/issues/2957
  
  MFC r238926:
  Partial MFV (illumos-gate 13753:2aba784c276b)
  2762 zpool command should have better support for feature flags
  
  References:
    https://www.illumos.org/issues/2762
  
  MFC r238950:
  Fix reporting of root pool upgrade notice.
  
  MFC r238951:
  Fix wrong indent according to style(9)
  
  MFC r239389:
  Backport fix for vendor issue #3085
  3085 zfs diff panics, then panics in a loop on booting
  
  References:
    https://www.illumos.org/issues/3085
  
  MFC r239394:
  Update zfs(8) manpage with illumos version of "zfs diff"
  
  Illumos issue:
    2399 zfs manual page does not document use of "zfs diff"
  
  References:
    https://www.illumos.org/issues/2399
  
  MFC r239620 [2]:
  Merge recent vendor changes:
  3086 unnecessarily setting DS_FLAG_INCONSISTENT on async destroyed datasets
  3090 vdev_reopen() during reguid causes vdev to be treated as corrupt
  3102 vdev_uberblock_load() and vdev_validate() may read the wrong label
  
  Referenes:
    https://www.illumos.org/issues/3086
    https://www.illumos.org/issues/3090
    https://www.illumos.org/issues/3102
  
  MFC r239774:
  Merge recent vendor changes:
  3100 zvol rename fails with EBUSY when dirty
  3104 eliminate empty bpobjs
  3120 zinject hangs in zfsdev_ioctl() due to uninitialized zc
  
  References:
    https://www.illumos.org/issues/3100
    https://www.illumos.org/issues/3104
    https://www.illumos.org/issues/3120
  
  MFC r239953 (joel):
  Mdoc fixes.
  
  MFC r239958 (joel):
  Minor mdoc fixes.
  
  MFC r239967 (joel):
  Mdoc fixes.
  
  MFC r239968 (joel):
  Remove trailing whitespace.
  
  MFC r240063 (gjb):
  Add myself to copyright sections, per CDDL license.
  
  MFC r240133:
  Merge recent vendor changes and sync code:
  1862 incremental zfs receive fails for sparse file > 8PB
  3112 ztest does not honor ZFS_DEBUG
  3122 zfs destroy filesystem should prefetch blocks
  3129 'zpool reopen' restarts resilvers
  3130 ztest failure: Assertion failed:
         0 == dmu_objset_destroy(name, B_FALSE) (0x0 == 0x10)
  
  References:
    https://www.illumos.org/issues/1862
    https://www.illumos.org/issues/3112
    https://www.illumos.org/issues/3122
    https://www.illumos.org/issues/3129
    https://www.illumos.org/issues/3130
  
  MFC r240153 (gjb) [3]:
  Typo fix and minor word swap.
  
  MFC r240303:
  Add assfail() and assfail3() to the opensolaris module.
  Remove obsoleted intermediate cddl/compat/opensolaris/sys/debug.h.
  
  MFC r240345 (avg):
  zfs: fix sa_modify_attrs handling of variable-sized attributes
  
  - skip length_idx index for a replaced variable-sized attribute
  - skip length_idx index for a removed variable-sized attribute
  - also re-arranged code to make sure that length_idx is always
    incremented for variable-sized attributes
  - additionally add an assertion that the number of actually produced
    attributes is the same as the expected number of resulting
    attributes
  
  MFC r240415:
  Merge recent zfs vendor changes, sync code and adjust userland DEBUG.
  
  Illumos issued covered:
  1884 Empty "used" field for zfs *space commands
  3006 VERIFY[S,U,P] and ASSERT[S,U,P] frequently check if first argument
       is zero
  3028 zfs {group,user}space -n prints (null) instead of numeric GID/UID
  3048 zfs {user,group}space [-s|-S] is broken
  3049 zfs {user,group}space -t doesn't really filter the results
  3060 zfs {user,group}space -H output isn't tab-delimited
  3061 zfs {user,group}space -o doesn't use specified fields order
  3064 usr/src/cmd/zpool/zpool_main.c misspells "successful"
  3093 zfs {user,group}space's -i is noop
  3098 zfs userspace/groupspace fail without saying why when run as non-root
  
  References:
    https://www.illumos.org/issues/ + [issue_id]
  
  MFC r240955 (partial):
  Merge recent vendor changes in ZFS.
  
  Illumos issued covered:
  3139 zdb dies when it tries to determine path of unlinked file
  3189 kernel panic in ZFS test suite during hotspare_onoffline_004_neg
  3208 moving zpool cross-endian results in incorrect user/group accounting
  
  References:
    https://www.illumos.org/issues/ + [issue_id]
  
  MFC r241655:
  Add missing initialization for do_prefix.
  Corrects porting error in r238391
  
  Vendor issue and changeset reference:
  2883 changing "canmount" property to "on" should not always remount dataset
  https://www.illumos.org/issues/2883
  Changeset 13743:95aba6e49b9f
  
  MFC r243014:
  Move zpool-features manual page from section 5 to section 7
  and fix references
  
  Reported by:	pluknet
  
  MFC r243505:
  Illumos 13886:e3261d03efbf
  
  3349 zpool upgrade -V bumps the on disk version number, but leaves
       the in core version
  
  References:
    https://www.illumos.org/issues/3349
  
  MFC r243506:
  zfs sha256 checksum is missing in zfs.8 manpage
  
  PR:	kern/167905 [1], kern/170912 [2], kern/170914 [2], doc/171356 [3]

Added:
  stable/8/cddl/contrib/opensolaris/cmd/zhack/
     - copied from r236884, head/cddl/contrib/opensolaris/cmd/zhack/
  stable/8/cddl/contrib/opensolaris/cmd/zpool/zpool-features.7
     - copied unchanged from r243014, head/cddl/contrib/opensolaris/cmd/zpool/zpool-features.7
  stable/8/cddl/usr.sbin/zhack/
     - copied from r236884, head/cddl/usr.sbin/zhack/
  stable/8/sys/cddl/compat/opensolaris/sys/assfail.h
     - copied, changed from r240303, head/sys/cddl/compat/opensolaris/sys/assfail.h
  stable/8/sys/cddl/contrib/opensolaris/common/nvpair/fnvpair.c
     - copied, changed from r236884, head/sys/cddl/contrib/opensolaris/common/nvpair/fnvpair.c
  stable/8/sys/cddl/contrib/opensolaris/common/zfs/zfeature_common.c
     - copied, changed from r236884, head/sys/cddl/contrib/opensolaris/common/zfs/zfeature_common.c
  stable/8/sys/cddl/contrib/opensolaris/common/zfs/zfeature_common.h
     - copied, changed from r236884, head/sys/cddl/contrib/opensolaris/common/zfs/zfeature_common.h
  stable/8/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/bptree.c
     - copied, changed from r236884, head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/bptree.c
  stable/8/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/bptree.h
     - copied unchanged from r236884, head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/bptree.h
  stable/8/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zfeature.h
     - copied, changed from r236884, head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zfeature.h
  stable/8/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfeature.c
     - copied, changed from r236884, head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfeature.c
Replaced:
  stable/8/sys/cddl/compat/opensolaris/sys/debug.h
     - copied unchanged from r240415, head/sys/cddl/compat/opensolaris/sys/debug.h
Modified:
  stable/8/Makefile.inc1   (contents, props changed)
  stable/8/UPDATING
  stable/8/cddl/contrib/opensolaris/cmd/zdb/zdb.8
  stable/8/cddl/contrib/opensolaris/cmd/zdb/zdb.c
  stable/8/cddl/contrib/opensolaris/cmd/zfs/zfs.8
  stable/8/cddl/contrib/opensolaris/cmd/zfs/zfs_main.c
  stable/8/cddl/contrib/opensolaris/cmd/zinject/zinject.c
  stable/8/cddl/contrib/opensolaris/cmd/zpool/zpool.8
  stable/8/cddl/contrib/opensolaris/cmd/zpool/zpool_main.c
  stable/8/cddl/contrib/opensolaris/cmd/ztest/ztest.c
  stable/8/cddl/contrib/opensolaris/lib/libnvpair/libnvpair.c
  stable/8/cddl/contrib/opensolaris/lib/libuutil/common/uu_misc.c
  stable/8/cddl/contrib/opensolaris/lib/libzfs/common/libzfs.h
  stable/8/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_config.c
  stable/8/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_dataset.c
  stable/8/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_import.c
  stable/8/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_pool.c
  stable/8/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_sendrecv.c
  stable/8/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_status.c
  stable/8/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_util.c
  stable/8/cddl/contrib/opensolaris/lib/libzpool/common/kernel.c
  stable/8/cddl/contrib/opensolaris/lib/libzpool/common/sys/zfs_context.h
  stable/8/cddl/lib/libnvpair/Makefile
  stable/8/cddl/lib/libzfs/Makefile
  stable/8/cddl/lib/libzpool/Makefile
  stable/8/cddl/sbin/zpool/Makefile
  stable/8/cddl/usr.bin/ztest/Makefile
  stable/8/cddl/usr.sbin/Makefile
  stable/8/cddl/usr.sbin/zdb/Makefile
  stable/8/cddl/usr.sbin/zhack/Makefile
  stable/8/rescue/rescue/Makefile
  stable/8/sys/boot/zfs/zfsimpl.c
  stable/8/sys/cddl/boot/zfs/zfsimpl.h
  stable/8/sys/cddl/compat/opensolaris/kern/opensolaris_cmn_err.c
  stable/8/sys/cddl/contrib/opensolaris/common/zfs/zpool_prop.c
  stable/8/sys/cddl/contrib/opensolaris/uts/common/Makefile.files
  stable/8/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c
  stable/8/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/bpobj.c
  stable/8/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dbuf.c
  stable/8/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/ddt.c
  stable/8/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu.c
  stable/8/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu_objset.c
  stable/8/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu_send.c
  stable/8/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu_traverse.c
  stable/8/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu_tx.c
  stable/8/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dnode.c
  stable/8/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dnode_sync.c
  stable/8/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_dataset.c
  stable/8/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_deadlist.c
  stable/8/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_deleg.c
  stable/8/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_dir.c
  stable/8/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_pool.c
  stable/8/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_scan.c
  stable/8/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_synctask.c
  stable/8/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/metaslab.c
  stable/8/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sa.c
  stable/8/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa.c
  stable/8/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa_config.c
  stable/8/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa_history.c
  stable/8/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa_misc.c
  stable/8/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/space_map.c
  stable/8/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/arc.h
  stable/8/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/bpobj.h
  stable/8/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/dmu.h
  stable/8/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/dmu_objset.h
  stable/8/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/dmu_traverse.h
  stable/8/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/dnode.h
  stable/8/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/dsl_dataset.h
  stable/8/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/dsl_pool.h
  stable/8/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/dsl_scan.h
  stable/8/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/sa_impl.h
  stable/8/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/spa.h
  stable/8/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/spa_impl.h
  stable/8/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/txg.h
  stable/8/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/vdev.h
  stable/8/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/vdev_impl.h
  stable/8/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zap.h
  stable/8/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zfs_debug.h
  stable/8/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zil.h
  stable/8/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zil_impl.h
  stable/8/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zio.h
  stable/8/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zio_impl.h
  stable/8/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/txg.c
  stable/8/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev.c
  stable/8/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_label.c
  stable/8/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_raidz.c
  stable/8/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zap.c
  stable/8/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zap_micro.c
  stable/8/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_debug.c
  stable/8/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ioctl.c
  stable/8/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_rlock.c
  stable/8/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vfsops.c
  stable/8/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c
  stable/8/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_znode.c
  stable/8/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zil.c
  stable/8/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zio.c
  stable/8/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zvol.c
  stable/8/sys/cddl/contrib/opensolaris/uts/common/sys/debug.h
  stable/8/sys/cddl/contrib/opensolaris/uts/common/sys/fs/zfs.h
  stable/8/sys/cddl/contrib/opensolaris/uts/common/sys/nvpair.h
  stable/8/sys/modules/zfs/Makefile
Directory Properties:
  stable/8/cddl/   (props changed)
  stable/8/cddl/contrib/opensolaris/   (props changed)
  stable/8/cddl/contrib/opensolaris/cmd/zfs/   (props changed)
  stable/8/cddl/contrib/opensolaris/lib/libzfs/   (props changed)
  stable/8/cddl/lib/   (props changed)
  stable/8/cddl/lib/libnvpair/   (props changed)
  stable/8/cddl/lib/libzpool/   (props changed)
  stable/8/cddl/sbin/   (props changed)
  stable/8/cddl/usr.bin/   (props changed)
  stable/8/cddl/usr.sbin/   (props changed)
  stable/8/rescue/rescue/   (props changed)
  stable/8/sys/   (props changed)
  stable/8/sys/boot/   (props changed)
  stable/8/sys/cddl/   (props changed)
  stable/8/sys/cddl/contrib/opensolaris/   (props changed)
  stable/8/sys/modules/   (props changed)

Modified: stable/8/Makefile.inc1
==============================================================================
--- stable/8/Makefile.inc1	Fri Nov 30 22:33:21 2012	(r243716)
+++ stable/8/Makefile.inc1	Fri Nov 30 22:38:42 2012	(r243717)
@@ -1120,7 +1120,7 @@ _prebuild_libs=	${_kerberos5_lib_libasn1
 		lib/ncurses/ncurses lib/ncurses/ncursesw \
 		lib/libopie lib/libpam ${_lib_libthr} \
 		lib/libradius lib/libsbuf lib/libtacplus \
-		${_cddl_lib_libumem} \
+		${_cddl_lib_libumem} ${_cddl_lib_libnvpair} \
 		lib/libutil ${_lib_libypclnt} lib/libz lib/msun \
 		${_secure_lib_libcrypto} ${_secure_lib_libssh} \
 		${_secure_lib_libssl}
@@ -1135,6 +1135,7 @@ lib/libopie__L lib/libtacplus__L: lib/li
 
 .if ${MK_CDDL} != "no"
 _cddl_lib_libumem= cddl/lib/libumem
+_cddl_lib_libnvpair= cddl/lib/libnvpair
 _cddl_lib= cddl/lib
 .endif
 

Modified: stable/8/UPDATING
==============================================================================
--- stable/8/UPDATING	Fri Nov 30 22:33:21 2012	(r243716)
+++ stable/8/UPDATING	Fri Nov 30 22:38:42 2012	(r243717)
@@ -15,6 +15,17 @@ NOTE TO PEOPLE WHO THINK THAT FreeBSD 8.
 	debugging tools present in HEAD were left in place because
 	sun4v support still needs work to become production ready.
 
+20121130:
+	A new version of ZFS (pool version 5000) has been merged to 8-STABLE.
+	Starting with this version the old system of ZFS pool versioning
+	is superseded by "feature flags". This concept enables forward
+	compatibility against certain future changes in functionality of ZFS
+	pools. The first two read-only compatible "feature flags" for ZFS
+	pools are "com.delphix:async_destroy" and "com.delphix:empty_bpobj".
+	For more information read the new zpool-features(7) manual page.
+	Please refer to the "ZFS notes" section of this file for information
+	on upgrading boot ZFS pools.
+
 20121018:
 	WITH_CTF can now be specified in src.conf (not recommended, there
 	are some problems with static executables), make.conf (would also

Modified: stable/8/cddl/contrib/opensolaris/cmd/zdb/zdb.8
==============================================================================
--- stable/8/cddl/contrib/opensolaris/cmd/zdb/zdb.8	Fri Nov 30 22:33:21 2012	(r243716)
+++ stable/8/cddl/contrib/opensolaris/cmd/zdb/zdb.8	Fri Nov 30 22:38:42 2012	(r243717)
@@ -93,14 +93,14 @@ If specified multiple times, verify the 
 .It Fl C
 Display information about the configuration. If specified with no other
 options, instead display information about the cache file
-.Ns ( Pa /etc/zfs/zpool.cache Ns ).
+.Po Pa /etc/zfs/zpool.cache Pc .
 To specify the cache file to display, see
 .Fl U
 .Pp
 If specified multiple times, and a pool name is also specified display both
 the cached configuration and the on-disk configuration.
 If specified multiple times with
-.FL e
+.Fl e
 also display the configuration that would be used were the pool to be
 imported.
 .It Fl d
@@ -135,7 +135,7 @@ option is also specified, also display t
 .It Fl L
 Disable leak tracing and the loading of space maps.
 By default,
-.Nm 
+.Nm
 verifies that all non-free blocks are referenced, which can be very expensive.
 .It Fl m
 Display the offset, spacemap, and free space of each metaslab.
@@ -253,7 +253,7 @@ MOS Configuration:
 .Li # Ic zdb -d rpool
 Dataset mos [META], ID 0, cr_txg 4, 26.9M, 1051 objects
 Dataset rpool/swap [ZVOL], ID 59, cr_txg 356, 486M, 2 objects
-...
+ ...
 .Ed
 .It Xo Sy Example 3 Display basic information about object 0 in
 .Sy 'rpool/export/home'
@@ -272,7 +272,7 @@ Dataset rpool/export/home [ZPL], ID 137,
 .Li # Ic zdb -S rpool
 Simulated DDT histogram:
 
-bucket             allocated                      referenced          
+bucket             allocated                      referenced
 ______  ______________________________  ______________________________
 refcnt  blocks   LSIZE   PSIZE   DSIZE  blocks   LSIZE   PSIZE   DSIZE
 ------  ------   -----   -----   -----  ------   -----   -----   -----

Modified: stable/8/cddl/contrib/opensolaris/cmd/zdb/zdb.c
==============================================================================
--- stable/8/cddl/contrib/opensolaris/cmd/zdb/zdb.c	Fri Nov 30 22:33:21 2012	(r243716)
+++ stable/8/cddl/contrib/opensolaris/cmd/zdb/zdb.c	Fri Nov 30 22:38:42 2012	(r243717)
@@ -18,8 +18,10 @@
  *
  * CDDL HEADER END
  */
+
 /*
  * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012 by Delphix. All rights reserved.
  */
 
 #include <stdio.h>
@@ -54,6 +56,7 @@
 #include <sys/zfs_fuid.h>
 #include <sys/arc.h>
 #include <sys/ddt.h>
+#include <sys/zfeature.h>
 #undef ZFS_MAXNAMELEN
 #undef verify
 #include <libzfs.h>
@@ -63,7 +66,8 @@
 #define	ZDB_CHECKSUM_NAME(idx) ((idx) < ZIO_CHECKSUM_FUNCTIONS ? \
     zio_checksum_table[(idx)].ci_name : "UNKNOWN")
 #define	ZDB_OT_NAME(idx) ((idx) < DMU_OT_NUMTYPES ? \
-    dmu_ot[(idx)].ot_name : "UNKNOWN")
+    dmu_ot[(idx)].ot_name : DMU_OT_IS_VALID(idx) ? \
+    dmu_ot_byteswap[DMU_OT_BYTESWAP(idx)].ob_name : "UNKNOWN")
 #define	ZDB_OT_TYPE(idx) ((idx) < DMU_OT_NUMTYPES ? (idx) : DMU_OT_NUMTYPES)
 
 #ifndef lint
@@ -1088,7 +1092,7 @@ dump_dsl_dataset(objset_t *os, uint64_t 
 
 	ASSERT(size == sizeof (*ds));
 	crtime = ds->ds_creation_time;
-	zdb_nicenum(ds->ds_used_bytes, used);
+	zdb_nicenum(ds->ds_referenced_bytes, used);
 	zdb_nicenum(ds->ds_compressed_bytes, compressed);
 	zdb_nicenum(ds->ds_uncompressed_bytes, uncompressed);
 	zdb_nicenum(ds->ds_unique_bytes, unique);
@@ -1132,6 +1136,44 @@ dump_dsl_dataset(objset_t *os, uint64_t 
 
 /* ARGSUSED */
 static int
+dump_bptree_cb(void *arg, const blkptr_t *bp, dmu_tx_t *tx)
+{
+	char blkbuf[BP_SPRINTF_LEN];
+
+	if (bp->blk_birth != 0) {
+		sprintf_blkptr(blkbuf, bp);
+		(void) printf("\t%s\n", blkbuf);
+	}
+	return (0);
+}
+
+static void
+dump_bptree(objset_t *os, uint64_t obj, char *name)
+{
+	char bytes[32];
+	bptree_phys_t *bt;
+	dmu_buf_t *db;
+
+	if (dump_opt['d'] < 3)
+		return;
+
+	VERIFY3U(0, ==, dmu_bonus_hold(os, obj, FTAG, &db));
+	bt = db->db_data;
+	zdb_nicenum(bt->bt_bytes, bytes);
+	(void) printf("\n    %s: %llu datasets, %s\n",
+	    name, (unsigned long long)(bt->bt_end - bt->bt_begin), bytes);
+	dmu_buf_rele(db, FTAG);
+
+	if (dump_opt['d'] < 5)
+		return;
+
+	(void) printf("\n");
+
+	(void) bptree_iterate(os, obj, B_FALSE, dump_bptree_cb, NULL, NULL);
+}
+
+/* ARGSUSED */
+static int
 dump_bpobj_cb(void *arg, const blkptr_t *bp, dmu_tx_t *tx)
 {
 	char blkbuf[BP_SPRINTF_LEN];
@@ -1883,11 +1925,13 @@ typedef struct zdb_blkstats {
  */
 #define	ZDB_OT_DEFERRED	(DMU_OT_NUMTYPES + 0)
 #define	ZDB_OT_DITTO	(DMU_OT_NUMTYPES + 1)
-#define	ZDB_OT_TOTAL	(DMU_OT_NUMTYPES + 2)
+#define	ZDB_OT_OTHER	(DMU_OT_NUMTYPES + 2)
+#define	ZDB_OT_TOTAL	(DMU_OT_NUMTYPES + 3)
 
 static char *zdb_ot_extname[] = {
 	"deferred free",
 	"dedup ditto",
+	"other",
 	"Total",
 };
 
@@ -1968,9 +2012,10 @@ zdb_blkptr_cb(spa_t *spa, zilog_t *zilog
 
 	type = BP_GET_TYPE(bp);
 
-	zdb_count_block(zcb, zilog, bp, type);
+	zdb_count_block(zcb, zilog, bp,
+	    (type & DMU_OT_NEWTYPE) ? ZDB_OT_OTHER : type);
 
-	is_metadata = (BP_GET_LEVEL(bp) != 0 || dmu_ot[type].ot_metadata);
+	is_metadata = (BP_GET_LEVEL(bp) != 0 || DMU_OT_IS_METADATA(type));
 
 	if (dump_opt['c'] > 1 || (dump_opt['c'] && is_metadata)) {
 		int ioerr;
@@ -2197,6 +2242,12 @@ dump_block_stats(spa_t *spa)
 		(void) bpobj_iterate_nofree(&spa->spa_dsl_pool->dp_free_bpobj,
 		    count_block_cb, &zcb, NULL);
 	}
+	if (spa_feature_is_active(spa,
+	    &spa_feature_table[SPA_FEATURE_ASYNC_DESTROY])) {
+		VERIFY3U(0, ==, bptree_iterate(spa->spa_meta_objset,
+		    spa->spa_dsl_pool->dp_bptree_obj, B_FALSE, count_block_cb,
+		    &zcb, NULL));
+	}
 
 	if (dump_opt['c'] > 1)
 		flags |= TRAVERSE_PREFETCH_DATA;
@@ -2373,7 +2424,7 @@ zdb_ddt_add_cb(spa_t *spa, zilog_t *zilo
 	}
 
 	if (BP_IS_HOLE(bp) || BP_GET_CHECKSUM(bp) == ZIO_CHECKSUM_OFF ||
-	    BP_GET_LEVEL(bp) > 0 || dmu_ot[BP_GET_TYPE(bp)].ot_metadata)
+	    BP_GET_LEVEL(bp) > 0 || DMU_OT_IS_METADATA(BP_GET_TYPE(bp)))
 		return (0);
 
 	ddt_key_fill(&zdde_search.zdde_key, bp);
@@ -2478,7 +2529,14 @@ dump_zpool(spa_t *spa)
 			dump_bpobj(&spa->spa_deferred_bpobj, "Deferred frees");
 			if (spa_version(spa) >= SPA_VERSION_DEADLISTS) {
 				dump_bpobj(&spa->spa_dsl_pool->dp_free_bpobj,
-				    "Pool frees");
+				    "Pool snapshot frees");
+			}
+
+			if (spa_feature_is_active(spa,
+			    &spa_feature_table[SPA_FEATURE_ASYNC_DESTROY])) {
+				dump_bptree(spa->spa_meta_objset,
+				    spa->spa_dsl_pool->dp_bptree_obj,
+				    "Pool dataset frees");
 			}
 			dump_dtl(spa->spa_root_vdev, 0);
 		}

Modified: stable/8/cddl/contrib/opensolaris/cmd/zfs/zfs.8
==============================================================================
--- stable/8/cddl/contrib/opensolaris/cmd/zfs/zfs.8	Fri Nov 30 22:33:21 2012	(r243716)
+++ stable/8/cddl/contrib/opensolaris/cmd/zfs/zfs.8	Fri Nov 30 22:38:42 2012	(r243717)
@@ -22,7 +22,7 @@
 .\" Copyright (c) 2012 Nexenta Systems, Inc. All Rights Reserved.
 .\" Copyright (c) 2012, Joyent, Inc. All rights reserved.
 .\" Copyright (c) 2011, Pawel Jakub Dawidek <pjd@FreeBSD.org>
-.\" Copyright (c) 2012, Bryan Drewery <bdrewery@FreeBSD.org>
+.\" Copyright (c) 2012, Glen Barber <gjb@FreeBSD.org>
 .\"
 .\" $FreeBSD$
 .\"
@@ -57,8 +57,8 @@
 .Op Fl dnpRrv
 .Sm off
 .Ar snapshot
-.Ns Op % Ns Ar snapname
-.Ns Op , Ns Ar ...
+.Op % Ns Ar snapname
+.Op , Ns Ar ...
 .Sm on
 .Nm
 .Cm snapshot
@@ -136,17 +136,21 @@
 .Fl a | Ar filesystem
 .Nm
 .Cm userspace
-.Op Fl niHp
+.Op Fl Hinp
 .Op Fl o Ar field Ns Op , Ns Ar ...
-.Op Fl sS Ar field
+.Op Fl s Ar field
+.Ar ...
+.Op Fl S Ar field
 .Ar ...
 .Op Fl t Ar type Ns Op , Ns Ar ...
 .Ar filesystem Ns | Ns Ar snapshot
 .Nm
 .Cm groupspace
-.Op Fl niHp
+.Op Fl Hinp
 .Op Fl o Ar field Ns Op , Ns Ar ...
-.Op Fl sS Ar field
+.Op Fl s Ar field
+.Ar ...
+.Op Fl S Ar field
 .Ar ...
 .Op Fl t Ar type Ns Op , Ns Ar ...
 .Ar filesystem Ns | Ns Ar snapshot
@@ -619,7 +623,7 @@ privilege with
 .Qq Nm Cm allow ,
 can access everyone's usage.
 .Pp
-The 
+The
 .Sy userused@ Ns ...
 properties are not displayed by
 .Qq Nm Cm get all .
@@ -819,7 +823,7 @@ command or unmounted by the
 command.
 .Pp
 This property is not inherited.
-.It Sy checksum Ns = Ns Cm on | off | fletcher2 | fletcher4
+.It Sy checksum Ns = Ns Cm on | off | fletcher2 | fletcher4 | sha256
 Controls the checksum used to verify data integrity. The default value is
 .Cm on ,
 which automatically selects an appropriate algorithm (currently,
@@ -1129,7 +1133,7 @@ will not use configured pool log devices
 will instead optimize synchronous operations for global pool throughput and
 efficient use of resources.
 .It Sy snapdir Ns = Ns Cm hidden | visible
-Controls whether the 
+Controls whether the
 .Pa \&.zfs
 directory is hidden or visible in the root of the file system as discussed in
 the
@@ -1196,7 +1200,7 @@ are not reflected in the reservation.
 The
 .Sy vscan
 property is currently not supported on
-.Fx . 
+.Fx .
 .It Sy xattr Ns = Ns Cm off | on
 The
 .Sy xattr
@@ -1283,7 +1287,7 @@ properties. The correlation between prop
 In addition, these options can be set on a per-mount basis using the
 .Fl o
 option, without affecting the property that is stored on disk. The values
-specified on the command line override the values stored in the dataset. These 
+specified on the command line override the values stored in the dataset. These
 properties are reported as "temporary" by the
 .Qq Nm Cm get
 command. If the properties are changed while the dataset is mounted, the new
@@ -1322,7 +1326,7 @@ domain name for the
 .Ar module
 component of property names to reduce the chance that two
 independently-developed packages use the same property name for different
-purposes. Property names beginning with 
+purposes. Property names beginning with
 .Em com.sun
 are reserved for use by Sun Microsystems.
 .Pp
@@ -1489,8 +1493,8 @@ behavior for mounted file systems in use
 .Op Fl dnpRrv
 .Sm off
 .Ar snapshot
-.Ns Op % Ns Ar snapname
-.Ns Op , Ns Ar ...
+.Op % Ns Ar snapname
+.Op , Ns Ar ...
 .Sm on
 .Xc
 .Pp
@@ -1978,9 +1982,11 @@ Upgrade the specified file system.
 .It Xo
 .Nm
 .Cm userspace
-.Op Fl niHp
+.Op Fl Hinp
 .Op Fl o Ar field Ns Op , Ns Ar ...
-.Op Fl sS Ar field
+.Op Fl s Ar field
+.Ar ...
+.Op Fl S Ar field
 .Ar ...
 .Op Fl t Ar type Ns Op , Ns Ar ...
 .Ar filesystem Ns | Ns Ar snapshot
@@ -1998,9 +2004,9 @@ Print numeric ID instead of user/group n
 .It Fl H
 Do not print headers, use tab-delimited output.
 .It Fl p
-Use exact (parseable) numeric output.
+Use exact (parsable) numeric output.
 .It Fl o Ar field Ns Op , Ns Ar ...
-Display only the specified fields from the following set,
+Display only the specified fields from the following set:
 .Sy type,name,used,quota .
 The default is to display all fields.
 .It Fl s Ar field
@@ -2015,7 +2021,7 @@ another. The default is
 Sort by this field in reverse order. See
 .Fl s .
 .It Fl t Ar type Ns Op , Ns Ar ...
-Print only the specified types from the following set,
+Print only the specified types from the following set:
 .Sy all,posixuser,smbuser,posixgroup,smbgroup .
 .Pp
 The default is
@@ -2029,9 +2035,11 @@ Translate SID to POSIX ID. This flag cur
 .It Xo
 .Nm
 .Cm groupspace
-.Op Fl niHp
+.Op Fl Hinp
 .Op Fl o Ar field Ns Op , Ns Ar ...
-.Op Fl sS Ar field
+.Op Fl s Ar field
+.Ar ...
+.Op Fl S Ar field
 .Ar ...
 .Op Fl t Ar type Ns Op , Ns Ar ...
 .Ar filesystem Ns | Ns Ar snapshot
@@ -2209,7 +2217,7 @@ and it is assumed to be from the same fi
 .Ar snapshot .
 .Pp
 If the destination is a clone, the source may be the origin snapshot, which
-must be fully specified (for example, 
+must be fully specified (for example,
 .Cm pool/fs@origin ,
 not just
 .Cm @origin ) .
@@ -2458,24 +2466,26 @@ subcommand or change a
 property. The following permissions are available:
 .Bl -column -offset 4n "secondarycache" "subcommand"
 .It NAME Ta TYPE Ta NOTES
-.It Xo allow Ta subcommand Ta Must
+.It allow Ta subcommand Ta Must Xo
 also have the permission that is being allowed
 .Xc
-.It Xo clone Ta subcommand Ta Must
+.It clone Ta subcommand Ta Must Xo
 also have the 'create' ability and 'mount' ability in the origin file system
 .Xc
 .It create Ta subcommand Ta Must also have the 'mount' ability
 .It destroy Ta subcommand Ta Must also have the 'mount' ability
+.It diff Ta subcommand Ta Allows lookup of paths within a dataset given an
+object number, and the ability to create snapshots necessary to 'zfs diff'
 .It hold Ta subcommand Ta Allows adding a user hold to a snapshot
 .It mount Ta subcommand Ta Allows mount/umount of Tn ZFS No datasets
-.It Xo promote Ta subcommand Ta Must
+.It promote Ta subcommand Ta Must Xo
 also have the 'mount' and 'promote' ability in the origin file system
 .Xc
 .It receive Ta subcommand Ta Must also have the 'mount' and 'create' ability
-.It Xo release Ta subcommand Ta Allows
+.It release Ta subcommand Ta Allows Xo
 releasing a user hold which might destroy the snapshot
 .Xc
-.It Xo rename Ta subcommand Ta Must
+.It rename Ta subcommand Ta Must Xo
 also have the 'mount' and 'create' ability in the new parent
 .Xc
 .It rollback Ta subcommand Ta Must also have the 'mount' ability
@@ -2491,7 +2501,6 @@ protocol
 .It userprop Ta other Ta Allows changing any user property
 .It userquota Ta other Ta Allows accessing any userquota@... property
 .It userused Ta other Ta Allows reading any userused@... property
-.It  Ta 
 .It aclinherit Ta property
 .It aclmode Ta property
 .It atime Ta property
@@ -2669,43 +2678,42 @@ descendent file systems.
 .Op Ar snapshot Ns | Ns Ar filesystem
 .Xc
 .Pp
-Describes differences between a snapshot and a successor dataset. The
-successor dataset can be a later snapshot or the current filesystem.
-.Pp
-The changed files are displayed including the change type. The change type
-is displayed useing a single character. If a file or directory was renamed,
-the old and the new names are displayed.
-.Pp
-The following change types can be displayed:
-.Pp
-.Bl -column -offset indent "CHARACTER" "CHANGE TYPE"
-.It CHARACTER Ta CHANGE TYPE
-.It \&+ Ta file was added
-.It \&- Ta file was removed
-.It \&M Ta file was modified
-.It \&R Ta file was renamed
+Display the difference between a snapshot of a given filesystem and another
+snapshot of that filesystem from a later time or the current contents of the
+filesystem.  The first column is a character indicating the type of change,
+the other columns indicate pathname, new pathname
+.Pq in case of rename ,
+change in link count, and optionally file type and/or change time.
+.Pp
+The types of change are:
+.Bl -column -offset 2n indent
+.It \&- Ta path was removed
+.It \&+ Ta path was added
+.It \&M Ta path was modified
+.It \&R Ta path was renamed
 .El
 .Bl -tag -width indent
 .It Fl F
-Display a single letter for the file type in second to last column.
-.Pp
-The following file types can be displayed:
-.Pp
-.Bl -column -offset indent "CHARACTER" "FILE TYPE"
-.It CHARACTER Ta FILE TYPE
-.It \&F Ta file
-.It \&/ Ta directory
+Display an indication of the type of file, in a manner similar to the
+.Fl F
+option of
+.Xr ls 1 .
+.Bl -column -offset 2n indent
 .It \&B Ta block device
+.It \&C Ta character device
+.It \&F Ta regular file
+.It \&/ Ta directory
 .It \&@ Ta symbolic link
 .It \&= Ta socket
 .It \&> Ta door (not supported on Fx )
-.It \&| Ta FIFO (not supported on Fx )
-.It \&P Ta event portal (not supported on Fx )
+.It \&| Ta named pipe (not supported on Fx )
+.It \&P Ta event port (not supported on Fx )
 .El
 .It Fl H
-Machine-parseable output, fields separated a tab character.
+Give more parseable tab-separated output, without header lines and without
+arrows.
 .It Fl t
-Display a change timestamp in the first column.
+Display the path's inode change time as the first column of output.
 .El
 .It Xo
 .Nm
@@ -2742,6 +2750,16 @@ Detaches the specified
 from the jail identified by JID
 .Ar jailid .
 .El
+.Sh EXIT STATUS
+The following exit values are returned:
+.Bl -tag -offset 2n -width 2n
+.It 0
+Successful completion.
+.It 1
+An error occurred.
+.It 2
+Invalid command line options were specified.
+.El
 .Sh EXAMPLES
 .Bl -tag -width 0n
 .It Sy Example 1 No Creating a Tn ZFS No File System Hierarchy
@@ -2807,7 +2825,7 @@ Snapshots are displayed if the
 .Sy listsnaps
 property is
 .Cm on .
-The default is 
+The default is
 .Cm off .
 See
 .Xr zpool 8
@@ -3158,16 +3176,21 @@ Local+Descendent permissions on (tank/us
         group staff @pset,create,mount
 -------------------------------------------------------------
 .Ed
-.El
-.Sh EXIT STATUS
-The following exit values are returned:
-.Bl -tag -offset 2n -width 2n
-.It 0
-Successful completion.
-.It 1
-An error occurred.
-.It 2
-Invalid command line options were specified.
+.It Sy Example 22 Showing the differences between a snapshot and a ZFS Dataset
+.Pp
+The following example shows how to see what has changed between a prior
+snapshot of a ZFS Dataset and its current state.  The
+.Fl F
+option is used to indicate type information for the files affected.
+.Bd -literal -offset 2n
+.Li # Ic zfs diff tank/test@before tank/test
+M       /       /tank/test/
+M       F       /tank/test/linked      (+1)
+R       F       /tank/test/oldname -> /tank/test/newname
+-       F       /tank/test/deleted
++       F       /tank/test/created
+M       F       /tank/test/modified
+.Ed
 .El
 .Sh SEE ALSO
 .Xr chmod 2 ,

Modified: stable/8/cddl/contrib/opensolaris/cmd/zfs/zfs_main.c
==============================================================================
--- stable/8/cddl/contrib/opensolaris/cmd/zfs/zfs_main.c	Fri Nov 30 22:33:21 2012	(r243716)
+++ stable/8/cddl/contrib/opensolaris/cmd/zfs/zfs_main.c	Fri Nov 30 22:38:42 2012	(r243717)
@@ -304,13 +304,13 @@ get_usage(zfs_help_t idx)
 		    "\tunallow [-r] -s @setname [<perm|@setname>[,...]] "
 		    "<filesystem|volume>\n"));
 	case HELP_USERSPACE:
-		return (gettext("\tuserspace [-niHp] [-o field[,...]] "
-		    "[-sS field] ... [-t type[,...]]\n"
-		    "\t    <filesystem|snapshot>\n"));
+		return (gettext("\tuserspace [-Hinp] [-o field[,...]] "
+		    "[-s field] ...\n\t[-S field] ... "
+		    "[-t type[,...]] <filesystem|snapshot>\n"));
 	case HELP_GROUPSPACE:
-		return (gettext("\tgroupspace [-niHp] [-o field[,...]] "
-		    "[-sS field] ... [-t type[,...]]\n"
-		    "\t    <filesystem|snapshot>\n"));
+		return (gettext("\tgroupspace [-Hinp] [-o field[,...]] "
+		    "[-s field] ...\n\t[-S field] ... "
+		    "[-t type[,...]] <filesystem|snapshot>\n"));
 	case HELP_HOLD:
 		return (gettext("\thold [-r] <tag> <snapshot> ...\n"));
 	case HELP_HOLDS:
@@ -1081,7 +1081,7 @@ snapshot_to_nvl_cb(zfs_handle_t *zhp, vo
 	int err = 0;
 
 	/* Check for clones. */
-	if (!cb->cb_doclones) {
+	if (!cb->cb_doclones && !cb->cb_defer_destroy) {
 		cb->cb_target = zhp;
 		cb->cb_first = B_TRUE;
 		err = zfs_iter_dependents(zhp, B_TRUE,
@@ -2057,30 +2057,52 @@ zfs_do_upgrade(int argc, char **argv)
 	return (ret);
 }
 
-#define	USTYPE_USR_BIT (0)
-#define	USTYPE_GRP_BIT (1)
-#define	USTYPE_PSX_BIT (2)
-#define	USTYPE_SMB_BIT (3)
-
-#define	USTYPE_USR (1 << USTYPE_USR_BIT)
-#define	USTYPE_GRP (1 << USTYPE_GRP_BIT)
-
-#define	USTYPE_PSX (1 << USTYPE_PSX_BIT)
-#define	USTYPE_SMB (1 << USTYPE_SMB_BIT)
-
-#define	USTYPE_PSX_USR (USTYPE_PSX | USTYPE_USR)
-#define	USTYPE_SMB_USR (USTYPE_SMB | USTYPE_USR)
-#define	USTYPE_PSX_GRP (USTYPE_PSX | USTYPE_GRP)
-#define	USTYPE_SMB_GRP (USTYPE_SMB | USTYPE_GRP)
-#define	USTYPE_ALL (USTYPE_PSX_USR | USTYPE_SMB_USR \
-		| USTYPE_PSX_GRP | USTYPE_SMB_GRP)
+/*
+ * zfs userspace [-Hinp] [-o field[,...]] [-s field [-s field]...]
+ *               [-S field [-S field]...] [-t type[,...]] filesystem | snapshot
+ * zfs groupspace [-Hinp] [-o field[,...]] [-s field [-s field]...]
+ *                [-S field [-S field]...] [-t type[,...]] filesystem | snapshot
+ *
+ *	-H      Scripted mode; elide headers and separate columns by tabs.
+ *	-i	Translate SID to POSIX ID.
+ *	-n	Print numeric ID instead of user/group name.
+ *	-o      Control which fields to display.
+ *	-p	Use exact (parseable) numeric output.
+ *	-s      Specify sort columns, descending order.
+ *	-S      Specify sort columns, ascending order.
+ *	-t      Control which object types to display.
+ *
+ *	Displays space consumed by, and quotas on, each user in the specified
+ *	filesystem or snapshot.
+ */
 
+/* us_field_types, us_field_hdr and us_field_names should be kept in sync */
+enum us_field_types {
+	USFIELD_TYPE,
+	USFIELD_NAME,
+	USFIELD_USED,
+	USFIELD_QUOTA
+};
+static char *us_field_hdr[] = { "TYPE", "NAME", "USED", "QUOTA" };
+static char *us_field_names[] = { "type", "name", "used", "quota" };
+#define	USFIELD_LAST	(sizeof (us_field_names) / sizeof (char *))
 
-#define	USPROP_USED_BIT (0)
-#define	USPROP_QUOTA_BIT (1)
+#define	USTYPE_PSX_GRP	(1 << 0)
+#define	USTYPE_PSX_USR	(1 << 1)
+#define	USTYPE_SMB_GRP	(1 << 2)
+#define	USTYPE_SMB_USR	(1 << 3)
+#define	USTYPE_ALL	\
+	(USTYPE_PSX_GRP | USTYPE_PSX_USR | USTYPE_SMB_GRP | USTYPE_SMB_USR)
 
-#define	USPROP_USED (1 << USPROP_USED_BIT)
-#define	USPROP_QUOTA (1 << USPROP_QUOTA_BIT)
+static int us_type_bits[] = {
+	USTYPE_PSX_GRP,
+	USTYPE_PSX_USR,
+	USTYPE_SMB_GRP,
+	USTYPE_SMB_USR,
+	USTYPE_ALL
+};
+static char *us_type_names[] = { "posixgroup", "posxiuser", "smbgroup",
+	"smbuser", "all" };
 
 typedef struct us_node {
 	nvlist_t	*usn_nvl;
@@ -2089,37 +2111,49 @@ typedef struct us_node {
 } us_node_t;
 
 typedef struct us_cbdata {
-	nvlist_t		**cb_nvlp;
-	uu_avl_pool_t		*cb_avl_pool;
-	uu_avl_t		*cb_avl;
-	boolean_t		cb_numname;
-	boolean_t		cb_nicenum;
-	boolean_t		cb_sid2posix;
-	zfs_userquota_prop_t	cb_prop;
-	zfs_sort_column_t	*cb_sortcol;
-	size_t			cb_max_typelen;
-	size_t			cb_max_namelen;
-	size_t			cb_max_usedlen;
-	size_t			cb_max_quotalen;
+	nvlist_t	**cb_nvlp;
+	uu_avl_pool_t	*cb_avl_pool;
+	uu_avl_t	*cb_avl;
+	boolean_t	cb_numname;
+	boolean_t	cb_nicenum;
+	boolean_t	cb_sid2posix;
+	zfs_userquota_prop_t cb_prop;
+	zfs_sort_column_t *cb_sortcol;
+	size_t		cb_width[USFIELD_LAST];
 } us_cbdata_t;
 
+static boolean_t us_populated = B_FALSE;
+
 typedef struct {
 	zfs_sort_column_t *si_sortcol;
-	boolean_t si_num_name;
-	boolean_t si_parsable;
+	boolean_t	si_numname;
 } us_sort_info_t;
 
 static int
+us_field_index(char *field)
+{
+	int i;
+
+	for (i = 0; i < USFIELD_LAST; i++) {
+		if (strcmp(field, us_field_names[i]) == 0)
+			return (i);
+	}
+
+	return (-1);
+}
+
+static int
 us_compare(const void *larg, const void *rarg, void *unused)
 {
 	const us_node_t *l = larg;
 	const us_node_t *r = rarg;
-	int rc = 0;
 	us_sort_info_t *si = (us_sort_info_t *)unused;
 	zfs_sort_column_t *sortcol = si->si_sortcol;
-	boolean_t num_name = si->si_num_name;
+	boolean_t numname = si->si_numname;
 	nvlist_t *lnvl = l->usn_nvl;
 	nvlist_t *rnvl = r->usn_nvl;
+	int rc = 0;
+	boolean_t lvb, rvb;
 
 	for (; sortcol != NULL; sortcol = sortcol->sc_next) {
 		char *lvstr = "";
@@ -2138,17 +2172,17 @@ us_compare(const void *larg, const void 
 			(void) nvlist_lookup_uint32(lnvl, propname, &lv32);
 			(void) nvlist_lookup_uint32(rnvl, propname, &rv32);
 			if (rv32 != lv32)
-				rc = (rv32 > lv32) ? 1 : -1;
+				rc = (rv32 < lv32) ? 1 : -1;
 			break;
 		case ZFS_PROP_NAME:
 			propname = "name";
-			if (num_name) {
-				(void) nvlist_lookup_uint32(lnvl, propname,
-				    &lv32);
-				(void) nvlist_lookup_uint32(rnvl, propname,
-				    &rv32);
-				if (rv32 != lv32)
-					rc = (rv32 > lv32) ? 1 : -1;
+			if (numname) {
+				(void) nvlist_lookup_uint64(lnvl, propname,
+				    &lv64);
+				(void) nvlist_lookup_uint64(rnvl, propname,
+				    &rv64);
+				if (rv64 != lv64)
+					rc = (rv64 < lv64) ? 1 : -1;
 			} else {
 				(void) nvlist_lookup_string(lnvl, propname,
 				    &lvstr);
@@ -2157,27 +2191,40 @@ us_compare(const void *larg, const void 
 				rc = strcmp(lvstr, rvstr);
 			}
 			break;
-
 		case ZFS_PROP_USED:
 		case ZFS_PROP_QUOTA:
-			if (ZFS_PROP_USED == prop)
+			if (!us_populated)
+				break;
+			if (prop == ZFS_PROP_USED)
 				propname = "used";
 			else
 				propname = "quota";
 			(void) nvlist_lookup_uint64(lnvl, propname, &lv64);
 			(void) nvlist_lookup_uint64(rnvl, propname, &rv64);
 			if (rv64 != lv64)
-				rc = (rv64 > lv64) ? 1 : -1;
+				rc = (rv64 < lv64) ? 1 : -1;
+			break;
 		}
 
-		if (rc)
+		if (rc != 0) {
 			if (rc < 0)
 				return (reverse ? 1 : -1);
 			else
 				return (reverse ? -1 : 1);
+		}
 	}
 
-	return (rc);
+	/*
+	 * If entries still seem to be the same, check if they are of the same
+	 * type (smbentity is added only if we are doing SID to POSIX ID
+	 * translation where we can have duplicate type/name combinations).
+	 */
+	if (nvlist_lookup_boolean_value(lnvl, "smbentity", &lvb) == 0 &&
+	    nvlist_lookup_boolean_value(rnvl, "smbentity", &rvb) == 0 &&
+	    lvb != rvb)
+		return (lvb < rvb ? -1 : 1);
+
+	return (0);
 }
 
 static inline const char *
@@ -2197,9 +2244,6 @@ us_type2str(unsigned field_type)
 	}
 }
 
-/*
- * zfs userspace
- */
 static int
 userspace_cb(void *arg, const char *domain, uid_t rid, uint64_t space)
 {
@@ -2207,7 +2251,6 @@ userspace_cb(void *arg, const char *doma
 	zfs_userquota_prop_t prop = cb->cb_prop;
 	char *name = NULL;
 	char *propname;
-	char namebuf[32];
 	char sizebuf[32];
 	us_node_t *node;
 	uu_avl_pool_t *avl_pool = cb->cb_avl_pool;
@@ -2221,32 +2264,30 @@ userspace_cb(void *arg, const char *doma
 	size_t namelen;
 	size_t typelen;
 	size_t sizelen;
+	int typeidx, nameidx, sizeidx;
 	us_sort_info_t sortinfo = { sortcol, cb->cb_numname };
+	boolean_t smbentity = B_FALSE;
 
-	if (domain == NULL || domain[0] == '\0') {
-		/* POSIX */
-		if (prop == ZFS_PROP_GROUPUSED || prop == ZFS_PROP_GROUPQUOTA) {
-			type = USTYPE_PSX_GRP;
-			struct group *g = getgrgid(rid);
-			if (g)
-				name = g->gr_name;
-		} else {
-			type = USTYPE_PSX_USR;
-			struct passwd *p = getpwuid(rid);
-			if (p)
-				name = p->pw_name;
-		}
-	} else {
-		char sid[ZFS_MAXNAMELEN+32];
+	if (nvlist_alloc(&props, NV_UNIQUE_NAME, 0) != 0)
+		nomem();
+	node = safe_malloc(sizeof (us_node_t));
+	uu_avl_node_init(node, &node->usn_avlnode, avl_pool);
+	node->usn_nvl = props;
+
+	if (domain != NULL && domain[0] != '\0') {
+		/* SMB */
+		char sid[ZFS_MAXNAMELEN + 32];
 		uid_t id;
 		uint64_t classes;
 #ifdef sun
-		int err = 0;
+		int err;
 		directory_error_t e;
 #endif
 
+		smbentity = B_TRUE;
+
 		(void) snprintf(sid, sizeof (sid), "%s-%u", domain, rid);
-		/* SMB */
+
 		if (prop == ZFS_PROP_GROUPUSED || prop == ZFS_PROP_GROUPQUOTA) {
 			type = USTYPE_SMB_GRP;
 #ifdef sun
@@ -2262,217 +2303,139 @@ userspace_cb(void *arg, const char *doma
 #ifdef sun
 		if (err == 0) {
 			rid = id;
-
-			e = directory_name_from_sid(NULL, sid, &name, &classes);
-			if (e != NULL) {
-				directory_error_free(e);
-				return (NULL);
+			if (!cb->cb_sid2posix) {
+				e = directory_name_from_sid(NULL, sid, &name,
+				    &classes);
+				if (e != NULL)
+					directory_error_free(e);
+				if (name == NULL)
+					name = sid;
 			}
-
-			if (name == NULL)
-				name = sid;
 		}
 #endif
 	}
 
-/*
- *	if (prop == ZFS_PROP_GROUPUSED || prop == ZFS_PROP_GROUPQUOTA)
- *		ug = "group";
- *	else
- *		ug = "user";
- */
-
-	if (prop == ZFS_PROP_USERUSED || prop == ZFS_PROP_GROUPUSED)
-		propname = "used";
-	else
-		propname = "quota";
-
-	(void) snprintf(namebuf, sizeof (namebuf), "%u", rid);
-	if (name == NULL)
-		name = namebuf;
-
-	if (cb->cb_nicenum)
-		zfs_nicenum(space, sizebuf, sizeof (sizebuf));
-	else
-		(void) sprintf(sizebuf, "%llu", space);
+	if (cb->cb_sid2posix || domain == NULL || domain[0] == '\0') {
+		/* POSIX or -i */
+		if (prop == ZFS_PROP_GROUPUSED || prop == ZFS_PROP_GROUPQUOTA) {
+			type = USTYPE_PSX_GRP;
+			if (!cb->cb_numname) {
+				struct group *g;
 
-	node = safe_malloc(sizeof (us_node_t));
-	uu_avl_node_init(node, &node->usn_avlnode, avl_pool);
+				if ((g = getgrgid(rid)) != NULL)
+					name = g->gr_name;
+			}
+		} else {
+			type = USTYPE_PSX_USR;
+			if (!cb->cb_numname) {
+				struct passwd *p;
 
-	if (nvlist_alloc(&props, NV_UNIQUE_NAME, 0) != 0) {
-		free(node);
-		return (-1);
+				if ((p = getpwuid(rid)) != NULL)
+					name = p->pw_name;
+			}
+		}
 	}
 
+	/*
+	 * Make sure that the type/name combination is unique when doing
+	 * SID to POSIX ID translation (hence changing the type from SMB to
+	 * POSIX).
+	 */
+	if (cb->cb_sid2posix &&
+	    nvlist_add_boolean_value(props, "smbentity", smbentity) != 0)
+		nomem();
+
+	/* Calculate/update width of TYPE field */
+	typestr = us_type2str(type);
+	typelen = strlen(gettext(typestr));
+	typeidx = us_field_index("type");
+	if (typelen > cb->cb_width[typeidx])
+		cb->cb_width[typeidx] = typelen;
 	if (nvlist_add_uint32(props, "type", type) != 0)
 		nomem();
 
-	if (cb->cb_numname) {
-		if (nvlist_add_uint32(props, "name", rid) != 0)
+	/* Calculate/update width of NAME field */
+	if ((cb->cb_numname && cb->cb_sid2posix) || name == NULL) {
+		if (nvlist_add_uint64(props, "name", rid) != 0)
 			nomem();
-		namelen = strlen(namebuf);
+		namelen = snprintf(NULL, 0, "%u", rid);
 	} else {
 		if (nvlist_add_string(props, "name", name) != 0)
 			nomem();
 		namelen = strlen(name);
 	}
+	nameidx = us_field_index("name");
+	if (namelen > cb->cb_width[nameidx])
+		cb->cb_width[nameidx] = namelen;
 
-	typestr = us_type2str(type);
-	typelen = strlen(gettext(typestr));
-	if (typelen > cb->cb_max_typelen)
-		cb->cb_max_typelen  = typelen;
-
-	if (namelen > cb->cb_max_namelen)
-		cb->cb_max_namelen  = namelen;
-
-	sizelen = strlen(sizebuf);
-	if (0 == strcmp(propname, "used")) {
-		if (sizelen > cb->cb_max_usedlen)

*** DIFF OUTPUT TRUNCATED AT 1000 LINES ***



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