VFS_BUSY(9)

NAME
vfs_busy, vfs_isbusy, vfs_unbusy - VFS locking API

SYNOPSIS
#include <sys/mount.h>

int
vfs_busy(struct mount *mp, int flags);
int
vfs_isbusy(struct mount *mp);
void
vfs_unbusy(struct mount *mp);

DESCRIPTION
The vfs_busy API is used to lock mount points to ensure consistent access. A read lock can be shared between multiple processes, while a write lock is exclusive. Normally a write lock is only acquired when unmounting.

The vfs_busy() function locks the mount point pointed to by mp, where flags describes the type of lock to acquire and whether or not to wait for a conflicting lock to be released. The following flags are available:

VB_READ
    Acquire a read lock.
VB_WRITE
    Acquire a write lock.
VB_NOWAIT
    Return immediately; do not wait for the conflicting lock to be released.
VB_WAIT
    Wait for the conflicting lock to be released.
VB_DUPOK
    Prevent witness(4) from logging when this thread already has a mount point locked.

If a conflicting lock was encountered, vfs_busy() returns an error.

The vfs_isbusy() function checks whether the given mount point is locked.

vfs_unbusy() unlocks the given mount point.

The vfs_busy API is implemented in the file sys/kern/vfs_subr.c.

SEE ALSO
witness(4), rwlock(9), vfs(9)