Author: avg
Date: Tue May 15 13:27:29 2018
New Revision: 333630
URL: https://svnweb.freebsd.org/changeset/base/333630

Log:
  Fix 'zpool create -t <tempname>'
  
  Creating a pool with a temporary name fails when we also specify custom
  dataset properties: this is because we mistakenly call
  zfs_set_prop_nvlist() on the "real" pool name which, as expected,
  cannot be found because the SPA is present in the namespace with the
  temporary name.
  
  Fix this by specifying the correct pool name when setting the dataset
  properties.
  
  Author: loli10K <[email protected]>
  Reviewed-by: Prakash Surya <[email protected]>
  Reviewed-by: Brian Behlendorf <[email protected]>
  
  Obtained from:        ZFS on Linux, zfsonlinux/zfs@4ceb8dd6fdfdde
  MFC after:    1 week

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

Modified: head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ioctl.c
==============================================================================
--- head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ioctl.c     Tue May 
15 13:19:00 2018        (r333629)
+++ head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ioctl.c     Tue May 
15 13:27:29 2018        (r333630)
@@ -1556,6 +1556,7 @@ zfs_ioc_pool_create(zfs_cmd_t *zc)
        nvlist_t *config, *props = NULL;
        nvlist_t *rootprops = NULL;
        nvlist_t *zplprops = NULL;
+       char *spa_name = zc->zc_name;
 
        if (error = get_nvlist(zc->zc_nvlist_conf, zc->zc_nvlist_conf_size,
            zc->zc_iflags, &config))
@@ -1571,6 +1572,7 @@ zfs_ioc_pool_create(zfs_cmd_t *zc)
        if (props) {
                nvlist_t *nvl = NULL;
                uint64_t version = SPA_VERSION;
+               char *tname;
 
                (void) nvlist_lookup_uint64(props,
                    zpool_prop_to_name(ZPOOL_PROP_VERSION), &version);
@@ -1593,6 +1595,10 @@ zfs_ioc_pool_create(zfs_cmd_t *zc)
                    zplprops, NULL);
                if (error != 0)
                        goto pool_props_bad;
+
+               if (nvlist_lookup_string(props,
+                   zpool_prop_to_name(ZPOOL_PROP_TNAME), &tname) == 0)
+                       spa_name = tname;
        }
 
        error = spa_create(zc->zc_name, config, props, zplprops);
@@ -1600,9 +1606,9 @@ zfs_ioc_pool_create(zfs_cmd_t *zc)
        /*
         * Set the remaining root properties
         */
-       if (!error && (error = zfs_set_prop_nvlist(zc->zc_name,
+       if (!error && (error = zfs_set_prop_nvlist(spa_name,
            ZPROP_SRC_LOCAL, rootprops, NULL)) != 0)
-               (void) spa_destroy(zc->zc_name);
+               (void) spa_destroy(spa_name);
 
 pool_props_bad:
        nvlist_free(rootprops);
_______________________________________________
[email protected] mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "[email protected]"

Reply via email to