Skip to content

Commit

Permalink
DLPX-62600 zfs sharenfs commands make slow progress on scalability sy…
Browse files Browse the repository at this point in the history
…stem (openzfs#45)
  • Loading branch information
grwilson authored and ahrens committed Apr 9, 2019
1 parent d511b68 commit 790fde1
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 3 deletions.
5 changes: 2 additions & 3 deletions cmd/zpool/zpool_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -1635,12 +1635,9 @@ zpool_export_one(zpool_handle_t *zhp, void *data)
{
export_cbdata_t *cb = data;

verify(sharetab_lock() == 0);
if (zpool_disable_datasets(zhp, cb->force) != 0) {
verify(sharetab_unlock() == 0);
return (1);
}
verify(sharetab_unlock() == 0);

/* The history must be logged as part of the export */
log_history = B_FALSE;
Expand Down Expand Up @@ -1714,7 +1711,9 @@ zpool_do_export(int argc, char **argv)
usage(B_FALSE);
}

verify(sharetab_lock() == 0);
ret = for_each_pool(argc, argv, B_TRUE, NULL, zpool_export_one, &cb);
verify(sharetab_unlock() == 0);

return (ret);
}
Expand Down
20 changes: 20 additions & 0 deletions lib/libshare/libshare.c
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,20 @@ sa_init(int init_service)

impl_handle->zfs_libhandle = libzfs_init();

/*
* When libshare initializes the shares below, it needs to parse the
* MNTTAB to determine if a filesystem is mounted by calling
* zfs_is_mounted(). On systems with thousands of filesystems,
* repeatedly parsing the MNTTAB can be very slow. As a performance
* improvement, we cache the MNTTAB so that we only have to read it
* once. Repeated calls to zfs_is_mounted will just lookup entries in
* the AVL tree. We can only safely do this when we've locked the
* sharetab to other zfs sharenfs operations from concurrently
* updating the MNTTAB.
*/
if (sharetab_locked())
libzfs_mnttab_cache(impl_handle->zfs_libhandle, B_TRUE);

if (impl_handle->zfs_libhandle != NULL) {
libzfs_print_on_error(impl_handle->zfs_libhandle, B_TRUE);
}
Expand Down Expand Up @@ -217,6 +231,12 @@ sharetab_unlock(void)
return (retval);
}

boolean_t
sharetab_locked(void)
{
return(sharetab_fd != -1);
}

static void
update_sharetab(sa_handle_impl_t impl_handle)
{
Expand Down
1 change: 1 addition & 0 deletions lib/libspl/include/libshare.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ extern int sa_disable_share(sa_share_t, char *);

extern int sharetab_lock(void);
extern int sharetab_unlock(void);
extern boolean_t sharetab_locked(void);

/* protocol specific interfaces */
extern int sa_parse_legacy_options(sa_group_t, char *, char *);
Expand Down

0 comments on commit 790fde1

Please sign in to comment.