summaryrefslogtreecommitdiff
path: root/static/freebsd/man9/VOP_LOCK.9 4.html
blob: 1045d3fb4fc56a04b53bbcf3f691e24439053f3c (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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
<table class="head">
  <tr>
    <td class="head-ltitle">VOP_LOCK(9)</td>
    <td class="head-vol">Kernel Developer's Manual</td>
    <td class="head-rtitle">VOP_LOCK(9)</td>
  </tr>
</table>
<div class="manual-text">
<section class="Sh">
<h1 class="Sh" id="NAME"><a class="permalink" href="#NAME">NAME</a></h1>
<p class="Pp"><code class="Nm">VOP_LOCK</code>,
    <code class="Nm">VOP_UNLOCK</code>, <code class="Nm">VOP_ISLOCKED</code>,
    <code class="Nm">vn_lock</code> &#x2014; <span class="Nd">serialize access
    to a vnode</span></p>
</section>
<section class="Sh">
<h1 class="Sh" id="SYNOPSIS"><a class="permalink" href="#SYNOPSIS">SYNOPSIS</a></h1>
<p class="Pp"><code class="In">#include
    &lt;<a class="In">sys/param.h</a>&gt;</code>
  <br/>
  <code class="In">#include &lt;<a class="In">sys/lock.h</a>&gt;</code>
  <br/>
  <code class="In">#include &lt;<a class="In">sys/vnode.h</a>&gt;</code></p>
<p class="Pp"><var class="Ft">int</var>
  <br/>
  <code class="Fn">VOP_LOCK</code>(<var class="Fa" style="white-space: nowrap;">struct
    vnode *vp</var>, <var class="Fa" style="white-space: nowrap;">int
    flags</var>);</p>
<p class="Pp"><var class="Ft">int</var>
  <br/>
  <code class="Fn">VOP_UNLOCK</code>(<var class="Fa" style="white-space: nowrap;">struct
    vnode *vp</var>);</p>
<p class="Pp"><var class="Ft">int</var>
  <br/>
  <code class="Fn">VOP_ISLOCKED</code>(<var class="Fa" style="white-space: nowrap;">struct
    vnode *vp</var>);</p>
<p class="Pp"><var class="Ft">int</var>
  <br/>
  <code class="Fn">vn_lock</code>(<var class="Fa" style="white-space: nowrap;">struct
    vnode *vp</var>, <var class="Fa" style="white-space: nowrap;">int
    flags</var>);</p>
</section>
<section class="Sh">
<h1 class="Sh" id="DESCRIPTION"><a class="permalink" href="#DESCRIPTION">DESCRIPTION</a></h1>
<p class="Pp">These calls are used to serialize access to the file system, such
    as to prevent two writes to the same file from happening at the same
  time.</p>
<p class="Pp">The arguments are:</p>
<dl class="Bl-tag">
  <dt><var class="Fa">vp</var></dt>
  <dd>The vnode being locked or unlocked.</dd>
  <dt><var class="Fa">flags</var></dt>
  <dd>One of the lock request types:
    <p class="Pp"></p>
    <div class="Bd-indent">
    <dl class="Bl-tag Bl-compact">
      <dt id="LK_SHARED"><a class="permalink" href="#LK_SHARED"><code class="Dv">LK_SHARED</code></a></dt>
      <dd>Shared lock.</dd>
      <dt id="LK_EXCLUSIVE"><a class="permalink" href="#LK_EXCLUSIVE"><code class="Dv">LK_EXCLUSIVE</code></a></dt>
      <dd>Exclusive lock.</dd>
      <dt id="LK_UPGRADE"><a class="permalink" href="#LK_UPGRADE"><code class="Dv">LK_UPGRADE</code></a></dt>
      <dd>Shared-to-exclusive upgrade.</dd>
      <dt id="LK_DOWNGRADE"><a class="permalink" href="#LK_DOWNGRADE"><code class="Dv">LK_DOWNGRADE</code></a></dt>
      <dd>Exclusive-to-shared downgrade.</dd>
      <dt id="LK_RELEASE"><a class="permalink" href="#LK_RELEASE"><code class="Dv">LK_RELEASE</code></a></dt>
      <dd>Release any type of lock.</dd>
      <dt id="LK_DRAIN"><a class="permalink" href="#LK_DRAIN"><code class="Dv">LK_DRAIN</code></a></dt>
      <dd>Wait for all lock activity to end.</dd>
    </dl>
    </div>
    <p class="Pp">The lock type may be <i class="Em">or</i>'ed with these lock
        flags:</p>
    <p class="Pp"></p>
    <div class="Bd-indent">
    <dl class="Bl-tag Bl-compact">
      <dt id="LK_NOWAIT"><a class="permalink" href="#LK_NOWAIT"><code class="Dv">LK_NOWAIT</code></a></dt>
      <dd>Do not sleep to wait for lock.</dd>
      <dt id="LK_SLEEPFAIL"><a class="permalink" href="#LK_SLEEPFAIL"><code class="Dv">LK_SLEEPFAIL</code></a></dt>
      <dd>Sleep, then return failure.</dd>
      <dt id="LK_CANRECURSE"><a class="permalink" href="#LK_CANRECURSE"><code class="Dv">LK_CANRECURSE</code></a></dt>
      <dd>Allow recursive exclusive lock.</dd>
      <dt id="LK_NOWITNESS"><a class="permalink" href="#LK_NOWITNESS"><code class="Dv">LK_NOWITNESS</code></a></dt>
      <dd>Instruct <a class="Xr">witness(4)</a> to ignore this instance.</dd>
    </dl>
    </div>
    <p class="Pp">The lock type may be <i class="Em">or</i>'ed with these
        control flags:</p>
    <p class="Pp"></p>
    <div class="Bd-indent">
    <dl class="Bl-tag Bl-compact">
      <dt id="LK_INTERLOCK"><a class="permalink" href="#LK_INTERLOCK"><code class="Dv">LK_INTERLOCK</code></a></dt>
      <dd>Specify when the caller already has a simple lock
          (<a class="permalink" href="#VOP_LOCK"><code class="Fn" id="VOP_LOCK">VOP_LOCK</code></a>()
          will unlock the simple lock after getting the lock).</dd>
      <dt id="LK_RETRY"><a class="permalink" href="#LK_RETRY"><code class="Dv">LK_RETRY</code></a></dt>
      <dd>Retry until locked.</dd>
    </dl>
    </div>
    <p class="Pp" id="vn_lock">Kernel code should use
        <a class="permalink" href="#vn_lock"><code class="Fn">vn_lock</code></a>()
        to lock a vnode rather than calling <code class="Fn">VOP_LOCK</code>()
        directly. <code class="Fn">vn_lock</code>() also does not want a thread
        specified as argument but it assumes curthread to be used.</p>
  </dd>
</dl>
</section>
<section class="Sh">
<h1 class="Sh" id="RETURN_VALUES"><a class="permalink" href="#RETURN_VALUES">RETURN
  VALUES</a></h1>
<p class="Pp">Zero is returned on success, otherwise an error is returned.</p>
</section>
<section class="Sh">
<h1 class="Sh" id="SEE_ALSO"><a class="permalink" href="#SEE_ALSO">SEE
  ALSO</a></h1>
<p class="Pp"><a class="Xr">vnode(9)</a></p>
</section>
<section class="Sh">
<h1 class="Sh" id="AUTHORS"><a class="permalink" href="#AUTHORS">AUTHORS</a></h1>
<p class="Pp">This manual page was written by <span class="An">Doug
    Rabson</span>.</p>
</section>
</div>
<table class="foot">
  <tr>
    <td class="foot-date">August 23, 2022</td>
    <td class="foot-os">FreeBSD 15.0</td>
  </tr>
</table>