1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2 * (visit-tags-table FILE)
3 * vim:expandtab:shiftwidth=8:tabstop=8:
6 #ifndef _LUSTRE_DLM_H__
7 #define _LUSTRE_DLM_H__
10 # include <linux/proc_fs.h>
13 #include <linux/lustre_lib.h>
14 #include <linux/lustre_net.h>
15 #include <linux/lustre_import.h>
16 #include <linux/lustre_handles.h>
17 #include <linux/lustre_export.h> /* for obd_export, for LDLM_DEBUG */
22 #define LDLM_DEFAULT_LRU_SIZE 100
27 ELDLM_LOCK_CHANGED = 300,
28 ELDLM_LOCK_ABORTED = 301,
29 ELDLM_LOCK_REPLACED = 302,
30 ELDLM_NO_LOCK_DATA = 303,
32 ELDLM_NAMESPACE_EXISTS = 400,
33 ELDLM_BAD_NAMESPACE = 401
36 #define LDLM_NAMESPACE_SERVER 0
37 #define LDLM_NAMESPACE_CLIENT 1
39 #define LDLM_FL_LOCK_CHANGED 0x000001 /* extent, mode, or resource changed */
41 /* If the server returns one of these flags, then the lock was put on that list.
42 * If the client sends one of these flags (during recovery ONLY!), it wants the
43 * lock added to the specified list, no questions asked. -p */
44 #define LDLM_FL_BLOCK_GRANTED 0x000002
45 #define LDLM_FL_BLOCK_CONV 0x000004
46 #define LDLM_FL_BLOCK_WAIT 0x000008
48 #define LDLM_FL_CBPENDING 0x000010 /* this lock is being destroyed */
49 #define LDLM_FL_AST_SENT 0x000020 /* blocking or cancel packet was sent */
50 #define LDLM_FL_WAIT_NOREPROC 0x000040 /* not a real flag, not saved in lock */
51 #define LDLM_FL_CANCEL 0x000080 /* cancellation callback already run */
53 /* Lock is being replayed. This could probably be implied by the fact that one
54 * of BLOCK_{GRANTED,CONV,WAIT} is set, but that is pretty dangerous. */
55 #define LDLM_FL_REPLAY 0x000100
57 #define LDLM_FL_INTENT_ONLY 0x000200 /* don't grant lock, just do intent */
58 #define LDLM_FL_LOCAL_ONLY 0x000400 /* see ldlm_cli_cancel_unused */
60 /* don't run the cancel callback under ldlm_cli_cancel_unused */
61 #define LDLM_FL_FAILED 0x000800
63 #define LDLM_FL_HAS_INTENT 0x001000 /* lock request has intent */
64 #define LDLM_FL_CANCELING 0x002000 /* lock cancel has already been sent */
65 #define LDLM_FL_LOCAL 0x004000 /* local lock (ie, no srv/cli split) */
66 #define LDLM_FL_WARN 0x008000 /* see ldlm_cli_cancel_unused */
67 #define LDLM_FL_DISCARD_DATA 0x010000 /* discard (no writeback) on cancel */
68 #define LDLM_FL_CONFIG_CHANGE 0x020000 /* see ldlm_cli_cancel_unused */
70 #define LDLM_FL_NO_TIMEOUT 0x020000 /* Blocked by group lock - wait
73 /* file & record locking */
74 #define LDLM_FL_BLOCK_NOWAIT 0x040000 /* server told not to wait if blocked */
75 #define LDLM_FL_TEST_LOCK 0x080000 /* return blocking lock */
77 /* These are flags that are mapped into the flags and ASTs of blocking locks */
78 #define LDLM_AST_DISCARD_DATA 0x80000000 /* Add FL_DISCARD to blocking ASTs */
79 /* Flags sent in AST lock_flags to be mapped into the receiving lock. */
80 #define LDLM_AST_FLAGS (LDLM_FL_DISCARD_DATA)
82 /* XXX FIXME: This is being added to b_size as a low-risk fix to the fact that
83 * the LVB filling happens _after_ the lock has been granted, so another thread
84 * can match before the LVB has been updated. As a dirty hack, we set
85 * LDLM_FL_CAN_MATCH only after we've done the LVB poop.
87 * The proper fix is to do the granting inside of the completion AST, which can
88 * be replaced with a LVB-aware wrapping function for OSC locks. That change is
89 * pretty high-risk, though, and would need a lot more testing. */
90 #define LDLM_FL_CAN_MATCH 0x100000
92 /* A lock contributes to the kms calculation until it has finished the part
93 * of it's cancelation that performs write back on its dirty pages. It
94 * can remain on the granted list during this whole time. Threads racing
95 * to update the kms after performing their writeback need to know to
96 * exclude each others locks from the calculation as they walk the granted
98 #define LDLM_FL_KMS_IGNORE 0x200000
100 /* completion ast to be executed */
101 #define LDLM_FL_CP_REQD 0x400000
103 /* cleanup_resource has already handled the lock */
104 #define LDLM_FL_CLEANED 0x800000
106 /* optimization hint: LDLM can run blocking callback from current context
107 * w/o involving separate thread. in order to decrease cs rate */
108 #define LDLM_FL_ATOMIC_CB 0x1000000
110 /* while this flag is set, the lock can't change resource */
111 #define LDLM_FL_LOCK_PROTECT 0x4000000
112 #define LDLM_FL_LOCK_PROTECT_BIT 26
114 /* The blocking callback is overloaded to perform two functions. These flags
115 * indicate which operation should be performed. */
116 #define LDLM_CB_BLOCKING 1
117 #define LDLM_CB_CANCELING 2
119 /* compatibility matrix */
120 #define LCK_COMPAT_EX LCK_NL
121 #define LCK_COMPAT_PW (LCK_COMPAT_EX | LCK_CR)
122 #define LCK_COMPAT_PR (LCK_COMPAT_PW | LCK_PR)
123 #define LCK_COMPAT_CW (LCK_COMPAT_PW | LCK_CW)
124 #define LCK_COMPAT_CR (LCK_COMPAT_CW | LCK_PR | LCK_PW)
125 #define LCK_COMPAT_NL (LCK_COMPAT_CR | LCK_EX)
126 #define LCK_COMPAT_GROUP (LCK_GROUP | LCK_NL)
128 static ldlm_mode_t lck_compat_array[] = {
129 [LCK_EX] LCK_COMPAT_EX,
130 [LCK_PW] LCK_COMPAT_PW,
131 [LCK_PR] LCK_COMPAT_PR,
132 [LCK_CW] LCK_COMPAT_CW,
133 [LCK_CR] LCK_COMPAT_CR,
134 [LCK_NL] LCK_COMPAT_NL,
135 [LCK_GROUP] LCK_COMPAT_GROUP
138 static inline void lockmode_verify(ldlm_mode_t mode)
140 LASSERT(mode >= LCK_EX && mode <= LCK_GROUP);
143 static inline int lockmode_compat(ldlm_mode_t exist, ldlm_mode_t new)
145 return (lck_compat_array[exist] & new);
150 * cluster name spaces
154 #define DLM_OST_NAMESPACE 1
155 #define DLM_MDS_NAMESPACE 2
158 - do we just separate this by security domains and use a prefix for
159 multiple namespaces in the same domain?
169 * waiting_locks_spinlock
183 struct ldlm_resource;
184 struct ldlm_namespace;
186 typedef int (*ldlm_res_policy)(struct ldlm_namespace *, struct ldlm_lock **,
187 void *req_cookie, ldlm_mode_t mode, int flags,
190 struct ldlm_valblock_ops {
191 int (*lvbo_init)(struct ldlm_resource *res);
193 int (*lvbo_update)(struct ldlm_resource *res,
194 struct lustre_msg *m,
195 int buf_idx, int increase);
198 struct ldlm_namespace {
200 __u32 ns_client; /* is this a client-side lock tree? */
201 struct list_head *ns_hash; /* hash table for ns */
202 spinlock_t ns_hash_lock;
203 __u32 ns_refcount; /* count of resources in the hash */
204 struct list_head ns_root_list; /* all root resources in ns */
205 struct list_head ns_list_chain; /* position in global NS list */
207 struct proc_dir_entry *ns_proc_dir;
210 struct list_head ns_unused_list; /* all root resources in ns */
212 spinlock_t ns_unused_lock;
214 unsigned int ns_max_unused;
215 unsigned long ns_next_dump; /* next dump time */
219 ldlm_res_policy ns_policy;
220 struct ldlm_valblock_ops *ns_lvbo;
222 wait_queue_head_t ns_waitq;
227 * Resource hash table
231 #define RES_HASH_BITS 10
232 #define RES_HASH_SIZE (1UL << RES_HASH_BITS)
233 #define RES_HASH_MASK (RES_HASH_SIZE - 1)
237 typedef int (*ldlm_blocking_callback)(struct ldlm_lock *lock,
238 struct ldlm_lock_desc *new, void *data,
240 typedef int (*ldlm_completion_callback)(struct ldlm_lock *lock, int flags,
242 typedef int (*ldlm_glimpse_callback)(struct ldlm_lock *lock, void *data);
245 struct portals_handle l_handle; // must be first in the structure
248 /* ldlm_lock_change_resource() can change this */
249 struct ldlm_resource *l_resource;
251 /* set once, no need to protect it */
252 struct ldlm_lock *l_parent;
254 /* protected by ns_hash_lock */
255 struct list_head l_children;
256 struct list_head l_childof;
258 /* protected by ns_hash_lock. FIXME */
259 struct list_head l_lru;
261 /* protected by lr_lock */
262 struct list_head l_res_link; // position in one of three res lists
264 /* protected by led_lock */
265 struct list_head l_export_chain; // per-export chain of locks
267 /* protected by lr_lock */
268 ldlm_mode_t l_req_mode;
269 ldlm_mode_t l_granted_mode;
271 ldlm_completion_callback l_completion_ast;
272 ldlm_blocking_callback l_blocking_ast;
273 ldlm_glimpse_callback l_glimpse_ast;
275 struct obd_export *l_export;
276 struct obd_export *l_conn_export;
278 /* protected by lr_lock */
281 struct lustre_handle l_remote_handle;
282 ldlm_policy_data_t l_policy_data;
284 /* protected by lr_lock */
289 /* If the lock is granted, a process sleeps on this waitq to learn when
290 * it's no longer in use. If the lock is not granted, a process sleeps
291 * on this waitq to learn when it becomes granted. */
292 wait_queue_head_t l_waitq;
293 struct timeval l_enqueued_time;
295 unsigned long l_last_used; /* jiffies */
296 struct ldlm_extent l_req_extent;
298 /* Client-side-only members */
299 __u32 l_lvb_len; /* temporary storage for */
300 void *l_lvb_data; /* an LVB received during */
301 void *l_lvb_swabber; /* an enqueue */
304 /* Server-side-only members */
306 /* protected by elt_lock */
307 struct list_head l_pending_chain; /* callbacks pending */
308 unsigned long l_callback_timeout;
310 __u32 l_pid; /* pid which created this lock */
311 __u32 l_pidb; /* who holds LOCK_PROTECT_BIT */
313 struct list_head l_tmp;
315 /* for ldlm_add_ast_work_item() */
316 struct list_head l_bl_ast;
317 struct list_head l_cp_ast;
318 struct ldlm_lock *l_blocking_lock;
322 #define LDLM_PLAIN 10
323 #define LDLM_EXTENT 11
324 #define LDLM_FLOCK 12
325 #define LDLM_IBITS 13
327 #define LDLM_MIN_TYPE 10
328 #define LDLM_MAX_TYPE 14
330 struct ldlm_resource {
331 struct ldlm_namespace *lr_namespace;
333 /* protected by ns_hash_lock */
334 struct list_head lr_hash;
335 struct ldlm_resource *lr_parent; /* 0 for a root resource */
336 struct list_head lr_children; /* list head for child resources */
337 struct list_head lr_childof; /* part of ns_root_list if root res,
338 * part of lr_children if child */
341 /* protected by lr_lock */
342 struct list_head lr_granted;
343 struct list_head lr_converting;
344 struct list_head lr_waiting;
345 ldlm_mode_t lr_most_restr;
346 __u32 lr_type; /* LDLM_PLAIN or LDLM_EXTENT */
347 struct ldlm_res_id lr_name;
348 atomic_t lr_refcount;
350 /* Server-side-only lock value block elements */
351 struct semaphore lr_lvb_sem;
355 /* lr_tmp holds a list head temporarily, during the building of a work
356 * queue. see ldlm_add_ast_work_item and ldlm_run_ast_work */
360 struct ldlm_ast_work {
361 struct ldlm_lock *w_lock;
363 struct ldlm_lock_desc w_desc;
364 struct list_head w_list;
370 extern struct obd_ops ldlm_obd_ops;
372 extern char *ldlm_lockname[];
373 extern char *ldlm_typename[];
374 extern char *ldlm_it2str(int it);
376 #define __LDLM_DEBUG(level, lock, format, a...) \
378 if (lock->l_resource == NULL) { \
379 CDEBUG(level, "### " format \
380 " ns: \?\? lock: %p/"LPX64" lrc: %d/%d,%d mode: %s/%s "\
381 "res: \?\? rrc=\?\? type: \?\?\? flags: %x remote: " \
382 LPX64" expref: %d pid: %u\n" , ## a, lock, \
383 lock->l_handle.h_cookie, atomic_read(&lock->l_refc), \
384 lock->l_readers, lock->l_writers, \
385 ldlm_lockname[lock->l_granted_mode], \
386 ldlm_lockname[lock->l_req_mode], \
387 lock->l_flags, lock->l_remote_handle.cookie, \
389 atomic_read(&lock->l_export->exp_refcount) : -99, \
393 if (lock->l_resource->lr_type == LDLM_EXTENT) { \
394 CDEBUG(level, "### " format \
395 " ns: %s lock: %p/"LPX64" lrc: %d/%d,%d mode: %s/%s " \
396 "res: "LPU64"/"LPU64"/"LPU64" rrc: %d type: %s ["LPU64 \
397 "->"LPU64"] (req "LPU64"->"LPU64") flags: %x remote: " \
398 LPX64" expref: %d pid: %u\n" , ## a, \
399 lock->l_resource->lr_namespace->ns_name, lock, \
400 lock->l_handle.h_cookie, atomic_read(&lock->l_refc), \
401 lock->l_readers, lock->l_writers, \
402 ldlm_lockname[lock->l_granted_mode], \
403 ldlm_lockname[lock->l_req_mode], \
404 lock->l_resource->lr_name.name[0], \
405 lock->l_resource->lr_name.name[1], \
406 lock->l_resource->lr_name.name[2], \
407 atomic_read(&lock->l_resource->lr_refcount), \
408 ldlm_typename[lock->l_resource->lr_type], \
409 lock->l_policy_data.l_extent.start, \
410 lock->l_policy_data.l_extent.end, \
411 lock->l_req_extent.start, lock->l_req_extent.end, \
412 lock->l_flags, lock->l_remote_handle.cookie, \
414 atomic_read(&lock->l_export->exp_refcount) : -99, \
418 if (lock->l_resource->lr_type == LDLM_FLOCK) { \
419 CDEBUG(level, "### " format \
420 " ns: %s lock: %p/"LPX64" lrc: %d/%d,%d mode: %s/%s " \
421 "res: "LPU64"/"LPU64"/"LPU64" rrc: %d type: %s pid: " \
422 LPU64" " "["LPU64"->"LPU64"] flags: %x remote: "LPX64 \
423 " expref: %d pid: %u\n" , ## a, \
424 lock->l_resource->lr_namespace->ns_name, lock, \
425 lock->l_handle.h_cookie, atomic_read(&lock->l_refc), \
426 lock->l_readers, lock->l_writers, \
427 ldlm_lockname[lock->l_granted_mode], \
428 ldlm_lockname[lock->l_req_mode], \
429 lock->l_resource->lr_name.name[0], \
430 lock->l_resource->lr_name.name[1], \
431 lock->l_resource->lr_name.name[2], \
432 atomic_read(&lock->l_resource->lr_refcount), \
433 ldlm_typename[lock->l_resource->lr_type], \
434 lock->l_policy_data.l_flock.pid, \
435 lock->l_policy_data.l_flock.start, \
436 lock->l_policy_data.l_flock.end, \
437 lock->l_flags, lock->l_remote_handle.cookie, \
439 atomic_read(&lock->l_export->exp_refcount) : -99, \
443 if (lock->l_resource->lr_type == LDLM_IBITS) { \
444 CDEBUG(level, "### " format \
445 " ns: %s lock: %p/"LPX64" lrc: %d/%d,%d mode: %s/%s " \
446 "res: "LPU64"/"LPU64"/"LPU64" bits "LPX64" rrc: %d " \
447 "type: %s flags: %x remote: "LPX64" expref: %d " \
449 lock->l_resource->lr_namespace->ns_name, \
450 lock, lock->l_handle.h_cookie, \
451 atomic_read (&lock->l_refc), \
452 lock->l_readers, lock->l_writers, \
453 ldlm_lockname[lock->l_granted_mode], \
454 ldlm_lockname[lock->l_req_mode], \
455 lock->l_resource->lr_name.name[0], \
456 lock->l_resource->lr_name.name[1], \
457 lock->l_resource->lr_name.name[2], \
458 lock->l_policy_data.l_inodebits.bits, \
459 atomic_read(&lock->l_resource->lr_refcount), \
460 ldlm_typename[lock->l_resource->lr_type], \
461 lock->l_flags, lock->l_remote_handle.cookie, \
463 atomic_read(&lock->l_export->exp_refcount) : -99, \
468 CDEBUG(level, "### " format \
469 " ns: %s lock: %p/"LPX64" lrc: %d/%d,%d mode: %s/%s " \
470 "res: "LPU64"/"LPU64"/"LPU64"/"LPU64" rrc: %d type: %s " \
471 "flags: %x remote: "LPX64" expref: %d " \
472 "pid: %u\n" , ## a, \
473 lock->l_resource->lr_namespace->ns_name, \
474 lock, lock->l_handle.h_cookie, \
475 atomic_read (&lock->l_refc), \
476 lock->l_readers, lock->l_writers, \
477 ldlm_lockname[lock->l_granted_mode], \
478 ldlm_lockname[lock->l_req_mode], \
479 lock->l_resource->lr_name.name[0], \
480 lock->l_resource->lr_name.name[1], \
481 lock->l_resource->lr_name.name[2], \
482 lock->l_resource->lr_name.name[3], \
483 atomic_read(&lock->l_resource->lr_refcount), \
484 ldlm_typename[lock->l_resource->lr_type], \
485 lock->l_flags, lock->l_remote_handle.cookie, \
487 atomic_read(&lock->l_export->exp_refcount) : -99, \
492 #define LDLM_DEBUG(lock, format, a...) __LDLM_DEBUG(D_DLMTRACE, lock, \
494 #define LDLM_ERROR(lock, format, a...) __LDLM_DEBUG(D_ERROR, lock, format, ## a)
496 #define LDLM_DEBUG_NOLOCK(format, a...) \
497 CDEBUG(D_DLMTRACE, "### " format "\n" , ## a)
499 typedef int (*ldlm_processing_policy)(struct ldlm_lock *lock, int *flags,
500 int first_enq, ldlm_error_t *err,
501 struct list_head *work_list);
507 #define LDLM_ITER_CONTINUE 1 /* keep iterating */
508 #define LDLM_ITER_STOP 2 /* stop iterating */
510 typedef int (*ldlm_iterator_t)(struct ldlm_lock *, void *);
511 typedef int (*ldlm_res_iterator_t)(struct ldlm_resource *, void *);
513 int ldlm_resource_foreach(struct ldlm_resource *res, ldlm_iterator_t iter,
515 int ldlm_namespace_foreach(struct ldlm_namespace *ns, ldlm_iterator_t iter,
517 int ldlm_namespace_foreach_res(struct ldlm_namespace *ns,
518 ldlm_res_iterator_t iter, void *closure);
520 int ldlm_replay_locks(struct obd_import *imp);
521 void ldlm_change_cbdata(struct ldlm_namespace *, struct ldlm_res_id *,
522 ldlm_iterator_t iter, void *data);
525 int ldlm_flock_completion_ast(struct ldlm_lock *lock, int flags, void *data);
528 __u64 ldlm_extent_shift_kms(struct ldlm_lock *lock, __u64 old_kms);
532 int ldlm_server_blocking_ast(struct ldlm_lock *, struct ldlm_lock_desc *,
533 void *data, int flag);
534 int ldlm_server_completion_ast(struct ldlm_lock *lock, int flags, void *data);
535 int ldlm_server_glimpse_ast(struct ldlm_lock *lock, void *data);
536 int ldlm_handle_enqueue(struct ptlrpc_request *req, ldlm_completion_callback,
537 ldlm_blocking_callback, ldlm_glimpse_callback);
538 int ldlm_handle_convert(struct ptlrpc_request *req);
539 int ldlm_handle_cancel(struct ptlrpc_request *req);
540 int ldlm_del_waiting_lock(struct ldlm_lock *lock);
541 int ldlm_get_ref(void);
542 void ldlm_put_ref(int force);
545 ldlm_processing_policy ldlm_get_processing_policy(struct ldlm_resource *res);
546 void ldlm_register_intent(struct ldlm_namespace *ns, ldlm_res_policy arg);
547 void ldlm_lock2handle(struct ldlm_lock *lock, struct lustre_handle *lockh);
548 struct ldlm_lock *__ldlm_handle2lock(struct lustre_handle *, int flags);
549 void ldlm_cancel_callback(struct ldlm_lock *);
550 int ldlm_lock_set_data(struct lustre_handle *, void *data);
551 void ldlm_lock_remove_from_lru(struct ldlm_lock *);
552 struct ldlm_lock *ldlm_handle2lock_ns(struct ldlm_namespace *,
553 struct lustre_handle *);
555 static inline struct ldlm_lock *ldlm_handle2lock(struct lustre_handle *h)
557 return __ldlm_handle2lock(h, 0);
560 #define LDLM_LOCK_PUT(lock) \
562 /*LDLM_DEBUG((lock), "put");*/ \
563 ldlm_lock_put(lock); \
566 #define LDLM_LOCK_GET(lock) \
568 ldlm_lock_get(lock); \
569 /*LDLM_DEBUG((lock), "get");*/ \
573 struct ldlm_lock *ldlm_lock_get(struct ldlm_lock *lock);
574 void ldlm_lock_put(struct ldlm_lock *lock);
575 void ldlm_lock_destroy(struct ldlm_lock *lock);
576 void ldlm_lock2desc(struct ldlm_lock *lock, struct ldlm_lock_desc *desc);
577 void ldlm_lock_addref(struct lustre_handle *lockh, __u32 mode);
578 void ldlm_lock_decref(struct lustre_handle *lockh, __u32 mode);
579 void ldlm_lock_decref_and_cancel(struct lustre_handle *lockh, __u32 mode);
580 void ldlm_lock_allow_match(struct ldlm_lock *lock);
581 int ldlm_lock_match(struct ldlm_namespace *ns, int flags, struct ldlm_res_id *,
582 __u32 type, ldlm_policy_data_t *, ldlm_mode_t mode,
583 struct lustre_handle *);
584 struct ldlm_resource *ldlm_lock_convert(struct ldlm_lock *lock, int new_mode,
586 void ldlm_lock_cancel(struct ldlm_lock *lock);
587 void ldlm_cancel_locks_for_export(struct obd_export *export);
588 void ldlm_reprocess_all(struct ldlm_resource *res);
589 void ldlm_reprocess_all_ns(struct ldlm_namespace *ns);
590 void ldlm_lock_dump(int level, struct ldlm_lock *lock, int pos);
591 void ldlm_lock_dump_handle(int level, struct lustre_handle *);
594 int ldlm_test(struct obd_device *device, struct lustre_handle *connh);
595 int ldlm_regression_start(struct obd_device *obddev,
596 struct lustre_handle *connh,
597 unsigned int threads, unsigned int max_locks_in,
598 unsigned int num_resources_in,
599 unsigned int num_extents_in);
600 int ldlm_regression_stop(void);
604 struct ldlm_namespace *ldlm_namespace_new(char *name, __u32 local);
605 int ldlm_namespace_cleanup(struct ldlm_namespace *ns, int flags);
606 int ldlm_namespace_free(struct ldlm_namespace *ns, int force);
607 int ldlm_proc_setup(void);
608 void ldlm_proc_cleanup(void);
610 /* resource.c - internal */
611 struct ldlm_resource *ldlm_resource_get(struct ldlm_namespace *ns,
612 struct ldlm_resource *parent,
613 struct ldlm_res_id, __u32 type,
615 struct ldlm_resource *ldlm_resource_getref(struct ldlm_resource *res);
616 int ldlm_resource_putref(struct ldlm_resource *res);
617 void ldlm_resource_add_lock(struct ldlm_resource *res, struct list_head *head,
618 struct ldlm_lock *lock);
619 void ldlm_resource_unlink_lock(struct ldlm_lock *lock);
620 void ldlm_res2desc(struct ldlm_resource *res, struct ldlm_resource_desc *desc);
621 void ldlm_dump_all_namespaces(int level);
622 void ldlm_namespace_dump(int level, struct ldlm_namespace *);
623 void ldlm_resource_dump(int level, struct ldlm_resource *);
624 int ldlm_lock_change_resource(struct ldlm_namespace *, struct ldlm_lock *,
628 int ldlm_expired_completion_wait(void *data);
629 int ldlm_completion_ast(struct ldlm_lock *lock, int flags, void *data);
630 int ldlm_cli_enqueue(struct obd_export *exp,
631 struct ptlrpc_request *req,
632 struct ldlm_namespace *ns,
635 ldlm_policy_data_t *,
638 ldlm_blocking_callback blocking,
639 ldlm_completion_callback completion,
640 ldlm_glimpse_callback glimpse,
645 struct lustre_handle *lockh);
646 int ldlm_server_ast(struct lustre_handle *lockh, struct ldlm_lock_desc *new,
647 void *data, __u32 data_len);
648 int ldlm_cli_convert(struct lustre_handle *, int new_mode, int *flags);
649 int ldlm_cli_cancel(struct lustre_handle *lockh);
650 int ldlm_cli_cancel_unused(struct ldlm_namespace *, struct ldlm_res_id *,
651 int flags, void *opaque);
654 /* This has to be here because recursive inclusion sucks. */
655 int intent_disposition(struct ldlm_reply *rep, int flag);
656 void intent_set_disposition(struct ldlm_reply *rep, int flag);
657 int mds_blocking_ast(struct ldlm_lock *lock, struct ldlm_lock_desc *desc,
658 void *data, int flag);
661 /* ioctls for trying requests */
662 #define IOC_LDLM_TYPE 'f'
663 #define IOC_LDLM_MIN_NR 40
665 #define IOC_LDLM_TEST _IOWR('f', 40, long)
666 #define IOC_LDLM_DUMP _IOWR('f', 41, long)
667 #define IOC_LDLM_REGRESS_START _IOWR('f', 42, long)
668 #define IOC_LDLM_REGRESS_STOP _IOWR('f', 43, long)
669 #define IOC_LDLM_MAX_NR 43
671 static inline void lock_res(struct ldlm_resource *res)
673 spin_lock(&res->lr_lock);
676 static inline void unlock_res(struct ldlm_resource *res)
678 spin_unlock(&res->lr_lock);
681 static inline void check_res_locked(struct ldlm_resource *res)
683 LASSERT_SPIN_LOCKED(&res->lr_lock);
686 struct ldlm_resource * lock_res_and_lock(struct ldlm_lock *lock);
687 void unlock_res_and_lock(struct ldlm_lock *lock);