svn commit: r316876 - vendor/illumos/dist/lib/libzfs/common
Andriy Gapon
avg at FreeBSD.org
Fri Apr 14 17:24:24 UTC 2017
Author: avg
Date: Fri Apr 14 17:24:22 2017
New Revision: 316876
URL: https://svnweb.freebsd.org/changeset/base/316876
Log:
7542 zfs_unmount failed with EZFS_UNSHARENFSFAILED
illumos/illumos-gate at 09c9e6dc9b69d10b771bb87e01040ec320a0bfd3
https://github.com/illumos/illumos-gate/commit/09c9e6dc9b69d10b771bb87e01040ec320a0bfd3
https://www.illumos.org/issues/7542
libshare keeps a cached copy of the sharetab listing in memory, which can
become out of date if shares are destroyed or created while leaving a libzfs
handle open. This results in a spurious unmounting failure when an NFS share
exists but isn't in the stale libshare cache.
Reviewed by: Matthew Ahrens <mahrens at delphix.com>
Reviewed by: Dan Kimmel <dan.kimmel at delphix.com>
Reviewed by: Matt Amdur <matt.amdur at delphix.com>
Approved by: Robert Mustacchi <rm at joyent.com>
Author: Chris Williamson <chris.williamson at delphix.com>
Modified:
vendor/illumos/dist/lib/libzfs/common/libzfs_impl.h
vendor/illumos/dist/lib/libzfs/common/libzfs_mount.c
Modified: vendor/illumos/dist/lib/libzfs/common/libzfs_impl.h
==============================================================================
--- vendor/illumos/dist/lib/libzfs/common/libzfs_impl.h Fri Apr 14 17:23:52 2017 (r316875)
+++ vendor/illumos/dist/lib/libzfs/common/libzfs_impl.h Fri Apr 14 17:24:22 2017 (r316876)
@@ -22,7 +22,7 @@
/*
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2011 Pawel Jakub Dawidek. All rights reserved.
- * Copyright (c) 2011, 2015 by Delphix. All rights reserved.
+ * Copyright (c) 2011, 2016 by Delphix. All rights reserved.
*/
#ifndef _LIBZFS_IMPL_H
@@ -72,7 +72,6 @@ struct libzfs_handle {
int libzfs_printerr;
int libzfs_storeerr; /* stuff error messages into buffer */
void *libzfs_sharehdl; /* libshare handle */
- uint_t libzfs_shareflags;
boolean_t libzfs_mnttab_enable;
avl_tree_t libzfs_mnttab_cache;
int libzfs_pool_iter;
@@ -82,8 +81,6 @@ struct libzfs_handle {
char libzfs_chassis_id[256];
};
-#define ZFSSHARE_MISS 0x01 /* Didn't find entry in cache */
-
struct zfs_handle {
libzfs_handle_t *zfs_hdl;
zpool_handle_t *zpool_hdl;
Modified: vendor/illumos/dist/lib/libzfs/common/libzfs_mount.c
==============================================================================
--- vendor/illumos/dist/lib/libzfs/common/libzfs_mount.c Fri Apr 14 17:23:52 2017 (r316875)
+++ vendor/illumos/dist/lib/libzfs/common/libzfs_mount.c Fri Apr 14 17:24:22 2017 (r316876)
@@ -21,7 +21,7 @@
/*
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
- * Copyright (c) 2014, 2015 by Delphix. All rights reserved.
+ * Copyright (c) 2014, 2016 by Delphix. All rights reserved.
* Copyright 2016 Igor Kozhukhov <ikozhukhov at gmail.com>
*/
@@ -657,35 +657,30 @@ _zfs_init_libshare(void)
int
zfs_init_libshare(libzfs_handle_t *zhandle, int service)
{
- int ret = SA_OK;
-
if (_sa_init == NULL)
- ret = SA_CONFIG_ERR;
+ return (SA_CONFIG_ERR);
- if (ret == SA_OK && zhandle->libzfs_shareflags & ZFSSHARE_MISS) {
- /*
- * We had a cache miss. Most likely it is a new ZFS
- * dataset that was just created. We want to make sure
- * so check timestamps to see if a different process
- * has updated any of the configuration. If there was
- * some non-ZFS change, we need to re-initialize the
- * internal cache.
- */
- zhandle->libzfs_shareflags &= ~ZFSSHARE_MISS;
- if (_sa_needs_refresh != NULL &&
- _sa_needs_refresh(zhandle->libzfs_sharehdl)) {
- zfs_uninit_libshare(zhandle);
- zhandle->libzfs_sharehdl = _sa_init(service);
- }
+ /*
+ * Attempt to refresh libshare. This is necessary if there was a cache
+ * miss for a new ZFS dataset that was just created, or if state of the
+ * sharetab file has changed since libshare was last initialized. We
+ * want to make sure so check timestamps to see if a different process
+ * has updated any of the configuration. If there was some non-ZFS
+ * change, we need to re-initialize the internal cache.
+ */
+ if (_sa_needs_refresh != NULL &&
+ _sa_needs_refresh(zhandle->libzfs_sharehdl)) {
+ zfs_uninit_libshare(zhandle);
+ zhandle->libzfs_sharehdl = _sa_init(service);
}
- if (ret == SA_OK && zhandle && zhandle->libzfs_sharehdl == NULL)
+ if (zhandle && zhandle->libzfs_sharehdl == NULL)
zhandle->libzfs_sharehdl = _sa_init(service);
- if (ret == SA_OK && zhandle->libzfs_sharehdl == NULL)
- ret = SA_NO_MEMORY;
+ if (zhandle->libzfs_sharehdl == NULL)
+ return (SA_NO_MEMORY);
- return (ret);
+ return (SA_OK);
}
/*
@@ -831,7 +826,6 @@ zfs_share_proto(zfs_handle_t *zhp, zfs_s
zfs_get_name(zhp));
return (-1);
}
- hdl->libzfs_shareflags |= ZFSSHARE_MISS;
share = zfs_sa_find_share(hdl->libzfs_sharehdl,
mountpoint);
}
More information about the svn-src-vendor
mailing list