Illumos 4953, 4954, 4955

4953 zfs rename <snapshot> need not involve libshare
4954 "zfs create" need not involve libshare if we are not sharing
4955 libshare's get_zfs_dataset need not sort the datasets
Reviewed by: George Wilson <george.wilson@delphix.com>
Reviewed by: Sebastien Roy <sebastien.roy@delphix.com>
Reviewed by: Dan McDonald <danmcd@omniti.com>
Reviewed by: Gordon Ross <gordon.ross@nexenta.com>
Approved by: Garrett D'Amore <garrett@damore.org>

References:
  https://www.illumos.org/issues/4953
  https://www.illumos.org/issues/4954
  https://www.illumos.org/issues/4955
  https://github.com/illumos/illumos-gate/commit/33cde0d

Porting notes:
- Dropped qsort libshare_zfs.c hunk, no equivalent ZoL code.

Ported-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #4219
This commit is contained in:
Matthew Ahrens 2016-01-13 16:10:38 -08:00 committed by Ned Bass
parent efde19487c
commit 2ea36ad824
2 changed files with 15 additions and 15 deletions

View File

@ -3889,7 +3889,6 @@ zfs_rename(zfs_handle_t *zhp, const char *target, boolean_t recursive,
} }
if (recursive) { if (recursive) {
parentname = zfs_strdup(zhp->zfs_hdl, zhp->zfs_name); parentname = zfs_strdup(zhp->zfs_hdl, zhp->zfs_name);
if (parentname == NULL) { if (parentname == NULL) {
ret = -1; ret = -1;
@ -3902,8 +3901,7 @@ zfs_rename(zfs_handle_t *zhp, const char *target, boolean_t recursive,
ret = -1; ret = -1;
goto error; goto error;
} }
} else if (zhp->zfs_type != ZFS_TYPE_SNAPSHOT) {
} else {
if ((cl = changelist_gather(zhp, ZFS_PROP_NAME, 0, if ((cl = changelist_gather(zhp, ZFS_PROP_NAME, 0,
force_unmount ? MS_FORCE : 0)) == NULL) force_unmount ? MS_FORCE : 0)) == NULL)
return (-1); return (-1);
@ -3952,23 +3950,23 @@ zfs_rename(zfs_handle_t *zhp, const char *target, boolean_t recursive,
* On failure, we still want to remount any filesystems that * On failure, we still want to remount any filesystems that
* were previously mounted, so we don't alter the system state. * were previously mounted, so we don't alter the system state.
*/ */
if (!recursive) if (cl != NULL)
(void) changelist_postfix(cl); (void) changelist_postfix(cl);
} else { } else {
if (!recursive) { if (cl != NULL) {
changelist_rename(cl, zfs_get_name(zhp), target); changelist_rename(cl, zfs_get_name(zhp), target);
ret = changelist_postfix(cl); ret = changelist_postfix(cl);
} }
} }
error: error:
if (parentname) { if (parentname != NULL) {
free(parentname); free(parentname);
} }
if (zhrp) { if (zhrp != NULL) {
zfs_close(zhrp); zfs_close(zhrp);
} }
if (cl) { if (cl != NULL) {
changelist_free(cl); changelist_free(cl);
} }
return (ret); return (ret);

View File

@ -21,6 +21,7 @@
/* /*
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014 by Delphix. All rights reserved.
*/ */
/* /*
@ -744,13 +745,6 @@ zfs_share_proto(zfs_handle_t *zhp, zfs_share_proto_t *proto)
if (!zfs_is_mountable(zhp, mountpoint, sizeof (mountpoint), NULL)) if (!zfs_is_mountable(zhp, mountpoint, sizeof (mountpoint), NULL))
return (0); return (0);
if ((ret = zfs_init_libshare(hdl, SA_INIT_SHARE_API)) != SA_OK) {
(void) zfs_error_fmt(hdl, EZFS_SHARENFSFAILED,
dgettext(TEXT_DOMAIN, "cannot share '%s': %s"),
zfs_get_name(zhp), sa_errorstr(ret));
return (-1);
}
for (curr_proto = proto; *curr_proto != PROTO_END; curr_proto++) { for (curr_proto = proto; *curr_proto != PROTO_END; curr_proto++) {
/* /*
* Return success if there are no share options. * Return success if there are no share options.
@ -761,6 +755,14 @@ zfs_share_proto(zfs_handle_t *zhp, zfs_share_proto_t *proto)
strcmp(shareopts, "off") == 0) strcmp(shareopts, "off") == 0)
continue; continue;
ret = zfs_init_libshare(hdl, SA_INIT_SHARE_API);
if (ret != SA_OK) {
(void) zfs_error_fmt(hdl, EZFS_SHARENFSFAILED,
dgettext(TEXT_DOMAIN, "cannot share '%s': %s"),
zfs_get_name(zhp), sa_errorstr(ret));
return (-1);
}
/* /*
* If the 'zoned' property is set, then zfs_is_mountable() * If the 'zoned' property is set, then zfs_is_mountable()
* will have already bailed out if we are in the global zone. * will have already bailed out if we are in the global zone.