]> git.proxmox.com Git - mirror_zfs.git/blobdiff - lib/libzfs/libzfs_dataset.c
Make createtxg and guid properties public
[mirror_zfs.git] / lib / libzfs / libzfs_dataset.c
index 4b4f8d8c9262e8512a924fe18b97404206076131..f1346b69c6f43316a46ac07328d733982643c900 100644 (file)
 
 /*
  * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
- * Copyright (c) 2012 by Delphix. All rights reserved.
+ * Copyright (c) 2013, Joyent, Inc. All rights reserved.
+ * Copyright (c) 2011, 2016 by Delphix. All rights reserved.
  * Copyright (c) 2012 DEY Storage Systems, Inc.  All rights reserved.
  * Copyright (c) 2012 Pawel Jakub Dawidek <pawel@dawidek.net>.
- * Copyright 2012 Nexenta Systems, Inc. All rights reserved.
  * Copyright (c) 2013 Martin Matuska. All rights reserved.
  * Copyright (c) 2013 Steven Hartland. All rights reserved.
+ * Copyright 2016 Nexenta Systems, Inc.
+ * Copyright 2016 Igor Kozhukhov <ikozhukhov@gmail.com>
  */
 
 #include <ctype.h>
@@ -42,7 +44,6 @@
 #include <fcntl.h>
 #include <sys/mntent.h>
 #include <sys/mount.h>
-#include <priv.h>
 #include <pwd.h>
 #include <grp.h>
 #include <stddef.h>
@@ -63,7 +64,6 @@
 #include "libzfs_impl.h"
 #include "zfs_deleg.h"
 
-static int zvol_create_link_common(libzfs_handle_t *, const char *, int);
 static int userquota_propname_decode(const char *propname, boolean_t zoned,
     zfs_userquota_prop_t *typep, char *domain, int domainlen, uint64_t *ridp);
 
@@ -81,8 +81,12 @@ zfs_type_to_name(zfs_type_t type)
                return (dgettext(TEXT_DOMAIN, "snapshot"));
        case ZFS_TYPE_VOLUME:
                return (dgettext(TEXT_DOMAIN, "volume"));
+       case ZFS_TYPE_POOL:
+               return (dgettext(TEXT_DOMAIN, "pool"));
+       case ZFS_TYPE_BOOKMARK:
+               return (dgettext(TEXT_DOMAIN, "bookmark"));
        default:
-               break;
+               assert(!"unhandled zfs_type_t");
        }
 
        return (NULL);
@@ -101,7 +105,7 @@ zfs_validate_name(libzfs_handle_t *hdl, const char *path, int type,
        char what;
 
        (void) zfs_prop_get_table();
-       if (dataset_namecheck(path, &why, &what) != 0) {
+       if (entity_namecheck(path, &why, &what) != 0) {
                if (hdl != NULL) {
                        switch (why) {
                        case NAME_ERR_TOOLONG:
@@ -130,9 +134,10 @@ zfs_validate_name(libzfs_handle_t *hdl, const char *path, int type,
                                    "'%c' in name"), what);
                                break;
 
-                       case NAME_ERR_MULTIPLE_AT:
+                       case NAME_ERR_MULTIPLE_DELIMITERS:
                                zfs_error_aux(hdl, dgettext(TEXT_DOMAIN,
-                                   "multiple '@' delimiters in name"));
+                                   "multiple '@' and/or '#' delimiters in "
+                                   "name"));
                                break;
 
                        case NAME_ERR_NOLETTER:
@@ -149,7 +154,10 @@ zfs_validate_name(libzfs_handle_t *hdl, const char *path, int type,
                                zfs_error_aux(hdl, dgettext(TEXT_DOMAIN,
                                    "reserved disk name"));
                                break;
+
                        default:
+                               zfs_error_aux(hdl, dgettext(TEXT_DOMAIN,
+                                   "(%d) not defined"), why);
                                break;
                        }
                }
@@ -160,7 +168,7 @@ zfs_validate_name(libzfs_handle_t *hdl, const char *path, int type,
        if (!(type & ZFS_TYPE_SNAPSHOT) && strchr(path, '@') != NULL) {
                if (hdl != NULL)
                        zfs_error_aux(hdl, dgettext(TEXT_DOMAIN,
-                           "snapshot delimiter '@' in filesystem name"));
+                           "snapshot delimiter '@' is not expected here"));
                return (0);
        }
 
@@ -171,6 +179,20 @@ zfs_validate_name(libzfs_handle_t *hdl, const char *path, int type,
                return (0);
        }
 
+       if (!(type & ZFS_TYPE_BOOKMARK) && strchr(path, '#') != NULL) {
+               if (hdl != NULL)
+                       zfs_error_aux(hdl, dgettext(TEXT_DOMAIN,
+                           "bookmark delimiter '#' is not expected here"));
+               return (0);
+       }
+
+       if (type == ZFS_TYPE_BOOKMARK && strchr(path, '#') == NULL) {
+               if (hdl != NULL)
+                       zfs_error_aux(hdl, dgettext(TEXT_DOMAIN,
+                           "missing '#' delimiter in bookmark name"));
+               return (0);
+       }
+
        if (modifying && strchr(path, '%') != NULL) {
                if (hdl != NULL)
                        zfs_error_aux(hdl, dgettext(TEXT_DOMAIN,
@@ -260,7 +282,7 @@ zpool_handle(zfs_handle_t *zhp)
        int len;
        zpool_handle_t *zph;
 
-       len = strcspn(zhp->zfs_name, "/@") + 1;
+       len = strcspn(zhp->zfs_name, "/@#") + 1;
        pool_name = zfs_alloc(zhp->zfs_hdl, len);
        (void) strlcpy(pool_name, zhp->zfs_name, len);
 
@@ -418,8 +440,7 @@ make_dataset_handle_common(zfs_handle_t *zhp, zfs_cmd_t *zc)
        else if (zhp->zfs_dmustats.dds_type == DMU_OST_ZFS)
                zhp->zfs_head_type = ZFS_TYPE_FILESYSTEM;
        else if (zhp->zfs_dmustats.dds_type == DMU_OST_OTHER)
-               return (-1); /* zpios' and other testing datasets are
-                               of this type, ignore if encountered */
+               return (-1);
        else
                abort();
 
@@ -548,8 +569,100 @@ zfs_handle_dup(zfs_handle_t *zhp_orig)
        return (zhp);
 }
 
+boolean_t
+zfs_bookmark_exists(const char *path)
+{
+       nvlist_t *bmarks;
+       nvlist_t *props;
+       char fsname[ZFS_MAX_DATASET_NAME_LEN];
+       char *bmark_name;
+       char *pound;
+       int err;
+       boolean_t rv;
+
+
+       (void) strlcpy(fsname, path, sizeof (fsname));
+       pound = strchr(fsname, '#');
+       if (pound == NULL)
+               return (B_FALSE);
+
+       *pound = '\0';
+       bmark_name = pound + 1;
+       props = fnvlist_alloc();
+       err = lzc_get_bookmarks(fsname, props, &bmarks);
+       nvlist_free(props);
+       if (err != 0) {
+               nvlist_free(bmarks);
+               return (B_FALSE);
+       }
+
+       rv = nvlist_exists(bmarks, bmark_name);
+       nvlist_free(bmarks);
+       return (rv);
+}
+
+zfs_handle_t *
+make_bookmark_handle(zfs_handle_t *parent, const char *path,
+    nvlist_t *bmark_props)
+{
+       zfs_handle_t *zhp = calloc(sizeof (zfs_handle_t), 1);
+
+       if (zhp == NULL)
+               return (NULL);
+
+       /* Fill in the name. */
+       zhp->zfs_hdl = parent->zfs_hdl;
+       (void) strlcpy(zhp->zfs_name, path, sizeof (zhp->zfs_name));
+
+       /* Set the property lists. */
+       if (nvlist_dup(bmark_props, &zhp->zfs_props, 0) != 0) {
+               free(zhp);
+               return (NULL);
+       }
+
+       /* Set the types. */
+       zhp->zfs_head_type = parent->zfs_head_type;
+       zhp->zfs_type = ZFS_TYPE_BOOKMARK;
+
+       if ((zhp->zpool_hdl = zpool_handle(zhp)) == NULL) {
+               nvlist_free(zhp->zfs_props);
+               free(zhp);
+               return (NULL);
+       }
+
+       return (zhp);
+}
+
+struct zfs_open_bookmarks_cb_data {
+       const char *path;
+       zfs_handle_t *zhp;
+};
+
+static int
+zfs_open_bookmarks_cb(zfs_handle_t *zhp, void *data)
+{
+       struct zfs_open_bookmarks_cb_data *dp = data;
+
+       /*
+        * Is it the one we are looking for?
+        */
+       if (strcmp(dp->path, zfs_get_name(zhp)) == 0) {
+               /*
+                * We found it.  Save it and let the caller know we are done.
+                */
+               dp->zhp = zhp;
+               return (EEXIST);
+       }
+
+       /*
+        * Not found.  Close the handle and ask for another one.
+        */
+       zfs_close(zhp);
+       return (0);
+}
+
 /*
- * Opens the given snapshot, filesystem, or volume.   The 'types'
+ * Opens the given snapshot, bookmark, filesystem, or volume.   The 'types'
  * argument is a mask of acceptable types.  The function will print an
  * appropriate error message and return NULL if it can't be opened.
  */
@@ -558,6 +671,7 @@ zfs_open(libzfs_handle_t *hdl, const char *path, int types)
 {
        zfs_handle_t *zhp;
        char errbuf[1024];
+       char *bookp;
 
        (void) snprintf(errbuf, sizeof (errbuf),
            dgettext(TEXT_DOMAIN, "cannot open '%s'"), path);
@@ -565,20 +679,68 @@ zfs_open(libzfs_handle_t *hdl, const char *path, int types)
        /*
         * Validate the name before we even try to open it.
         */
-       if (!zfs_validate_name(hdl, path, ZFS_TYPE_DATASET, B_FALSE)) {
-               zfs_error_aux(hdl, dgettext(TEXT_DOMAIN,
-                   "invalid dataset name"));
+       if (!zfs_validate_name(hdl, path, types, B_FALSE)) {
                (void) zfs_error(hdl, EZFS_INVALIDNAME, errbuf);
                return (NULL);
        }
 
        /*
-        * Try to get stats for the dataset, which will tell us if it exists.
+        * Bookmarks needs to be handled separately.
         */
-       errno = 0;
-       if ((zhp = make_dataset_handle(hdl, path)) == NULL) {
-               (void) zfs_standard_error(hdl, errno, errbuf);
-               return (NULL);
+       bookp = strchr(path, '#');
+       if (bookp == NULL) {
+               /*
+                * Try to get stats for the dataset, which will tell us if it
+                * exists.
+                */
+               errno = 0;
+               if ((zhp = make_dataset_handle(hdl, path)) == NULL) {
+                       (void) zfs_standard_error(hdl, errno, errbuf);
+                       return (NULL);
+               }
+       } else {
+               char dsname[ZFS_MAX_DATASET_NAME_LEN];
+               zfs_handle_t *pzhp;
+               struct zfs_open_bookmarks_cb_data cb_data = {path, NULL};
+
+               /*
+                * We need to cut out '#' and everything after '#'
+                * to get the parent dataset name only.
+                */
+               assert(bookp - path < sizeof (dsname));
+               (void) strncpy(dsname, path, bookp - path);
+               dsname[bookp - path] = '\0';
+
+               /*
+                * Create handle for the parent dataset.
+                */
+               errno = 0;
+               if ((pzhp = make_dataset_handle(hdl, dsname)) == NULL) {
+                       (void) zfs_standard_error(hdl, errno, errbuf);
+                       return (NULL);
+               }
+
+               /*
+                * Iterate bookmarks to find the right one.
+                */
+               errno = 0;
+               if ((zfs_iter_bookmarks(pzhp, zfs_open_bookmarks_cb,
+                   &cb_data) == 0) && (cb_data.zhp == NULL)) {
+                       (void) zfs_error(hdl, EZFS_NOENT, errbuf);
+                       zfs_close(pzhp);
+                       return (NULL);
+               }
+               if (cb_data.zhp == NULL) {
+                       (void) zfs_standard_error(hdl, errno, errbuf);
+                       zfs_close(pzhp);
+                       return (NULL);
+               }
+               zhp = cb_data.zhp;
+
+               /*
+                * Cleanup.
+                */
+               zfs_close(pzhp);
        }
 
        if (!(types & zhp->zfs_type)) {
@@ -612,15 +774,13 @@ typedef struct mnttab_node {
 static int
 libzfs_mnttab_cache_compare(const void *arg1, const void *arg2)
 {
-       const mnttab_node_t *mtn1 = arg1;
-       const mnttab_node_t *mtn2 = arg2;
+       const mnttab_node_t *mtn1 = (const mnttab_node_t *)arg1;
+       const mnttab_node_t *mtn2 = (const mnttab_node_t *)arg2;
        int rv;
 
        rv = strcmp(mtn1->mtn_mt.mnt_special, mtn2->mtn_mt.mnt_special);
 
-       if (rv == 0)
-               return (0);
-       return (rv > 0 ? 1 : -1);
+       return (AVL_ISIGN(rv));
 }
 
 void
@@ -642,14 +802,27 @@ libzfs_mnttab_update(libzfs_handle_t *hdl)
 
        while (getmntent(hdl->libzfs_mnttab, &entry) == 0) {
                mnttab_node_t *mtn;
+               avl_index_t where;
 
                if (strcmp(entry.mnt_fstype, MNTTYPE_ZFS) != 0)
                        continue;
+
                mtn = zfs_alloc(hdl, sizeof (mnttab_node_t));
                mtn->mtn_mt.mnt_special = zfs_strdup(hdl, entry.mnt_special);
                mtn->mtn_mt.mnt_mountp = zfs_strdup(hdl, entry.mnt_mountp);
                mtn->mtn_mt.mnt_fstype = zfs_strdup(hdl, entry.mnt_fstype);
                mtn->mtn_mt.mnt_mntopts = zfs_strdup(hdl, entry.mnt_mntopts);
+
+               /* Exclude duplicate mounts */
+               if (avl_find(&hdl->libzfs_mnttab_cache, mtn, &where) != NULL) {
+                       free(mtn->mtn_mt.mnt_special);
+                       free(mtn->mtn_mt.mnt_mountp);
+                       free(mtn->mtn_mt.mnt_fstype);
+                       free(mtn->mtn_mt.mnt_mntopts);
+                       free(mtn);
+                       continue;
+               }
+
                avl_add(&hdl->libzfs_mnttab_cache, mtn);
        }
 
@@ -662,7 +835,8 @@ libzfs_mnttab_fini(libzfs_handle_t *hdl)
        void *cookie = NULL;
        mnttab_node_t *mtn;
 
-       while ((mtn = avl_destroy_nodes(&hdl->libzfs_mnttab_cache, &cookie))) {
+       while ((mtn = avl_destroy_nodes(&hdl->libzfs_mnttab_cache, &cookie))
+           != NULL) {
                free(mtn->mtn_mt.mnt_special);
                free(mtn->mtn_mt.mnt_mountp);
                free(mtn->mtn_mt.mnt_fstype);
@@ -740,7 +914,8 @@ libzfs_mnttab_remove(libzfs_handle_t *hdl, const char *fsname)
        mnttab_node_t *ret;
 
        find.mtn_mt.mnt_special = (char *)fsname;
-       if ((ret = avl_find(&hdl->libzfs_mnttab_cache, (void *)&find, NULL))) {
+       if ((ret = avl_find(&hdl->libzfs_mnttab_cache, (void *)&find, NULL))
+           != NULL) {
                avl_remove(&hdl->libzfs_mnttab_cache, ret);
                free(ret->mtn_mt.mnt_special);
                free(ret->mtn_mt.mnt_mountp);
@@ -789,7 +964,8 @@ zfs_which_resv_prop(zfs_handle_t *zhp, zfs_prop_t *resv_prop)
  */
 nvlist_t *
 zfs_valid_proplist(libzfs_handle_t *hdl, zfs_type_t type, nvlist_t *nvl,
-    uint64_t zoned, zfs_handle_t *zhp, const char *errbuf)
+    uint64_t zoned, zfs_handle_t *zhp, zpool_handle_t *zpool_hdl,
+    const char *errbuf)
 {
        nvpair_t *elem;
        uint64_t intval;
@@ -870,7 +1046,9 @@ zfs_valid_proplist(libzfs_handle_t *hdl, zfs_type_t type, nvlist_t *nvl,
                        }
 
                        if (uqtype != ZFS_PROP_USERQUOTA &&
-                           uqtype != ZFS_PROP_GROUPQUOTA) {
+                           uqtype != ZFS_PROP_GROUPQUOTA &&
+                           uqtype != ZFS_PROP_USEROBJQUOTA &&
+                           uqtype != ZFS_PROP_GROUPOBJQUOTA) {
                                zfs_error_aux(hdl,
                                    dgettext(TEXT_DOMAIN, "'%s' is readonly"),
                                    propname);
@@ -937,7 +1115,7 @@ zfs_valid_proplist(libzfs_handle_t *hdl, zfs_type_t type, nvlist_t *nvl,
                        goto error;
                }
 
-               if (!zfs_prop_valid_for_type(prop, type)) {
+               if (!zfs_prop_valid_for_type(prop, type, B_FALSE)) {
                        zfs_error_aux(hdl,
                            dgettext(TEXT_DOMAIN, "'%s' does not "
                            "apply to datasets of this type"), propname);
@@ -979,21 +1157,31 @@ zfs_valid_proplist(libzfs_handle_t *hdl, zfs_type_t type, nvlist_t *nvl,
                        break;
                }
 
-               case ZFS_PROP_RECORDSIZE:
                case ZFS_PROP_VOLBLOCKSIZE:
-                       /* must be power of two within SPA_{MIN,MAX}BLOCKSIZE */
+               case ZFS_PROP_RECORDSIZE:
+               {
+                       int maxbs = SPA_MAXBLOCKSIZE;
+                       char buf[64];
+
+                       if (zpool_hdl != NULL) {
+                               maxbs = zpool_get_prop_int(zpool_hdl,
+                                   ZPOOL_PROP_MAXBLOCKSIZE, NULL);
+                       }
+                       /*
+                        * The value must be a power of two between
+                        * SPA_MINBLOCKSIZE and maxbs.
+                        */
                        if (intval < SPA_MINBLOCKSIZE ||
-                           intval > SPA_MAXBLOCKSIZE || !ISP2(intval)) {
+                           intval > maxbs || !ISP2(intval)) {
+                               zfs_nicebytes(maxbs, buf, sizeof (buf));
                                zfs_error_aux(hdl, dgettext(TEXT_DOMAIN,
-                                   "'%s' must be power of 2 from %u "
-                                   "to %uk"), propname,
-                                   (uint_t)SPA_MINBLOCKSIZE,
-                                   (uint_t)SPA_MAXBLOCKSIZE >> 10);
+                                   "'%s' must be power of 2 from 512B "
+                                   "to %s"), propname, buf);
                                (void) zfs_error(hdl, EZFS_BADPROP, errbuf);
                                goto error;
                        }
                        break;
-
+               }
                case ZFS_PROP_MLSLABEL:
                {
 #ifdef HAVE_MLSLABEL
@@ -1076,7 +1264,12 @@ badlabel:
                                            "component of '%s' is too long"),
                                            propname);
                                        break;
+
                                default:
+                                       zfs_error_aux(hdl,
+                                           dgettext(TEXT_DOMAIN,
+                                           "(%d) not defined"),
+                                           why);
                                        break;
                                }
                                (void) zfs_error(hdl, EZFS_BADPROP, errbuf);
@@ -1196,12 +1389,15 @@ badlabel:
                        }
 
                        break;
+
                case ZFS_PROP_UTF8ONLY:
                        chosen_utf = (int)intval;
                        break;
+
                case ZFS_PROP_NORMALIZE:
                        chosen_normal = (int)intval;
                        break;
+
                default:
                        break;
                }
@@ -1232,7 +1428,7 @@ badlabel:
 
                        case ZFS_PROP_VOLSIZE:
                                if (intval % blocksize != 0) {
-                                       zfs_nicenum(blocksize, buf,
+                                       zfs_nicebytes(blocksize, buf,
                                            sizeof (buf));
                                        zfs_error_aux(hdl, dgettext(TEXT_DOMAIN,
                                            "'%s' must be a multiple of "
@@ -1252,6 +1448,7 @@ badlabel:
                                        goto error;
                                }
                                break;
+
                        default:
                                break;
                        }
@@ -1293,6 +1490,7 @@ zfs_add_synthetic_resv(zfs_handle_t *zhp, nvlist_t *nvl)
        uint64_t old_reservation;
        uint64_t new_reservation;
        zfs_prop_t resv_prop;
+       nvlist_t *props;
 
        /*
         * If this is an existing volume, and someone is setting the volsize,
@@ -1302,16 +1500,25 @@ zfs_add_synthetic_resv(zfs_handle_t *zhp, nvlist_t *nvl)
        if (zfs_which_resv_prop(zhp, &resv_prop) < 0)
                return (-1);
        old_reservation = zfs_prop_get_int(zhp, resv_prop);
-       if ((zvol_volsize_to_reservation(old_volsize, zhp->zfs_props) !=
-           old_reservation) || nvlist_lookup_uint64(nvl,
-           zfs_prop_to_name(resv_prop), &new_reservation) != ENOENT) {
+
+       props = fnvlist_alloc();
+       fnvlist_add_uint64(props, zfs_prop_to_name(ZFS_PROP_VOLBLOCKSIZE),
+           zfs_prop_get_int(zhp, ZFS_PROP_VOLBLOCKSIZE));
+
+       if ((zvol_volsize_to_reservation(old_volsize, props) !=
+           old_reservation) || nvlist_exists(nvl,
+           zfs_prop_to_name(resv_prop))) {
+               fnvlist_free(props);
                return (0);
        }
        if (nvlist_lookup_uint64(nvl, zfs_prop_to_name(ZFS_PROP_VOLSIZE),
-           &new_volsize) != 0)
+           &new_volsize) != 0) {
+               fnvlist_free(props);
                return (-1);
-       new_reservation = zvol_volsize_to_reservation(new_volsize,
-           zhp->zfs_props);
+       }
+       new_reservation = zvol_volsize_to_reservation(new_volsize, props);
+       fnvlist_free(props);
+
        if (nvlist_add_uint64(nvl, zfs_prop_to_name(resv_prop),
            new_reservation) != 0) {
                (void) no_memory(zhp->zfs_hdl);
@@ -1362,6 +1569,12 @@ zfs_setprop_error(libzfs_handle_t *hdl, zfs_prop_t prop, int err,
                (void) zfs_error(hdl, EZFS_DSREADONLY, errbuf);
                break;
 
+       case E2BIG:
+               zfs_error_aux(hdl, dgettext(TEXT_DOMAIN,
+                   "property value too long"));
+               (void) zfs_error(hdl, EZFS_BADPROP, errbuf);
+               break;
+
        case ENOTSUP:
                zfs_error_aux(hdl, dgettext(TEXT_DOMAIN,
                    "pool and or dataset must be upgraded to set this "
@@ -1370,11 +1583,19 @@ zfs_setprop_error(libzfs_handle_t *hdl, zfs_prop_t prop, int err,
                break;
 
        case ERANGE:
-               if (prop == ZFS_PROP_COMPRESSION) {
+               if (prop == ZFS_PROP_COMPRESSION ||
+                   prop == ZFS_PROP_DNODESIZE ||
+                   prop == ZFS_PROP_RECORDSIZE) {
                        (void) zfs_error_aux(hdl, dgettext(TEXT_DOMAIN,
                            "property setting is not allowed on "
                            "bootable datasets"));
                        (void) zfs_error(hdl, EZFS_NOTSUP, errbuf);
+               } else if (prop == ZFS_PROP_CHECKSUM ||
+                   prop == ZFS_PROP_DEDUP) {
+                       (void) zfs_error_aux(hdl, dgettext(TEXT_DOMAIN,
+                           "property setting is not allowed on "
+                           "root pools"));
+                       (void) zfs_error(hdl, EZFS_NOTSUP, errbuf);
                } else {
                        (void) zfs_standard_error(hdl, err, errbuf);
                }
@@ -1410,6 +1631,7 @@ zfs_is_namespace_prop(zfs_prop_t prop)
        switch (prop) {
 
        case ZFS_PROP_ATIME:
+       case ZFS_PROP_RELATIME:
        case ZFS_PROP_DEVICES:
        case ZFS_PROP_EXEC:
        case ZFS_PROP_SETUID:
@@ -1429,15 +1651,10 @@ zfs_is_namespace_prop(zfs_prop_t prop)
 int
 zfs_prop_set(zfs_handle_t *zhp, const char *propname, const char *propval)
 {
-       zfs_cmd_t zc = {"\0"};
        int ret = -1;
-       prop_changelist_t *cl = NULL;
        char errbuf[1024];
        libzfs_handle_t *hdl = zhp->zfs_hdl;
-       nvlist_t *nvl = NULL, *realprops;
-       zfs_prop_t prop;
-       boolean_t do_prefix = B_TRUE;
-       int added_resv = 0;
+       nvlist_t *nvl = NULL;
 
        (void) snprintf(errbuf, sizeof (errbuf),
            dgettext(TEXT_DOMAIN, "cannot set property for '%s'"),
@@ -1449,65 +1666,136 @@ zfs_prop_set(zfs_handle_t *zhp, const char *propname, const char *propval)
                goto error;
        }
 
-       if ((realprops = zfs_valid_proplist(hdl, zhp->zfs_type, nvl,
-           zfs_prop_get_int(zhp, ZFS_PROP_ZONED), zhp, errbuf)) == NULL)
-               goto error;
+       ret = zfs_prop_set_list(zhp, nvl);
 
+error:
        nvlist_free(nvl);
-       nvl = realprops;
+       return (ret);
+}
 
-       prop = zfs_name_to_prop(propname);
 
-       if (prop == ZFS_PROP_VOLSIZE) {
-               if ((added_resv = zfs_add_synthetic_resv(zhp, nvl)) == -1)
-                       goto error;
-       }
 
-       if ((cl = changelist_gather(zhp, prop, 0, 0)) == NULL)
-               goto error;
+/*
+ * Given an nvlist of property names and values, set the properties for the
+ * given dataset.
+ */
+int
+zfs_prop_set_list(zfs_handle_t *zhp, nvlist_t *props)
+{
+       zfs_cmd_t zc = {"\0"};
+       int ret = -1;
+       prop_changelist_t **cls = NULL;
+       int cl_idx;
+       char errbuf[1024];
+       libzfs_handle_t *hdl = zhp->zfs_hdl;
+       nvlist_t *nvl;
+       int nvl_len = 0;
+       int added_resv = 0;
+       zfs_prop_t prop = 0;
+       nvpair_t *elem;
 
-       if (prop == ZFS_PROP_MOUNTPOINT && changelist_haszonedchild(cl)) {
-               zfs_error_aux(hdl, dgettext(TEXT_DOMAIN,
-                   "child dataset with inherited mountpoint is used "
-                   "in a non-global zone"));
-               ret = zfs_error(hdl, EZFS_ZONED, errbuf);
+       (void) snprintf(errbuf, sizeof (errbuf),
+           dgettext(TEXT_DOMAIN, "cannot set property for '%s'"),
+           zhp->zfs_name);
+
+       if ((nvl = zfs_valid_proplist(hdl, zhp->zfs_type, props,
+           zfs_prop_get_int(zhp, ZFS_PROP_ZONED), zhp, zhp->zpool_hdl,
+           errbuf)) == NULL)
                goto error;
-       }
 
        /*
-        * We don't want to unmount & remount the dataset when changing
-        * its canmount property to 'on' or 'noauto'.  We only use
-        * the changelist logic to unmount when setting canmount=off.
+        * We have to check for any extra properties which need to be added
+        * before computing the length of the nvlist.
         */
-       if (prop == ZFS_PROP_CANMOUNT) {
-               uint64_t idx;
-               int err = zprop_string_to_index(prop, propval, &idx,
-                   ZFS_TYPE_DATASET);
-               if (err == 0 && idx != ZFS_CANMOUNT_OFF)
-                       do_prefix = B_FALSE;
+       for (elem = nvlist_next_nvpair(nvl, NULL);
+           elem != NULL;
+           elem = nvlist_next_nvpair(nvl, elem)) {
+               if (zfs_name_to_prop(nvpair_name(elem)) == ZFS_PROP_VOLSIZE &&
+                   (added_resv = zfs_add_synthetic_resv(zhp, nvl)) == -1) {
+                       goto error;
+               }
        }
-
-       if (do_prefix && (ret = changelist_prefix(cl)) != 0)
+       /*
+        * Check how many properties we're setting and allocate an array to
+        * store changelist pointers for postfix().
+        */
+       for (elem = nvlist_next_nvpair(nvl, NULL);
+           elem != NULL;
+           elem = nvlist_next_nvpair(nvl, elem))
+               nvl_len++;
+       if ((cls = calloc(nvl_len, sizeof (prop_changelist_t *))) == NULL)
                goto error;
 
+       cl_idx = 0;
+       for (elem = nvlist_next_nvpair(nvl, NULL);
+           elem != NULL;
+           elem = nvlist_next_nvpair(nvl, elem)) {
+
+               prop = zfs_name_to_prop(nvpair_name(elem));
+
+               assert(cl_idx < nvl_len);
+               /*
+                * We don't want to unmount & remount the dataset when changing
+                * its canmount property to 'on' or 'noauto'.  We only use
+                * the changelist logic to unmount when setting canmount=off.
+                */
+               if (prop != ZFS_PROP_CANMOUNT ||
+                   (fnvpair_value_uint64(elem) == ZFS_CANMOUNT_OFF &&
+                   zfs_is_mounted(zhp, NULL))) {
+                       cls[cl_idx] = changelist_gather(zhp, prop, 0, 0);
+                       if (cls[cl_idx] == NULL)
+                               goto error;
+               }
+
+               if (prop == ZFS_PROP_MOUNTPOINT &&
+                   changelist_haszonedchild(cls[cl_idx])) {
+                       zfs_error_aux(hdl, dgettext(TEXT_DOMAIN,
+                           "child dataset with inherited mountpoint is used "
+                           "in a non-global zone"));
+                       ret = zfs_error(hdl, EZFS_ZONED, errbuf);
+                       goto error;
+               }
+
+               if (cls[cl_idx] != NULL &&
+                   (ret = changelist_prefix(cls[cl_idx])) != 0)
+                       goto error;
+
+               cl_idx++;
+       }
+       assert(cl_idx == nvl_len);
+
        /*
-        * Execute the corresponding ioctl() to set this property.
+        * Execute the corresponding ioctl() to set this list of properties.
         */
        (void) strlcpy(zc.zc_name, zhp->zfs_name, sizeof (zc.zc_name));
 
-       if (zcmd_write_src_nvlist(hdl, &zc, nvl) != 0)
+       if ((ret = zcmd_write_src_nvlist(hdl, &zc, nvl)) != 0 ||
+           (ret = zcmd_alloc_dst_nvlist(hdl, &zc, 0)) != 0)
                goto error;
 
        ret = zfs_ioctl(hdl, ZFS_IOC_SET_PROP, &zc);
 
        if (ret != 0) {
-               zfs_setprop_error(hdl, prop, errno, errbuf);
+               /* Get the list of unset properties back and report them. */
+               nvlist_t *errorprops = NULL;
+               if (zcmd_read_dst_nvlist(hdl, &zc, &errorprops) != 0)
+                       goto error;
+               for (elem = nvlist_next_nvpair(nvl, NULL);
+                   elem != NULL;
+                   elem = nvlist_next_nvpair(nvl, elem)) {
+                       prop = zfs_name_to_prop(nvpair_name(elem));
+                       zfs_setprop_error(hdl, prop, errno, errbuf);
+               }
+               nvlist_free(errorprops);
+
                if (added_resv && errno == ENOSPC) {
                        /* clean up the volsize property we tried to set */
                        uint64_t old_volsize = zfs_prop_get_int(zhp,
                            ZFS_PROP_VOLSIZE);
                        nvlist_free(nvl);
+                       nvl = NULL;
                        zcmd_free_nvlists(&zc);
+
                        if (nvlist_alloc(&nvl, NV_UNIQUE_NAME, 0) != 0)
                                goto error;
                        if (nvlist_add_uint64(nvl,
@@ -1519,8 +1807,13 @@ zfs_prop_set(zfs_handle_t *zhp, const char *propname, const char *propval)
                        (void) zfs_ioctl(hdl, ZFS_IOC_SET_PROP, &zc);
                }
        } else {
-               if (do_prefix)
-                       ret = changelist_postfix(cl);
+               for (cl_idx = 0; cl_idx < nvl_len; cl_idx++) {
+                       if (cls[cl_idx] != NULL) {
+                               int clp_err = changelist_postfix(cls[cl_idx]);
+                               if (clp_err != 0)
+                                       ret = clp_err;
+                       }
+               }
 
                if (ret == 0) {
                        /*
@@ -1543,8 +1836,13 @@ zfs_prop_set(zfs_handle_t *zhp, const char *propname, const char *propval)
 error:
        nvlist_free(nvl);
        zcmd_free_nvlists(&zc);
-       if (cl)
-               changelist_free(cl);
+       if (cls != NULL) {
+               for (cl_idx = 0; cl_idx < nvl_len; cl_idx++) {
+                       if (cls[cl_idx] != NULL)
+                               changelist_free(cls[cl_idx]);
+               }
+               free(cls);
+       }
        return (ret);
 }
 
@@ -1598,7 +1896,7 @@ zfs_prop_inherit(zfs_handle_t *zhp, const char *propname, boolean_t received)
        /*
         * Check to see if the value applies to this type
         */
-       if (!zfs_prop_valid_for_type(prop, zhp->zfs_type))
+       if (!zfs_prop_valid_for_type(prop, zhp->zfs_type, B_FALSE))
                return (zfs_error(hdl, EZFS_PROPTYPE, errbuf));
 
        /*
@@ -1643,6 +1941,15 @@ zfs_prop_inherit(zfs_handle_t *zhp, const char *propname, boolean_t received)
                 * Refresh the statistics so the new property is reflected.
                 */
                (void) get_stats(zhp);
+
+               /*
+                * Remount the filesystem to propagate the change
+                * if one of the options handled by the generic
+                * Linux namespace layer has been modified.
+                */
+               if (zfs_is_namespace_prop(prop) &&
+                   zfs_is_mounted(zhp, NULL))
+                       ret = zfs_mount(zhp, MNTOPT_REMOUNT, 0);
        }
 
 error:
@@ -1675,22 +1982,21 @@ getprop_uint64(zfs_handle_t *zhp, zfs_prop_t prop, char **source)
        return (value);
 }
 
-static char *
+static const char *
 getprop_string(zfs_handle_t *zhp, zfs_prop_t prop, char **source)
 {
        nvlist_t *nv;
-       char *value;
+       const char *value;
 
        *source = NULL;
        if (nvlist_lookup_nvlist(zhp->zfs_props,
            zfs_prop_to_name(prop), &nv) == 0) {
-               verify(nvlist_lookup_string(nv, ZPROP_VALUE, &value) == 0);
+               value = fnvlist_lookup_string(nv, ZPROP_VALUE);
                (void) nvlist_lookup_string(nv, ZPROP_SOURCE, source);
        } else {
                verify(!zhp->zfs_props_table ||
                    zhp->zfs_props_table[prop] == B_TRUE);
-               if ((value = (char *)zfs_prop_default_string(prop)) == NULL)
-                       value = "";
+               value = zfs_prop_default_string(prop);
                *source = "";
        }
 
@@ -1722,9 +2028,9 @@ zfs_unset_recvd_props_mode(zfs_handle_t *zhp, uint64_t *cookie)
  * zfs_prop_get_int() are built using this interface.
  *
  * Certain properties can be overridden using 'mount -o'.  In this case, scan
- * the contents of the /etc/mtab entry, searching for the appropriate options.
- * If they differ from the on-disk values, report the current values and mark
- * the source "temporary".
+ * the contents of the /proc/self/mounts entry, searching for the
+ * appropriate options. If they differ from the on-disk values, report the
+ * current values and mark the source "temporary".
  */
 static int
 get_numeric_property(zfs_handle_t *zhp, zfs_prop_t prop, zprop_source_t *src,
@@ -1739,12 +2045,27 @@ get_numeric_property(zfs_handle_t *zhp, zfs_prop_t prop, zprop_source_t *src,
 
        *source = NULL;
 
+       /*
+        * If the property is being fetched for a snapshot, check whether
+        * the property is valid for the snapshot's head dataset type.
+        */
+       if (zhp->zfs_type == ZFS_TYPE_SNAPSHOT &&
+           !zfs_prop_valid_for_type(prop, zhp->zfs_head_type, B_TRUE)) {
+               *val = zfs_prop_default_numeric(prop);
+               return (-1);
+       }
+
        switch (prop) {
        case ZFS_PROP_ATIME:
                mntopt_on = MNTOPT_ATIME;
                mntopt_off = MNTOPT_NOATIME;
                break;
 
+       case ZFS_PROP_RELATIME:
+               mntopt_on = MNTOPT_RELATIME;
+               mntopt_off = MNTOPT_NORELATIME;
+               break;
+
        case ZFS_PROP_DEVICES:
                mntopt_on = MNTOPT_DEVICES;
                mntopt_off = MNTOPT_NODEVICES;
@@ -1774,14 +2095,16 @@ get_numeric_property(zfs_handle_t *zhp, zfs_prop_t prop, zprop_source_t *src,
                mntopt_on = MNTOPT_NBMAND;
                mntopt_off = MNTOPT_NONBMAND;
                break;
+
        default:
                break;
        }
 
        /*
         * Because looking up the mount options is potentially expensive
-        * (iterating over all of /etc/mtab), we defer its calculation until
-        * we're looking up a property which requires its presence.
+        * (iterating over all of /proc/self/mounts), we defer its
+        * calculation until we're looking up a property which requires
+        * its presence.
         */
        if (!zhp->zfs_mntcheck &&
            (mntopt_on != NULL || prop == ZFS_PROP_MOUNTED)) {
@@ -1805,6 +2128,7 @@ get_numeric_property(zfs_handle_t *zhp, zfs_prop_t prop, zprop_source_t *src,
 
        switch (prop) {
        case ZFS_PROP_ATIME:
+       case ZFS_PROP_RELATIME:
        case ZFS_PROP_DEVICES:
        case ZFS_PROP_EXEC:
        case ZFS_PROP_READONLY:
@@ -1833,6 +2157,10 @@ get_numeric_property(zfs_handle_t *zhp, zfs_prop_t prop, zprop_source_t *src,
        case ZFS_PROP_REFQUOTA:
        case ZFS_PROP_RESERVATION:
        case ZFS_PROP_REFRESERVATION:
+       case ZFS_PROP_FILESYSTEM_LIMIT:
+       case ZFS_PROP_SNAPSHOT_LIMIT:
+       case ZFS_PROP_FILESYSTEM_COUNT:
+       case ZFS_PROP_SNAPSHOT_COUNT:
                *val = getprop_uint64(zhp, prop, source);
 
                if (*source == NULL) {
@@ -1853,12 +2181,14 @@ get_numeric_property(zfs_handle_t *zhp, zfs_prop_t prop, zprop_source_t *src,
        case ZFS_PROP_NORMALIZE:
        case ZFS_PROP_UTF8ONLY:
        case ZFS_PROP_CASE:
-               if (!zfs_prop_valid_for_type(prop, zhp->zfs_head_type) ||
-                   zcmd_alloc_dst_nvlist(zhp->zfs_hdl, &zc, 0) != 0)
+               if (zcmd_alloc_dst_nvlist(zhp->zfs_hdl, &zc, 0) != 0)
                        return (-1);
                (void) strlcpy(zc.zc_name, zhp->zfs_name, sizeof (zc.zc_name));
                if (zfs_ioctl(zhp->zfs_hdl, ZFS_IOC_OBJSET_ZPLPROPS, &zc)) {
                        zcmd_free_nvlists(&zc);
+                       if (prop == ZFS_PROP_VERSION &&
+                           zhp->zfs_type == ZFS_TYPE_VOLUME)
+                               *val = zfs_prop_default_numeric(prop);
                        return (-1);
                }
                if (zcmd_read_dst_nvlist(zhp->zfs_hdl, &zc, &zplprops) != 0 ||
@@ -1867,11 +2197,14 @@ get_numeric_property(zfs_handle_t *zhp, zfs_prop_t prop, zprop_source_t *src,
                        zcmd_free_nvlists(&zc);
                        return (-1);
                }
-               if (zplprops)
-                       nvlist_free(zplprops);
+               nvlist_free(zplprops);
                zcmd_free_nvlists(&zc);
                break;
 
+       case ZFS_PROP_INCONSISTENT:
+               *val = zhp->zfs_dmustats.dds_inconsistent;
+               break;
+
        default:
                switch (zfs_prop_get_type(prop)) {
                case PROP_TYPE_NUMBER:
@@ -1880,11 +2213,15 @@ get_numeric_property(zfs_handle_t *zhp, zfs_prop_t prop, zprop_source_t *src,
                        /*
                         * If we tried to use a default value for a
                         * readonly property, it means that it was not
-                        * present.
+                        * present.  Note this only applies to "truly"
+                        * readonly properties, not set-once properties
+                        * like volblocksize.
                         */
                        if (zfs_prop_readonly(prop) &&
+                           !zfs_prop_setonce(prop) &&
                            *source != NULL && (*source)[0] == '\0') {
                                *source = NULL;
+                               return (-1);
                        }
                        break;
 
@@ -1987,7 +2324,7 @@ struct get_clones_arg {
        uint64_t numclones;
        nvlist_t *value;
        const char *origin;
-       char buf[ZFS_MAXNAMELEN];
+       char buf[ZFS_MAX_DATASET_NAME_LEN];
 };
 
 int
@@ -2042,7 +2379,7 @@ zfs_get_clones_nvl(zfs_handle_t *zhp)
 
                if (gca.numclones != 0) {
                        zfs_handle_t *root;
-                       char pool[ZFS_MAXNAMELEN];
+                       char pool[ZFS_MAX_DATASET_NAME_LEN];
                        char *cp = pool;
 
                        /* get the pool name */
@@ -2050,6 +2387,11 @@ zfs_get_clones_nvl(zfs_handle_t *zhp)
                        (void) strsep(&cp, "/@");
                        root = zfs_open(zhp->zfs_hdl, pool,
                            ZFS_TYPE_FILESYSTEM);
+                       if (root == NULL) {
+                               nvlist_free(nv);
+                               nvlist_free(value);
+                               return (NULL);
+                       }
 
                        (void) get_clones_cb(root, &gca);
                }
@@ -2086,14 +2428,14 @@ zfs_prop_get(zfs_handle_t *zhp, zfs_prop_t prop, char *propbuf, size_t proplen,
 {
        char *source = NULL;
        uint64_t val;
-       char *str;
+       const char *str;
        const char *strval;
        boolean_t received = zfs_is_recvd_props_mode(zhp);
 
        /*
         * Check to see if this property applies to our object
         */
-       if (!zfs_prop_valid_for_type(prop, zhp->zfs_type))
+       if (!zfs_prop_valid_for_type(prop, zhp->zfs_type, B_FALSE))
                return (-1);
 
        if (received && zfs_prop_readonly(prop))
@@ -2117,7 +2459,8 @@ zfs_prop_get(zfs_handle_t *zhp, zfs_prop_t prop, char *propbuf, size_t proplen,
                            localtime_r(&time, &t) == NULL ||
                            strftime(propbuf, proplen, "%a %b %e %k:%M %Y",
                            &t) == 0)
-                               (void) snprintf(propbuf, proplen, "%llu", (u_longlong_t) val);
+                               (void) snprintf(propbuf, proplen, "%llu",
+                                   (u_longlong_t)val);
                }
                break;
 
@@ -2156,8 +2499,8 @@ zfs_prop_get(zfs_handle_t *zhp, zfs_prop_t prop, char *propbuf, size_t proplen,
                        }
 
                        if ((zpool_get_prop(zhp->zpool_hdl,
-                           ZPOOL_PROP_ALTROOT, buf, MAXPATHLEN, NULL)) ||
-                           (strcmp(root, "-") == 0))
+                           ZPOOL_PROP_ALTROOT, buf, MAXPATHLEN, NULL,
+                           B_FALSE)) || (strcmp(root, "-") == 0))
                                root[0] = '\0';
                        /*
                         * Special case an alternate root of '/'. This will
@@ -2191,14 +2534,10 @@ zfs_prop_get(zfs_handle_t *zhp, zfs_prop_t prop, char *propbuf, size_t proplen,
                break;
 
        case ZFS_PROP_ORIGIN:
-               (void) strlcpy(propbuf, getprop_string(zhp, prop, &source),
-                   proplen);
-               /*
-                * If there is no parent at all, return failure to indicate that
-                * it doesn't apply to this dataset.
-                */
-               if (propbuf[0] == '\0')
+               str = getprop_string(zhp, prop, &source);
+               if (str == NULL)
                        return (-1);
+               (void) strlcpy(propbuf, str, proplen);
                break;
 
        case ZFS_PROP_CLONES:
@@ -2230,7 +2569,31 @@ zfs_prop_get(zfs_handle_t *zhp, zfs_prop_t prop, char *propbuf, size_t proplen,
                                (void) snprintf(propbuf, proplen, "%llu",
                                    (u_longlong_t)val);
                        else
-                               zfs_nicenum(val, propbuf, proplen);
+                               zfs_nicebytes(val, propbuf, proplen);
+               }
+               break;
+
+       case ZFS_PROP_FILESYSTEM_LIMIT:
+       case ZFS_PROP_SNAPSHOT_LIMIT:
+       case ZFS_PROP_FILESYSTEM_COUNT:
+       case ZFS_PROP_SNAPSHOT_COUNT:
+
+               if (get_numeric_property(zhp, prop, src, &source, &val) != 0)
+                       return (-1);
+
+               /*
+                * If limit is UINT64_MAX, we translate this into 'none' (unless
+                * literal is set), and indicate that it's the default value.
+                * Otherwise, we print the number nicely and indicate that it's
+                * set locally.
+                */
+               if (literal) {
+                       (void) snprintf(propbuf, proplen, "%llu",
+                           (u_longlong_t)val);
+               } else if (val == UINT64_MAX) {
+                       (void) strlcpy(propbuf, "none", proplen);
+               } else {
+                       zfs_nicenum(val, propbuf, proplen);
                }
                break;
 
@@ -2254,6 +2617,9 @@ zfs_prop_get(zfs_handle_t *zhp, zfs_prop_t prop, char *propbuf, size_t proplen,
                case ZFS_TYPE_SNAPSHOT:
                        str = "snapshot";
                        break;
+               case ZFS_TYPE_BOOKMARK:
+                       str = "bookmark";
+                       break;
                default:
                        abort();
                }
@@ -2329,6 +2695,7 @@ zfs_prop_get(zfs_handle_t *zhp, zfs_prop_t prop, char *propbuf, size_t proplen,
                break;
 
        case ZFS_PROP_GUID:
+       case ZFS_PROP_CREATETXG:
                /*
                 * GUIDs are stored as numbers, but they are identifiers.
                 * We don't want them to be pretty printed, because pretty
@@ -2339,6 +2706,22 @@ zfs_prop_get(zfs_handle_t *zhp, zfs_prop_t prop, char *propbuf, size_t proplen,
                (void) snprintf(propbuf, proplen, "%llu", (u_longlong_t)val);
                break;
 
+       case ZFS_PROP_REFERENCED:
+       case ZFS_PROP_AVAILABLE:
+       case ZFS_PROP_USED:
+       case ZFS_PROP_USEDSNAP:
+       case ZFS_PROP_USEDDS:
+       case ZFS_PROP_USEDREFRESERV:
+       case ZFS_PROP_USEDCHILD:
+               if (get_numeric_property(zhp, prop, src, &source, &val) != 0)
+                       return (-1);
+               if (literal)
+                       (void) snprintf(propbuf, proplen, "%llu",
+                           (u_longlong_t)val);
+               else
+                       zfs_nicebytes(val, propbuf, proplen);
+               break;
+
        default:
                switch (zfs_prop_get_type(prop)) {
                case PROP_TYPE_NUMBER:
@@ -2353,8 +2736,10 @@ zfs_prop_get(zfs_handle_t *zhp, zfs_prop_t prop, char *propbuf, size_t proplen,
                        break;
 
                case PROP_TYPE_STRING:
-                       (void) strlcpy(propbuf,
-                           getprop_string(zhp, prop, &source), proplen);
+                       str = getprop_string(zhp, prop, &source);
+                       if (str == NULL)
+                               return (-1);
+                       (void) strlcpy(propbuf, str, proplen);
                        break;
 
                case PROP_TYPE_INDEX:
@@ -2385,7 +2770,7 @@ uint64_t
 zfs_prop_get_int(zfs_handle_t *zhp, zfs_prop_t prop)
 {
        char *source;
-       uint64_t val;
+       uint64_t val = 0;
 
        (void) get_numeric_property(zhp, prop, NULL, &source, &val);
 
@@ -2413,7 +2798,7 @@ zfs_prop_get_numeric(zfs_handle_t *zhp, zfs_prop_t prop, uint64_t *value,
        /*
         * Check to see if this property applies to our object
         */
-       if (!zfs_prop_valid_for_type(prop, zhp->zfs_type)) {
+       if (!zfs_prop_valid_for_type(prop, zhp->zfs_type, B_FALSE)) {
                return (zfs_error_fmt(zhp->zfs_hdl, EZFS_PROPTYPE,
                    dgettext(TEXT_DOMAIN, "cannot get property '%s'"),
                    zfs_prop_to_name(prop)));
@@ -2492,8 +2877,12 @@ userquota_propname_decode(const char *propname, boolean_t zoned,
                return (EINVAL);
        *typep = type;
 
-       isuser = (type == ZFS_PROP_USERQUOTA || type == ZFS_PROP_USERUSED);
-       isgroup = (type == ZFS_PROP_GROUPQUOTA || type == ZFS_PROP_GROUPUSED);
+       isuser = (type == ZFS_PROP_USERQUOTA || type == ZFS_PROP_USERUSED ||
+           type == ZFS_PROP_USEROBJQUOTA ||
+           type == ZFS_PROP_USEROBJUSED);
+       isgroup = (type == ZFS_PROP_GROUPQUOTA || type == ZFS_PROP_GROUPUSED ||
+           type == ZFS_PROP_GROUPOBJQUOTA ||
+           type == ZFS_PROP_GROUPOBJUSED);
 
        cp = strchr(propname, '@') + 1;
 
@@ -2624,10 +3013,14 @@ zfs_prop_get_userquota(zfs_handle_t *zhp, const char *propname,
 
        if (literal) {
                (void) snprintf(propbuf, proplen, "%llu",
-                              (u_longlong_t)propvalue);
+                   (u_longlong_t)propvalue);
        } else if (propvalue == 0 &&
-           (type == ZFS_PROP_USERQUOTA || type == ZFS_PROP_GROUPQUOTA)) {
+           (type == ZFS_PROP_USERQUOTA || type == ZFS_PROP_GROUPQUOTA ||
+           type == ZFS_PROP_USEROBJQUOTA || type == ZFS_PROP_GROUPOBJQUOTA)) {
                (void) strlcpy(propbuf, "none", proplen);
+       } else if (type == ZFS_PROP_USERQUOTA || type == ZFS_PROP_GROUPQUOTA ||
+           type == ZFS_PROP_USERUSED || type == ZFS_PROP_GROUPUSED) {
+               zfs_nicebytes(propvalue, propbuf, proplen);
        } else {
                zfs_nicenum(propvalue, propbuf, proplen);
        }
@@ -2681,9 +3074,10 @@ zfs_prop_get_written(zfs_handle_t *zhp, const char *propname,
                return (err);
 
        if (literal) {
-               (void) snprintf(propbuf, proplen, "%llu", (long long unsigned int)propvalue);
+               (void) snprintf(propbuf, proplen, "%llu",
+                   (u_longlong_t)propvalue);
        } else {
-               zfs_nicenum(propvalue, propbuf, proplen);
+               zfs_nicebytes(propvalue, propbuf, proplen);
        }
 
        return (0);
@@ -2698,6 +3092,15 @@ zfs_get_name(const zfs_handle_t *zhp)
        return (zhp->zfs_name);
 }
 
+/*
+ * Returns the name of the parent pool for the given zfs handle.
+ */
+const char *
+zfs_get_pool_name(const zfs_handle_t *zhp)
+{
+       return (zhp->zpool_hdl->zpool_name);
+}
+
 /*
  * Returns the type of the given zfs handle.
  */
@@ -2760,7 +3163,7 @@ check_parents(libzfs_handle_t *hdl, const char *path, uint64_t *zoned,
     boolean_t accept_ancestor, int *prefixlen)
 {
        zfs_cmd_t zc = {"\0"};
-       char parent[ZFS_MAXNAMELEN];
+       char parent[ZFS_MAX_DATASET_NAME_LEN];
        char *slash;
        zfs_handle_t *zhp;
        char errbuf[1024];
@@ -2888,7 +3291,7 @@ create_parents(libzfs_handle_t *hdl, char *target, int prefixlen)
         * up to the prefixlen-long one.
         */
        for (cp = target + prefixlen + 1;
-           (cp = strchr(cp, '/')); *cp = '/', cp++) {
+           (cp = strchr(cp, '/')) != NULL; *cp = '/', cp++) {
 
                *cp = '\0';
 
@@ -2967,7 +3370,8 @@ zfs_create(libzfs_handle_t *hdl, const char *path, zfs_type_t type,
        uint64_t blocksize = zfs_prop_default_numeric(ZFS_PROP_VOLBLOCKSIZE);
        char errbuf[1024];
        uint64_t zoned;
-       dmu_objset_type_t ost;
+       enum lzc_dataset_type ost;
+       zpool_handle_t *zpool_handle;
 
        (void) snprintf(errbuf, sizeof (errbuf), dgettext(TEXT_DOMAIN,
            "cannot create '%s'"), path);
@@ -2994,13 +3398,28 @@ zfs_create(libzfs_handle_t *hdl, const char *path, zfs_type_t type,
        }
 
        if (type == ZFS_TYPE_VOLUME)
-               ost = DMU_OST_ZVOL;
+               ost = LZC_DATSET_TYPE_ZVOL;
        else
-               ost = DMU_OST_ZFS;
+               ost = LZC_DATSET_TYPE_ZFS;
+
+       /* open zpool handle for prop validation */
+       char pool_path[ZFS_MAX_DATASET_NAME_LEN];
+       (void) strlcpy(pool_path, path, sizeof (pool_path));
+
+       /* truncate pool_path at first slash */
+       char *p = strchr(pool_path, '/');
+       if (p != NULL)
+               *p = '\0';
+
+       if ((zpool_handle = zpool_open(hdl, pool_path)) == NULL)
+               return (-1);
 
        if (props && (props = zfs_valid_proplist(hdl, type, props,
-           zoned, NULL, errbuf)) == 0)
+           zoned, NULL, zpool_handle, errbuf)) == 0) {
+               zpool_close(zpool_handle);
                return (-1);
+       }
+       zpool_close(zpool_handle);
 
        if (type == ZFS_TYPE_VOLUME) {
                /*
@@ -3052,20 +3471,9 @@ zfs_create(libzfs_handle_t *hdl, const char *path, zfs_type_t type,
        ret = lzc_create(path, ost, props);
        nvlist_free(props);
 
-       if (ret == 0 && type == ZFS_TYPE_VOLUME) {
-               ret = zvol_create_link(hdl, path);
-               if (ret) {
-                       (void) zfs_standard_error(hdl, errno,
-                           dgettext(TEXT_DOMAIN,
-                           "Volume successfully created, but device links "
-                           "were not created"));
-                       return (-1);
-               }
-       }
-
        /* check for failure */
        if (ret != 0) {
-               char parent[ZFS_MAXNAMELEN];
+               char parent[ZFS_MAX_DATASET_NAME_LEN];
                (void) parent_name(path, parent, sizeof (parent));
 
                switch (errno) {
@@ -3079,15 +3487,6 @@ zfs_create(libzfs_handle_t *hdl, const char *path, zfs_type_t type,
                            "parent '%s' is not a filesystem"), parent);
                        return (zfs_error(hdl, EZFS_BADTYPE, errbuf));
 
-               case EDOM:
-                       zfs_error_aux(hdl, dgettext(TEXT_DOMAIN,
-                           "volume block size must be power of 2 from "
-                           "%u to %uk"),
-                           (uint_t)SPA_MINBLOCKSIZE,
-                           (uint_t)SPA_MAXBLOCKSIZE >> 10);
-
-                       return (zfs_error(hdl, EZFS_BADPROP, errbuf));
-
                case ENOTSUP:
                        zfs_error_aux(hdl, dgettext(TEXT_DOMAIN,
                            "pool must be upgraded to set this "
@@ -3121,12 +3520,22 @@ zfs_destroy(zfs_handle_t *zhp, boolean_t defer)
 {
        zfs_cmd_t zc = {"\0"};
 
+       if (zhp->zfs_type == ZFS_TYPE_BOOKMARK) {
+               nvlist_t *nv = fnvlist_alloc();
+               fnvlist_add_boolean(nv, zhp->zfs_name);
+               int error = lzc_destroy_bookmarks(nv, NULL);
+               fnvlist_free(nv);
+               if (error != 0) {
+                       return (zfs_standard_error_fmt(zhp->zfs_hdl, errno,
+                           dgettext(TEXT_DOMAIN, "cannot destroy '%s'"),
+                           zhp->zfs_name));
+               }
+               return (0);
+       }
+
        (void) strlcpy(zc.zc_name, zhp->zfs_name, sizeof (zc.zc_name));
 
        if (ZFS_IS_VOLUME(zhp)) {
-               if (zvol_remove_link(zhp->zfs_hdl, zhp->zfs_name) != 0)
-                       return (-1);
-
                zc.zc_objset_type = DMU_OST_ZVOL;
        } else {
                zc.zc_objset_type = DMU_OST_ZFS;
@@ -3154,7 +3563,7 @@ static int
 zfs_check_snap_cb(zfs_handle_t *zhp, void *arg)
 {
        struct destroydata *dd = arg;
-       char name[ZFS_MAXNAMELEN];
+       char name[ZFS_MAX_DATASET_NAME_LEN];
        int rv = 0;
 
        (void) snprintf(name, sizeof (name),
@@ -3163,15 +3572,6 @@ zfs_check_snap_cb(zfs_handle_t *zhp, void *arg)
        if (lzc_exists(name))
                verify(nvlist_add_boolean(dd->nvl, name) == 0);
 
-       if (zhp->zfs_type == ZFS_TYPE_VOLUME) {
-               (void) zvol_remove_link(zhp->zfs_hdl, name);
-               /*
-                * NB: this is simply a best-effort.  We don't want to
-                * return an error, because then we wouldn't visit all
-                * the volumes.
-                */
-       }
-
        rv = zfs_iter_filesystems(zhp, zfs_check_snap_cb, dd);
        zfs_close(zhp);
        return (rv);
@@ -3208,13 +3608,15 @@ int
 zfs_destroy_snaps_nvl(libzfs_handle_t *hdl, nvlist_t *snaps, boolean_t defer)
 {
        int ret;
-       nvlist_t *errlist;
+       nvlist_t *errlist = NULL;
        nvpair_t *pair;
 
        ret = lzc_destroy_snaps(snaps, defer, &errlist);
 
-       if (ret == 0)
+       if (ret == 0) {
+               nvlist_free(errlist);
                return (0);
+       }
 
        if (nvlist_empty(errlist)) {
                char errbuf[1024];
@@ -3242,6 +3644,7 @@ zfs_destroy_snaps_nvl(libzfs_handle_t *hdl, nvlist_t *snaps, boolean_t defer)
                }
        }
 
+       nvlist_free(errlist);
        return (ret);
 }
 
@@ -3251,7 +3654,7 @@ zfs_destroy_snaps_nvl(libzfs_handle_t *hdl, nvlist_t *snaps, boolean_t defer)
 int
 zfs_clone(zfs_handle_t *zhp, const char *target, nvlist_t *props)
 {
-       char parent[ZFS_MAXNAMELEN];
+       char parent[ZFS_MAX_DATASET_NAME_LEN];
        int ret;
        char errbuf[1024];
        libzfs_handle_t *hdl = zhp->zfs_hdl;
@@ -3282,7 +3685,7 @@ zfs_clone(zfs_handle_t *zhp, const char *target, nvlist_t *props)
                        type = ZFS_TYPE_FILESYSTEM;
                }
                if ((props = zfs_valid_proplist(hdl, type, props, zoned,
-                   zhp, errbuf)) == NULL)
+                   zhp, zhp->zpool_hdl, errbuf)) == NULL)
                        return (-1);
        }
 
@@ -3316,70 +3719,11 @@ zfs_clone(zfs_handle_t *zhp, const char *target, nvlist_t *props)
                        return (zfs_standard_error(zhp->zfs_hdl, errno,
                            errbuf));
                }
-       } else if (ZFS_IS_VOLUME(zhp)) {
-               ret = zvol_create_link(zhp->zfs_hdl, target);
        }
 
        return (ret);
 }
 
-typedef struct promote_data {
-       char cb_mountpoint[MAXPATHLEN];
-       const char *cb_target;
-       const char *cb_errbuf;
-       uint64_t cb_pivot_txg;
-} promote_data_t;
-
-static int
-promote_snap_cb(zfs_handle_t *zhp, void *data)
-{
-       promote_data_t *pd = data;
-       zfs_handle_t *szhp;
-       char snapname[MAXPATHLEN];
-       int rv = 0;
-
-       /* We don't care about snapshots after the pivot point */
-       if (zfs_prop_get_int(zhp, ZFS_PROP_CREATETXG) > pd->cb_pivot_txg) {
-               zfs_close(zhp);
-               return (0);
-       }
-
-       /* Remove the device link if it's a zvol. */
-       if (ZFS_IS_VOLUME(zhp))
-               (void) zvol_remove_link(zhp->zfs_hdl, zhp->zfs_name);
-
-       /* Check for conflicting names */
-       (void) strlcpy(snapname, pd->cb_target, sizeof (snapname));
-       (void) strlcat(snapname, strchr(zhp->zfs_name, '@'), sizeof (snapname));
-       szhp = make_dataset_handle(zhp->zfs_hdl, snapname);
-       if (szhp != NULL) {
-               zfs_close(szhp);
-               zfs_error_aux(zhp->zfs_hdl, dgettext(TEXT_DOMAIN,
-                   "snapshot name '%s' from origin \n"
-                   "conflicts with '%s' from target"),
-                   zhp->zfs_name, snapname);
-               rv = zfs_error(zhp->zfs_hdl, EZFS_EXISTS, pd->cb_errbuf);
-       }
-       zfs_close(zhp);
-       return (rv);
-}
-
-static int
-promote_snap_done_cb(zfs_handle_t *zhp, void *data)
-{
-       promote_data_t *pd = data;
-
-       /* We don't care about snapshots after the pivot point */
-       if (zfs_prop_get_int(zhp, ZFS_PROP_CREATETXG) <= pd->cb_pivot_txg) {
-               /* Create the device link if it's a zvol. */
-               if (ZFS_IS_VOLUME(zhp))
-                       (void) zvol_create_link(zhp->zfs_hdl, zhp->zfs_name);
-       }
-
-       zfs_close(zhp);
-       return (0);
-}
-
 /*
  * Promotes the given clone fs to be the clone parent.
  */
@@ -3389,10 +3733,7 @@ zfs_promote(zfs_handle_t *zhp)
        libzfs_handle_t *hdl = zhp->zfs_hdl;
        zfs_cmd_t zc = {"\0"};
        char parent[MAXPATHLEN];
-       char *cp;
        int ret;
-       zfs_handle_t *pzhp;
-       promote_data_t pd;
        char errbuf[1024];
 
        (void) snprintf(errbuf, sizeof (errbuf), dgettext(TEXT_DOMAIN,
@@ -3410,29 +3751,7 @@ zfs_promote(zfs_handle_t *zhp)
                    "not a cloned filesystem"));
                return (zfs_error(hdl, EZFS_BADTYPE, errbuf));
        }
-       cp = strchr(parent, '@');
-       *cp = '\0';
 
-       /* Walk the snapshots we will be moving */
-       pzhp = zfs_open(hdl, zhp->zfs_dmustats.dds_origin, ZFS_TYPE_SNAPSHOT);
-       if (pzhp == NULL)
-               return (-1);
-       pd.cb_pivot_txg = zfs_prop_get_int(pzhp, ZFS_PROP_CREATETXG);
-       zfs_close(pzhp);
-       pd.cb_target = zhp->zfs_name;
-       pd.cb_errbuf = errbuf;
-       pzhp = zfs_open(hdl, parent, ZFS_TYPE_DATASET);
-       if (pzhp == NULL)
-               return (-1);
-       (void) zfs_prop_get(pzhp, ZFS_PROP_MOUNTPOINT, pd.cb_mountpoint,
-           sizeof (pd.cb_mountpoint), NULL, NULL, 0, FALSE);
-       ret = zfs_iter_snapshots(pzhp, B_FALSE, promote_snap_cb, &pd);
-       if (ret != 0) {
-               zfs_close(pzhp);
-               return (-1);
-       }
-
-       /* issue the ioctl */
        (void) strlcpy(zc.zc_value, zhp->zfs_dmustats.dds_origin,
            sizeof (zc.zc_value));
        (void) strlcpy(zc.zc_name, zhp->zfs_name, sizeof (zc.zc_name));
@@ -3441,17 +3760,9 @@ zfs_promote(zfs_handle_t *zhp)
        if (ret != 0) {
                int save_errno = errno;
 
-               (void) zfs_iter_snapshots(pzhp, B_FALSE, promote_snap_done_cb,
-                   &pd);
-               zfs_close(pzhp);
-
                switch (save_errno) {
                case EEXIST:
-                       /*
-                        * There is a conflicting snapshot name.  We
-                        * should have caught this above, but they could
-                        * have renamed something in the mean time.
-                        */
+                       /* There is a conflicting snapshot name. */
                        zfs_error_aux(hdl, dgettext(TEXT_DOMAIN,
                            "conflicting snapshot '%s' from parent '%s'"),
                            zc.zc_string, parent);
@@ -3460,45 +3771,7 @@ zfs_promote(zfs_handle_t *zhp)
                default:
                        return (zfs_standard_error(hdl, save_errno, errbuf));
                }
-       } else {
-               (void) zfs_iter_snapshots(zhp, B_FALSE, promote_snap_done_cb,
-                   &pd);
-       }
-
-       zfs_close(pzhp);
-       return (ret);
-}
-
-struct createdata {
-       const char *cd_snapname;
-       int cd_ifexists;
-};
-
-static int
-zfs_create_link_cb(zfs_handle_t *zhp, void *arg)
-{
-       struct createdata *cd = arg;
-       int ret;
-
-       if (zhp->zfs_type == ZFS_TYPE_VOLUME) {
-               char name[MAXPATHLEN];
-
-               (void) strlcpy(name, zhp->zfs_name, sizeof (name));
-               (void) strlcat(name, "@", sizeof (name));
-               (void) strlcat(name, cd->cd_snapname, sizeof (name));
-               (void) zvol_create_link_common(zhp->zfs_hdl, name,
-                   cd->cd_ifexists);
-               /*
-                * NB: this is simply a best-effort.  We don't want to
-                * return an error, because then we wouldn't visit all
-                * the volumes.
-                */
        }
-
-       ret = zfs_iter_filesystems(zhp, zfs_create_link_cb, cd);
-
-       zfs_close(zhp);
-
        return (ret);
 }
 
@@ -3511,16 +3784,19 @@ static int
 zfs_snapshot_cb(zfs_handle_t *zhp, void *arg)
 {
        snapdata_t *sd = arg;
-       char name[ZFS_MAXNAMELEN];
+       char name[ZFS_MAX_DATASET_NAME_LEN];
        int rv = 0;
 
-       (void) snprintf(name, sizeof (name),
-           "%s@%s", zfs_get_name(zhp), sd->sd_snapname);
+       if (zfs_prop_get_int(zhp, ZFS_PROP_INCONSISTENT) == 0) {
+               (void) snprintf(name, sizeof (name),
+                   "%s@%s", zfs_get_name(zhp), sd->sd_snapname);
 
-       fnvlist_add_boolean(sd->sd_nvl, name);
+               fnvlist_add_boolean(sd->sd_nvl, name);
 
-       rv = zfs_iter_filesystems(zhp, zfs_snapshot_cb, sd);
+               rv = zfs_iter_filesystems(zhp, zfs_snapshot_cb, sd);
+       }
        zfs_close(zhp);
+
        return (rv);
 }
 
@@ -3535,6 +3811,8 @@ zfs_snapshot_nvl(libzfs_handle_t *hdl, nvlist_t *snaps, nvlist_t *props)
        char errbuf[1024];
        nvpair_t *elem;
        nvlist_t *errors;
+       zpool_handle_t *zpool_hdl;
+       char pool[ZFS_MAX_DATASET_NAME_LEN];
 
        (void) snprintf(errbuf, sizeof (errbuf), dgettext(TEXT_DOMAIN,
            "cannot create snapshots "));
@@ -3553,11 +3831,24 @@ zfs_snapshot_nvl(libzfs_handle_t *hdl, nvlist_t *snaps, nvlist_t *props)
                }
        }
 
+       /*
+        * get pool handle for prop validation. assumes all snaps are in the
+        * same pool, as does lzc_snapshot (below).
+        */
+       elem = nvlist_next_nvpair(snaps, NULL);
+       (void) strlcpy(pool, nvpair_name(elem), sizeof (pool));
+       pool[strcspn(pool, "/@")] = '\0';
+       zpool_hdl = zpool_open(hdl, pool);
+       if (zpool_hdl == NULL)
+               return (-1);
+
        if (props != NULL &&
            (props = zfs_valid_proplist(hdl, ZFS_TYPE_SNAPSHOT,
-           props, B_FALSE, NULL, errbuf)) == NULL) {
+           props, B_FALSE, NULL, zpool_hdl, errbuf)) == NULL) {
+               zpool_close(zpool_hdl);
                return (-1);
        }
+       zpool_close(zpool_hdl);
 
        ret = lzc_snapshot(snaps, props, &errors);
 
@@ -3586,31 +3877,6 @@ zfs_snapshot_nvl(libzfs_handle_t *hdl, nvlist_t *snaps, nvlist_t *props)
                                (void) zfs_standard_error(hdl, ret, errbuf);
                        }
                }
-       } else {
-               zfs_handle_t *zhp;
-               int linktries = 0, linkok = 0, linkfail = 0;
-               nvpair_t *snap;
-
-               for (snap = nvlist_next_nvpair(snaps, NULL); snap != NULL;
-                   snap = nvlist_next_nvpair(snaps, snap)) {
-                       char *cp, *snapname;
-
-                       snapname = nvpair_name(snap);
-                       cp = strchr(snapname, '@');
-                       *cp = '\0';
-
-                       if ((zhp = zfs_open(hdl, snapname, ZFS_TYPE_FILESYSTEM |
-                               ZFS_TYPE_VOLUME)) != NULL) {
-                               if (zhp->zfs_type == ZFS_TYPE_VOLUME) {
-                                       ++linktries;
-                                       *cp = '@';
-                                       if (zvol_create_link(zhp->zfs_hdl, nvpair_name(snap)))
-                                               ++linkfail;
-                                       else
-                                               ++linkok;
-                               }
-                       }
-               }
        }
 
        nvlist_free(props);
@@ -3624,7 +3890,7 @@ zfs_snapshot(libzfs_handle_t *hdl, const char *path, boolean_t recursive,
 {
        int ret;
        snapdata_t sd = { 0 };
-       char fsname[ZFS_MAXNAMELEN];
+       char fsname[ZFS_MAX_DATASET_NAME_LEN];
        char *cp;
        zfs_handle_t *zhp;
        char errbuf[1024];
@@ -3634,7 +3900,7 @@ zfs_snapshot(libzfs_handle_t *hdl, const char *path, boolean_t recursive,
 
        if (!zfs_validate_name(hdl, path, ZFS_TYPE_SNAPSHOT, B_TRUE))
                return (zfs_error(hdl, EZFS_INVALIDNAME, errbuf));
+
        (void) strlcpy(fsname, path, sizeof (fsname));
        cp = strchr(fsname, '@');
        *cp = '\0';
@@ -3668,45 +3934,44 @@ typedef struct rollback_data {
        const char      *cb_target;             /* the snapshot */
        uint64_t        cb_create;              /* creation time reference */
        boolean_t       cb_error;
-       boolean_t       cb_dependent;
        boolean_t       cb_force;
 } rollback_data_t;
 
 static int
-rollback_destroy(zfs_handle_t *zhp, void *data)
+rollback_destroy_dependent(zfs_handle_t *zhp, void *data)
 {
        rollback_data_t *cbp = data;
+       prop_changelist_t *clp;
 
-       if (!cbp->cb_dependent) {
-               if (strcmp(zhp->zfs_name, cbp->cb_target) != 0 &&
-                   zfs_get_type(zhp) == ZFS_TYPE_SNAPSHOT &&
-                   zfs_prop_get_int(zhp, ZFS_PROP_CREATETXG) >
-                   cbp->cb_create) {
+       /* We must destroy this clone; first unmount it */
+       clp = changelist_gather(zhp, ZFS_PROP_NAME, 0,
+           cbp->cb_force ? MS_FORCE: 0);
+       if (clp == NULL || changelist_prefix(clp) != 0) {
+               cbp->cb_error = B_TRUE;
+               zfs_close(zhp);
+               return (0);
+       }
+       if (zfs_destroy(zhp, B_FALSE) != 0)
+               cbp->cb_error = B_TRUE;
+       else
+               changelist_remove(clp, zhp->zfs_name);
+       (void) changelist_postfix(clp);
+       changelist_free(clp);
 
-                       cbp->cb_dependent = B_TRUE;
-                       cbp->cb_error |= zfs_iter_dependents(zhp, B_FALSE,
-                           rollback_destroy, cbp);
-                       cbp->cb_dependent = B_FALSE;
+       zfs_close(zhp);
+       return (0);
+}
 
-                       cbp->cb_error |= zfs_destroy(zhp, B_FALSE);
-               }
-       } else {
-               /* We must destroy this clone; first unmount it */
-               prop_changelist_t *clp;
+static int
+rollback_destroy(zfs_handle_t *zhp, void *data)
+{
+       rollback_data_t *cbp = data;
 
-               clp = changelist_gather(zhp, ZFS_PROP_NAME, 0,
-                   cbp->cb_force ? MS_FORCE: 0);
-               if (clp == NULL || changelist_prefix(clp) != 0) {
-                       cbp->cb_error = B_TRUE;
-                       zfs_close(zhp);
-                       return (0);
-               }
-               if (zfs_destroy(zhp, B_FALSE) != 0)
-                       cbp->cb_error = B_TRUE;
-               else
-                       changelist_remove(clp, zhp->zfs_name);
-               (void) changelist_postfix(clp);
-               changelist_free(clp);
+       if (zfs_prop_get_int(zhp, ZFS_PROP_CREATETXG) > cbp->cb_create) {
+               cbp->cb_error |= zfs_iter_dependents(zhp, B_FALSE,
+                   rollback_destroy_dependent, cbp);
+
+               cbp->cb_error |= zfs_destroy(zhp, B_FALSE);
        }
 
        zfs_close(zhp);
@@ -3717,15 +3982,14 @@ rollback_destroy(zfs_handle_t *zhp, void *data)
  * Given a dataset, rollback to a specific snapshot, discarding any
  * data changes since then and making it the active dataset.
  *
- * Any snapshots more recent than the target are destroyed, along with
- * their dependents.
+ * Any snapshots and bookmarks more recent than the target are
+ * destroyed, along with their dependents (i.e. clones).
  */
 int
 zfs_rollback(zfs_handle_t *zhp, zfs_handle_t *snap, boolean_t force)
 {
        rollback_data_t cb = { 0 };
        int err;
-       zfs_cmd_t zc = {"\0"};
        boolean_t restore_resv = 0;
        uint64_t old_volsize = 0, new_volsize;
        zfs_prop_t resv_prop = { 0 };
@@ -3739,7 +4003,8 @@ zfs_rollback(zfs_handle_t *zhp, zfs_handle_t *snap, boolean_t force)
        cb.cb_force = force;
        cb.cb_target = snap->zfs_name;
        cb.cb_create = zfs_prop_get_int(snap, ZFS_PROP_CREATETXG);
-       (void) zfs_iter_children(zhp, rollback_destroy, &cb);
+       (void) zfs_iter_snapshots(zhp, B_FALSE, rollback_destroy, &cb);
+       (void) zfs_iter_bookmarks(zhp, rollback_destroy, &cb);
 
        if (cb.cb_error)
                return (-1);
@@ -3750,8 +4015,6 @@ zfs_rollback(zfs_handle_t *zhp, zfs_handle_t *snap, boolean_t force)
         */
 
        if (zhp->zfs_type == ZFS_TYPE_VOLUME) {
-               if (zvol_remove_link(zhp->zfs_hdl, zhp->zfs_name) != 0)
-                       return (-1);
                if (zfs_which_resv_prop(zhp, &resv_prop) < 0)
                        return (-1);
                old_volsize = zfs_prop_get_int(zhp, ZFS_PROP_VOLSIZE);
@@ -3759,22 +4022,15 @@ zfs_rollback(zfs_handle_t *zhp, zfs_handle_t *snap, boolean_t force)
                    (old_volsize == zfs_prop_get_int(zhp, resv_prop));
        }
 
-       (void) strlcpy(zc.zc_name, zhp->zfs_name, sizeof (zc.zc_name));
-
-       if (ZFS_IS_VOLUME(zhp))
-               zc.zc_objset_type = DMU_OST_ZVOL;
-       else
-               zc.zc_objset_type = DMU_OST_ZFS;
-
        /*
         * We rely on zfs_iter_children() to verify that there are no
         * newer snapshots for the given dataset.  Therefore, we can
         * simply pass the name on to the ioctl() call.  There is still
         * an unlikely race condition where the user has taken a
         * snapshot since we verified that this was the most recent.
-        *
         */
-       if ((err = zfs_ioctl(zhp->zfs_hdl, ZFS_IOC_ROLLBACK, &zc)) != 0) {
+       err = lzc_rollback(zhp->zfs_name, NULL, 0);
+       if (err != 0) {
                (void) zfs_standard_error_fmt(zhp->zfs_hdl, errno,
                    dgettext(TEXT_DOMAIN, "cannot rollback '%s'"),
                    zhp->zfs_name);
@@ -3789,10 +4045,6 @@ zfs_rollback(zfs_handle_t *zhp, zfs_handle_t *snap, boolean_t force)
         */
        if ((zhp->zfs_type == ZFS_TYPE_VOLUME) &&
            (zhp = make_dataset_handle(zhp->zfs_hdl, zhp->zfs_name))) {
-               if ((err = zvol_create_link(zhp->zfs_hdl, zhp->zfs_name))) {
-                       zfs_close(zhp);
-                       return (err);
-               }
                if (restore_resv) {
                        new_volsize = zfs_prop_get_int(zhp, ZFS_PROP_VOLSIZE);
                        if (old_volsize != new_volsize)
@@ -3811,13 +4063,13 @@ int
 zfs_rename(zfs_handle_t *zhp, const char *target, boolean_t recursive,
     boolean_t force_unmount)
 {
-       int ret;
+       int ret = 0;
        zfs_cmd_t zc = {"\0"};
        char *delim;
        prop_changelist_t *cl = NULL;
        zfs_handle_t *zhrp = NULL;
        char *parentname = NULL;
-       char parent[ZFS_MAXNAMELEN];
+       char parent[ZFS_MAX_DATASET_NAME_LEN];
        libzfs_handle_t *hdl = zhp->zfs_hdl;
        char errbuf[1024];
 
@@ -3906,8 +4158,6 @@ zfs_rename(zfs_handle_t *zhp, const char *target, boolean_t recursive,
        }
 
        if (recursive) {
-               struct destroydata dd;
-
                parentname = zfs_strdup(zhp->zfs_hdl, zhp->zfs_name);
                if (parentname == NULL) {
                        ret = -1;
@@ -3920,17 +4170,7 @@ zfs_rename(zfs_handle_t *zhp, const char *target, boolean_t recursive,
                        ret = -1;
                        goto error;
                }
-
-               dd.snapname = delim + 1;
-
-               /* We remove any zvol links prior to renaming them */
-               verify(nvlist_alloc(&dd.nvl, NV_UNIQUE_NAME, 0) == 0);
-               ret = zfs_iter_filesystems(zhrp, zfs_check_snap_cb, &dd);
-               nvlist_free(dd.nvl);
-               if (ret) {
-                       goto error;
-               }
-       } else {
+       } else if (zhp->zfs_type != ZFS_TYPE_SNAPSHOT) {
                if ((cl = changelist_gather(zhp, ZFS_PROP_NAME, 0,
                    force_unmount ? MS_FORCE : 0)) == NULL)
                        return (-1);
@@ -3979,165 +4219,28 @@ zfs_rename(zfs_handle_t *zhp, const char *target, boolean_t recursive,
                 * On failure, we still want to remount any filesystems that
                 * were previously mounted, so we don't alter the system state.
                 */
-               if (recursive) {
-                       struct createdata cd;
-
-                       /* only create links for datasets that had existed */
-                       cd.cd_snapname = delim + 1;
-                       cd.cd_ifexists = B_TRUE;
-                       (void) zfs_iter_filesystems(zhrp, zfs_create_link_cb,
-                           &cd);
-               } else {
+               if (cl != NULL)
                        (void) changelist_postfix(cl);
-               }
        } else {
-               if (recursive) {
-                       struct createdata cd;
-
-                       /* only create links for datasets that had existed */
-                       cd.cd_snapname = strchr(target, '@') + 1;
-                       cd.cd_ifexists = B_TRUE;
-                       ret = zfs_iter_filesystems(zhrp, zfs_create_link_cb,
-                           &cd);
-               } else {
+               if (cl != NULL) {
                        changelist_rename(cl, zfs_get_name(zhp), target);
                        ret = changelist_postfix(cl);
                }
        }
 
 error:
-       if (parentname) {
+       if (parentname != NULL) {
                free(parentname);
        }
-       if (zhrp) {
+       if (zhrp != NULL) {
                zfs_close(zhrp);
        }
-       if (cl) {
+       if (cl != NULL) {
                changelist_free(cl);
        }
        return (ret);
 }
 
-/*
- * Given a zvol dataset, issue the ioctl to create the appropriate minor node,
- * and wait briefly for udev to create the /dev link.
- */
-int
-zvol_create_link(libzfs_handle_t *hdl, const char *dataset)
-{
-       return (zvol_create_link_common(hdl, dataset, B_FALSE));
-}
-
-static int
-zvol_create_link_common(libzfs_handle_t *hdl, const char *dataset, int ifexists)
-{
-       zfs_cmd_t zc = {"\0"};
-       char path[MAXPATHLEN];
-       int error;
-
-       (void) strlcpy(zc.zc_name, dataset, sizeof (zc.zc_name));
-
-       /*
-        * Issue the appropriate ioctl.
-        */
-       if (ioctl(hdl->libzfs_fd, ZFS_IOC_CREATE_MINOR, &zc) != 0) {
-               switch (errno) {
-               case EEXIST:
-                       /*
-                        * Silently ignore the case where the link already
-                        * exists.  This allows 'zfs volinit' to be run multiple
-                        * times without errors.
-                        */
-                       return (0);
-
-               case ENODEV:
-                       /*
-                        * snapdev set to hidden :
-                        *  device creation was not permitted (see zvol.c)
-                        *  ignore error quietly
-                        */
-                       return (0);
-
-               case ENOENT:
-                       /*
-                        * Dataset does not exist in the kernel.  If we
-                        * don't care (see zfs_rename), then ignore the
-                        * error quietly.
-                        */
-                       if (ifexists) {
-                               return (0);
-                       }
-
-                       /* FALLTHROUGH */
-
-               default:
-                       return (zfs_standard_error_fmt(hdl, errno,
-                           dgettext(TEXT_DOMAIN, "cannot create device links "
-                           "for '%s'"), dataset));
-               }
-       }
-
-       /*
-        * Wait for udev to create the device.
-        */
-       (void) snprintf(path, sizeof (path), "%s/%s", ZVOL_DIR, dataset);
-       error = zpool_label_disk_wait(path, DISK_LABEL_WAIT);
-       if (error)
-               (void) printf(gettext("%s may not be immediately "
-                   "available\n"), path);
-
-       return (0);
-}
-
-/*
- * Remove a minor node for the given zvol and the associated /dev links.
- */
-int
-zvol_remove_link(libzfs_handle_t *hdl, const char *dataset)
-{
-       zfs_cmd_t zc = {"\0"};
-       int timeout = 3000; /* in milliseconds */
-       int error = 0;
-       int i;
-
-       (void) strlcpy(zc.zc_name, dataset, sizeof (zc.zc_name));
-
-       /*
-        * Due to concurrent updates by udev the device may be reported as
-        * busy.  In this case don't immediately fail.  Instead briefly delay
-        * and retry the ioctl() which is now likely to succeed.  If unable
-        * remove the link after timeout milliseconds return the failure.
-        */
-       for (i = 0; i < timeout; i++) {
-               error = ioctl(hdl->libzfs_fd, ZFS_IOC_REMOVE_MINOR, &zc);
-               if (error && errno == EBUSY) {
-                       usleep(1000);
-                       continue;
-               } else {
-                       break;
-               }
-       }
-
-       if (error) {
-               switch (errno) {
-               case ENXIO:
-                       /*
-                        * Silently ignore the case where the link no longer
-                        * exists, so that 'zfs volfini' can be run multiple
-                        * times without errors.
-                        */
-                       return (0);
-
-               default:
-                       return (zfs_standard_error_fmt(hdl, errno,
-                           dgettext(TEXT_DOMAIN, "cannot remove device "
-                           "links for '%s': %s"), dataset, strerror(errno)));
-               }
-       }
-
-       return (0);
-}
-
 nvlist_t *
 zfs_get_user_props(zfs_handle_t *zhp)
 {
@@ -4158,7 +4261,8 @@ zfs_get_user_props(zfs_handle_t *zhp)
  *        of the RECEIVED column.
  */
 int
-zfs_expand_proplist(zfs_handle_t *zhp, zprop_list_t **plp, boolean_t received)
+zfs_expand_proplist(zfs_handle_t *zhp, zprop_list_t **plp, boolean_t received,
+    boolean_t literal)
 {
        libzfs_handle_t *hdl = zhp->zfs_hdl;
        zprop_list_t *entry;
@@ -4220,18 +4324,18 @@ zfs_expand_proplist(zfs_handle_t *zhp, zprop_list_t **plp, boolean_t received)
         * Now go through and check the width of any non-fixed columns
         */
        for (entry = *plp; entry != NULL; entry = entry->pl_next) {
-               if (entry->pl_fixed)
+               if (entry->pl_fixed && !literal)
                        continue;
 
                if (entry->pl_prop != ZPROP_INVAL) {
                        if (zfs_prop_get(zhp, entry->pl_prop,
-                           buf, sizeof (buf), NULL, NULL, 0, B_FALSE) == 0) {
+                           buf, sizeof (buf), NULL, NULL, 0, literal) == 0) {
                                if (strlen(buf) > entry->pl_width)
                                        entry->pl_width = strlen(buf);
                        }
                        if (received && zfs_prop_get_recvd(zhp,
                            zfs_prop_to_name(entry->pl_prop),
-                           buf, sizeof (buf), B_FALSE) == 0)
+                           buf, sizeof (buf), literal) == 0)
                                if (strlen(buf) > entry->pl_recvd_width)
                                        entry->pl_recvd_width = strlen(buf);
                } else {
@@ -4244,7 +4348,7 @@ zfs_expand_proplist(zfs_handle_t *zhp, zprop_list_t **plp, boolean_t received)
                        }
                        if (received && zfs_prop_get_recvd(zhp,
                            entry->pl_user_prop,
-                           buf, sizeof (buf), B_FALSE) == 0)
+                           buf, sizeof (buf), literal) == 0)
                                if (strlen(buf) > entry->pl_recvd_width)
                                        entry->pl_recvd_width = strlen(buf);
                }
@@ -4257,6 +4361,7 @@ void
 zfs_prune_proplist(zfs_handle_t *zhp, uint8_t *props)
 {
        nvpair_t *curr;
+       nvpair_t *next;
 
        /*
         * Keep a reference to the props-table against which we prune the
@@ -4268,7 +4373,7 @@ zfs_prune_proplist(zfs_handle_t *zhp, uint8_t *props)
 
        while (curr) {
                zfs_prop_t zfs_prop = zfs_name_to_prop(nvpair_name(curr));
-               nvpair_t *next = nvlist_next_nvpair(zhp->zfs_props, curr);
+               next = nvlist_next_nvpair(zhp->zfs_props, curr);
 
                /*
                 * User properties will result in ZPROP_INVAL, and since we
@@ -4299,7 +4404,7 @@ zfs_smb_acl_mgmt(libzfs_handle_t *hdl, char *dataset, char *path,
        if (cmd == ZFS_SMB_ACL_RENAME) {
                if (nvlist_alloc(&nvlist, NV_UNIQUE_NAME, 0) != 0) {
                        (void) no_memory(hdl);
-                       return (-1);
+                       return (0);
                }
        }
 
@@ -4330,8 +4435,7 @@ zfs_smb_acl_mgmt(libzfs_handle_t *hdl, char *dataset, char *path,
                return (-1);
        }
        error = ioctl(hdl->libzfs_fd, ZFS_IOC_SMB_ACL, &zc);
-       if (nvlist)
-               nvlist_free(nvlist);
+       nvlist_free(nvlist);
        return (error);
 }
 
@@ -4385,7 +4489,14 @@ zfs_userspace(zfs_handle_t *zhp, zfs_userquota_prop_t type,
 
                zc.zc_nvlist_dst_size = sizeof (buf);
                if (zfs_ioctl(hdl, ZFS_IOC_USERSPACE_MANY, &zc) != 0) {
-                       char errbuf[ZFS_MAXNAMELEN + 32];
+                       char errbuf[1024];
+
+                       if ((errno == ENOTSUP &&
+                           (type == ZFS_PROP_USEROBJUSED ||
+                           type == ZFS_PROP_GROUPOBJUSED ||
+                           type == ZFS_PROP_USEROBJQUOTA ||
+                           type == ZFS_PROP_GROUPOBJQUOTA)))
+                               break;
 
                        (void) snprintf(errbuf, sizeof (errbuf),
                            dgettext(TEXT_DOMAIN,
@@ -4412,13 +4523,14 @@ struct holdarg {
        const char *snapname;
        const char *tag;
        boolean_t recursive;
+       int error;
 };
 
 static int
 zfs_hold_one(zfs_handle_t *zhp, void *arg)
 {
        struct holdarg *ha = arg;
-       char name[ZFS_MAXNAMELEN];
+       char name[ZFS_MAX_DATASET_NAME_LEN];
        int rv = 0;
 
        (void) snprintf(name, sizeof (name),
@@ -4537,17 +4649,22 @@ static int
 zfs_release_one(zfs_handle_t *zhp, void *arg)
 {
        struct holdarg *ha = arg;
-       char name[ZFS_MAXNAMELEN];
+       char name[ZFS_MAX_DATASET_NAME_LEN];
        int rv = 0;
+       nvlist_t *existing_holds;
 
        (void) snprintf(name, sizeof (name),
            "%s@%s", zhp->zfs_name, ha->snapname);
 
-       if (lzc_exists(name)) {
-               nvlist_t *holds = fnvlist_alloc();
-               fnvlist_add_boolean(holds, ha->tag);
-               fnvlist_add_nvlist(ha->nvl, name, holds);
-               fnvlist_free(holds);
+       if (lzc_get_holds(name, &existing_holds) != 0) {
+               ha->error = ENOENT;
+       } else if (!nvlist_exists(existing_holds, ha->tag)) {
+               ha->error = ESRCH;
+       } else {
+               nvlist_t *torelease = fnvlist_alloc();
+               fnvlist_add_boolean(torelease, ha->tag);
+               fnvlist_add_nvlist(ha->nvl, name, torelease);
+               fnvlist_free(torelease);
        }
 
        if (ha->recursive)
@@ -4571,16 +4688,21 @@ zfs_release(zfs_handle_t *zhp, const char *snapname, const char *tag,
        ha.snapname = snapname;
        ha.tag = tag;
        ha.recursive = recursive;
+       ha.error = 0;
        (void) zfs_release_one(zfs_handle_dup(zhp), &ha);
 
        if (nvlist_empty(ha.nvl)) {
                fnvlist_free(ha.nvl);
-               ret = ENOENT;
+               ret = ha.error;
                (void) snprintf(errbuf, sizeof (errbuf),
                    dgettext(TEXT_DOMAIN,
                    "cannot release hold from snapshot '%s@%s'"),
                    zhp->zfs_name, snapname);
-               (void) zfs_standard_error(hdl, ret, errbuf);
+               if (ret == ESRCH) {
+                       (void) zfs_error(hdl, EZFS_REFTAG_RELE, errbuf);
+               } else {
+                       (void) zfs_standard_error(hdl, ret, errbuf);
+               }
                return (ret);
        }
 
@@ -4656,7 +4778,7 @@ tryagain:
        zc.zc_nvlist_dst_size = nvsz;
        zc.zc_nvlist_dst = (uintptr_t)nvbuf;
 
-       (void) strlcpy(zc.zc_name, zhp->zfs_name, ZFS_MAXNAMELEN);
+       (void) strlcpy(zc.zc_name, zhp->zfs_name, sizeof (zc.zc_name));
 
        if (ioctl(hdl->libzfs_fd, ZFS_IOC_GET_FSACL, &zc) != 0) {
                (void) snprintf(errbuf, sizeof (errbuf),