mirror_zfs/module
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
..
avl Fix various typos 2021-04-02 18:52:15 -07:00
icp Replace ZoL with OpenZFS where applicable 2021-05-07 17:20:37 -07:00
lua cppcheck: integrete cppcheck 2021-01-26 16:12:26 -08:00
nvpair Links in Source Files 2020-09-02 09:42:12 -07:00
os libzfs: On FreeBSD, use MNT_NOWAIT with getfsstat 2021-06-08 07:36:43 -06:00
spl Cleanup linux module kbuild files 2020-06-10 09:24:15 -07:00
unicode Fix various typos 2021-04-02 18:52:15 -07:00
zcommon libzfs: add keylocation=https://, backed by fetch(3) or libcurl 2021-05-12 21:21:35 -07:00
zfs libzfs: On FreeBSD, use MNT_NOWAIT with getfsstat 2021-06-08 07:36:43 -06:00
zstd Fix various typos 2021-04-02 18:52:15 -07:00
.gitignore Cleanup linux module kbuild files 2020-06-10 09:24:15 -07:00
Kbuild.in Add zstd support to zfs 2020-08-20 10:30:06 -07:00
Makefile.bsd Restore FreeBSD resource usage accounting 2021-02-19 22:34:33 -08:00
Makefile.in FreeBSD module --enable-debug --enable-invariants 2021-03-05 12:16:41 -08:00