mirror_zfs/module/os/freebsd/zfs
Alan Somers 75b4cbf625
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 07:36:43 -06:00
..
abd_os.c FreeBSD: Clean up ASSERT/VERIFY use in module 2021-04-30 16:36:10 -07:00
arc_os.c FreeBSD: avoid memory allocation in arc_prune_async 2021-05-25 19:38:34 -06:00
crypto_os.c FreeBSD: Retry OCF ENOMEM errors. 2021-05-24 14:42:45 -06:00
dmu_os.c FreeBSD: Clean up ASSERT/VERIFY use in module 2021-04-30 16:36:10 -07:00
hkdf.c Add FreeBSD support to OpenZFS 2020-04-14 11:36:28 -07:00
kmod_core.c Move zfsdev_state_{init,destroy} to common code 2021-04-08 21:17:43 -07:00
spa_os.c FreeBSD: Clean up ASSERT/VERIFY use in module 2021-04-30 16:36:10 -07:00
sysctl_os.c Reference_tracking_enable should be a module param 2021-03-16 14:56:17 -07:00
vdev_file.c FreeBSD: Clean up ASSERT/VERIFY use in module 2021-04-30 16:36:10 -07:00
vdev_geom.c FreeBSD: Clean up ASSERT/VERIFY use in module 2021-04-30 16:36:10 -07:00
vdev_label_os.c FreeBSD: Clean up ASSERT/VERIFY use in module 2021-04-30 16:36:10 -07:00
zfs_acl.c FreeBSD: Remove !FreeBSD ifdef'd code 2021-05-07 15:13:44 -07:00
zfs_ctldir.c FreeBSD: Clean up ASSERT/VERIFY use in module 2021-04-30 16:36:10 -07:00
zfs_debug.c Add note for printing all dbgmsg entries on FreeBSD 2021-05-25 18:08:27 -07:00
zfs_dir.c Clean up use of zfs_log_create in zfs_dir 2021-05-07 15:13:10 -07:00
zfs_file_os.c FreeBSD: Fix stable/12 after AT_BENEATH removal 2021-04-02 11:06:44 -07:00
zfs_ioctl_compat.c FreeBSD: Fix legacy compat for platform IOCs 2020-09-30 13:25:50 -07:00
zfs_ioctl_os.c libzfs: On FreeBSD, use MNT_NOWAIT with getfsstat 2021-06-08 07:36:43 -06:00
zfs_racct.c Restore FreeBSD resource usage accounting 2021-02-19 22:34:33 -08:00
zfs_vfsops.c FreeBSD: incorporate changes to the VFS_QUOTACTL(9) KPI 2021-06-04 14:11:08 -06:00
zfs_vnops_os.c FreeBSD: Implement xattr=sa 2021-05-13 15:14:12 -07:00
zfs_znode.c FreeBSD: Implement xattr=sa 2021-05-13 15:14:12 -07:00
zio_crypt.c Revert "Fix raw sends on encrypted datasets when copying back snapshots" 2021-05-13 10:00:17 -07:00
zvol_os.c FreeBSD: Update dataset_kstats for zvols in dev mode 2021-05-26 12:14:26 -06:00