MFV r316876: 7542 zfs_unmount failed with EZFS_UNSHARENFSFAILED

illumos/illumos-gate@09c9e6dc9b
09c9e6dc9b

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@delphix.com>
Reviewed by: Dan Kimmel <dan.kimmel@delphix.com>
Reviewed by: Matt Amdur <matt.amdur@delphix.com>
Approved by: Robert Mustacchi <rm@joyent.com>
Author: Chris Williamson <chris.williamson@delphix.com>
This commit is contained in:
Alexander Motin 2018-02-20 20:30:40 +00:00
commit 806141acfc
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=329663
2 changed files with 18 additions and 27 deletions

View File

@ -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.
* Copyright (c) 2013 Martin Matuska <mm@FreeBSD.org>. All rights reserved.
*/
@ -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 {
boolean_t libzfs_prop_debug;
};
#define ZFSSHARE_MISS 0x01 /* Didn't find entry in cache */
struct zfs_handle {
libzfs_handle_t *zfs_hdl;
zpool_handle_t *zpool_hdl;

View File

@ -22,7 +22,7 @@
/*
* Copyright 2015 Nexenta Systems, Inc. All rights reserved.
* 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@gmail.com>
* Copyright 2017 Joyent, Inc.
* Copyright 2017 RackTop Systems.
@ -672,8 +672,6 @@ _zfs_init_libshare(void)
int
zfs_init_libshare(libzfs_handle_t *zhandle, int service)
{
int ret = SA_OK;
#ifdef illumos
/*
* libshare is either not installed or we're in a branded zone. The
@ -684,31 +682,28 @@ zfs_init_libshare(libzfs_handle_t *zhandle, int service)
if (_sa_init == NULL)
return (SA_OK);
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);
#endif
return (ret);
return (SA_OK);
}
/*
@ -864,7 +859,6 @@ zfs_share_proto(zfs_handle_t *zhp, zfs_share_proto_t *proto)
zfs_get_name(zhp));
return (-1);
}
hdl->libzfs_shareflags |= ZFSSHARE_MISS;
share = zfs_sa_find_share(hdl->libzfs_sharehdl,
mountpoint);
}