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