1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2 * vim:expandtab:shiftwidth=8:tabstop=8:
4 * Copyright (C) 2002, 2003 Cluster File Systems, Inc.
5 * Author: Phil Schwan <phil@clusterfs.com>
6 * Author: Peter Braam <braam@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/lustre_dlm.h>
28 # include <liblustre.h>
31 #include <linux/obd_class.h>
32 #include "ldlm_internal.h"
34 kmem_cache_t *ldlm_resource_slab, *ldlm_lock_slab;
36 DECLARE_MUTEX(ldlm_namespace_lock);
37 struct list_head ldlm_namespace_list = LIST_HEAD_INIT(ldlm_namespace_list);
38 struct proc_dir_entry *ldlm_type_proc_dir = NULL;
39 struct proc_dir_entry *ldlm_ns_proc_dir = NULL;
40 struct proc_dir_entry *ldlm_svc_proc_dir = NULL;
43 static int ldlm_proc_dump_ns(struct file *file, const char *buffer,
44 unsigned long count, void *data)
46 ldlm_dump_all_namespaces(D_DLMTRACE);
50 int ldlm_proc_setup(void)
53 struct lprocfs_vars list[] = {
54 { "dump_namespaces", NULL, ldlm_proc_dump_ns, NULL },
57 LASSERT(ldlm_ns_proc_dir == NULL);
59 ldlm_type_proc_dir = lprocfs_register(OBD_LDLM_DEVICENAME,
62 if (IS_ERR(ldlm_type_proc_dir)) {
63 CERROR("LProcFS failed in ldlm-init\n");
64 rc = PTR_ERR(ldlm_type_proc_dir);
68 ldlm_ns_proc_dir = lprocfs_register("namespaces",
71 if (IS_ERR(ldlm_ns_proc_dir)) {
72 CERROR("LProcFS failed in ldlm-init\n");
73 rc = PTR_ERR(ldlm_ns_proc_dir);
77 ldlm_svc_proc_dir = lprocfs_register("services",
80 if (IS_ERR(ldlm_svc_proc_dir)) {
81 CERROR("LProcFS failed in ldlm-init\n");
82 rc = PTR_ERR(ldlm_svc_proc_dir);
86 rc = lprocfs_add_vars(ldlm_type_proc_dir, list, NULL);
91 lprocfs_remove(ldlm_ns_proc_dir);
93 lprocfs_remove(ldlm_type_proc_dir);
95 ldlm_type_proc_dir = NULL;
96 ldlm_ns_proc_dir = NULL;
97 ldlm_svc_proc_dir = NULL;
101 void ldlm_proc_cleanup(void)
103 if (ldlm_svc_proc_dir) {
104 lprocfs_remove(ldlm_svc_proc_dir);
105 ldlm_svc_proc_dir = NULL;
108 if (ldlm_ns_proc_dir) {
109 lprocfs_remove(ldlm_ns_proc_dir);
110 ldlm_ns_proc_dir = NULL;
113 if (ldlm_type_proc_dir) {
114 lprocfs_remove(ldlm_type_proc_dir);
115 ldlm_type_proc_dir = NULL;
119 static int lprocfs_uint_rd(char *page, char **start, off_t off,
120 int count, int *eof, void *data)
122 unsigned int *temp = (unsigned int *)data;
123 return snprintf(page, count, "%u\n", *temp);
126 static int lprocfs_read_lru_size(char *page, char **start, off_t off,
127 int count, int *eof, void *data)
129 struct ldlm_namespace *ns = data;
130 return lprocfs_uint_rd(page, start, off, count, eof,
134 #define MAX_STRING_SIZE 128
135 static int lprocfs_write_lru_size(struct file *file, const char *buffer,
136 unsigned long count, void *data)
138 struct ldlm_namespace *ns = data;
139 char dummy[MAX_STRING_SIZE + 1], *end;
142 dummy[MAX_STRING_SIZE] = '\0';
143 if (copy_from_user(dummy, buffer, MAX_STRING_SIZE))
146 if (count == 6 && memcmp(dummy, "clear", 5) == 0) {
148 "dropping all unused locks from namespace %s\n",
150 tmp = ns->ns_max_unused;
151 ns->ns_max_unused = 0;
152 ldlm_cancel_lru(ns, LDLM_SYNC);
153 ns->ns_max_unused = tmp;
157 tmp = simple_strtoul(dummy, &end, 0);
158 if (tmp == 0 && *end) {
159 CERROR("invalid value written\n");
163 CDEBUG(D_DLMTRACE, "changing namespace %s max_unused from %u to %u\n",
164 ns->ns_name, ns->ns_max_unused, (unsigned int)tmp);
166 ns->ns_max_unused = (unsigned int)tmp;
167 ldlm_cancel_lru(ns, LDLM_ASYNC);
171 void ldlm_proc_namespace(struct ldlm_namespace *ns)
173 struct lprocfs_vars lock_vars[2];
174 char lock_name[MAX_STRING_SIZE + 1];
177 LASSERT(ns->ns_name != NULL);
179 lock_name[MAX_STRING_SIZE] = '\0';
181 memset(lock_vars, 0, sizeof(lock_vars));
182 lock_vars[0].read_fptr = lprocfs_rd_u64;
183 lock_vars[0].name = lock_name;
185 snprintf(lock_name, MAX_STRING_SIZE, "%s/resource_count", ns->ns_name);
186 lock_vars[0].data = &ns->ns_resources;
187 lprocfs_add_vars(ldlm_ns_proc_dir, lock_vars, 0);
189 snprintf(lock_name, MAX_STRING_SIZE, "%s/lock_count", ns->ns_name);
190 lock_vars[0].data = &ns->ns_locks;
191 lprocfs_add_vars(ldlm_ns_proc_dir, lock_vars, 0);
194 snprintf(lock_name, MAX_STRING_SIZE, "%s/lock_unused_count",
196 lock_vars[0].data = &ns->ns_nr_unused;
197 lock_vars[0].read_fptr = lprocfs_uint_rd;
198 lprocfs_add_vars(ldlm_ns_proc_dir, lock_vars, 0);
200 snprintf(lock_name, MAX_STRING_SIZE, "%s/lru_size",
202 lock_vars[0].data = ns;
203 lock_vars[0].read_fptr = lprocfs_read_lru_size;
204 lock_vars[0].write_fptr = lprocfs_write_lru_size;
205 lprocfs_add_vars(ldlm_ns_proc_dir, lock_vars, 0);
209 #undef MAX_STRING_SIZE
211 struct ldlm_namespace *ldlm_namespace_new(char *name, __u32 client)
213 struct ldlm_namespace *ns = NULL;
214 struct list_head *bucket;
220 CERROR("ldlm_get_ref failed: %d\n", rc);
224 OBD_ALLOC(ns, sizeof(*ns));
228 OBD_VMALLOC(ns->ns_hash, sizeof(*ns->ns_hash) * RES_HASH_SIZE);
232 OBD_ALLOC(ns->ns_name, strlen(name) + 1);
234 GOTO(out_hash, NULL);
236 strcpy(ns->ns_name, name);
238 INIT_LIST_HEAD(&ns->ns_root_list);
240 ns->ns_client = client;
241 spin_lock_init(&ns->ns_hash_lock);
242 atomic_set(&ns->ns_locks, 0);
243 ns->ns_resources = 0;
244 init_waitqueue_head(&ns->ns_waitq);
246 for (bucket = ns->ns_hash + RES_HASH_SIZE - 1; bucket >= ns->ns_hash;
248 INIT_LIST_HEAD(bucket);
250 INIT_LIST_HEAD(&ns->ns_unused_list);
251 ns->ns_nr_unused = 0;
252 ns->ns_max_unused = LDLM_DEFAULT_LRU_SIZE;
253 spin_lock_init(&ns->ns_unused_lock);
255 down(&ldlm_namespace_lock);
256 list_add(&ns->ns_list_chain, &ldlm_namespace_list);
257 up(&ldlm_namespace_lock);
259 ldlm_proc_namespace(ns);
264 POISON(ns->ns_hash, 0x5a, sizeof(*ns->ns_hash) * RES_HASH_SIZE);
265 OBD_VFREE(ns->ns_hash, sizeof(*ns->ns_hash) * RES_HASH_SIZE);
267 OBD_FREE(ns, sizeof(*ns));
273 extern struct ldlm_lock *ldlm_lock_get(struct ldlm_lock *lock);
275 /* If flags contains FL_LOCAL_ONLY, don't try to tell the server, just cleanup.
276 * This is currently only used for recovery, and we make certain assumptions
277 * as a result--notably, that we shouldn't cancel locks with refs. -phil
279 * Called with the ns_lock held. */
280 static void cleanup_resource(struct ldlm_resource *res, struct list_head *q,
283 struct list_head *tmp;
284 int rc = 0, client = res->lr_namespace->ns_client;
285 int local_only = (flags & LDLM_FL_LOCAL_ONLY);
290 struct ldlm_lock *lock = NULL;
292 /* first, we look for non-cleaned-yet lock
293 * all cleaned locks are marked by CLEANED flag */
295 list_for_each(tmp, q) {
296 lock = list_entry(tmp, struct ldlm_lock, l_res_link);
297 if (lock->l_flags & LDLM_FL_CLEANED) {
302 lock->l_flags |= LDLM_FL_CLEANED;
311 /* Set CBPENDING so nothing in the cancellation path
312 * can match this lock */
313 lock->l_flags |= LDLM_FL_CBPENDING;
314 lock->l_flags |= LDLM_FL_FAILED;
315 lock->l_flags |= flags;
317 if (local_only && (lock->l_readers || lock->l_writers)) {
318 /* This is a little bit gross, but much better than the
319 * alternative: pretend that we got a blocking AST from
320 * the server, so that when the lock is decref'd, it
321 * will go away ... */
322 /* ... without sending a CANCEL message. */
323 lock->l_flags |= LDLM_FL_LOCAL_ONLY;
325 LDLM_DEBUG(lock, "setting FL_LOCAL_ONLY");
326 if (lock->l_completion_ast)
327 lock->l_completion_ast(lock, 0, NULL);
333 struct lustre_handle lockh;
336 ldlm_lock2handle(lock, &lockh);
338 rc = ldlm_cli_cancel(&lockh);
340 CERROR("ldlm_cli_cancel: %d\n", rc);
342 /* Force local cleanup on errors, too. */
343 if (local_only || rc != ELDLM_OK)
344 ldlm_lock_cancel(lock);
346 ldlm_resource_unlink_lock(lock);
348 LDLM_DEBUG(lock, "Freeing a lock still held by a "
350 ldlm_lock_destroy(lock);
358 int ldlm_namespace_cleanup(struct ldlm_namespace *ns, int flags)
360 struct list_head *tmp;
364 CDEBUG(D_INFO, "NULL ns, skipping cleanup\n");
368 for (i = 0; i < RES_HASH_SIZE; i++) {
369 spin_lock(&ns->ns_hash_lock);
370 tmp = ns->ns_hash[i].next;
371 while (tmp != &(ns->ns_hash[i])) {
372 struct ldlm_resource *res;
373 res = list_entry(tmp, struct ldlm_resource, lr_hash);
374 ldlm_resource_getref(res);
375 spin_unlock(&ns->ns_hash_lock);
377 cleanup_resource(res, &res->lr_granted, flags);
378 cleanup_resource(res, &res->lr_converting, flags);
379 cleanup_resource(res, &res->lr_waiting, flags);
381 spin_lock(&ns->ns_hash_lock);
385 /* XXX what a mess: don't force cleanup if we're
386 * local_only (which is only used by recovery). In that
387 * case, we probably still have outstanding lock refs
388 * which reference these resources. -phil */
389 if (!ldlm_resource_putref_locked(res) &&
390 !(flags & LDLM_FL_LOCAL_ONLY)) {
391 CERROR("Resource refcount nonzero (%d) after "
392 "lock cleanup; forcing cleanup.\n",
393 atomic_read(&res->lr_refcount));
394 ldlm_resource_dump(D_ERROR, res);
395 atomic_set(&res->lr_refcount, 1);
396 ldlm_resource_putref_locked(res);
399 /* XXX: former stuff caused issues in case of race
400 * between ldlm_namespace_cleanup() and lockd() when
401 * client gets blocking ast when lock gets distracted by
402 * server. This is 1_4 branch solution, let's see how
404 if (!ldlm_resource_putref_locked(res)) {
405 CERROR("Namespace %s resource refcount nonzero "
406 "(%d) after lock cleanup; forcing cleanup.\n",
407 ns->ns_name, atomic_read(&res->lr_refcount));
408 ldlm_resource_dump(D_ERROR, res);
411 spin_unlock(&ns->ns_hash_lock);
417 /* Cleanup, but also free, the namespace */
418 int ldlm_namespace_free(struct ldlm_namespace *ns, int force)
423 down(&ldlm_namespace_lock);
424 list_del(&ns->ns_list_chain);
425 up(&ldlm_namespace_lock);
427 /* At shutdown time, don't call the cancellation callback */
428 ldlm_namespace_cleanup(ns, 0);
432 struct proc_dir_entry *dir;
433 dir = lprocfs_srch(ldlm_ns_proc_dir, ns->ns_name);
435 CERROR("dlm namespace %s has no procfs dir?\n",
443 POISON(ns->ns_hash, 0x5a, sizeof(*ns->ns_hash) * RES_HASH_SIZE);
444 OBD_VFREE(ns->ns_hash, sizeof(*ns->ns_hash) * RES_HASH_SIZE);
445 OBD_FREE(ns->ns_name, strlen(ns->ns_name) + 1);
446 OBD_FREE(ns, sizeof(*ns));
453 static __u32 ldlm_hash_fn(struct ldlm_resource *parent, struct ldlm_res_id name)
458 for (i = 0; i < RES_NAME_SIZE; i++)
459 hash += name.name[i];
461 hash += (__u32)((unsigned long)parent >> 4);
463 return (hash & RES_HASH_MASK);
466 static struct ldlm_resource *ldlm_resource_new(void)
468 struct ldlm_resource *res;
470 OBD_SLAB_ALLOC(res, ldlm_resource_slab, SLAB_NOFS, sizeof *res);
474 memset(res, 0, sizeof(*res));
476 INIT_LIST_HEAD(&res->lr_children);
477 INIT_LIST_HEAD(&res->lr_childof);
478 INIT_LIST_HEAD(&res->lr_granted);
479 INIT_LIST_HEAD(&res->lr_converting);
480 INIT_LIST_HEAD(&res->lr_waiting);
481 atomic_set(&res->lr_refcount, 1);
482 spin_lock_init(&res->lr_lock);
484 /* one who creates the resource must unlock
485 * the semaphore after lvb initialization */
486 init_MUTEX_LOCKED(&res->lr_lvb_sem);
491 /* must be called with hash lock held */
492 static struct ldlm_resource *
493 ldlm_resource_find(struct ldlm_namespace *ns, struct ldlm_res_id name, __u32 hash)
495 struct list_head *bucket, *tmp;
496 struct ldlm_resource *res;
498 LASSERT_SPIN_LOCKED(&ns->ns_hash_lock);
499 bucket = ns->ns_hash + hash;
501 list_for_each(tmp, bucket) {
502 res = list_entry(tmp, struct ldlm_resource, lr_hash);
503 if (memcmp(&res->lr_name, &name, sizeof(res->lr_name)) == 0)
510 /* Args: locked namespace
511 * Returns: newly-allocated, referenced, unlocked resource */
512 static struct ldlm_resource *
513 ldlm_resource_add(struct ldlm_namespace *ns, struct ldlm_resource *parent,
514 struct ldlm_res_id name, __u32 hash, __u32 type)
516 struct list_head *bucket;
517 struct ldlm_resource *res, *old_res;
520 LASSERTF(type >= LDLM_MIN_TYPE && type <= LDLM_MAX_TYPE,
523 res = ldlm_resource_new();
527 memcpy(&res->lr_name, &name, sizeof(res->lr_name));
528 res->lr_namespace = ns;
530 res->lr_most_restr = LCK_NL;
532 spin_lock(&ns->ns_hash_lock);
533 old_res = ldlm_resource_find(ns, name, hash);
535 /* someone won the race and added the resource before */
536 ldlm_resource_getref(old_res);
537 spin_unlock(&ns->ns_hash_lock);
538 OBD_SLAB_FREE(res, ldlm_resource_slab, sizeof *res);
539 /* synchronize WRT resource creation */
540 if (ns->ns_lvbo && ns->ns_lvbo->lvbo_init) {
541 down(&old_res->lr_lvb_sem);
542 up(&old_res->lr_lvb_sem);
547 /* we won! let's add the resource */
548 bucket = ns->ns_hash + hash;
549 list_add(&res->lr_hash, bucket);
553 if (parent == NULL) {
554 list_add(&res->lr_childof, &ns->ns_root_list);
556 res->lr_parent = parent;
557 list_add(&res->lr_childof, &parent->lr_children);
559 spin_unlock(&ns->ns_hash_lock);
561 if (ns->ns_lvbo && ns->ns_lvbo->lvbo_init) {
564 OBD_FAIL_TIMEOUT(OBD_FAIL_LDLM_CREATE_RESOURCE, 2);
565 rc = ns->ns_lvbo->lvbo_init(res);
567 CERROR("lvbo_init failed for resource "
568 LPU64": rc %d\n", name.name[0], rc);
569 /* we create resource with locked lr_lvb_sem */
570 up(&res->lr_lvb_sem);
576 /* Args: unlocked namespace
577 * Locks: takes and releases ns->ns_lock and res->lr_lock
578 * Returns: referenced, unlocked ldlm_resource or NULL */
579 struct ldlm_resource *
580 ldlm_resource_get(struct ldlm_namespace *ns, struct ldlm_resource *parent,
581 struct ldlm_res_id name, __u32 type, int create)
583 __u32 hash = ldlm_hash_fn(parent, name);
584 struct ldlm_resource *res = NULL;
588 LASSERT(ns->ns_hash != NULL);
589 LASSERT(name.name[0] != 0);
591 spin_lock(&ns->ns_hash_lock);
592 res = ldlm_resource_find(ns, name, hash);
594 ldlm_resource_getref(res);
595 spin_unlock(&ns->ns_hash_lock);
596 /* synchronize WRT resource creation */
597 if (ns->ns_lvbo && ns->ns_lvbo->lvbo_init) {
598 down(&res->lr_lvb_sem);
599 up(&res->lr_lvb_sem);
603 spin_unlock(&ns->ns_hash_lock);
608 res = ldlm_resource_add(ns, parent, name, hash, type);
612 struct ldlm_resource *ldlm_resource_getref(struct ldlm_resource *res)
614 LASSERT(res != NULL);
615 LASSERT(res != LP_POISON);
616 atomic_inc(&res->lr_refcount);
617 CDEBUG(D_INFO, "getref res: %p count: %d\n", res,
618 atomic_read(&res->lr_refcount));
622 void __ldlm_resource_putref_final(struct ldlm_resource *res)
624 struct ldlm_namespace *ns = res->lr_namespace;
626 LASSERT_SPIN_LOCKED(&ns->ns_hash_lock);
628 if (!list_empty(&res->lr_granted)) {
629 ldlm_resource_dump(D_ERROR, res);
633 if (!list_empty(&res->lr_converting)) {
634 ldlm_resource_dump(D_ERROR, res);
638 if (!list_empty(&res->lr_waiting)) {
639 ldlm_resource_dump(D_ERROR, res);
643 if (!list_empty(&res->lr_children)) {
644 ldlm_resource_dump(D_ERROR, res);
649 list_del_init(&res->lr_hash);
650 list_del_init(&res->lr_childof);
653 if (ns->ns_resources == 0)
654 wake_up(&ns->ns_waitq);
657 /* Returns 1 if the resource was freed, 0 if it remains. */
658 int ldlm_resource_putref(struct ldlm_resource *res)
660 struct ldlm_namespace *ns = res->lr_namespace;
664 CDEBUG(D_INFO, "putref res: %p count: %d\n", res,
665 atomic_read(&res->lr_refcount) - 1);
666 LASSERT(atomic_read(&res->lr_refcount) > 0);
667 LASSERT(atomic_read(&res->lr_refcount) < LI_POISON);
669 LASSERT(atomic_read(&res->lr_refcount) >= 0);
670 if (atomic_dec_and_lock(&res->lr_refcount, &ns->ns_hash_lock)) {
671 __ldlm_resource_putref_final(res);
672 spin_unlock(&ns->ns_hash_lock);
673 if (res->lr_lvb_data)
674 OBD_FREE(res->lr_lvb_data, res->lr_lvb_len);
675 OBD_SLAB_FREE(res, ldlm_resource_slab, sizeof *res);
682 /* Returns 1 if the resource was freed, 0 if it remains. */
683 int ldlm_resource_putref_locked(struct ldlm_resource *res)
688 CDEBUG(D_INFO, "putref res: %p count: %d\n", res,
689 atomic_read(&res->lr_refcount) - 1);
690 LASSERT(atomic_read(&res->lr_refcount) > 0);
691 LASSERT(atomic_read(&res->lr_refcount) < LI_POISON);
693 LASSERT(atomic_read(&res->lr_refcount) >= 0);
694 if (atomic_dec_and_test(&res->lr_refcount)) {
695 __ldlm_resource_putref_final(res);
696 if (res->lr_lvb_data)
697 OBD_FREE(res->lr_lvb_data, res->lr_lvb_len);
698 OBD_SLAB_FREE(res, ldlm_resource_slab, sizeof *res);
705 void ldlm_resource_add_lock(struct ldlm_resource *res, struct list_head *head,
706 struct ldlm_lock *lock)
708 check_res_locked(res);
710 ldlm_resource_dump(D_OTHER, res);
711 CDEBUG(D_OTHER, "About to add this lock:\n");
712 ldlm_lock_dump(D_OTHER, lock, 0);
714 if (lock->l_destroyed) {
715 CDEBUG(D_OTHER, "Lock destroyed, not adding to resource\n");
719 LASSERT(list_empty(&lock->l_res_link));
721 list_add_tail(&lock->l_res_link, head);
724 void ldlm_resource_unlink_lock(struct ldlm_lock *lock)
726 check_res_locked(lock->l_resource);
727 list_del_init(&lock->l_res_link);
730 void ldlm_res2desc(struct ldlm_resource *res, struct ldlm_resource_desc *desc)
732 desc->lr_type = res->lr_type;
733 memcpy(&desc->lr_name, &res->lr_name, sizeof(desc->lr_name));
736 void ldlm_dump_all_namespaces(int level)
738 struct list_head *tmp;
740 down(&ldlm_namespace_lock);
742 list_for_each(tmp, &ldlm_namespace_list) {
743 struct ldlm_namespace *ns;
744 ns = list_entry(tmp, struct ldlm_namespace, ns_list_chain);
745 ldlm_namespace_dump(level, ns);
748 up(&ldlm_namespace_lock);
751 void ldlm_namespace_dump(int level, struct ldlm_namespace *ns)
753 struct list_head *tmp;
755 CDEBUG(level, "--- Namespace: %s (rc: %d, client: %d)\n",
756 ns->ns_name, ns->ns_refcount, ns->ns_client);
758 if (time_before(jiffies, ns->ns_next_dump))
761 spin_lock(&ns->ns_hash_lock);
762 tmp = ns->ns_root_list.next;
763 while (tmp != &ns->ns_root_list) {
764 struct ldlm_resource *res;
765 res = list_entry(tmp, struct ldlm_resource, lr_childof);
767 ldlm_resource_getref(res);
768 spin_unlock(&ns->ns_hash_lock);
771 ldlm_resource_dump(level, res);
774 spin_lock(&ns->ns_hash_lock);
776 ldlm_resource_putref_locked(res);
778 ns->ns_next_dump = jiffies + 10 * HZ;
779 spin_unlock(&ns->ns_hash_lock);
782 void ldlm_resource_dump(int level, struct ldlm_resource *res)
784 struct list_head *tmp;
787 if (RES_NAME_SIZE != 4)
790 CDEBUG(level, "--- Resource: %p ("LPU64"/"LPU64"/"LPU64"/"LPU64
791 ") (rc: %d)\n", res, res->lr_name.name[0], res->lr_name.name[1],
792 res->lr_name.name[2], res->lr_name.name[3],
793 atomic_read(&res->lr_refcount));
795 if (!list_empty(&res->lr_granted)) {
797 CDEBUG(level, "Granted locks:\n");
798 list_for_each(tmp, &res->lr_granted) {
799 struct ldlm_lock *lock;
800 lock = list_entry(tmp, struct ldlm_lock, l_res_link);
801 ldlm_lock_dump(level, lock, ++pos);
804 if (!list_empty(&res->lr_converting)) {
806 CDEBUG(level, "Converting locks:\n");
807 list_for_each(tmp, &res->lr_converting) {
808 struct ldlm_lock *lock;
809 lock = list_entry(tmp, struct ldlm_lock, l_res_link);
810 ldlm_lock_dump(level, lock, ++pos);
813 if (!list_empty(&res->lr_waiting)) {
815 CDEBUG(level, "Waiting locks:\n");
816 list_for_each(tmp, &res->lr_waiting) {
817 struct ldlm_lock *lock;
818 lock = list_entry(tmp, struct ldlm_lock, l_res_link);
819 ldlm_lock_dump(level, lock, ++pos);