Skip to content

Commit e3e670d

Browse files
ahrensbehlendorf
authored andcommitted
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 illumos/illumos-gate@33cde0d Porting notes: - Dropped qsort libshare_zfs.c hunk, no equivalent ZoL code. Ported-by: Brian Behlendorf <behlendorf1@llnl.gov> Closes #4219
1 parent 812e91a commit e3e670d

File tree

2 files changed

+15
-15
lines changed

2 files changed

+15
-15
lines changed

lib/libzfs/libzfs_dataset.c

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3992,7 +3992,6 @@ zfs_rename(zfs_handle_t *zhp, const char *target, boolean_t recursive,
39923992
}
39933993

39943994
if (recursive) {
3995-
39963995
parentname = zfs_strdup(zhp->zfs_hdl, zhp->zfs_name);
39973996
if (parentname == NULL) {
39983997
ret = -1;
@@ -4005,8 +4004,7 @@ zfs_rename(zfs_handle_t *zhp, const char *target, boolean_t recursive,
40054004
ret = -1;
40064005
goto error;
40074006
}
4008-
4009-
} else {
4007+
} else if (zhp->zfs_type != ZFS_TYPE_SNAPSHOT) {
40104008
if ((cl = changelist_gather(zhp, ZFS_PROP_NAME, 0,
40114009
force_unmount ? MS_FORCE : 0)) == NULL)
40124010
return (-1);
@@ -4055,23 +4053,23 @@ zfs_rename(zfs_handle_t *zhp, const char *target, boolean_t recursive,
40554053
* On failure, we still want to remount any filesystems that
40564054
* were previously mounted, so we don't alter the system state.
40574055
*/
4058-
if (!recursive)
4056+
if (cl != NULL)
40594057
(void) changelist_postfix(cl);
40604058
} else {
4061-
if (!recursive) {
4059+
if (cl != NULL) {
40624060
changelist_rename(cl, zfs_get_name(zhp), target);
40634061
ret = changelist_postfix(cl);
40644062
}
40654063
}
40664064

40674065
error:
4068-
if (parentname) {
4066+
if (parentname != NULL) {
40694067
free(parentname);
40704068
}
4071-
if (zhrp) {
4069+
if (zhrp != NULL) {
40724070
zfs_close(zhrp);
40734071
}
4074-
if (cl) {
4072+
if (cl != NULL) {
40754073
changelist_free(cl);
40764074
}
40774075
return (ret);

lib/libzfs/libzfs_mount.c

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
/*
2323
* Copyright 2015 Nexenta Systems, Inc. All rights reserved.
2424
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
25+
* Copyright (c) 2014 by Delphix. All rights reserved.
2526
*/
2627

2728
/*
@@ -745,13 +746,6 @@ zfs_share_proto(zfs_handle_t *zhp, zfs_share_proto_t *proto)
745746
if (!zfs_is_mountable(zhp, mountpoint, sizeof (mountpoint), NULL))
746747
return (0);
747748

748-
if ((ret = zfs_init_libshare(hdl, SA_INIT_SHARE_API)) != SA_OK) {
749-
(void) zfs_error_fmt(hdl, EZFS_SHARENFSFAILED,
750-
dgettext(TEXT_DOMAIN, "cannot share '%s': %s"),
751-
zfs_get_name(zhp), sa_errorstr(ret));
752-
return (-1);
753-
}
754-
755749
for (curr_proto = proto; *curr_proto != PROTO_END; curr_proto++) {
756750
/*
757751
* Return success if there are no share options.
@@ -762,6 +756,14 @@ zfs_share_proto(zfs_handle_t *zhp, zfs_share_proto_t *proto)
762756
strcmp(shareopts, "off") == 0)
763757
continue;
764758

759+
ret = zfs_init_libshare(hdl, SA_INIT_SHARE_API);
760+
if (ret != SA_OK) {
761+
(void) zfs_error_fmt(hdl, EZFS_SHARENFSFAILED,
762+
dgettext(TEXT_DOMAIN, "cannot share '%s': %s"),
763+
zfs_get_name(zhp), sa_errorstr(ret));
764+
return (-1);
765+
}
766+
765767
/*
766768
* If the 'zoned' property is set, then zfs_is_mountable()
767769
* will have already bailed out if we are in the global zone.

0 commit comments

Comments
 (0)