mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2026-05-22 10:37:35 +03:00
Remove dependency on sharetab file and refactor sharing logic
== Motivation and Context The current implementation of 'sharenfs' and 'sharesmb' relies on the use of the sharetab file. The use of this file is os-specific and not required by linux or freebsd. Currently the code must maintain updates to this file which adds complexity and presents a significant performance impact when sharing many datasets. In addition, concurrently running 'zfs sharenfs' command results in missing entries in the sharetab file leading to unexpected failures. == Description This change removes the sharetab logic from the linux and freebsd implementation of 'sharenfs' and 'sharesmb'. It still preserves an os-specific library which contains the logic required for sharing NFS or SMB. The following entry points exist in the vastly simplified libshare library: - sa_enable_share -- shares a dataset but may not commit the change - sa_disable_share -- unshares a dataset but may not commit the change - sa_is_shared -- determine if a dataset is shared - sa_commit_share -- notify NFS/SMB subsystem to commit the shares - sa_validate_shareopts -- determine if sharing options are valid The sa_commit_share entry point is provided as a performance enhancement and is not required. The sa_enable_share/sa_disable_share may commit the share as part of the implementation. Libshare provides a framework for both NFS and SMB but some operating systems may not fully support these protocols or all features of the protocol. NFS Operation: For linux, libshare updates /etc/exports.d/zfs.exports to add and remove shares and then commits the changes by invoking 'exportfs -r'. This file, is automatically read by the kernel NFS implementation which makes for better integration with the NFS systemd service. For FreeBSD, libshare updates /etc/zfs/exports to add and remove shares and then commits the changes by sending a SIGHUP to mountd. SMB Operation: For linux, libshare adds and removes files in /var/lib/samba/usershares by calling the 'net' command directly. There is no need to commit the changes. FreeBSD does not support SMB. == Performance Results To test sharing performance we created a pool with an increasing number of datasets and invoked various zfs actions that would enable and disable sharing. The performance testing was limited to NFS sharing. The following tests were performed on an 8 vCPU system with 128GB and a pool comprised of 4 50GB SSDs: Scale testing: - Share all filesystems in parallel -- zfs sharenfs=on <dataset> & - Unshare all filesystems in parallel -- zfs sharenfs=off <dataset> & Functional testing: - share each filesystem serially -- zfs share -a - unshare each filesystem serially -- zfs unshare -a - reset sharenfs property and unshare -- zfs inherit -r sharenfs <pool> For 'zfs sharenfs=on' scale testing we saw an average reduction in time of 89.43% and for 'zfs sharenfs=off' we saw an average reduction in time of 83.36%. Functional testing also shows a huge improvement: - zfs share -- 97.97% reduction in time - zfs unshare -- 96.47% reduction in time - zfs inhert -r sharenfs -- 99.01% reduction in time Reviewed-by: Matt Ahrens <matt@delphix.com> Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Reviewed-by: Ryan Moeller <ryan@ixsystems.com> Reviewed-by: Bryant G. Ly <bryangly@gmail.com> Signed-off-by: George Wilson <gwilson@delphix.com> External-Issue: DLPX-68690 Closes #1603 Closes #7692 Closes #7943 Closes #10300
This commit is contained in:
@@ -22,14 +22,11 @@
|
||||
/*
|
||||
* Copyright 2008 Sun Microsystems, Inc. All rights reserved.
|
||||
* Use is subject to license terms.
|
||||
* Copyright (c) 2019, 2020 by Delphix. All rights reserved.
|
||||
*/
|
||||
#ifndef _LIBSPL_LIBSHARE_H
|
||||
#define _LIBSPL_LIBSHARE_H
|
||||
|
||||
typedef void *sa_handle_t; /* opaque handle to access core functions */
|
||||
typedef void *sa_group_t;
|
||||
typedef void *sa_share_t;
|
||||
|
||||
/* API Initialization */
|
||||
#define SA_INIT_SHARE_API 0x0001 /* init share specific interface */
|
||||
#define SA_INIT_CONTROL_API 0x0002 /* init control specific interface */
|
||||
@@ -74,23 +71,16 @@ typedef void *sa_share_t;
|
||||
#define SA_SHARE_EXISTS 33 /* path or file is already shared */
|
||||
|
||||
/* initialization */
|
||||
extern sa_handle_t sa_init(int);
|
||||
extern void sa_fini(sa_handle_t);
|
||||
extern char *sa_errorstr(int);
|
||||
|
||||
/* share control */
|
||||
extern sa_share_t sa_find_share(sa_handle_t, char *);
|
||||
extern int sa_enable_share(sa_group_t, char *);
|
||||
extern int sa_disable_share(sa_share_t, char *);
|
||||
extern int sa_enable_share(const char *, const char *, const char *,
|
||||
char *);
|
||||
extern int sa_disable_share(const char *, char *);
|
||||
extern boolean_t sa_is_shared(const char *, char *);
|
||||
extern void sa_commit_shares(const char *);
|
||||
|
||||
/* protocol specific interfaces */
|
||||
extern int sa_parse_legacy_options(sa_group_t, char *, char *);
|
||||
|
||||
/* ZFS functions */
|
||||
extern boolean_t sa_needs_refresh(sa_handle_t handle);
|
||||
libzfs_handle_t *sa_get_zfs_handle(sa_handle_t handle);
|
||||
extern int sa_zfs_process_share(sa_handle_t handle, sa_group_t group,
|
||||
sa_share_t share, char *mountpoint, char *proto, zprop_source_t source,
|
||||
char *shareopts, char *sourcestr, char *dataset);
|
||||
extern int sa_validate_shareopts(char *, char *);
|
||||
|
||||
#endif /* _LIBSPL_LIBSHARE_H */
|
||||
|
||||
Reference in New Issue
Block a user