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