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 spin_lock(&ns->ns_counter_lock);
157 spin_unlock(&ns->ns_counter_lock);
159 lock->l_resource = NULL;
160 LDLM_DEBUG(lock, "final lock_put on destroyed lock, freeing");
161 if (lock->l_export && lock->l_export->exp_connection)
162 ptlrpc_put_connection(lock->l_export->exp_connection);
163 kmem_cache_free(ldlm_lock_slab, lock);
164 CDEBUG(D_MALLOC, "kfreed 'lock': %d at %p (tot 0).\n",
165 sizeof(*lock), lock);
167 l_unlock(&ns->ns_lock);
171 void ldlm_lock_destroy(struct ldlm_lock *lock)
174 l_lock(&lock->l_resource->lr_namespace->ns_lock);
176 if (!list_empty(&lock->l_children)) {
177 LDLM_DEBUG(lock, "still has children (%p)!",
178 lock->l_children.next);
179 ldlm_lock_dump(lock);
182 if (lock->l_readers || lock->l_writers) {
183 LDLM_DEBUG(lock, "lock still has references");
184 ldlm_lock_dump(lock);
188 if (!list_empty(&lock->l_res_link)) {
189 ldlm_lock_dump(lock);
193 if (lock->l_flags & LDLM_FL_DESTROYED) {
194 l_unlock(&lock->l_resource->lr_namespace->ns_lock);
199 list_del(&lock->l_export_chain);
200 lock->l_export = NULL;
201 lock->l_flags |= LDLM_FL_DESTROYED;
203 l_unlock(&lock->l_resource->lr_namespace->ns_lock);
209 usage: pass in a resource on which you have done get
210 pass in a parent lock on which you have done a get
211 do not put the resource or the parent
212 returns: lock with refcount 1
214 static struct ldlm_lock *ldlm_lock_new(struct ldlm_lock *parent,
215 struct ldlm_resource *resource)
217 struct ldlm_lock *lock;
220 if (resource == NULL)
223 lock = kmem_cache_alloc(ldlm_lock_slab, SLAB_KERNEL);
226 CDEBUG(D_MALLOC, "kmalloced 'lock': %d at "
227 "%p (tot %d).\n", sizeof(*lock), lock, 1);
229 memset(lock, 0, sizeof(*lock));
230 get_random_bytes(&lock->l_random, sizeof(__u64));
232 lock->l_resource = resource;
233 /* this refcount matches the one of the resource passed
234 in which is not being put away */
236 INIT_LIST_HEAD(&lock->l_children);
237 INIT_LIST_HEAD(&lock->l_res_link);
238 INIT_LIST_HEAD(&lock->l_export_chain);
239 INIT_LIST_HEAD(&lock->l_pending_chain);
240 init_waitqueue_head(&lock->l_waitq);
242 spin_lock(&resource->lr_namespace->ns_counter_lock);
243 resource->lr_namespace->ns_locks++;
244 spin_unlock(&resource->lr_namespace->ns_counter_lock);
246 if (parent != NULL) {
247 l_lock(&parent->l_resource->lr_namespace->ns_lock);
248 lock->l_parent = parent;
249 list_add(&lock->l_childof, &parent->l_children);
250 l_unlock(&parent->l_resource->lr_namespace->ns_lock);
252 /* this is the extra refcount, to prevent the lock
258 int ldlm_lock_change_resource(struct ldlm_lock *lock, __u64 new_resid[3])
260 struct ldlm_namespace *ns = lock->l_resource->lr_namespace;
261 struct ldlm_resource *oldres = lock->l_resource;
265 l_lock(&ns->ns_lock);
266 if (memcmp(new_resid, lock->l_resource->lr_name,
267 sizeof(lock->l_resource->lr_name)) == 0) {
269 l_unlock(&ns->ns_lock);
273 type = lock->l_resource->lr_type;
274 if (new_resid[0] == 0)
276 lock->l_resource = ldlm_resource_get(ns, NULL, new_resid, type, 1);
277 if (lock->l_resource == NULL) {
282 /* move references over */
283 for (i = 0; i < lock->l_refc; i++) {
285 ldlm_resource_getref(lock->l_resource);
286 rc = ldlm_resource_put(oldres);
287 if (rc == 1 && i != lock->l_refc - 1)
290 /* compensate for the initial get above.. */
291 ldlm_resource_put(lock->l_resource);
293 l_unlock(&ns->ns_lock);
301 void ldlm_lock2handle(struct ldlm_lock *lock, struct lustre_handle *lockh)
303 lockh->addr = (__u64) (unsigned long)lock;
304 lockh->cookie = lock->l_random;
307 struct ldlm_lock *ldlm_handle2lock(struct lustre_handle *handle)
309 struct ldlm_lock *lock = NULL, *retval = NULL;
312 if (!handle || !handle->addr)
315 lock = (struct ldlm_lock *)(unsigned long)(handle->addr);
316 if (!kmem_cache_validate(ldlm_lock_slab, (void *)lock))
319 l_lock(&lock->l_resource->lr_namespace->ns_lock);
320 if (lock->l_random != handle->cookie)
323 if (lock->l_flags & LDLM_FL_DESTROYED)
326 retval = LDLM_LOCK_GET(lock);
329 l_unlock(&lock->l_resource->lr_namespace->ns_lock);
333 static int ldlm_plain_compat(struct ldlm_lock *a, struct ldlm_lock *b)
335 return lockmode_compat(a->l_req_mode, b->l_req_mode);
338 void ldlm_lock2desc(struct ldlm_lock *lock, struct ldlm_lock_desc *desc)
340 ldlm_res2desc(lock->l_resource, &desc->l_resource);
341 desc->l_req_mode = lock->l_req_mode;
342 desc->l_granted_mode = lock->l_granted_mode;
343 memcpy(&desc->l_extent, &lock->l_extent, sizeof(desc->l_extent));
344 memcpy(desc->l_version, lock->l_version, sizeof(desc->l_version));
347 static void ldlm_add_ast_work_item(struct ldlm_lock *lock,
348 struct ldlm_lock *new)
350 struct ldlm_ast_work *w;
353 l_lock(&lock->l_resource->lr_namespace->ns_lock);
354 if (new && (lock->l_flags & LDLM_FL_AST_SENT))
357 OBD_ALLOC(w, sizeof(*w));
364 lock->l_flags |= LDLM_FL_AST_SENT;
366 ldlm_lock2desc(new, &w->w_desc);
369 w->w_lock = LDLM_LOCK_GET(lock);
370 list_add(&w->w_list, lock->l_resource->lr_tmp);
372 l_unlock(&lock->l_resource->lr_namespace->ns_lock);
376 void ldlm_lock_addref(struct lustre_handle *lockh, __u32 mode)
378 struct ldlm_lock *lock;
380 lock = ldlm_handle2lock(lockh);
381 ldlm_lock_addref_internal(lock, mode);
385 /* only called for local locks */
386 void ldlm_lock_addref_internal(struct ldlm_lock *lock, __u32 mode)
388 l_lock(&lock->l_resource->lr_namespace->ns_lock);
389 if (mode == LCK_NL || mode == LCK_CR || mode == LCK_PR)
393 l_unlock(&lock->l_resource->lr_namespace->ns_lock);
395 LDLM_DEBUG(lock, "ldlm_lock_addref(%s)", ldlm_lockname[mode]);
398 /* Args: unlocked lock */
399 void ldlm_lock_decref(struct lustre_handle *lockh, __u32 mode)
401 struct ldlm_lock *lock = ldlm_handle2lock(lockh);
407 LDLM_DEBUG(lock, "ldlm_lock_decref(%s)", ldlm_lockname[mode]);
408 l_lock(&lock->l_resource->lr_namespace->ns_lock);
409 if (mode == LCK_NL || mode == LCK_CR || mode == LCK_PR)
414 /* If we received a blocked AST and this was the last reference,
415 * run the callback. */
416 if (!lock->l_readers && !lock->l_writers &&
417 (lock->l_flags & LDLM_FL_CBPENDING)) {
418 if (!lock->l_resource->lr_namespace->ns_client) {
419 CERROR("LDLM_FL_CBPENDING set on non-local lock!\n");
423 LDLM_DEBUG(lock, "final decref done on cbpending lock");
424 l_unlock(&lock->l_resource->lr_namespace->ns_lock);
426 /* FIXME: need a real 'desc' here */
427 lock->l_blocking_ast(lock, NULL, lock->l_data,
428 lock->l_data_len, LDLM_CB_BLOCKING);
430 l_unlock(&lock->l_resource->lr_namespace->ns_lock);
432 LDLM_LOCK_PUT(lock); /* matches the ldlm_lock_get in addref */
433 LDLM_LOCK_PUT(lock); /* matches the handle2lock above */
438 static int ldlm_lock_compat_list(struct ldlm_lock *lock, int send_cbs,
439 struct list_head *queue)
441 struct list_head *tmp, *pos;
444 list_for_each_safe(tmp, pos, queue) {
445 struct ldlm_lock *child;
446 ldlm_res_compat compat;
448 child = list_entry(tmp, struct ldlm_lock, l_res_link);
452 compat = ldlm_res_compat_table[child->l_resource->lr_type];
453 if (compat && compat(child, lock)) {
454 CDEBUG(D_OTHER, "compat function succeded, next.\n");
457 if (lockmode_compat(child->l_granted_mode, lock->l_req_mode)) {
458 CDEBUG(D_OTHER, "lock modes are compatible, next.\n");
464 if (send_cbs && child->l_blocking_ast != NULL) {
465 CDEBUG(D_OTHER, "lock %p incompatible; sending "
466 "blocking AST.\n", child);
467 ldlm_add_ast_work_item(child, lock);
474 static int ldlm_lock_compat(struct ldlm_lock *lock, int send_cbs)
479 l_lock(&lock->l_resource->lr_namespace->ns_lock);
480 rc = ldlm_lock_compat_list(lock, send_cbs,
481 &lock->l_resource->lr_granted);
482 /* FIXME: should we be sending ASTs to converting? */
484 rc = ldlm_lock_compat_list
485 (lock, send_cbs, &lock->l_resource->lr_converting);
487 l_unlock(&lock->l_resource->lr_namespace->ns_lock);
492 - ldlm_handle_enqueuque - resource
494 void ldlm_grant_lock(struct ldlm_lock *lock)
496 struct ldlm_resource *res = lock->l_resource;
499 l_lock(&lock->l_resource->lr_namespace->ns_lock);
500 ldlm_resource_add_lock(res, &res->lr_granted, lock);
501 lock->l_granted_mode = lock->l_req_mode;
503 if (lock->l_granted_mode < res->lr_most_restr)
504 res->lr_most_restr = lock->l_granted_mode;
506 if (lock->l_completion_ast) {
507 ldlm_add_ast_work_item(lock, NULL);
509 l_unlock(&lock->l_resource->lr_namespace->ns_lock);
513 /* returns a referenced lock or NULL */
514 static struct ldlm_lock *search_queue(struct list_head *queue, ldlm_mode_t mode,
515 struct ldlm_extent *extent)
517 struct ldlm_lock *lock;
518 struct list_head *tmp;
520 list_for_each(tmp, queue) {
521 lock = list_entry(tmp, struct ldlm_lock, l_res_link);
523 if (lock->l_flags & (LDLM_FL_CBPENDING | LDLM_FL_DESTROYED))
526 /* lock_convert() takes the resource lock, so we're sure that
527 * req_mode, lr_type, and l_cookie won't change beneath us */
528 if (lock->l_req_mode != mode)
531 if (lock->l_resource->lr_type == LDLM_EXTENT &&
532 (lock->l_extent.start > extent->start ||
533 lock->l_extent.end < extent->end))
536 ldlm_lock_addref_internal(lock, mode);
543 /* Must be called with no resource or lock locks held.
545 * Returns 1 if it finds an already-existing lock that is compatible; in this
546 * case, lockh is filled in with a addref()ed lock
548 int ldlm_lock_match(struct ldlm_namespace *ns, __u64 * res_id, __u32 type,
549 void *cookie, int cookielen, ldlm_mode_t mode,
550 struct lustre_handle *lockh)
552 struct ldlm_resource *res;
553 struct ldlm_lock *lock;
557 res = ldlm_resource_get(ns, NULL, res_id, type, 0);
561 ns = res->lr_namespace;
562 l_lock(&ns->ns_lock);
564 if ((lock = search_queue(&res->lr_granted, mode, cookie)))
566 if ((lock = search_queue(&res->lr_converting, mode, cookie)))
568 if ((lock = search_queue(&res->lr_waiting, mode, cookie)))
573 ldlm_resource_put(res);
574 l_unlock(&ns->ns_lock);
577 ldlm_lock2handle(lock, lockh);
578 if (lock->l_completion_ast)
579 lock->l_completion_ast(lock, LDLM_FL_WAIT_NOREPROC);
582 LDLM_DEBUG(lock, "matched");
584 LDLM_DEBUG_NOLOCK("not matched");
588 /* Returns a referenced lock */
589 struct ldlm_lock *ldlm_lock_create(struct ldlm_namespace *ns,
590 struct lustre_handle *parent_lock_handle,
591 __u64 * res_id, __u32 type,
592 ldlm_mode_t mode, void *data, __u32 data_len)
594 struct ldlm_resource *res, *parent_res = NULL;
595 struct ldlm_lock *lock, *parent_lock;
597 parent_lock = ldlm_handle2lock(parent_lock_handle);
599 parent_res = parent_lock->l_resource;
601 res = ldlm_resource_get(ns, parent_res, res_id, type, 1);
605 lock = ldlm_lock_new(parent_lock, res);
607 ldlm_resource_put(res);
611 lock->l_req_mode = mode;
613 lock->l_data_len = data_len;
618 /* Must be called with lock->l_lock and lock->l_resource->lr_lock not held */
619 ldlm_error_t ldlm_lock_enqueue(struct ldlm_lock * lock,
620 void *cookie, int cookie_len,
622 ldlm_completion_callback completion,
623 ldlm_blocking_callback blocking)
625 struct ldlm_resource *res;
627 ldlm_res_policy policy;
630 res = lock->l_resource;
631 lock->l_blocking_ast = blocking;
633 if (res->lr_type == LDLM_EXTENT)
634 memcpy(&lock->l_extent, cookie, sizeof(lock->l_extent));
636 /* policies are not executed on the client */
637 local = res->lr_namespace->ns_client;
638 if (!local && (policy = ldlm_res_policy_table[res->lr_type])) {
640 rc = policy(lock, cookie, lock->l_req_mode, NULL);
642 if (rc == ELDLM_LOCK_CHANGED) {
643 res = lock->l_resource;
644 *flags |= LDLM_FL_LOCK_CHANGED;
645 } else if (rc == ELDLM_LOCK_ABORTED) {
646 ldlm_lock_destroy(lock);
651 lock->l_cookie = cookie;
652 lock->l_cookie_len = cookie_len;
654 l_lock(&res->lr_namespace->ns_lock);
655 if (local && lock->l_req_mode == lock->l_granted_mode) {
656 /* The server returned a blocked lock, but it was granted before
657 * we got a chance to actually enqueue it. We don't need to do
659 *flags &= ~(LDLM_FL_BLOCK_GRANTED |
660 LDLM_FL_BLOCK_CONV | LDLM_FL_BLOCK_WAIT);
664 /* This distinction between local lock trees is very important; a client
665 * namespace only has information about locks taken by that client, and
666 * thus doesn't have enough information to decide for itself if it can
667 * be granted (below). In this case, we do exactly what the server
668 * tells us to do, as dictated by the 'flags' */
669 ldlm_resource_unlink_lock(lock);
671 if (*flags & LDLM_FL_BLOCK_CONV)
672 ldlm_resource_add_lock(res, res->lr_converting.prev,
674 else if (*flags & (LDLM_FL_BLOCK_WAIT | LDLM_FL_BLOCK_GRANTED))
675 ldlm_resource_add_lock(res, res->lr_waiting.prev, lock);
677 ldlm_grant_lock(lock);
681 /* FIXME: We may want to optimize by checking lr_most_restr */
682 if (!list_empty(&res->lr_converting)) {
683 ldlm_resource_add_lock(res, res->lr_waiting.prev, lock);
684 *flags |= LDLM_FL_BLOCK_CONV;
687 if (!list_empty(&res->lr_waiting)) {
688 ldlm_resource_add_lock(res, res->lr_waiting.prev, lock);
689 *flags |= LDLM_FL_BLOCK_WAIT;
692 if (!ldlm_lock_compat(lock, 0)) {
693 ldlm_resource_add_lock(res, res->lr_waiting.prev, lock);
694 *flags |= LDLM_FL_BLOCK_GRANTED;
698 ldlm_grant_lock(lock);
701 l_unlock(&res->lr_namespace->ns_lock);
702 /* Don't set 'completion_ast' until here so that if the lock is granted
703 * immediately we don't do an unnecessary completion call. */
704 lock->l_completion_ast = completion;
708 /* Must be called with namespace taken: queue is waiting or converting. */
709 static int ldlm_reprocess_queue(struct ldlm_resource *res,
710 struct list_head *queue)
712 struct list_head *tmp, *pos;
715 list_for_each_safe(tmp, pos, queue) {
716 struct ldlm_lock *pending;
717 pending = list_entry(tmp, struct ldlm_lock, l_res_link);
719 CDEBUG(D_INFO, "Reprocessing lock %p\n", pending);
721 if (!ldlm_lock_compat(pending, 1))
724 list_del_init(&pending->l_res_link);
725 ldlm_grant_lock(pending);
731 void ldlm_run_ast_work(struct list_head *rpc_list)
733 struct list_head *tmp, *pos;
737 list_for_each_safe(tmp, pos, rpc_list) {
738 struct ldlm_ast_work *w =
739 list_entry(tmp, struct ldlm_ast_work, w_list);
742 rc = w->w_lock->l_blocking_ast
743 (w->w_lock, &w->w_desc, w->w_data,
744 w->w_datalen, LDLM_CB_BLOCKING);
746 rc = w->w_lock->l_completion_ast(w->w_lock, w->w_flags);
748 CERROR("Failed AST - should clean & disconnect "
750 LDLM_LOCK_PUT(w->w_lock);
751 list_del(&w->w_list);
752 OBD_FREE(w, sizeof(*w));
757 /* Must be called with resource->lr_lock not taken. */
758 void ldlm_reprocess_all(struct ldlm_resource *res)
760 struct list_head rpc_list = LIST_HEAD_INIT(rpc_list);
763 /* Local lock trees don't get reprocessed. */
764 if (res->lr_namespace->ns_client) {
769 l_lock(&res->lr_namespace->ns_lock);
770 res->lr_tmp = &rpc_list;
772 ldlm_reprocess_queue(res, &res->lr_converting);
773 if (list_empty(&res->lr_converting))
774 ldlm_reprocess_queue(res, &res->lr_waiting);
777 l_unlock(&res->lr_namespace->ns_lock);
779 ldlm_run_ast_work(&rpc_list);
783 void ldlm_cancel_callback(struct ldlm_lock *lock)
785 l_lock(&lock->l_resource->lr_namespace->ns_lock);
786 if (!(lock->l_flags & LDLM_FL_CANCEL)) {
787 lock->l_flags |= LDLM_FL_CANCEL;
788 lock->l_blocking_ast(lock, NULL, lock->l_data,
789 lock->l_data_len, LDLM_CB_CANCELING);
791 l_unlock(&lock->l_resource->lr_namespace->ns_lock);
794 void ldlm_lock_cancel(struct ldlm_lock *lock)
796 struct ldlm_resource *res;
797 struct ldlm_namespace *ns;
800 res = lock->l_resource;
801 ns = res->lr_namespace;
803 l_lock(&ns->ns_lock);
804 if (lock->l_readers || lock->l_writers)
805 CDEBUG(D_INFO, "lock still has references (%d readers, %d "
806 "writers)\n", lock->l_readers, lock->l_writers);
808 ldlm_cancel_callback(lock);
810 ldlm_resource_unlink_lock(lock);
811 ldlm_lock_destroy(lock);
812 l_unlock(&ns->ns_lock);
816 struct ldlm_resource *ldlm_lock_convert(struct ldlm_lock *lock, int new_mode,
819 struct list_head rpc_list = LIST_HEAD_INIT(rpc_list);
820 struct ldlm_resource *res;
821 struct ldlm_namespace *ns;
825 res = lock->l_resource;
826 ns = res->lr_namespace;
828 l_lock(&ns->ns_lock);
830 lock->l_req_mode = new_mode;
831 ldlm_resource_unlink_lock(lock);
833 /* If this is a local resource, put it on the appropriate list. */
834 if (res->lr_namespace->ns_client) {
835 if (*flags & (LDLM_FL_BLOCK_CONV | LDLM_FL_BLOCK_GRANTED))
836 ldlm_resource_add_lock(res, res->lr_converting.prev,
839 res->lr_tmp = &rpc_list;
840 ldlm_grant_lock(lock);
843 /* FIXME: completion handling not with ns_lock held ! */
844 if (lock->l_completion_ast)
845 lock->l_completion_ast(lock, 0);
848 /* FIXME: We should try the conversion right away and possibly
849 * return success without the need for an extra AST */
850 ldlm_resource_add_lock(res, res->lr_converting.prev, lock);
851 *flags |= LDLM_FL_BLOCK_CONV;
854 l_unlock(&ns->ns_lock);
857 ldlm_run_ast_work(&rpc_list);
861 void ldlm_lock_dump(struct ldlm_lock *lock)
865 if (!(portal_debug & D_OTHER))
868 if (RES_VERSION_SIZE != 4)
872 CDEBUG(D_OTHER, " NULL LDLM lock\n");
876 snprintf(ver, sizeof(ver), "%x %x %x %x",
877 lock->l_version[0], lock->l_version[1],
878 lock->l_version[2], lock->l_version[3]);
880 CDEBUG(D_OTHER, " -- Lock dump: %p (%s)\n", lock, ver);
881 if (lock->l_export && lock->l_export->exp_connection)
882 CDEBUG(D_OTHER, " Node: NID %x (rhandle: "LPX64")\n",
883 lock->l_export->exp_connection->c_peer.peer_nid,
884 lock->l_remote_handle.addr);
886 CDEBUG(D_OTHER, " Node: local\n");
887 CDEBUG(D_OTHER, " Parent: %p\n", lock->l_parent);
888 CDEBUG(D_OTHER, " Resource: %p ("LPD64")\n", lock->l_resource,
889 lock->l_resource->lr_name[0]);
890 CDEBUG(D_OTHER, " Requested mode: %d, granted mode: %d\n",
891 (int)lock->l_req_mode, (int)lock->l_granted_mode);
892 CDEBUG(D_OTHER, " Readers: %u ; Writers; %u\n",
893 lock->l_readers, lock->l_writers);
894 if (lock->l_resource->lr_type == LDLM_EXTENT)
895 CDEBUG(D_OTHER, " Extent: %Lu -> %Lu\n",
896 (unsigned long long)lock->l_extent.start,
897 (unsigned long long)lock->l_extent.end);