summaryrefslogtreecommitdiff
path: root/share/man/man9/vfs_busy.9
blob: a468452e26e741c9ec6c29fcc0db64a61e21c86a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
.\"	$OpenBSD: vfs_busy.9,v 1.2 2007/05/31 19:20:01 jmc 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
.In sys/mount.h
.Pp
.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.
.Pp
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:
.Pp
.Bl -tag -width "VB_NOWAITXX" -offset indent -compact
.It VB_READ
Acquire a read lock.
.It VB_WRITE
Acquire a write lock.
.It VB_NOWAIT
Return immediately; do not wait for the conflicting lock to be released.
.It VB_WAIT
Wait for the conflicting lock to be released.
.El
.Pp
If a conflicting lock was encountered,
.Fn vfs_busy
returns an error.
.Pp
The
.Fn vfs_isbusy
function checks whether the given mount point is locked.
.Pp
.Fn vfs_unbusy
unlocks the given mount point.
.Pp
The
.Nm vfs_busy
API is implemented in the file
.Pa sys/kern/vfs_subr.c .
.Sh SEE ALSO
.Xr rwlock 9 ,
.Xr vfs 9