Whamcloud - gitweb
924b38358f210df0dc510db7d68fa404fb69f2f0
[fs/lustre-release.git] / lustre / include / lustre_dlm_flags.h
1 /*  -*- buffer-read-only: t -*- vi: set ro:
2  *
3  * This program is free software; you can redistribute it and/or modify
4  * it under the terms of the GNU General Public License version 2 only,
5  * as published by the Free Software Foundation.
6  *
7  * Lustre is distributed in the hope that it will be useful, but
8  * WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10  * See the GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License along
13  * with this program.  If not, see <http://www.gnu.org/licenses/>.
14  */
15 /**
16  * \file lustre_dlm_flags.h
17  * The flags and collections of flags (masks) for \see struct ldlm_lock.
18  *
19  * \addtogroup LDLM Lustre Distributed Lock Manager
20  * @{
21  *
22  * \name flags
23  * The flags and collections of flags (masks) for \see struct ldlm_lock.
24  * @{
25  */
26 #ifndef LDLM_ALL_FLAGS_MASK
27
28 /** l_flags bits marked as "all_flags" bits */
29 #define LDLM_FL_ALL_FLAGS_MASK          0x00FFFFFFC28F932FULL
30
31 /** extent, mode, or resource changed */
32 #define LDLM_FL_LOCK_CHANGED            0x0000000000000001ULL // bit   0
33 #define ldlm_is_lock_changed(_l)        LDLM_TEST_FLAG(( _l), 1ULL <<  0)
34 #define ldlm_set_lock_changed(_l)       LDLM_SET_FLAG((  _l), 1ULL <<  0)
35 #define ldlm_clear_lock_changed(_l)     LDLM_CLEAR_FLAG((_l), 1ULL <<  0)
36
37 /**
38  * Server placed lock on granted list, or a recovering client wants the
39  * lock added to the granted list, no questions asked. */
40 #define LDLM_FL_BLOCK_GRANTED           0x0000000000000002ULL // bit   1
41 #define ldlm_is_block_granted(_l)       LDLM_TEST_FLAG(( _l), 1ULL <<  1)
42 #define ldlm_set_block_granted(_l)      LDLM_SET_FLAG((  _l), 1ULL <<  1)
43 #define ldlm_clear_block_granted(_l)    LDLM_CLEAR_FLAG((_l), 1ULL <<  1)
44
45 /**
46  * Server placed lock on conv list, or a recovering client wants the lock
47  * added to the conv list, no questions asked. (obsoleted) */
48 #define LDLM_FL_BLOCK_CONV              0x0000000000000004ULL // bit   2
49 #define ldlm_is_block_conv(_l)          LDLM_TEST_FLAG(( _l), 1ULL <<  2)
50 #define ldlm_set_block_conv(_l)         LDLM_SET_FLAG((  _l), 1ULL <<  2)
51 #define ldlm_clear_block_conv(_l)       LDLM_CLEAR_FLAG((_l), 1ULL <<  2)
52
53 /**
54  * Server placed lock on wait list, or a recovering client wants the lock
55  * added to the wait list, no questions asked. */
56 #define LDLM_FL_BLOCK_WAIT              0x0000000000000008ULL // bit   3
57 #define ldlm_is_block_wait(_l)          LDLM_TEST_FLAG(( _l), 1ULL <<  3)
58 #define ldlm_set_block_wait(_l)         LDLM_SET_FLAG((  _l), 1ULL <<  3)
59 #define ldlm_clear_block_wait(_l)       LDLM_CLEAR_FLAG((_l), 1ULL <<  3)
60
61 /**
62  * Lock request is speculative/asynchronous, and cannot wait for any reason.
63  * Fail the lock request if any blocking locks are encountered.
64  * */
65 #define LDLM_FL_SPECULATIVE             0x0000000000000010ULL /* bit   4 */
66 #define ldlm_is_speculative(_l)         LDLM_TEST_FLAG((_l), 1ULL <<  4)
67 #define ldlm_set_speculative(_l)        LDLM_SET_FLAG((_l), 1ULL <<  4)
68 #define ldlm_clear_specualtive_(_l)     LDLM_CLEAR_FLAG((_l), 1ULL <<  4)
69
70 /** blocking or cancel packet was queued for sending. */
71 #define LDLM_FL_AST_SENT                0x0000000000000020ULL // bit   5
72 #define ldlm_is_ast_sent(_l)            LDLM_TEST_FLAG(( _l), 1ULL <<  5)
73 #define ldlm_set_ast_sent(_l)           LDLM_SET_FLAG((  _l), 1ULL <<  5)
74 #define ldlm_clear_ast_sent(_l)         LDLM_CLEAR_FLAG((_l), 1ULL <<  5)
75
76 /**
77  * Lock is being replayed.  This could probably be implied by the fact that
78  * one of BLOCK_{GRANTED,CONV,WAIT} is set, but that is pretty dangerous. */
79 #define LDLM_FL_REPLAY                  0x0000000000000100ULL // bit   8
80 #define ldlm_is_replay(_l)              LDLM_TEST_FLAG(( _l), 1ULL <<  8)
81 #define ldlm_set_replay(_l)             LDLM_SET_FLAG((  _l), 1ULL <<  8)
82 #define ldlm_clear_replay(_l)           LDLM_CLEAR_FLAG((_l), 1ULL <<  8)
83
84 /** Don't grant lock, just do intent. */
85 #define LDLM_FL_INTENT_ONLY             0x0000000000000200ULL // bit   9
86 #define ldlm_is_intent_only(_l)         LDLM_TEST_FLAG(( _l), 1ULL <<  9)
87 #define ldlm_set_intent_only(_l)        LDLM_SET_FLAG((  _l), 1ULL <<  9)
88 #define ldlm_clear_intent_only(_l)      LDLM_CLEAR_FLAG((_l), 1ULL <<  9)
89
90 /** lock request has intent */
91 #define LDLM_FL_HAS_INTENT              0x0000000000001000ULL // bit  12
92 #define ldlm_is_has_intent(_l)          LDLM_TEST_FLAG(( _l), 1ULL << 12)
93 #define ldlm_set_has_intent(_l)         LDLM_SET_FLAG((  _l), 1ULL << 12)
94 #define ldlm_clear_has_intent(_l)       LDLM_CLEAR_FLAG((_l), 1ULL << 12)
95
96 /** flock deadlock detected */
97 #define LDLM_FL_FLOCK_DEADLOCK          0x0000000000008000ULL // bit  15
98 #define ldlm_is_flock_deadlock(_l)      LDLM_TEST_FLAG(( _l), 1ULL << 15)
99 #define ldlm_set_flock_deadlock(_l)     LDLM_SET_FLAG((  _l), 1ULL << 15)
100 #define ldlm_clear_flock_deadlock(_l)   LDLM_CLEAR_FLAG((_l), 1ULL << 15)
101
102 /** discard (no writeback (PW locks) or page retention (PR locks)) on cancel */
103 #define LDLM_FL_DISCARD_DATA            0x0000000000010000ULL // bit  16
104 #define ldlm_is_discard_data(_l)        LDLM_TEST_FLAG(( _l), 1ULL << 16)
105 #define ldlm_set_discard_data(_l)       LDLM_SET_FLAG((  _l), 1ULL << 16)
106 #define ldlm_clear_discard_data(_l)     LDLM_CLEAR_FLAG((_l), 1ULL << 16)
107
108 /** Blocked by group lock - wait indefinitely */
109 #define LDLM_FL_NO_TIMEOUT              0x0000000000020000ULL // bit  17
110 #define ldlm_is_no_timeout(_l)          LDLM_TEST_FLAG(( _l), 1ULL << 17)
111 #define ldlm_set_no_timeout(_l)         LDLM_SET_FLAG((  _l), 1ULL << 17)
112 #define ldlm_clear_no_timeout(_l)       LDLM_CLEAR_FLAG((_l), 1ULL << 17)
113
114 /**
115  * Server told not to wait if blocked. For AGL, OST will not send glimpse
116  * callback. */
117 #define LDLM_FL_BLOCK_NOWAIT            0x0000000000040000ULL // bit  18
118 #define ldlm_is_block_nowait(_l)        LDLM_TEST_FLAG(( _l), 1ULL << 18)
119 #define ldlm_set_block_nowait(_l)       LDLM_SET_FLAG((  _l), 1ULL << 18)
120 #define ldlm_clear_block_nowait(_l)     LDLM_CLEAR_FLAG((_l), 1ULL << 18)
121
122 /** return blocking lock */
123 #define LDLM_FL_TEST_LOCK               0x0000000000080000ULL // bit  19
124 #define ldlm_is_test_lock(_l)           LDLM_TEST_FLAG(( _l), 1ULL << 19)
125 #define ldlm_set_test_lock(_l)          LDLM_SET_FLAG((  _l), 1ULL << 19)
126 #define ldlm_clear_test_lock(_l)        LDLM_CLEAR_FLAG((_l), 1ULL << 19)
127
128 /** match lock only */
129 #define LDLM_FL_MATCH_LOCK               0x0000000000100000ULL // bit  20
130
131 /**
132  * Immediatelly cancel such locks when they block some other locks. Send
133  * cancel notification to original lock holder, but expect no reply. This
134  * is for clients (like liblustre) that cannot be expected to reliably
135  * response to blocking AST. */
136 #define LDLM_FL_CANCEL_ON_BLOCK         0x0000000000800000ULL // bit  23
137 #define ldlm_is_cancel_on_block(_l)     LDLM_TEST_FLAG(( _l), 1ULL << 23)
138 #define ldlm_set_cancel_on_block(_l)    LDLM_SET_FLAG((  _l), 1ULL << 23)
139 #define ldlm_clear_cancel_on_block(_l)  LDLM_CLEAR_FLAG((_l), 1ULL << 23)
140
141 /*
142  * Flag indicates that lock is being converted (downgraded) during the blocking
143  * AST instead of cancelling. Used for IBITS locks now and drops conflicting
144  * bits only keepeing other.
145  */
146 #define LDLM_FL_CONVERTING              0x0000000002000000ULL /* bit  25 */
147 #define ldlm_is_converting(_l)          LDLM_TEST_FLAG((_l), 1ULL << 25)
148 #define ldlm_set_converting(_l)         LDLM_SET_FLAG((_l), 1ULL << 25)
149 #define ldlm_clear_converting(_l)       LDLM_CLEAR_FLAG((_l), 1ULL << 25)
150
151 /**
152  * Do not expand this lock.  Grant it only on the extent requested.
153  * Used for manually requested locks from the client (LU_LADVISE_LOCKAHEAD).
154  * */
155 #define LDLM_FL_NO_EXPANSION            0x0000000020000000ULL /* bit  29 */
156 #define ldlm_is_do_not_expand(_l)       LDLM_TEST_FLAG((_l), 1ULL << 29)
157 #define ldlm_set_do_not_expand(_l)      LDLM_SET_FLAG((_l), 1ULL << 29)
158 #define ldlm_clear_do_not_expand(_l)    LDLM_CLEAR_FLAG((_l), 1ULL << 29)
159
160 /**
161  * measure lock contention and return -EUSERS if locking contention is high */
162 #define LDLM_FL_DENY_ON_CONTENTION        0x0000000040000000ULL // bit  30
163 #define ldlm_is_deny_on_contention(_l)    LDLM_TEST_FLAG(( _l), 1ULL << 30)
164 #define ldlm_set_deny_on_contention(_l)   LDLM_SET_FLAG((  _l), 1ULL << 30)
165 #define ldlm_clear_deny_on_contention(_l) LDLM_CLEAR_FLAG((_l), 1ULL << 30)
166
167 /**
168  * These are flags that are mapped into the flags and ASTs of blocking
169  * locks Add FL_DISCARD to blocking ASTs */
170 #define LDLM_FL_AST_DISCARD_DATA        0x0000000080000000ULL // bit  31
171 #define ldlm_is_ast_discard_data(_l)    LDLM_TEST_FLAG(( _l), 1ULL << 31)
172 #define ldlm_set_ast_discard_data(_l)   LDLM_SET_FLAG((  _l), 1ULL << 31)
173 #define ldlm_clear_ast_discard_data(_l) LDLM_CLEAR_FLAG((_l), 1ULL << 31)
174
175 /**
176  * Used for marking lock as a target for -EINTR while cp_ast sleep emulation
177  * + race with upcoming bl_ast. */
178 #define LDLM_FL_FAIL_LOC                0x0000000100000000ULL // bit  32
179 #define ldlm_is_fail_loc(_l)            LDLM_TEST_FLAG(( _l), 1ULL << 32)
180 #define ldlm_set_fail_loc(_l)           LDLM_SET_FLAG((  _l), 1ULL << 32)
181 #define ldlm_clear_fail_loc(_l)         LDLM_CLEAR_FLAG((_l), 1ULL << 32)
182
183 /** this lock is being destroyed */
184 #define LDLM_FL_CBPENDING               0x0000000400000000ULL // bit  34
185 #define ldlm_is_cbpending(_l)           LDLM_TEST_FLAG(( _l), 1ULL << 34)
186 #define ldlm_set_cbpending(_l)          LDLM_SET_FLAG((  _l), 1ULL << 34)
187 #define ldlm_clear_cbpending(_l)        LDLM_CLEAR_FLAG((_l), 1ULL << 34)
188
189 /** not a real flag, not saved in lock */
190 #define LDLM_FL_WAIT_NOREPROC           0x0000000800000000ULL // bit  35
191 #define ldlm_is_wait_noreproc(_l)       LDLM_TEST_FLAG(( _l), 1ULL << 35)
192 #define ldlm_set_wait_noreproc(_l)      LDLM_SET_FLAG((  _l), 1ULL << 35)
193 #define ldlm_clear_wait_noreproc(_l)    LDLM_CLEAR_FLAG((_l), 1ULL << 35)
194
195 /** cancellation callback already run */
196 #define LDLM_FL_CANCEL                  0x0000001000000000ULL // bit  36
197 #define ldlm_is_cancel(_l)              LDLM_TEST_FLAG(( _l), 1ULL << 36)
198 #define ldlm_set_cancel(_l)             LDLM_SET_FLAG((  _l), 1ULL << 36)
199 #define ldlm_clear_cancel(_l)           LDLM_CLEAR_FLAG((_l), 1ULL << 36)
200
201 /** whatever it might mean -- never transmitted? */
202 #define LDLM_FL_LOCAL_ONLY              0x0000002000000000ULL // bit  37
203 #define ldlm_is_local_only(_l)          LDLM_TEST_FLAG(( _l), 1ULL << 37)
204 #define ldlm_set_local_only(_l)         LDLM_SET_FLAG((  _l), 1ULL << 37)
205 #define ldlm_clear_local_only(_l)       LDLM_CLEAR_FLAG((_l), 1ULL << 37)
206
207 /** don't run the cancel callback under ldlm_cli_cancel_unused */
208 #define LDLM_FL_FAILED                  0x0000004000000000ULL // bit  38
209 #define ldlm_is_failed(_l)              LDLM_TEST_FLAG(( _l), 1ULL << 38)
210 #define ldlm_set_failed(_l)             LDLM_SET_FLAG((  _l), 1ULL << 38)
211 #define ldlm_clear_failed(_l)           LDLM_CLEAR_FLAG((_l), 1ULL << 38)
212
213 /** lock cancel has already been sent */
214 #define LDLM_FL_CANCELING               0x0000008000000000ULL // bit  39
215 #define ldlm_is_canceling(_l)           LDLM_TEST_FLAG(( _l), 1ULL << 39)
216 #define ldlm_set_canceling(_l)          LDLM_SET_FLAG((  _l), 1ULL << 39)
217 #define ldlm_clear_canceling(_l)        LDLM_CLEAR_FLAG((_l), 1ULL << 39)
218
219 /** local lock (ie, no srv/cli split) */
220 #define LDLM_FL_LOCAL                   0x0000010000000000ULL // bit  40
221 #define ldlm_is_local(_l)               LDLM_TEST_FLAG(( _l), 1ULL << 40)
222 #define ldlm_set_local(_l)              LDLM_SET_FLAG((  _l), 1ULL << 40)
223 #define ldlm_clear_local(_l)            LDLM_CLEAR_FLAG((_l), 1ULL << 40)
224
225 /**
226  * XXX FIXME: This is being added to b_size as a low-risk fix to the
227  * fact that the LVB filling happens _after_ the lock has been granted,
228  * so another thread can match it before the LVB has been updated.  As a
229  * dirty hack, we set LDLM_FL_LVB_READY only after we've done the LVB poop.
230  * this is only needed on LOV/OSC now, where LVB is actually used and
231  * callers must set it in input flags.
232  *
233  * The proper fix is to do the granting inside of the completion AST,
234  * which can be replaced with a LVB-aware wrapping function for OSC locks.
235  * That change is pretty high-risk, though, and would need a lot more
236  * testing. */
237 #define LDLM_FL_LVB_READY               0x0000020000000000ULL // bit  41
238 #define ldlm_is_lvb_ready(_l)           LDLM_TEST_FLAG(( _l), 1ULL << 41)
239 #define ldlm_set_lvb_ready(_l)          LDLM_SET_FLAG((  _l), 1ULL << 41)
240 #define ldlm_clear_lvb_ready(_l)        LDLM_CLEAR_FLAG((_l), 1ULL << 41)
241
242 /**
243  * A lock contributes to the known minimum size (KMS) calculation until it
244  * has finished the part of its cancelation that performs write back on its
245  * dirty pages.  It can remain on the granted list during this whole time.
246  * Threads racing to update the KMS after performing their writeback need
247  * to know to exclude each other's locks from the calculation as they walk
248  * the granted list. */
249 #define LDLM_FL_KMS_IGNORE              0x0000040000000000ULL // bit  42
250 #define ldlm_is_kms_ignore(_l)          LDLM_TEST_FLAG(( _l), 1ULL << 42)
251 #define ldlm_set_kms_ignore(_l)         LDLM_SET_FLAG((  _l), 1ULL << 42)
252 #define ldlm_clear_kms_ignore(_l)       LDLM_CLEAR_FLAG((_l), 1ULL << 42)
253
254 /** completion AST to be executed */
255 #define LDLM_FL_CP_REQD                 0x0000080000000000ULL // bit  43
256 #define ldlm_is_cp_reqd(_l)             LDLM_TEST_FLAG(( _l), 1ULL << 43)
257 #define ldlm_set_cp_reqd(_l)            LDLM_SET_FLAG((  _l), 1ULL << 43)
258 #define ldlm_clear_cp_reqd(_l)          LDLM_CLEAR_FLAG((_l), 1ULL << 43)
259
260 /** cleanup_resource has already handled the lock */
261 #define LDLM_FL_CLEANED                 0x0000100000000000ULL // bit  44
262 #define ldlm_is_cleaned(_l)             LDLM_TEST_FLAG(( _l), 1ULL << 44)
263 #define ldlm_set_cleaned(_l)            LDLM_SET_FLAG((  _l), 1ULL << 44)
264 #define ldlm_clear_cleaned(_l)          LDLM_CLEAR_FLAG((_l), 1ULL << 44)
265
266 /**
267  * optimization hint: LDLM can run blocking callback from current context
268  * w/o involving separate thread. in order to decrease cs rate */
269 #define LDLM_FL_ATOMIC_CB               0x0000200000000000ULL // bit  45
270 #define ldlm_is_atomic_cb(_l)           LDLM_TEST_FLAG(( _l), 1ULL << 45)
271 #define ldlm_set_atomic_cb(_l)          LDLM_SET_FLAG((  _l), 1ULL << 45)
272 #define ldlm_clear_atomic_cb(_l)        LDLM_CLEAR_FLAG((_l), 1ULL << 45)
273
274 /**
275  * It may happen that a client initiates two operations, e.g. unlink and
276  * mkdir, such that the server sends a blocking AST for conflicting locks
277  * to this client for the first operation, whereas the second operation
278  * has canceled this lock and is waiting for rpc_lock which is taken by
279  * the first operation. LDLM_FL_BL_AST is set by ldlm_callback_handler() in
280  * the lock to prevent the Early Lock Cancel (ELC) code from cancelling it. */
281 #define LDLM_FL_BL_AST                  0x0000400000000000ULL // bit  46
282 #define ldlm_is_bl_ast(_l)              LDLM_TEST_FLAG(( _l), 1ULL << 46)
283 #define ldlm_set_bl_ast(_l)             LDLM_SET_FLAG((  _l), 1ULL << 46)
284 #define ldlm_clear_bl_ast(_l)           LDLM_CLEAR_FLAG((_l), 1ULL << 46)
285
286 /**
287  * Set by ldlm_cancel_callback() when lock cache is dropped to let
288  * ldlm_callback_handler() return EINVAL to the server. It is used when
289  * ELC RPC is already prepared and is waiting for rpc_lock, too late to
290  * send a separate CANCEL RPC. */
291 #define LDLM_FL_BL_DONE                 0x0000800000000000ULL // bit  47
292 #define ldlm_is_bl_done(_l)             LDLM_TEST_FLAG(( _l), 1ULL << 47)
293 #define ldlm_set_bl_done(_l)            LDLM_SET_FLAG((  _l), 1ULL << 47)
294 #define ldlm_clear_bl_done(_l)          LDLM_CLEAR_FLAG((_l), 1ULL << 47)
295
296 /**
297  * Don't put lock into the LRU list, so that it is not canceled due
298  * to aging.  Used by MGC locks, they are cancelled only at unmount or
299  * by callback. */
300 #define LDLM_FL_NO_LRU                  0x0001000000000000ULL // bit  48
301 #define ldlm_is_no_lru(_l)              LDLM_TEST_FLAG(( _l), 1ULL << 48)
302 #define ldlm_set_no_lru(_l)             LDLM_SET_FLAG((  _l), 1ULL << 48)
303 #define ldlm_clear_no_lru(_l)           LDLM_CLEAR_FLAG((_l), 1ULL << 48)
304
305 /**
306  * Set for locks that failed and where the server has been notified.
307  *
308  * Protected by lock and resource locks. */
309 #define LDLM_FL_FAIL_NOTIFIED           0x0002000000000000ULL // bit  49
310 #define ldlm_is_fail_notified(_l)       LDLM_TEST_FLAG(( _l), 1ULL << 49)
311 #define ldlm_set_fail_notified(_l)      LDLM_SET_FLAG((  _l), 1ULL << 49)
312 #define ldlm_clear_fail_notified(_l)    LDLM_CLEAR_FLAG((_l), 1ULL << 49)
313
314 /**
315  * Set for locks that were removed from class hash table and will
316  * be destroyed when last reference to them is released. Set by
317  * ldlm_lock_destroy_internal().
318  *
319  * Protected by lock and resource locks. */
320 #define LDLM_FL_DESTROYED               0x0004000000000000ULL // bit  50
321 #define ldlm_is_destroyed(_l)           LDLM_TEST_FLAG(( _l), 1ULL << 50)
322 #define ldlm_set_destroyed(_l)          LDLM_SET_FLAG((  _l), 1ULL << 50)
323 #define ldlm_clear_destroyed(_l)        LDLM_CLEAR_FLAG((_l), 1ULL << 50)
324
325 /**
326  * It's set in lock_res_and_lock() and unset in unlock_res_and_lock().
327  *
328  * NB: compared with check_res_locked(), checking this bit is cheaper.
329  * Also, spin_is_locked() is deprecated for kernel code; one reason is
330  * because it works only for SMP so user needs to add extra macros like
331  * LASSERT_SPIN_LOCKED for uniprocessor kernels. */
332 #define LDLM_FL_RES_LOCKED              0x0010000000000000ULL // bit  52
333 #define ldlm_is_res_locked(_l)          LDLM_TEST_FLAG(( _l), 1ULL << 52)
334 #define ldlm_set_res_locked(_l)         LDLM_SET_FLAG((  _l), 1ULL << 52)
335 #define ldlm_clear_res_locked(_l)       LDLM_CLEAR_FLAG((_l), 1ULL << 52)
336
337 /**
338  * It's set once we call ldlm_add_waiting_lock_res_locked() to start the
339  * lock-timeout timer and it will never be reset.
340  *
341  * Protected by lock and resource locks. */
342 #define LDLM_FL_WAITED                  0x0020000000000000ULL // bit  53
343 #define ldlm_is_waited(_l)              LDLM_TEST_FLAG(( _l), 1ULL << 53)
344 #define ldlm_set_waited(_l)             LDLM_SET_FLAG((  _l), 1ULL << 53)
345 #define ldlm_clear_waited(_l)           LDLM_CLEAR_FLAG((_l), 1ULL << 53)
346
347 /** Flag whether this is a server namespace lock. */
348 #define LDLM_FL_NS_SRV                  0x0040000000000000ULL // bit  54
349 #define ldlm_is_ns_srv(_l)              LDLM_TEST_FLAG(( _l), 1ULL << 54)
350 #define ldlm_set_ns_srv(_l)             LDLM_SET_FLAG((  _l), 1ULL << 54)
351 #define ldlm_clear_ns_srv(_l)           LDLM_CLEAR_FLAG((_l), 1ULL << 54)
352
353 /** Flag whether this lock can be reused. Used by exclusive open. */
354 #define LDLM_FL_EXCL                    0x0080000000000000ULL // bit  55
355 #define ldlm_is_excl(_l)                LDLM_TEST_FLAG(( _l), 1ULL << 55)
356 #define ldlm_set_excl(_l)               LDLM_SET_FLAG((  _l), 1ULL << 55)
357 #define ldlm_clear_excl(_l)             LDLM_CLEAR_FLAG((_l), 1ULL << 55)
358
359 /** Flag whether a lock is found on server for re-sent RPC. */
360 #define LDLM_FL_RESENT                   0x0100000000000000ULL // bit  56
361
362 /**
363  * This flags means to use non-delay RPC to send dlm request RPC.
364  */
365 #define LDLM_FL_NDELAY                   0x0400000000000000ULL /* bit  58 */
366 #define ldlm_is_ndelay(_l)               LDLM_TEST_FLAG((_l), 1ULL << 58)
367 #define ldlm_set_ndelay(_l)              LDLM_SET_FLAG((_l), 1ULL << 58)
368
369 /**
370  * LVB from this lock is cached in osc object
371  */
372 #define LDLM_FL_LVB_CACHED              0x0800000000000000ULL /* bit  59 */
373 #define ldlm_is_lvb_cached(_l)          LDLM_TEST_FLAG((_l), 1ULL << 59)
374 #define ldlm_set_lvb_cached(_l)         LDLM_SET_FLAG((_l), 1ULL << 59)
375 #define ldlm_clear_lvb_cached(_l)       LDLM_CLEAR_FLAG((_l), 1ULL << 59)
376
377 /** l_flags bits marked as "ast" bits */
378 #define LDLM_FL_AST_MASK                (LDLM_FL_FLOCK_DEADLOCK         |\
379                                          LDLM_FL_DISCARD_DATA)
380
381 /** l_flags bits marked as "blocked" bits */
382 #define LDLM_FL_BLOCKED_MASK            (LDLM_FL_BLOCK_GRANTED          |\
383                                          LDLM_FL_BLOCK_WAIT)
384
385 /** l_flags bits marked as "gone" bits */
386 #define LDLM_FL_GONE_MASK               (LDLM_FL_DESTROYED              |\
387                                          LDLM_FL_FAILED)
388
389 /** l_flags bits marked as "inherit" bits
390  * Flags inherited from wire on enqueue/reply between client/server.
391  * CANCEL_ON_BLOCK so server will not grant if a blocking lock is found
392  * NO_TIMEOUT flag to force ldlm_lock_match() to wait with no timeout.
393  * TEST_LOCK flag to not let TEST lock to be granted.
394  * NO_EXPANSION to tell server not to expand extent of lock request */
395 #define LDLM_FL_INHERIT_MASK            (LDLM_FL_CANCEL_ON_BLOCK        |\
396                                          LDLM_FL_NO_TIMEOUT             |\
397                                          LDLM_FL_TEST_LOCK              |\
398                                          LDLM_FL_NO_EXPANSION)
399
400 /** flags returned in @flags parameter on ldlm_lock_enqueue,
401  * to be re-constructed on re-send */
402 #define LDLM_FL_SRV_ENQ_MASK    (LDLM_FL_LOCK_CHANGED           |\
403                                  LDLM_FL_BLOCKED_MASK           |\
404                                  LDLM_FL_NO_TIMEOUT)
405
406 /** test for ldlm_lock flag bit set */
407 #define LDLM_TEST_FLAG(_l, _b)    (((_l)->l_flags & (_b)) != 0)
408
409 /** multi-bit test: are any of mask bits set? */
410 #define LDLM_HAVE_MASK(_l, _m)    (((_l)->l_flags & LDLM_FL_##_m##_MASK) != 0)
411
412 /** set a ldlm_lock flag bit */
413 #define LDLM_SET_FLAG(_l, _b)     ((_l)->l_flags |= (_b))
414
415 /** clear a ldlm_lock flag bit */
416 #define LDLM_CLEAR_FLAG(_l, _b)   ((_l)->l_flags &= ~(_b))
417
418 /** @} subgroup */
419 /** @} group */
420 #endif /* LDLM_ALL_FLAGS_MASK */
421