$OpenBSD: vfs_busy.9,v 1.3 2018/06/04 04:57:09 guenther Exp $

Copyright (c) 2006 Nikolay Sturm <sturm@openbsd.org>

Permission to use, copy, modify, and distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.

THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

.Dd $Mdocdate: May 31 2007 $ .Dt VFS_BUSY 9 .Os .Sh NAME .Nm vfs_busy , .Nm vfs_isbusy , .Nm vfs_unbusy .Nd VFS locking API .Sh SYNOPSIS n sys/mount.h

p .Ft int .Fn vfs_busy "struct mount *mp" "int flags" .Ft int .Fn vfs_isbusy "struct mount *mp" .Ft void .Fn vfs_unbusy "struct mount *mp" .Sh DESCRIPTION The .Nm 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.

p The .Fn vfs_busy function locks the mount point pointed to by .Fa mp , where .Fa 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:

p l -tag -width "VB_NOWAITXX" -offset indent -compact t VB_READ Acquire a read lock. t VB_WRITE Acquire a write lock. t VB_NOWAIT Return immediately; do not wait for the conflicting lock to be released. t VB_WAIT Wait for the conflicting lock to be released. t VB_DUPOK Prevent .Xr witness 4 from logging when this thread already has a mount point locked. .El

p If a conflicting lock was encountered, .Fn vfs_busy returns an error.

p The .Fn vfs_isbusy function checks whether the given mount point is locked.

p .Fn vfs_unbusy unlocks the given mount point.

p The .Nm vfs_busy API is implemented in the file

a sys/kern/vfs_subr.c . .Sh SEE ALSO .Xr witness 4 , .Xr rwlock 9 , .Xr vfs 9