vfs: add the concept of vnode state transitions
authorMateusz Guzik <mjg@FreeBSD.org>
Mon, 19 Dec 2022 13:00:30 +0000 (13:00 +0000)
committerMateusz Guzik <mjg@FreeBSD.org>
Mon, 26 Dec 2022 17:35:12 +0000 (17:35 +0000)
commit829f0bcb5fe24bb523c5a9e7bd3bb79412e06906
tree6999f405c60926df7312a7f4e039f014cab35d8d
parented1bb254101ec3107d00257209204f8497fb0c1e
vfs: add the concept of vnode state transitions

To quote from a comment above vput_final:
<quote>
* XXX Some filesystems pass in an exclusively locked vnode and strongly depend
* on the lock being held all the way until VOP_INACTIVE. This in particular
* happens with UFS which adds half-constructed vnodes to the hash, where they
* can be found by other code.
</quote>

As is there is no mechanism which allows filesystems to denote that a
vnode is fully initialized, consequently problems like the above are
only found the hard way(tm).

Add rudimentary support for state transitions, which in particular allow
to assert the vnode is not legally unlocked until its fate is decided
(either construction finishes or vgone is called to abort it).

The new field lands in a 1-byte hole, thus it does not grow the struct.

Bump __FreeBSD_version to 1400077

Reviewed by: kib (previous version)
Tested by: pho
Differential Revision: https://reviews.freebsd.org/D37759
23 files changed:
sys/contrib/openzfs/module/os/freebsd/zfs/zfs_znode.c
sys/fs/autofs/autofs_vnops.c
sys/fs/cd9660/cd9660_vfsops.c
sys/fs/devfs/devfs_vnops.c
sys/fs/ext2fs/ext2_alloc.c
sys/fs/ext2fs/ext2_vfsops.c
sys/fs/fdescfs/fdesc_vnops.c
sys/fs/fuse/fuse_node.c
sys/fs/mntfs/mntfs_vnops.c
sys/fs/msdosfs/msdosfs_denode.c
sys/fs/nfsclient/nfs_clnode.c
sys/fs/nfsclient/nfs_clport.c
sys/fs/nullfs/null_subr.c
sys/fs/pseudofs/pseudofs_vncache.c
sys/fs/smbfs/smbfs_node.c
sys/fs/tmpfs/tmpfs_subr.c
sys/fs/udf/udf_vfsops.c
sys/fs/unionfs/union_subr.c
sys/kern/vfs_lookup.c
sys/kern/vfs_subr.c
sys/sys/param.h
sys/sys/vnode.h
sys/ufs/ffs/ffs_vfsops.c