1.\" Copyright (c) 1996 Doug Rabson 2.\" 3.\" All rights reserved. 4.\" 5.\" This program is free software. 6.\" 7.\" Redistribution and use in source and binary forms, with or without 8.\" modification, are permitted provided that the following conditions 9.\" are met: 10.\" 1. Redistributions of source code must retain the above copyright 11.\" notice, this list of conditions and the following disclaimer. 12.\" 2. Redistributions in binary form must reproduce the above copyright 13.\" notice, this list of conditions and the following disclaimer in the 14.\" documentation and/or other materials provided with the distribution. 15.\" 16.\" THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY EXPRESS OR 17.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 18.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 19.\" IN NO EVENT SHALL THE DEVELOPERS BE LIABLE FOR ANY DIRECT, INDIRECT, 20.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 21.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 22.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 23.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 25.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26.\" 27.\" 28.Dd November 17, 2014 29.Dt VN_LOCK 9 30.Os 31.Sh NAME 32.Nm vn_lock , 33.Nm vn_unlock , 34.Nm vn_islocked 35.Nd serialize access to a vnode 36.Sh SYNOPSIS 37.In sys/vnode.h 38.Ft int 39.Fn vn_lock "struct vnode *vp" "int flags" 40.Ft void 41.Fn vn_unlock "struct vnode *vp" 42.Ft int 43.Fn vn_islocked "struct vnode *vp" 44.Sh DESCRIPTION 45These calls are used to serialize access to the filesystem, such as 46to prevent two writes to the same file from happening at the 47same time. 48.Pp 49The arguments are: 50.Bl -tag -width flags 51.It Fa vp 52the vnode being locked or unlocked 53.It Fa flags 54One of the lock request types: 55.Bl -column ".Dv LK_FAILRECLAIM" -offset indent 56.It Dv LK_RETRY Ta "Automatically retry on timeout" 57.It Dv LK_FAILRECLAIM Ta "Fail if the vnode is being reclaimed" 58.El 59.El 60.Pp 61The 62.Fn vn_lock 63function will require either 64.Dv LK_EXCLUSIVE 65or 66.Dv LK_SHARED 67to be 68.Em or Ns 'ed 69with the request flags described above in order to specify the type 70of lock to be used. 71.Pp 72The 73.Fn vn_unlock 74function uses 75.Dv LK_RELEASE 76internally to release a previously held lock. 77.Pp 78Please note all these functions rely on 79.Xr lockmgr 9 80to perform their operations. 81.Sh RETURN VALUES 82The 83.Fn vn_lock 84function returns zero on success and non-zero on failure. 85.Pp 86The 87.Fn vn_islocked 88function has identical return values as 89.Xr lockstatus 9 . 90.Sh SEE ALSO 91.Xr lockmgr 9 , 92.Xr vnode 9 93.Sh AUTHORS 94This man page was written by 95.An Doug Rabson . 96