VFS_BUSY(9) Kernel Developer's Manual VFS_BUSY(9)

vfs_busy, vfs_isbusy, vfs_unbusyVFS locking API

#include <sys/mount.h>


int
vfs_busy(struct mount *mp, int flags);

int
vfs_isbusy(struct mount *mp);

void
vfs_unbusy(struct mount *mp);

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 () 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, () returns an error.

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

() unlocks the given mount point.

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

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

June 4, 2018 OpenBSD 7.5