kernel - Normalize the vx_*() vnode interface * The vx_*() vnode interface is used for initial allocations, reclaims, and terminations. Normalize all use cases to prevent the mixing together of the vx_*() API and the vn_*() API. For example, vx_lock() should not be paired with vn_unlock(), and so forth. * Integrate an update-counter mechanism into the vx_*() API, assert reasonability. * Change vfs_cache.c to use an int update counter instead of a long. The vfs_cache code can't quite use the spin-lock update counter API yet. Use proper atomics for load and store. * Implement VOP_GETATTR_QUICK, meant to be a 'quick' version of VOP_GETATTR() that only retrieves information related to permissions and ownership. This will be fast-pathed in a later commit. * Implement vx_downgrade() to convert an exclusive vx_lock into an exclusive vn_lock (for vnodes). Adjust all use cases in the getnewvnode() path. * Remove unnecessary locks in tmpfs_getattr() and don't use any in tmpfs_getattr_quick(). * Remove unnecessary locks in hammer2_vop_getattr() and don't use any in hammer2_vop_getattr_quick()
kernel - Rejigger mount code to add vfs_flags in struct vfsops * Rejigger the mount code so we can add a vfs_flags field to vfsops, which mount_init() has visibility to. * Allows nullfs to flag that its mounts do not need a syncer thread. Previously nullfs would destroy the syncer thread after the fact. * Improves dsynth performance (it does lots of nullfs mounts).
Rename some functions to better names. devfs_find_device_by_udev() -> devfs_find_device_by_devid() dev2udev() -> devid_from_dev() udev2dev() -> dev_from_devid() This fits with the rest of the code. 'dev' usually means a cdev_t, such as in make_dev(), etc. Instead of 'udev', use 'devid', since that's what dev_t is, a "Device ID".
kernel: Cleanup <sys/uio.h> issues. The iovec_free() inline very complicates this header inclusion. The NULL check is not always seen from <sys/_null.h>. Luckily only three kernel sources needs it: kern_subr.c, sys_generic.c and uipc_syscalls.c. Also just a single dev/drm source makes use of 'struct uio'. * Include <sys/uio.h> explicitly first in drm_fops.c to avoid kfree() macro override in drm compat layer. * Use <sys/_uio.h> where only enums and struct uio is needed, but ensure that userland will not include it for possible later <sys/user.h> use. * Stop using <sys/vnode.h> as shortcut for uiomove*() prototypes. The uiomove*() family functions possibly transfer data across kernel/user space boundary. This header presence explicitly mark sources as such. * Prefer to add <sys/uio.h> after <sys/systm.h>, but before <sys/proc.h> and definitely before <sys/malloc.h> (except for 3 mentioned sources). This will allow to remove <sys/malloc.h> from <sys/uio.h> later on. * Adjust <sys/user.h> to use component headers instead of <sys/uio.h>. While there, use opportunity for a minimal whitespace cleanup. No functional differences observed in compiler intermediates.
kernel: Remove numerous #include <sys/thread2.h>. Most of them were added when we converted spl*() calls to crit_enter()/crit_exit(), almost 14 years ago. We can now remove a good chunk of them again for where crit_*() are no longer used. I had to adjust some files that were relying on thread2.h or headers that it includes coming in via other headers that it was removed from.
kernel - Reduce excessive inode hash table allocations * Reduce excessive inode hash table allocations in various filesystems (primarily ufs). Introduce vfs_inodehashsize() to calculate a reasonable hash table size instead of using 'maxvnodes'. * The new formula is to generally use maxvnodes / 2 (2 x stacking for the chained hash table). When maxvnodes is large we use maxvnodes / 4, and if maxvnodes is very large (> 1M vnodes) we use maxvnodes / 8. This significantly reduces the amount of kernel memory used when mounting ufs, ext2fs, hpfs, isofs, msdosfs, nfs, ntfs, and smbfs filesystems.
kernel - Rename desiredvnodes to maxvnodes, fix deadlock * Rename the kernel variable 'desiredvnodes' to 'maxvnodes' to match the sysctl name (which has always been 'maxvnodes'), and to make the code more readable. * Probable fix to a rare mount/umount deadlock which can occur in two situations (1) When a large number of mounts and unmounts are running concurrently, and (2) During a umount -a, shutdown, or reboot. * Considered minor, normal use cases will not reproduce this bug. Only synth or poudriere can generate the mount/umount traffic necessary to reproduce this bug. * Also fixes a minor kernel memory leak of the mount structure which can occur when a 'df' or filesystem sync races a umount. Also minor. Reported-by: marino (mount race)
sys/kern: Don't implement .vfs_sync unless sync is supported The only reason filesystems without requirement of syncing (e.g. no backing storage) need to implement .vfs_sync is because those fs need a sync with a return value of 0 on unmount. If unmount allows sync with return value of EOPNOTSUPP for fs that do not support sync, those fs no longer have to implement .vfs_sync with vfs_stdsync() only to pass dounmount(). The drawback is when there is a sync (other than vfs_stdnosync) that returns EOPNOTSUPP for real errors. The existing fs in DragonFly don't do this (and shouldn't either). Also see https://bugs.dragonflybsd.org/issues/2912. # grep "\.vfs_sync" sys/vfs sys/gnu/vfs -rI | grep vfs_stdsync sys/vfs/udf/udf_vfsops.c: .vfs_sync = vfs_stdsync, sys/vfs/portal/portal_vfsops.c: .vfs_sync = vfs_stdsync sys/vfs/devfs/devfs_vfsops.c: .vfs_sync = vfs_stdsync, sys/vfs/isofs/cd9660/cd9660_vfsops.c: .vfs_sync = vfs_stdsync, sys/vfs/autofs/autofs_vfsops.c: .vfs_sync = vfs_stdsync, /* for unmount(2) */ sys/vfs/tmpfs/tmpfs_vfsops.c: .vfs_sync = vfs_stdsync, sys/vfs/dirfs/dirfs_vfsops.c: .vfs_sync = vfs_stdsync, sys/vfs/ntfs/ntfs_vfsops.c: .vfs_sync = vfs_stdsync, sys/vfs/procfs/procfs_vfsops.c: .vfs_sync = vfs_stdsync sys/vfs/hpfs/hpfs_vfsops.c: .vfs_sync = vfs_stdsync, sys/vfs/nullfs/null_vfsops.c: .vfs_sync = vfs_stdsync,