1.\" $OpenBSD: vfs_busy.9,v 1.3 2018/06/04 04:57:09 guenther Exp $ 2.\" 3.\" Copyright (c) 2006 Nikolay Sturm <sturm@openbsd.org> 4.\" 5.\" Permission to use, copy, modify, and distribute this software for any 6.\" purpose with or without fee is hereby granted, provided that the above 7.\" copyright notice and this permission notice appear in all copies. 8.\" 9.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 10.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 11.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 12.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 13.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 16.\" 17.Dd $Mdocdate: June 4 2018 $ 18.Dt VFS_BUSY 9 19.Os 20.Sh NAME 21.Nm vfs_busy , 22.Nm vfs_isbusy , 23.Nm vfs_unbusy 24.Nd VFS locking API 25.Sh SYNOPSIS 26.In sys/mount.h 27.Pp 28.Ft int 29.Fn vfs_busy "struct mount *mp" "int flags" 30.Ft int 31.Fn vfs_isbusy "struct mount *mp" 32.Ft void 33.Fn vfs_unbusy "struct mount *mp" 34.Sh DESCRIPTION 35The 36.Nm vfs_busy 37API is used to lock mount points to ensure consistent access. 38A read lock can be shared between multiple processes, while a write lock is 39exclusive. 40Normally a write lock is only acquired when unmounting. 41.Pp 42The 43.Fn vfs_busy 44function locks the mount point pointed to by 45.Fa mp , 46where 47.Fa flags 48describes the type of lock to acquire and whether or not to wait for a 49conflicting lock to be released. 50The following flags are available: 51.Pp 52.Bl -tag -width "VB_NOWAITXX" -offset indent -compact 53.It VB_READ 54Acquire a read lock. 55.It VB_WRITE 56Acquire a write lock. 57.It VB_NOWAIT 58Return immediately; do not wait for the conflicting lock to be released. 59.It VB_WAIT 60Wait for the conflicting lock to be released. 61.It VB_DUPOK 62Prevent 63.Xr witness 4 64from logging when this thread already has a mount point locked. 65.El 66.Pp 67If a conflicting lock was encountered, 68.Fn vfs_busy 69returns an error. 70.Pp 71The 72.Fn vfs_isbusy 73function checks whether the given mount point is locked. 74.Pp 75.Fn vfs_unbusy 76unlocks the given mount point. 77.Pp 78The 79.Nm vfs_busy 80API is implemented in the file 81.Pa sys/kern/vfs_subr.c . 82.Sh SEE ALSO 83.Xr witness 4 , 84.Xr rwlock 9 , 85.Xr vfs 9 86