Fixing VFS layering violations in FreeBSD
$Date: 1999/02/25 10:29:51 $
VFS layering violations
In some cases layering violations are convenient and can be justified in
subsystems of production systems, a good example is the network protocol
stack. In the case of virtual file systems, vnode and other resource management
layering violations cause problems including the following:
Redundant code in the underlying file systems implementations
Layering violations were left in the file systems when the vfs layer was
inserted between the syscall layer and the various filesystem implementations.
Complications for non-terminal layers such as nullfs
By looking at VOP_CREATE in vn_open() in vfs_vnops.c
and ufs_create()/ufs_makeinode() in ufs_vnops.c
it is evident that the underlying file systems are cleaning up after the
namei() call in the vfs layer. This creates redundant work for all
fs implementors and a little extra complexity in all the underlying file
systems. In some fs implementations, operations are implemented solely
to release these namei() resources.
To see how this affects stackable file system development, a good place
to start is vnode_if.src.
As an example, look at the name creation operations: vop_create, vop_mkdir,
vop_link, vop_symlink, and vop_mknod. In these operations the directory
vnode, dvp, is tagged as WILLRELE because each underlying file system does
a vrele() or vput() operation on it. Not only is this redundant, it also
requires special case handling in non-terminal file systems such as nullfs,
see null_bypass() in null_vnops.c
for details. Also note that null_bypass() does not deal with locking state.
VFS refcounting and locking patches
vop1a - The first round of WILLRELE dvp fixes are
in this patch. This patch cleans up the handling of the dvp argument for 5
name creation VOPs and for 2 of 3 name change VOPs. This patch also includes
fixes for the vp argument of the vop_rmdir and vop_remove operations.
The next set of patches will be for vop_rename and for the vpp argument of
vop_mknod and vop_symlink.
The changes are under review for FreeBSD by John Dyson, Poul-Henning Kamp,
Terry Lambert, and Mike Smith. The solution to fixing the layering
violations were described to me in email exchanges with Kirk McKusick.
Terry Lambert's nameifree() patches
are for similar layering violations related to namei path buffers.
The Design and Implementation of the 4.4BSD Operating System, by
Marshall Kirk McKusick, Keith Bostic, Michael J. Karels, and John S. Quartermann,