Fixing VFS layering violations in FreeBSD

Michael Hancock
$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: Layering violations were left in the file systems when the vfs layer was inserted between the syscall layer and the various filesystem implementations.

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


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.

Related work

Terry Lambert's nameifree() patches are for similar layering violations related to namei path buffers.