Skip to content

Commit

Permalink
Merge pull request openzfs#16 from bgly/fixnfs
Browse files Browse the repository at this point in the history
DLPX-62600 zfs sharenfs commands make slow progress on scalability sy…
  • Loading branch information
Bryant G. Ly authored Dec 10, 2019
2 parents ec9c367 + 8733578 commit bb451b1
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 @@ -1648,12 +1648,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 || cb->hardforce) != 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 @@ -1727,7 +1724,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 @@ -92,6 +92,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 @@ -218,6 +232,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 @@ -87,6 +87,7 @@ extern int sa_generate_share(const char *, const 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 bb451b1

Please sign in to comment.