1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2 * vim:expandtab:shiftwidth=8:tabstop=8:
4 * Copyright (c) 2002 Cluster File Systems, Inc.
5 * Author: Peter Braam <braam@clusterfs.com>
6 * Author: Phil Schwan <phil@clusterfs.com>
8 * This file is part of Lustre, http://www.lustre.org.
10 * Lustre is free software; you can redistribute it and/or
11 * modify it under the terms of version 2 of the GNU General Public
12 * License as published by the Free Software Foundation.
14 * Lustre is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with Lustre; if not, write to the Free Software
21 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24 #define DEBUG_SUBSYSTEM S_LDLM
26 #include <linux/slab.h>
27 #include <linux/module.h>
28 #include <linux/random.h>
29 #include <linux/lustre_dlm.h>
30 #include <linux/lustre_mds.h>
31 #include <linux/obd_class.h>
34 char *ldlm_lockname[] = {
43 char *ldlm_typename[] = {
46 [LDLM_MDSINTENT] "INT"
49 char *ldlm_it2str(int it)
56 case (IT_OPEN | IT_CREAT):
87 CERROR("Unknown intent %d\n", it);
92 extern kmem_cache_t *ldlm_lock_slab;
94 static int ldlm_plain_compat(struct ldlm_lock *a, struct ldlm_lock *b);
96 ldlm_res_compat ldlm_res_compat_table[] = {
97 [LDLM_PLAIN] ldlm_plain_compat,
98 [LDLM_EXTENT] ldlm_extent_compat,
99 [LDLM_MDSINTENT] ldlm_plain_compat
102 ldlm_res_policy ldlm_res_policy_table[] = {
104 [LDLM_EXTENT] ldlm_extent_policy,
105 [LDLM_MDSINTENT] NULL
108 void ldlm_register_intent(int (*arg) (struct ldlm_lock * lock, void *req_cookie,
109 ldlm_mode_t mode, void *data))
111 ldlm_res_policy_table[LDLM_MDSINTENT] = arg;
114 void ldlm_unregister_intent(void)
116 ldlm_res_policy_table[LDLM_MDSINTENT] = NULL;
120 * REFCOUNTED LOCK OBJECTS
125 * Lock refcounts, during creation:
126 * - one special one for allocation, dec'd only once in destroy
127 * - one for being a lock that's in-use
128 * - one for the addref associated with a new lock
130 struct ldlm_lock *ldlm_lock_get(struct ldlm_lock *lock)
132 l_lock(&lock->l_resource->lr_namespace->ns_lock);
134 ldlm_resource_getref(lock->l_resource);
135 l_unlock(&lock->l_resource->lr_namespace->ns_lock);
139 void ldlm_lock_put(struct ldlm_lock *lock)
141 struct ldlm_namespace *ns = lock->l_resource->lr_namespace;
144 l_lock(&ns->ns_lock);
146 //LDLM_DEBUG(lock, "after refc--");
147 if (lock->l_refc < 0)
150 ldlm_resource_put(lock->l_resource);
152 LDLM_LOCK_PUT(lock->l_parent);
154 if (lock->l_refc == 0 && (lock->l_flags & LDLM_FL_DESTROYED)) {
155 lock->l_blocking_ast(lock, NULL, lock->l_data,
156 lock->l_data_len, LDLM_CB_DYING);
158 spin_lock(&ns->ns_counter_lock);
160 spin_unlock(&ns->ns_counter_lock);
162 lock->l_resource = NULL;
163 LDLM_DEBUG(lock, "final lock_put on destroyed lock, freeing");
164 if (lock->l_export && lock->l_export->exp_connection)
165 ptlrpc_put_connection(lock->l_export->exp_connection);
166 kmem_cache_free(ldlm_lock_slab, lock);
167 CDEBUG(D_MALLOC, "kfreed 'lock': %d at %p (tot 0).\n",
168 sizeof(*lock), lock);
170 l_unlock(&ns->ns_lock);
174 void ldlm_lock_destroy(struct ldlm_lock *lock)
177 l_lock(&lock->l_resource->lr_namespace->ns_lock);
179 if (!list_empty(&lock->l_children)) {
180 LDLM_DEBUG(lock, "still has children (%p)!",
181 lock->l_children.next);
182 ldlm_lock_dump(lock);
185 if (lock->l_readers || lock->l_writers) {
186 LDLM_DEBUG(lock, "lock still has references");
187 ldlm_lock_dump(lock);
191 if (!list_empty(&lock->l_res_link)) {
192 ldlm_lock_dump(lock);
196 if (lock->l_flags & LDLM_FL_DESTROYED) {
197 l_unlock(&lock->l_resource->lr_namespace->ns_lock);
202 list_del(&lock->l_export_chain);
203 lock->l_export = NULL;
204 lock->l_flags |= LDLM_FL_DESTROYED;
206 l_unlock(&lock->l_resource->lr_namespace->ns_lock);
212 usage: pass in a resource on which you have done get
213 pass in a parent lock on which you have done a get
214 do not put the resource or the parent
215 returns: lock with refcount 1
217 static struct ldlm_lock *ldlm_lock_new(struct ldlm_lock *parent,
218 struct ldlm_resource *resource)
220 struct ldlm_lock *lock;
223 if (resource == NULL)
226 lock = kmem_cache_alloc(ldlm_lock_slab, SLAB_KERNEL);
229 CDEBUG(D_MALLOC, "kmalloced 'lock': %d at "
230 "%p (tot %d).\n", sizeof(*lock), lock, 1);
232 memset(lock, 0, sizeof(*lock));
233 get_random_bytes(&lock->l_random, sizeof(__u64));
235 lock->l_resource = resource;
236 /* this refcount matches the one of the resource passed
237 in which is not being put away */
239 INIT_LIST_HEAD(&lock->l_children);
240 INIT_LIST_HEAD(&lock->l_res_link);
241 INIT_LIST_HEAD(&lock->l_export_chain);
242 INIT_LIST_HEAD(&lock->l_pending_chain);
243 init_waitqueue_head(&lock->l_waitq);
245 spin_lock(&resource->lr_namespace->ns_counter_lock);
246 resource->lr_namespace->ns_locks++;
247 spin_unlock(&resource->lr_namespace->ns_counter_lock);
249 if (parent != NULL) {
250 l_lock(&parent->l_resource->lr_namespace->ns_lock);
251 lock->l_parent = parent;
252 list_add(&lock->l_childof, &parent->l_children);
253 l_unlock(&parent->l_resource->lr_namespace->ns_lock);
255 /* this is the extra refcount, to prevent the lock
261 int ldlm_lock_change_resource(struct ldlm_lock *lock, __u64 new_resid[3])
263 struct ldlm_namespace *ns = lock->l_resource->lr_namespace;
264 struct ldlm_resource *oldres = lock->l_resource;
268 l_lock(&ns->ns_lock);
269 if (memcmp(new_resid, lock->l_resource->lr_name,
270 sizeof(lock->l_resource->lr_name)) == 0) {
272 l_unlock(&ns->ns_lock);
276 type = lock->l_resource->lr_type;
277 if (new_resid[0] == 0)
279 lock->l_resource = ldlm_resource_get(ns, NULL, new_resid, type, 1);
280 if (lock->l_resource == NULL) {
285 /* move references over */
286 for (i = 0; i < lock->l_refc; i++) {
288 ldlm_resource_getref(lock->l_resource);
289 rc = ldlm_resource_put(oldres);
290 if (rc == 1 && i != lock->l_refc - 1)
293 /* compensate for the initial get above.. */
294 ldlm_resource_put(lock->l_resource);
296 l_unlock(&ns->ns_lock);
304 void ldlm_lock2handle(struct ldlm_lock *lock, struct lustre_handle *lockh)
306 lockh->addr = (__u64) (unsigned long)lock;
307 lockh->cookie = lock->l_random;
310 struct ldlm_lock *ldlm_handle2lock(struct lustre_handle *handle)
312 struct ldlm_lock *lock = NULL, *retval = NULL;
315 if (!handle || !handle->addr)
318 lock = (struct ldlm_lock *)(unsigned long)(handle->addr);
319 if (!kmem_cache_validate(ldlm_lock_slab, (void *)lock))
322 l_lock(&lock->l_resource->lr_namespace->ns_lock);
323 if (lock->l_random != handle->cookie)
326 if (lock->l_flags & LDLM_FL_DESTROYED)
329 retval = LDLM_LOCK_GET(lock);
332 l_unlock(&lock->l_resource->lr_namespace->ns_lock);
336 static int ldlm_plain_compat(struct ldlm_lock *a, struct ldlm_lock *b)
338 return lockmode_compat(a->l_req_mode, b->l_req_mode);
341 void ldlm_lock2desc(struct ldlm_lock *lock, struct ldlm_lock_desc *desc)
343 ldlm_res2desc(lock->l_resource, &desc->l_resource);
344 desc->l_req_mode = lock->l_req_mode;
345 desc->l_granted_mode = lock->l_granted_mode;
346 memcpy(&desc->l_extent, &lock->l_extent, sizeof(desc->l_extent));
347 memcpy(desc->l_version, lock->l_version, sizeof(desc->l_version));
350 static void ldlm_add_ast_work_item(struct ldlm_lock *lock,
351 struct ldlm_lock *new)
353 struct ldlm_ast_work *w;
356 l_lock(&lock->l_resource->lr_namespace->ns_lock);
357 if (new && (lock->l_flags & LDLM_FL_AST_SENT))
360 OBD_ALLOC(w, sizeof(*w));
367 lock->l_flags |= LDLM_FL_AST_SENT;
369 ldlm_lock2desc(new, &w->w_desc);
372 w->w_lock = LDLM_LOCK_GET(lock);
373 list_add(&w->w_list, lock->l_resource->lr_tmp);
375 l_unlock(&lock->l_resource->lr_namespace->ns_lock);
379 void ldlm_lock_addref(struct lustre_handle *lockh, __u32 mode)
381 struct ldlm_lock *lock;
383 lock = ldlm_handle2lock(lockh);
384 ldlm_lock_addref_internal(lock, mode);
388 /* only called for local locks */
389 void ldlm_lock_addref_internal(struct ldlm_lock *lock, __u32 mode)
391 l_lock(&lock->l_resource->lr_namespace->ns_lock);
392 if (mode == LCK_NL || mode == LCK_CR || mode == LCK_PR)
396 l_unlock(&lock->l_resource->lr_namespace->ns_lock);
398 LDLM_DEBUG(lock, "ldlm_lock_addref(%s)", ldlm_lockname[mode]);
401 /* Args: unlocked lock */
402 void ldlm_lock_decref(struct lustre_handle *lockh, __u32 mode)
404 struct ldlm_lock *lock = ldlm_handle2lock(lockh);
410 LDLM_DEBUG(lock, "ldlm_lock_decref(%s)", ldlm_lockname[mode]);
411 l_lock(&lock->l_resource->lr_namespace->ns_lock);
412 if (mode == LCK_NL || mode == LCK_CR || mode == LCK_PR)
417 /* If we received a blocked AST and this was the last reference,
418 * run the callback. */
419 if (!lock->l_readers && !lock->l_writers &&
420 (lock->l_flags & LDLM_FL_CBPENDING)) {
421 if (!lock->l_resource->lr_namespace->ns_client) {
422 CERROR("LDLM_FL_CBPENDING set on non-local lock!\n");
426 LDLM_DEBUG(lock, "final decref done on cbpending lock");
427 l_unlock(&lock->l_resource->lr_namespace->ns_lock);
429 /* FIXME: need a real 'desc' here */
430 lock->l_blocking_ast(lock, NULL, lock->l_data,
431 lock->l_data_len, LDLM_CB_BLOCKING);
433 l_unlock(&lock->l_resource->lr_namespace->ns_lock);
435 LDLM_LOCK_PUT(lock); /* matches the ldlm_lock_get in addref */
436 LDLM_LOCK_PUT(lock); /* matches the handle2lock above */
441 static int ldlm_lock_compat_list(struct ldlm_lock *lock, int send_cbs,
442 struct list_head *queue)
444 struct list_head *tmp, *pos;
447 list_for_each_safe(tmp, pos, queue) {
448 struct ldlm_lock *child;
449 ldlm_res_compat compat;
451 child = list_entry(tmp, struct ldlm_lock, l_res_link);
455 compat = ldlm_res_compat_table[child->l_resource->lr_type];
456 if (compat && compat(child, lock)) {
457 CDEBUG(D_OTHER, "compat function succeded, next.\n");
460 if (lockmode_compat(child->l_granted_mode, lock->l_req_mode)) {
461 CDEBUG(D_OTHER, "lock modes are compatible, next.\n");
467 if (send_cbs && child->l_blocking_ast != NULL) {
468 CDEBUG(D_OTHER, "lock %p incompatible; sending "
469 "blocking AST.\n", child);
470 ldlm_add_ast_work_item(child, lock);
477 static int ldlm_lock_compat(struct ldlm_lock *lock, int send_cbs)
482 l_lock(&lock->l_resource->lr_namespace->ns_lock);
483 rc = ldlm_lock_compat_list(lock, send_cbs,
484 &lock->l_resource->lr_granted);
485 /* FIXME: should we be sending ASTs to converting? */
487 rc = ldlm_lock_compat_list
488 (lock, send_cbs, &lock->l_resource->lr_converting);
490 l_unlock(&lock->l_resource->lr_namespace->ns_lock);
495 - ldlm_handle_enqueuque - resource
497 void ldlm_grant_lock(struct ldlm_lock *lock)
499 struct ldlm_resource *res = lock->l_resource;
502 l_lock(&lock->l_resource->lr_namespace->ns_lock);
503 ldlm_resource_add_lock(res, &res->lr_granted, lock);
504 lock->l_granted_mode = lock->l_req_mode;
506 if (lock->l_granted_mode < res->lr_most_restr)
507 res->lr_most_restr = lock->l_granted_mode;
509 if (lock->l_completion_ast) {
510 ldlm_add_ast_work_item(lock, NULL);
512 l_unlock(&lock->l_resource->lr_namespace->ns_lock);
516 /* returns a referenced lock or NULL */
517 static struct ldlm_lock *search_queue(struct list_head *queue, ldlm_mode_t mode,
518 struct ldlm_extent *extent)
520 struct ldlm_lock *lock;
521 struct list_head *tmp;
523 list_for_each(tmp, queue) {
524 lock = list_entry(tmp, struct ldlm_lock, l_res_link);
526 if (lock->l_flags & (LDLM_FL_CBPENDING | LDLM_FL_DESTROYED))
529 /* lock_convert() takes the resource lock, so we're sure that
530 * req_mode, lr_type, and l_cookie won't change beneath us */
531 if (lock->l_req_mode != mode)
534 if (lock->l_resource->lr_type == LDLM_EXTENT &&
535 (lock->l_extent.start > extent->start ||
536 lock->l_extent.end < extent->end))
539 ldlm_lock_addref_internal(lock, mode);
546 /* Must be called with no resource or lock locks held.
548 * Returns 1 if it finds an already-existing lock that is compatible; in this
549 * case, lockh is filled in with a addref()ed lock
551 int ldlm_lock_match(struct ldlm_namespace *ns, __u64 * res_id, __u32 type,
552 void *cookie, int cookielen, ldlm_mode_t mode,
553 struct lustre_handle *lockh)
555 struct ldlm_resource *res;
556 struct ldlm_lock *lock;
560 res = ldlm_resource_get(ns, NULL, res_id, type, 0);
564 ns = res->lr_namespace;
565 l_lock(&ns->ns_lock);
567 if ((lock = search_queue(&res->lr_granted, mode, cookie)))
569 if ((lock = search_queue(&res->lr_converting, mode, cookie)))
571 if ((lock = search_queue(&res->lr_waiting, mode, cookie)))
576 ldlm_resource_put(res);
577 l_unlock(&ns->ns_lock);
580 ldlm_lock2handle(lock, lockh);
581 if (lock->l_completion_ast)
582 lock->l_completion_ast(lock, LDLM_FL_WAIT_NOREPROC);
585 LDLM_DEBUG(lock, "matched");
587 LDLM_DEBUG_NOLOCK("not matched");
591 /* Returns a referenced lock */
592 struct ldlm_lock *ldlm_lock_create(struct ldlm_namespace *ns,
593 struct lustre_handle *parent_lock_handle,
594 __u64 * res_id, __u32 type,
595 ldlm_mode_t mode, void *data, __u32 data_len)
597 struct ldlm_resource *res, *parent_res = NULL;
598 struct ldlm_lock *lock, *parent_lock;
600 parent_lock = ldlm_handle2lock(parent_lock_handle);
602 parent_res = parent_lock->l_resource;
604 res = ldlm_resource_get(ns, parent_res, res_id, type, 1);
608 lock = ldlm_lock_new(parent_lock, res);
610 ldlm_resource_put(res);
614 lock->l_req_mode = mode;
616 lock->l_data_len = data_len;
621 /* Must be called with lock->l_lock and lock->l_resource->lr_lock not held */
622 ldlm_error_t ldlm_lock_enqueue(struct ldlm_lock * lock,
623 void *cookie, int cookie_len,
625 ldlm_completion_callback completion,
626 ldlm_blocking_callback blocking)
628 struct ldlm_resource *res;
630 ldlm_res_policy policy;
633 res = lock->l_resource;
634 lock->l_blocking_ast = blocking;
636 if (res->lr_type == LDLM_EXTENT)
637 memcpy(&lock->l_extent, cookie, sizeof(lock->l_extent));
639 /* policies are not executed on the client */
640 local = res->lr_namespace->ns_client;
641 if (!local && (policy = ldlm_res_policy_table[res->lr_type])) {
643 rc = policy(lock, cookie, lock->l_req_mode, NULL);
645 if (rc == ELDLM_LOCK_CHANGED) {
646 res = lock->l_resource;
647 *flags |= LDLM_FL_LOCK_CHANGED;
648 } else if (rc == ELDLM_LOCK_ABORTED) {
649 ldlm_lock_destroy(lock);
654 lock->l_cookie = cookie;
655 lock->l_cookie_len = cookie_len;
657 l_lock(&res->lr_namespace->ns_lock);
658 if (local && lock->l_req_mode == lock->l_granted_mode) {
659 /* The server returned a blocked lock, but it was granted before
660 * we got a chance to actually enqueue it. We don't need to do
662 *flags &= ~(LDLM_FL_BLOCK_GRANTED |
663 LDLM_FL_BLOCK_CONV | LDLM_FL_BLOCK_WAIT);
667 /* This distinction between local lock trees is very important; a client
668 * namespace only has information about locks taken by that client, and
669 * thus doesn't have enough information to decide for itself if it can
670 * be granted (below). In this case, we do exactly what the server
671 * tells us to do, as dictated by the 'flags' */
672 ldlm_resource_unlink_lock(lock);
674 if (*flags & LDLM_FL_BLOCK_CONV)
675 ldlm_resource_add_lock(res, res->lr_converting.prev,
677 else if (*flags & (LDLM_FL_BLOCK_WAIT | LDLM_FL_BLOCK_GRANTED))
678 ldlm_resource_add_lock(res, res->lr_waiting.prev, lock);
680 ldlm_grant_lock(lock);
684 /* FIXME: We may want to optimize by checking lr_most_restr */
685 if (!list_empty(&res->lr_converting)) {
686 ldlm_resource_add_lock(res, res->lr_waiting.prev, lock);
687 *flags |= LDLM_FL_BLOCK_CONV;
690 if (!list_empty(&res->lr_waiting)) {
691 ldlm_resource_add_lock(res, res->lr_waiting.prev, lock);
692 *flags |= LDLM_FL_BLOCK_WAIT;
695 if (!ldlm_lock_compat(lock, 0)) {
696 ldlm_resource_add_lock(res, res->lr_waiting.prev, lock);
697 *flags |= LDLM_FL_BLOCK_GRANTED;
701 ldlm_grant_lock(lock);
704 l_unlock(&res->lr_namespace->ns_lock);
705 /* Don't set 'completion_ast' until here so that if the lock is granted
706 * immediately we don't do an unnecessary completion call. */
707 lock->l_completion_ast = completion;
711 /* Must be called with namespace taken: queue is waiting or converting. */
712 static int ldlm_reprocess_queue(struct ldlm_resource *res,
713 struct list_head *queue)
715 struct list_head *tmp, *pos;
718 list_for_each_safe(tmp, pos, queue) {
719 struct ldlm_lock *pending;
720 pending = list_entry(tmp, struct ldlm_lock, l_res_link);
722 CDEBUG(D_INFO, "Reprocessing lock %p\n", pending);
724 if (!ldlm_lock_compat(pending, 1))
727 list_del_init(&pending->l_res_link);
728 ldlm_grant_lock(pending);
734 void ldlm_run_ast_work(struct list_head *rpc_list)
736 struct list_head *tmp, *pos;
740 list_for_each_safe(tmp, pos, rpc_list) {
741 struct ldlm_ast_work *w =
742 list_entry(tmp, struct ldlm_ast_work, w_list);
745 rc = w->w_lock->l_blocking_ast
746 (w->w_lock, &w->w_desc, w->w_data,
747 w->w_datalen, LDLM_CB_BLOCKING);
749 rc = w->w_lock->l_completion_ast(w->w_lock, w->w_flags);
751 CERROR("Failed AST - should clean & disconnect "
753 LDLM_LOCK_PUT(w->w_lock);
754 list_del(&w->w_list);
755 OBD_FREE(w, sizeof(*w));
760 /* Must be called with resource->lr_lock not taken. */
761 void ldlm_reprocess_all(struct ldlm_resource *res)
763 struct list_head rpc_list = LIST_HEAD_INIT(rpc_list);
766 /* Local lock trees don't get reprocessed. */
767 if (res->lr_namespace->ns_client) {
772 l_lock(&res->lr_namespace->ns_lock);
773 res->lr_tmp = &rpc_list;
775 ldlm_reprocess_queue(res, &res->lr_converting);
776 if (list_empty(&res->lr_converting))
777 ldlm_reprocess_queue(res, &res->lr_waiting);
780 l_unlock(&res->lr_namespace->ns_lock);
782 ldlm_run_ast_work(&rpc_list);
786 void ldlm_lock_cancel(struct ldlm_lock *lock)
788 struct ldlm_resource *res;
789 struct ldlm_namespace *ns;
792 res = lock->l_resource;
793 ns = res->lr_namespace;
795 l_lock(&ns->ns_lock);
796 if (lock->l_readers || lock->l_writers)
797 CDEBUG(D_INFO, "lock still has references (%d readers, %d "
798 "writers)\n", lock->l_readers, lock->l_writers);
800 ldlm_resource_unlink_lock(lock);
801 ldlm_lock_destroy(lock);
802 l_unlock(&ns->ns_lock);
806 struct ldlm_resource *ldlm_lock_convert(struct ldlm_lock *lock, int new_mode,
809 struct list_head rpc_list = LIST_HEAD_INIT(rpc_list);
810 struct ldlm_resource *res;
811 struct ldlm_namespace *ns;
815 res = lock->l_resource;
816 ns = res->lr_namespace;
818 l_lock(&ns->ns_lock);
820 lock->l_req_mode = new_mode;
821 ldlm_resource_unlink_lock(lock);
823 /* If this is a local resource, put it on the appropriate list. */
824 if (res->lr_namespace->ns_client) {
825 if (*flags & (LDLM_FL_BLOCK_CONV | LDLM_FL_BLOCK_GRANTED))
826 ldlm_resource_add_lock(res, res->lr_converting.prev,
829 res->lr_tmp = &rpc_list;
830 ldlm_grant_lock(lock);
833 /* FIXME: completion handling not with ns_lock held ! */
834 if (lock->l_completion_ast)
835 lock->l_completion_ast(lock, 0);
838 /* FIXME: We should try the conversion right away and possibly
839 * return success without the need for an extra AST */
840 ldlm_resource_add_lock(res, res->lr_converting.prev, lock);
841 *flags |= LDLM_FL_BLOCK_CONV;
844 l_unlock(&ns->ns_lock);
847 ldlm_run_ast_work(&rpc_list);
851 void ldlm_lock_dump(struct ldlm_lock *lock)
855 if (!(portal_debug & D_OTHER))
858 if (RES_VERSION_SIZE != 4)
862 CDEBUG(D_OTHER, " NULL LDLM lock\n");
866 snprintf(ver, sizeof(ver), "%x %x %x %x",
867 lock->l_version[0], lock->l_version[1],
868 lock->l_version[2], lock->l_version[3]);
870 CDEBUG(D_OTHER, " -- Lock dump: %p (%s)\n", lock, ver);
871 if (lock->l_export && lock->l_export->exp_connection)
872 CDEBUG(D_OTHER, " Node: NID %x (rhandle: "LPX64")\n",
873 lock->l_export->exp_connection->c_peer.peer_nid,
874 lock->l_remote_handle.addr);
876 CDEBUG(D_OTHER, " Node: local\n");
877 CDEBUG(D_OTHER, " Parent: %p\n", lock->l_parent);
878 CDEBUG(D_OTHER, " Resource: %p ("LPD64")\n", lock->l_resource,
879 lock->l_resource->lr_name[0]);
880 CDEBUG(D_OTHER, " Requested mode: %d, granted mode: %d\n",
881 (int)lock->l_req_mode, (int)lock->l_granted_mode);
882 CDEBUG(D_OTHER, " Readers: %u ; Writers; %u\n",
883 lock->l_readers, lock->l_writers);
884 if (lock->l_resource->lr_type == LDLM_EXTENT)
885 CDEBUG(D_OTHER, " Extent: %Lu -> %Lu\n",
886 (unsigned long long)lock->l_extent.start,
887 (unsigned long long)lock->l_extent.end);