mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2024-12-27 11:29:36 +03:00
c15d36c674
== 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
87 lines
3.6 KiB
C
87 lines
3.6 KiB
C
/*
|
|
* CDDL HEADER START
|
|
*
|
|
* The contents of this file are subject to the terms of the
|
|
* Common Development and Distribution License (the "License").
|
|
* You may not use this file except in compliance with the License.
|
|
*
|
|
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
|
|
* or http://www.opensolaris.org/os/licensing.
|
|
* See the License for the specific language governing permissions
|
|
* and limitations under the License.
|
|
*
|
|
* When distributing Covered Code, include this CDDL HEADER in each
|
|
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
|
|
* If applicable, add the following below this CDDL HEADER, with the
|
|
* fields enclosed by brackets "[]" replaced with your own identifying
|
|
* information: Portions Copyright [yyyy] [name of copyright owner]
|
|
*
|
|
* CDDL HEADER END
|
|
*/
|
|
|
|
/*
|
|
* 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
|
|
|
|
/* API Initialization */
|
|
#define SA_INIT_SHARE_API 0x0001 /* init share specific interface */
|
|
#define SA_INIT_CONTROL_API 0x0002 /* init control specific interface */
|
|
|
|
/*
|
|
* defined error values
|
|
*/
|
|
|
|
#define SA_OK 0
|
|
#define SA_NO_SUCH_PATH 1 /* provided path doesn't exist */
|
|
#define SA_NO_MEMORY 2 /* no memory for data structures */
|
|
#define SA_DUPLICATE_NAME 3 /* object name is already in use */
|
|
#define SA_BAD_PATH 4 /* not a full path */
|
|
#define SA_NO_SUCH_GROUP 5 /* group is not defined */
|
|
#define SA_CONFIG_ERR 6 /* system configuration error */
|
|
#define SA_SYSTEM_ERR 7 /* system error, use errno */
|
|
#define SA_SYNTAX_ERR 8 /* syntax error on command line */
|
|
#define SA_NO_PERMISSION 9 /* no permission for operation */
|
|
#define SA_BUSY 10 /* resource is busy */
|
|
#define SA_NO_SUCH_PROP 11 /* property doesn't exist */
|
|
#define SA_INVALID_NAME 12 /* name of object is invalid */
|
|
#define SA_INVALID_PROTOCOL 13 /* specified protocol not valid */
|
|
#define SA_NOT_ALLOWED 14 /* operation not allowed */
|
|
#define SA_BAD_VALUE 15 /* bad value for property */
|
|
#define SA_INVALID_SECURITY 16 /* invalid security type */
|
|
#define SA_NO_SUCH_SECURITY 17 /* security set not found */
|
|
#define SA_VALUE_CONFLICT 18 /* property value conflict */
|
|
#define SA_NOT_IMPLEMENTED 19 /* plugin interface not implemented */
|
|
#define SA_INVALID_PATH 20 /* path is sub-dir of existing share */
|
|
#define SA_NOT_SUPPORTED 21 /* operation not supported for proto */
|
|
#define SA_PROP_SHARE_ONLY 22 /* property valid on share only */
|
|
#define SA_NOT_SHARED 23 /* path is not shared */
|
|
#define SA_NO_SUCH_RESOURCE 24 /* resource not found */
|
|
#define SA_RESOURCE_REQUIRED 25 /* resource name is required */
|
|
#define SA_MULTIPLE_ERROR 26 /* multiple protocols reported error */
|
|
#define SA_PATH_IS_SUBDIR 27 /* check_path found path is subdir */
|
|
#define SA_PATH_IS_PARENTDIR 28 /* check_path found path is parent */
|
|
#define SA_NO_SECTION 29 /* protocol requires section info */
|
|
#define SA_NO_SUCH_SECTION 30 /* no section found */
|
|
#define SA_NO_PROPERTIES 31 /* no properties found */
|
|
#define SA_PASSWORD_ENC 32 /* passwords must be encrypted */
|
|
#define SA_SHARE_EXISTS 33 /* path or file is already shared */
|
|
|
|
/* initialization */
|
|
extern char *sa_errorstr(int);
|
|
|
|
/* share control */
|
|
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_validate_shareopts(char *, char *);
|
|
|
|
#endif /* _LIBSPL_LIBSHARE_H */
|