2019-09-27 17:46:28 +00:00
|
|
|
/*
|
|
|
|
* 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
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef _ZFS_IOCTL_IMPL_H_
|
|
|
|
#define _ZFS_IOCTL_IMPL_H_
|
|
|
|
|
|
|
|
extern kmutex_t zfsdev_state_lock;
|
2020-08-18 16:33:55 +00:00
|
|
|
extern unsigned long zfs_max_nvlist_src_size;
|
2019-09-27 17:46:28 +00:00
|
|
|
|
|
|
|
typedef int zfs_ioc_legacy_func_t(zfs_cmd_t *);
|
|
|
|
typedef int zfs_ioc_func_t(const char *, nvlist_t *, nvlist_t *);
|
|
|
|
typedef int zfs_secpolicy_func_t(zfs_cmd_t *, nvlist_t *, cred_t *);
|
|
|
|
|
|
|
|
typedef enum {
|
|
|
|
POOL_CHECK_NONE = 1 << 0,
|
|
|
|
POOL_CHECK_SUSPENDED = 1 << 1,
|
|
|
|
POOL_CHECK_READONLY = 1 << 2,
|
|
|
|
} zfs_ioc_poolcheck_t;
|
|
|
|
|
|
|
|
typedef enum {
|
|
|
|
NO_NAME,
|
|
|
|
POOL_NAME,
|
|
|
|
DATASET_NAME,
|
|
|
|
ENTITY_NAME
|
|
|
|
} zfs_ioc_namecheck_t;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* IOC Keys are used to document and validate user->kernel interface inputs.
|
|
|
|
* See zfs_keys_recv_new for an example declaration. Any key name that is not
|
|
|
|
* listed will be rejected as input.
|
|
|
|
*
|
|
|
|
* The keyname 'optional' is always allowed, and must be an nvlist if present.
|
|
|
|
* Arguments which older kernels can safely ignore can be placed under the
|
|
|
|
* "optional" key.
|
|
|
|
*
|
|
|
|
* When adding new keys to an existing ioc for new functionality, consider:
|
|
|
|
* - adding an entry into zfs_sysfs.c zfs_features[] list
|
|
|
|
* - updating the libzfs_input_check.c test utility
|
|
|
|
*
|
|
|
|
* Note: in the ZK_WILDCARDLIST case, the name serves as documentation
|
|
|
|
* for the expected name (bookmark, snapshot, property, etc) but there
|
|
|
|
* is no validation in the preflight zfs_check_input_nvpairs() check.
|
|
|
|
*/
|
|
|
|
typedef enum {
|
|
|
|
ZK_OPTIONAL = 1 << 0, /* pair is optional */
|
|
|
|
ZK_WILDCARDLIST = 1 << 1, /* one or more unspecified key names */
|
|
|
|
} ioc_key_flag_t;
|
|
|
|
|
|
|
|
typedef struct zfs_ioc_key {
|
|
|
|
const char *zkey_name;
|
|
|
|
data_type_t zkey_type;
|
|
|
|
ioc_key_flag_t zkey_flags;
|
|
|
|
} zfs_ioc_key_t;
|
|
|
|
|
|
|
|
int zfs_secpolicy_config(zfs_cmd_t *, nvlist_t *, cred_t *);
|
|
|
|
|
|
|
|
void zfs_ioctl_register_dataset_nolog(zfs_ioc_t, zfs_ioc_legacy_func_t *,
|
|
|
|
zfs_secpolicy_func_t *, zfs_ioc_poolcheck_t);
|
|
|
|
|
|
|
|
void zfs_ioctl_register(const char *, zfs_ioc_t, zfs_ioc_func_t *,
|
|
|
|
zfs_secpolicy_func_t *, zfs_ioc_namecheck_t, zfs_ioc_poolcheck_t,
|
|
|
|
boolean_t, boolean_t, const zfs_ioc_key_t *, size_t);
|
|
|
|
|
2020-08-18 16:33:55 +00:00
|
|
|
uint64_t zfs_max_nvlist_src_size_os(void);
|
libzfs: On FreeBSD, use MNT_NOWAIT with getfsstat
`getfsstat(2)` is used to retrieve the list of mounted file systems,
which libzfs uses when fetching properties like mountpoint, atime,
setuid, etc. The `mode` parameter may be `MNT_NOWAIT`, which uses
information in the VFS's cache, or `MNT_WAIT`, which effectively does a
`statfs` on every single mounted file system in order to fetch the most
up-to-date information. As far as I can tell, the only fields that
libzfs cares about are the filesystem's name, mountpoint, fstypename,
and mount flags. Those things are always updated on mount and unmount,
so they will always be accurate in the VFS's mount cache except in two
circumstances:
1) When a file system is busy unmounting
2) When a ZFS file system changes the value of a mount-overridable
property like atime or setuid, but doesn't remount the file system.
Right now that only happens when the property is changed by an
unprivileged user who has delegated authority to change the property
but not to mount the dataset. But perhaps libzfs could choose to do
it for other reasons in the future.
Switching to `MNT_NOWAIT` will greatly improve speed with no downside,
as long as we explicitly update the mount cache whenever we change a
mount-overridable property.
For comparison, Illumos gets this information using the native
`getmntany` and `getmntent` functions, which also use cached
information. The illumos function that would refresh the cache,
`resetmnttab`, is never called by libzfs.
And on GNU/Linux, `getmntany` and `getmntent` don't even communicate
with the kernel directly. They simply parse the file they are given,
which is usually /etc/mtab or /proc/mounts. Perhaps the implementation
of /proc/mounts is synchronous, ala MNT_WAIT; I don't know.
Sponsored-by: Axcient
Reviewed-by: Ryan Moeller <ryan@iXsystems.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Alan Somers <asomers@gmail.com>
Closes: #12091
2021-06-08 13:36:43 +00:00
|
|
|
void zfs_ioctl_update_mount_cache(const char *dsname);
|
2019-09-27 17:46:28 +00:00
|
|
|
void zfs_ioctl_init_os(void);
|
|
|
|
|
2019-12-10 17:21:07 +00:00
|
|
|
boolean_t zfs_vfs_held(zfsvfs_t *);
|
2019-09-27 17:46:28 +00:00
|
|
|
int zfs_vfs_ref(zfsvfs_t **);
|
2019-12-10 17:21:07 +00:00
|
|
|
void zfs_vfs_rele(zfsvfs_t *);
|
2019-09-27 17:46:28 +00:00
|
|
|
|
2020-06-08 20:57:22 +00:00
|
|
|
long zfsdev_ioctl_common(uint_t, zfs_cmd_t *, int);
|
2019-09-27 17:46:28 +00:00
|
|
|
int zfsdev_attach(void);
|
|
|
|
void zfsdev_detach(void);
|
2021-03-16 13:04:58 +00:00
|
|
|
void zfsdev_private_set_state(void *, zfsdev_state_t *);
|
|
|
|
zfsdev_state_t *zfsdev_private_get_state(void *);
|
|
|
|
int zfsdev_state_init(void *);
|
|
|
|
void zfsdev_state_destroy(void *);
|
2019-09-27 17:46:28 +00:00
|
|
|
int zfs_kmod_init(void);
|
|
|
|
void zfs_kmod_fini(void);
|
|
|
|
|
|
|
|
#endif
|