4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 only,
8 * as published by the Free Software Foundation.
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * General Public License version 2 for more details (a copy is included
14 * in the LICENSE file that accompanied this code).
16 * You should have received a copy of the GNU General Public License
17 * version 2 along with this program; If not, see
18 * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf
20 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
21 * CA 95054 USA or visit www.sun.com if you need additional information or
27 * Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved.
28 * Use is subject to license terms.
30 * Copyright (c) 2010, 2015, Intel Corporation.
33 * This file is part of Lustre, http://www.lustre.org/
34 * Lustre is a trademark of Sun Microsystems, Inc.
36 * lustre/ldlm/ldlm_resource.c
38 * Author: Phil Schwan <phil@clusterfs.com>
39 * Author: Peter Braam <braam@clusterfs.com>
42 #define DEBUG_SUBSYSTEM S_LDLM
43 #include <lustre_dlm.h>
44 #include <lustre_fid.h>
45 #include <obd_class.h>
46 #include "ldlm_internal.h"
48 struct kmem_cache *ldlm_resource_slab, *ldlm_lock_slab;
49 struct kmem_cache *ldlm_interval_tree_slab;
51 int ldlm_srv_namespace_nr = 0;
52 int ldlm_cli_namespace_nr = 0;
54 struct mutex ldlm_srv_namespace_lock;
55 struct list_head ldlm_srv_namespace_list;
57 struct mutex ldlm_cli_namespace_lock;
58 /* Client Namespaces that have active resources in them.
59 * Once all resources go away, ldlm_poold moves such namespaces to the
61 struct list_head ldlm_cli_active_namespace_list;
62 /* Client namespaces that don't have any locks in them */
63 struct list_head ldlm_cli_inactive_namespace_list;
65 static struct proc_dir_entry *ldlm_type_proc_dir;
66 static struct proc_dir_entry *ldlm_ns_proc_dir;
67 struct proc_dir_entry *ldlm_svc_proc_dir;
69 /* during debug dump certain amount of granted locks for one resource to avoid
71 static unsigned int ldlm_dump_granted_max = 256;
75 lprocfs_dump_ns_seq_write(struct file *file, const char __user *buffer,
76 size_t count, loff_t *off)
78 ldlm_dump_all_namespaces(LDLM_NAMESPACE_SERVER, D_DLMTRACE);
79 ldlm_dump_all_namespaces(LDLM_NAMESPACE_CLIENT, D_DLMTRACE);
82 LPROC_SEQ_FOPS_WO_TYPE(ldlm, dump_ns);
84 LPROC_SEQ_FOPS_RW_TYPE(ldlm_rw, uint);
85 LPROC_SEQ_FOPS_RO_TYPE(ldlm, uint);
87 #ifdef HAVE_SERVER_SUPPORT
89 static int seq_watermark_show(struct seq_file *m, void *data)
91 seq_printf(m, LPU64"\n", *(__u64 *)m->private);
95 static ssize_t seq_watermark_write(struct file *file,
96 const char __user *buffer, size_t count,
101 __u64 *data = ((struct seq_file *)file->private_data)->private;
102 bool wm_low = (data == &ldlm_reclaim_threshold_mb) ? true : false;
105 rc = lprocfs_str_with_units_to_s64(buffer, count, &value, 'M');
107 CERROR("Failed to set %s, rc = %d.\n",
108 wm_low ? "lock_reclaim_threshold_mb" : "lock_limit_mb",
111 } else if (value != 0 && value < (1 << 20)) {
112 CERROR("%s should be greater than 1MB.\n",
113 wm_low ? "lock_reclaim_threshold_mb" : "lock_limit_mb");
116 watermark = value >> 20;
119 if (ldlm_lock_limit_mb != 0 && watermark > ldlm_lock_limit_mb) {
120 CERROR("lock_reclaim_threshold_mb must be smaller than "
126 if (watermark != 0) {
128 do_div(watermark, sizeof(struct ldlm_lock));
130 ldlm_reclaim_threshold = watermark;
132 if (ldlm_reclaim_threshold_mb != 0 &&
133 watermark < ldlm_reclaim_threshold_mb) {
134 CERROR("lock_limit_mb must be greater than "
135 "lock_reclaim_threshold_mb.\n");
140 if (watermark != 0) {
142 do_div(watermark, sizeof(struct ldlm_lock));
144 ldlm_lock_limit = watermark;
150 static int seq_watermark_open(struct inode *inode, struct file *file)
152 return single_open(file, seq_watermark_show, PDE_DATA(inode));
155 static const struct file_operations ldlm_watermark_fops = {
156 .owner = THIS_MODULE,
157 .open = seq_watermark_open,
159 .write = seq_watermark_write,
161 .release = lprocfs_single_release,
164 static int seq_granted_show(struct seq_file *m, void *data)
166 seq_printf(m, LPU64"\n", percpu_counter_sum_positive(
167 (struct percpu_counter *)m->private));
171 static int seq_granted_open(struct inode *inode, struct file *file)
173 return single_open(file, seq_granted_show, PDE_DATA(inode));
176 static const struct file_operations ldlm_granted_fops = {
177 .owner = THIS_MODULE,
178 .open = seq_granted_open,
181 .release = seq_release,
184 #endif /* HAVE_SERVER_SUPPORT */
186 int ldlm_proc_setup(void)
189 struct lprocfs_vars list[] = {
190 { .name = "dump_namespaces",
191 .fops = &ldlm_dump_ns_fops,
193 { .name = "dump_granted_max",
194 .fops = &ldlm_rw_uint_fops,
195 .data = &ldlm_dump_granted_max },
196 { .name = "cancel_unused_locks_before_replay",
197 .fops = &ldlm_rw_uint_fops,
198 .data = &ldlm_cancel_unused_locks_before_replay },
199 #ifdef HAVE_SERVER_SUPPORT
200 { .name = "lock_reclaim_threshold_mb",
201 .fops = &ldlm_watermark_fops,
202 .data = &ldlm_reclaim_threshold_mb },
203 { .name = "lock_limit_mb",
204 .fops = &ldlm_watermark_fops,
205 .data = &ldlm_lock_limit_mb },
206 { .name = "lock_granted_count",
207 .fops = &ldlm_granted_fops,
208 .data = &ldlm_granted_total },
212 LASSERT(ldlm_ns_proc_dir == NULL);
214 ldlm_type_proc_dir = lprocfs_register(OBD_LDLM_DEVICENAME,
217 if (IS_ERR(ldlm_type_proc_dir)) {
218 CERROR("LProcFS failed in ldlm-init\n");
219 rc = PTR_ERR(ldlm_type_proc_dir);
223 ldlm_ns_proc_dir = lprocfs_register("namespaces",
226 if (IS_ERR(ldlm_ns_proc_dir)) {
227 CERROR("LProcFS failed in ldlm-init\n");
228 rc = PTR_ERR(ldlm_ns_proc_dir);
232 ldlm_svc_proc_dir = lprocfs_register("services",
235 if (IS_ERR(ldlm_svc_proc_dir)) {
236 CERROR("LProcFS failed in ldlm-init\n");
237 rc = PTR_ERR(ldlm_svc_proc_dir);
241 rc = lprocfs_add_vars(ldlm_type_proc_dir, list, NULL);
243 CERROR("LProcFS failed in ldlm-init\n");
250 lprocfs_remove(&ldlm_svc_proc_dir);
252 lprocfs_remove(&ldlm_ns_proc_dir);
254 lprocfs_remove(&ldlm_type_proc_dir);
256 ldlm_svc_proc_dir = NULL;
260 void ldlm_proc_cleanup(void)
262 if (ldlm_svc_proc_dir)
263 lprocfs_remove(&ldlm_svc_proc_dir);
265 if (ldlm_ns_proc_dir)
266 lprocfs_remove(&ldlm_ns_proc_dir);
268 if (ldlm_type_proc_dir)
269 lprocfs_remove(&ldlm_type_proc_dir);
272 static int lprocfs_ns_resources_seq_show(struct seq_file *m, void *v)
274 struct ldlm_namespace *ns = m->private;
276 struct cfs_hash_bd bd;
279 /* result is not strictly consistant */
280 cfs_hash_for_each_bucket(ns->ns_rs_hash, &bd, i)
281 res += cfs_hash_bd_count_get(&bd);
282 return lprocfs_u64_seq_show(m, &res);
284 LPROC_SEQ_FOPS_RO(lprocfs_ns_resources);
286 static int lprocfs_ns_locks_seq_show(struct seq_file *m, void *v)
288 struct ldlm_namespace *ns = m->private;
291 locks = lprocfs_stats_collector(ns->ns_stats, LDLM_NSS_LOCKS,
292 LPROCFS_FIELDS_FLAGS_SUM);
293 return lprocfs_u64_seq_show(m, &locks);
295 LPROC_SEQ_FOPS_RO(lprocfs_ns_locks);
297 static int lprocfs_lru_size_seq_show(struct seq_file *m, void *v)
299 struct ldlm_namespace *ns = m->private;
300 __u32 *nr = &ns->ns_max_unused;
302 if (ns_connect_lru_resize(ns))
303 nr = &ns->ns_nr_unused;
304 return lprocfs_uint_seq_show(m, nr);
307 static ssize_t lprocfs_lru_size_seq_write(struct file *file,
308 const char __user *buffer,
309 size_t count, loff_t *off)
311 struct ldlm_namespace *ns = ((struct seq_file *)file->private_data)->private;
312 char dummy[MAX_STRING_SIZE + 1], *end;
316 dummy[MAX_STRING_SIZE] = '\0';
317 if (copy_from_user(dummy, buffer, MAX_STRING_SIZE))
320 if (strncmp(dummy, "clear", 5) == 0) {
322 "dropping all unused locks from namespace %s\n",
324 if (ns_connect_lru_resize(ns)) {
325 int canceled, unused = ns->ns_nr_unused;
327 /* Try to cancel all @ns_nr_unused locks. */
328 canceled = ldlm_cancel_lru(ns, unused, 0,
329 LDLM_LRU_FLAG_PASSED);
330 if (canceled < unused) {
332 "not all requested locks are canceled, "
333 "requested: %d, canceled: %d\n", unused,
338 tmp = ns->ns_max_unused;
339 ns->ns_max_unused = 0;
340 ldlm_cancel_lru(ns, 0, 0, LDLM_LRU_FLAG_PASSED);
341 ns->ns_max_unused = tmp;
346 tmp = simple_strtoul(dummy, &end, 0);
348 CERROR("invalid value written\n");
351 lru_resize = (tmp == 0);
353 if (ns_connect_lru_resize(ns)) {
355 ns->ns_max_unused = tmp;
357 if (tmp > ns->ns_nr_unused)
358 tmp = ns->ns_nr_unused;
359 tmp = ns->ns_nr_unused - tmp;
362 "changing namespace %s unused locks from %u to %u\n",
363 ldlm_ns_name(ns), ns->ns_nr_unused,
365 ldlm_cancel_lru(ns, tmp, LCF_ASYNC, LDLM_LRU_FLAG_PASSED);
369 "disable lru_resize for namespace %s\n",
371 ns->ns_connect_flags &= ~OBD_CONNECT_LRU_RESIZE;
375 "changing namespace %s max_unused from %u to %u\n",
376 ldlm_ns_name(ns), ns->ns_max_unused,
378 ns->ns_max_unused = (unsigned int)tmp;
379 ldlm_cancel_lru(ns, 0, LCF_ASYNC, LDLM_LRU_FLAG_PASSED);
381 /* Make sure that LRU resize was originally supported before
382 * turning it on here. */
384 (ns->ns_orig_connect_flags & OBD_CONNECT_LRU_RESIZE)) {
386 "enable lru_resize for namespace %s\n",
388 ns->ns_connect_flags |= OBD_CONNECT_LRU_RESIZE;
394 LPROC_SEQ_FOPS(lprocfs_lru_size);
396 static int lprocfs_elc_seq_show(struct seq_file *m, void *v)
398 struct ldlm_namespace *ns = m->private;
399 unsigned int supp = ns_connect_cancelset(ns);
401 return lprocfs_uint_seq_show(m, &supp);
404 static ssize_t lprocfs_elc_seq_write(struct file *file,
405 const char __user *buffer,
406 size_t count, loff_t *off)
408 struct ldlm_namespace *ns = ((struct seq_file *)file->private_data)->private;
409 unsigned int supp = -1;
412 rc = lprocfs_wr_uint(file, buffer, count, &supp);
417 ns->ns_connect_flags &= ~OBD_CONNECT_CANCELSET;
418 else if (ns->ns_orig_connect_flags & OBD_CONNECT_CANCELSET)
419 ns->ns_connect_flags |= OBD_CONNECT_CANCELSET;
422 LPROC_SEQ_FOPS(lprocfs_elc);
424 static void ldlm_namespace_proc_unregister(struct ldlm_namespace *ns)
426 if (ns->ns_proc_dir_entry == NULL)
427 CERROR("dlm namespace %s has no procfs dir?\n",
430 lprocfs_remove(&ns->ns_proc_dir_entry);
432 if (ns->ns_stats != NULL)
433 lprocfs_free_stats(&ns->ns_stats);
436 static int ldlm_namespace_proc_register(struct ldlm_namespace *ns)
438 struct lprocfs_vars lock_vars[2];
439 char lock_name[MAX_STRING_SIZE + 1];
440 struct proc_dir_entry *ns_pde;
443 LASSERT(ns->ns_rs_hash != NULL);
445 if (ns->ns_proc_dir_entry != NULL) {
446 ns_pde = ns->ns_proc_dir_entry;
448 ns_pde = proc_mkdir(ldlm_ns_name(ns), ldlm_ns_proc_dir);
451 ns->ns_proc_dir_entry = ns_pde;
454 ns->ns_stats = lprocfs_alloc_stats(LDLM_NSS_LAST, 0);
455 if (ns->ns_stats == NULL)
458 lprocfs_counter_init(ns->ns_stats, LDLM_NSS_LOCKS,
459 LPROCFS_CNTR_AVGMINMAX, "locks", "locks");
461 lock_name[MAX_STRING_SIZE] = '\0';
463 memset(lock_vars, 0, sizeof(lock_vars));
464 lock_vars[0].name = lock_name;
466 ldlm_add_var(&lock_vars[0], ns_pde, "resource_count", ns,
467 &lprocfs_ns_resources_fops);
468 ldlm_add_var(&lock_vars[0], ns_pde, "lock_count", ns,
469 &lprocfs_ns_locks_fops);
471 if (ns_is_client(ns)) {
472 ldlm_add_var(&lock_vars[0], ns_pde, "lock_unused_count",
473 &ns->ns_nr_unused, &ldlm_uint_fops);
474 ldlm_add_var(&lock_vars[0], ns_pde, "lru_size", ns,
475 &lprocfs_lru_size_fops);
476 ldlm_add_var(&lock_vars[0], ns_pde, "lru_max_age",
477 &ns->ns_max_age, &ldlm_rw_uint_fops);
478 ldlm_add_var(&lock_vars[0], ns_pde, "early_lock_cancel",
479 ns, &lprocfs_elc_fops);
481 ldlm_add_var(&lock_vars[0], ns_pde, "ctime_age_limit",
482 &ns->ns_ctime_age_limit, &ldlm_rw_uint_fops);
483 ldlm_add_var(&lock_vars[0], ns_pde, "lock_timeouts",
484 &ns->ns_timeouts, &ldlm_uint_fops);
485 ldlm_add_var(&lock_vars[0], ns_pde, "max_nolock_bytes",
486 &ns->ns_max_nolock_size, &ldlm_rw_uint_fops);
487 ldlm_add_var(&lock_vars[0], ns_pde, "contention_seconds",
488 &ns->ns_contention_time, &ldlm_rw_uint_fops);
489 ldlm_add_var(&lock_vars[0], ns_pde, "contended_locks",
490 &ns->ns_contended_locks, &ldlm_rw_uint_fops);
491 ldlm_add_var(&lock_vars[0], ns_pde, "max_parallel_ast",
492 &ns->ns_max_parallel_ast, &ldlm_rw_uint_fops);
496 #undef MAX_STRING_SIZE
497 #else /* CONFIG_PROC_FS */
499 #define ldlm_namespace_proc_unregister(ns) ({;})
500 #define ldlm_namespace_proc_register(ns) ({0;})
502 #endif /* CONFIG_PROC_FS */
504 static unsigned ldlm_res_hop_hash(struct cfs_hash *hs,
505 const void *key, unsigned mask)
507 const struct ldlm_res_id *id = key;
511 for (i = 0; i < RES_NAME_SIZE; i++)
516 static unsigned ldlm_res_hop_fid_hash(struct cfs_hash *hs,
517 const void *key, unsigned mask)
519 const struct ldlm_res_id *id = key;
524 fid.f_seq = id->name[LUSTRE_RES_ID_SEQ_OFF];
525 fid.f_oid = (__u32)id->name[LUSTRE_RES_ID_VER_OID_OFF];
526 fid.f_ver = (__u32)(id->name[LUSTRE_RES_ID_VER_OID_OFF] >> 32);
528 hash = fid_flatten32(&fid);
529 hash += (hash >> 4) + (hash << 12); /* mixing oid and seq */
530 if (id->name[LUSTRE_RES_ID_HSH_OFF] != 0) {
531 val = id->name[LUSTRE_RES_ID_HSH_OFF];
532 hash += (val >> 5) + (val << 11);
536 hash = hash_long(hash, hs->hs_bkt_bits);
537 /* give me another random factor */
538 hash -= hash_long((unsigned long)hs, val % 11 + 3);
540 hash <<= hs->hs_cur_bits - hs->hs_bkt_bits;
541 hash |= ldlm_res_hop_hash(hs, key, CFS_HASH_NBKT(hs) - 1);
546 static void *ldlm_res_hop_key(struct hlist_node *hnode)
548 struct ldlm_resource *res;
550 res = hlist_entry(hnode, struct ldlm_resource, lr_hash);
551 return &res->lr_name;
554 static int ldlm_res_hop_keycmp(const void *key, struct hlist_node *hnode)
556 struct ldlm_resource *res;
558 res = hlist_entry(hnode, struct ldlm_resource, lr_hash);
559 return ldlm_res_eq((const struct ldlm_res_id *)key,
560 (const struct ldlm_res_id *)&res->lr_name);
563 static void *ldlm_res_hop_object(struct hlist_node *hnode)
565 return hlist_entry(hnode, struct ldlm_resource, lr_hash);
569 ldlm_res_hop_get_locked(struct cfs_hash *hs, struct hlist_node *hnode)
571 struct ldlm_resource *res;
573 res = hlist_entry(hnode, struct ldlm_resource, lr_hash);
574 ldlm_resource_getref(res);
577 static void ldlm_res_hop_put(struct cfs_hash *hs, struct hlist_node *hnode)
579 struct ldlm_resource *res;
581 res = hlist_entry(hnode, struct ldlm_resource, lr_hash);
582 ldlm_resource_putref(res);
585 static struct cfs_hash_ops ldlm_ns_hash_ops = {
586 .hs_hash = ldlm_res_hop_hash,
587 .hs_key = ldlm_res_hop_key,
588 .hs_keycmp = ldlm_res_hop_keycmp,
590 .hs_object = ldlm_res_hop_object,
591 .hs_get = ldlm_res_hop_get_locked,
592 .hs_put = ldlm_res_hop_put
595 static struct cfs_hash_ops ldlm_ns_fid_hash_ops = {
596 .hs_hash = ldlm_res_hop_fid_hash,
597 .hs_key = ldlm_res_hop_key,
598 .hs_keycmp = ldlm_res_hop_keycmp,
600 .hs_object = ldlm_res_hop_object,
601 .hs_get = ldlm_res_hop_get_locked,
602 .hs_put = ldlm_res_hop_put
605 typedef struct ldlm_ns_hash_def {
606 enum ldlm_ns_type nsd_type;
607 /** hash bucket bits */
608 unsigned nsd_bkt_bits;
610 unsigned nsd_all_bits;
611 /** hash operations */
612 struct cfs_hash_ops *nsd_hops;
613 } ldlm_ns_hash_def_t;
615 static struct ldlm_ns_hash_def ldlm_ns_hash_defs[] =
618 .nsd_type = LDLM_NS_TYPE_MDC,
621 .nsd_hops = &ldlm_ns_fid_hash_ops,
624 .nsd_type = LDLM_NS_TYPE_MDT,
627 .nsd_hops = &ldlm_ns_fid_hash_ops,
630 .nsd_type = LDLM_NS_TYPE_OSC,
633 .nsd_hops = &ldlm_ns_hash_ops,
636 .nsd_type = LDLM_NS_TYPE_OST,
639 .nsd_hops = &ldlm_ns_hash_ops,
642 .nsd_type = LDLM_NS_TYPE_MGC,
645 .nsd_hops = &ldlm_ns_hash_ops,
648 .nsd_type = LDLM_NS_TYPE_MGT,
651 .nsd_hops = &ldlm_ns_hash_ops,
654 .nsd_type = LDLM_NS_TYPE_UNKNOWN,
659 * Create and initialize new empty namespace.
661 struct ldlm_namespace *ldlm_namespace_new(struct obd_device *obd, char *name,
662 enum ldlm_side client,
663 enum ldlm_appetite apt,
664 enum ldlm_ns_type ns_type)
666 struct ldlm_namespace *ns = NULL;
667 struct ldlm_ns_bucket *nsb;
668 struct ldlm_ns_hash_def *nsd;
669 struct cfs_hash_bd bd;
674 LASSERT(obd != NULL);
678 CERROR("ldlm_get_ref failed: %d\n", rc);
682 for (idx = 0;;idx++) {
683 nsd = &ldlm_ns_hash_defs[idx];
684 if (nsd->nsd_type == LDLM_NS_TYPE_UNKNOWN) {
685 CERROR("Unknown type %d for ns %s\n", ns_type, name);
689 if (nsd->nsd_type == ns_type)
697 ns->ns_rs_hash = cfs_hash_create(name,
698 nsd->nsd_all_bits, nsd->nsd_all_bits,
699 nsd->nsd_bkt_bits, sizeof(*nsb),
705 CFS_HASH_SPIN_BKTLOCK |
706 CFS_HASH_NO_ITEMREF);
707 if (ns->ns_rs_hash == NULL)
710 cfs_hash_for_each_bucket(ns->ns_rs_hash, &bd, idx) {
711 nsb = cfs_hash_bd_extra_get(ns->ns_rs_hash, &bd);
712 at_init(&nsb->nsb_at_estimate, ldlm_enqueue_min, 0);
713 nsb->nsb_namespace = ns;
714 nsb->nsb_reclaim_start = 0;
718 ns->ns_appetite = apt;
719 ns->ns_client = client;
721 INIT_LIST_HEAD(&ns->ns_list_chain);
722 INIT_LIST_HEAD(&ns->ns_unused_list);
723 spin_lock_init(&ns->ns_lock);
724 atomic_set(&ns->ns_bref, 0);
725 init_waitqueue_head(&ns->ns_waitq);
727 ns->ns_max_nolock_size = NS_DEFAULT_MAX_NOLOCK_BYTES;
728 ns->ns_contention_time = NS_DEFAULT_CONTENTION_SECONDS;
729 ns->ns_contended_locks = NS_DEFAULT_CONTENDED_LOCKS;
731 ns->ns_max_parallel_ast = LDLM_DEFAULT_PARALLEL_AST_LIMIT;
732 ns->ns_nr_unused = 0;
733 ns->ns_max_unused = LDLM_DEFAULT_LRU_SIZE;
734 ns->ns_max_age = LDLM_DEFAULT_MAX_ALIVE;
735 ns->ns_ctime_age_limit = LDLM_CTIME_AGE_LIMIT;
737 ns->ns_orig_connect_flags = 0;
738 ns->ns_connect_flags = 0;
740 ns->ns_reclaim_start = 0;
741 rc = ldlm_namespace_proc_register(ns);
743 CERROR("Can't initialize ns proc, rc %d\n", rc);
747 idx = ldlm_namespace_nr_read(client);
748 rc = ldlm_pool_init(&ns->ns_pool, ns, idx, client);
750 CERROR("Can't initialize lock pool, rc %d\n", rc);
754 ldlm_namespace_register(ns, client);
757 ldlm_namespace_proc_unregister(ns);
758 ldlm_namespace_cleanup(ns, 0);
760 cfs_hash_putref(ns->ns_rs_hash);
767 EXPORT_SYMBOL(ldlm_namespace_new);
769 extern struct ldlm_lock *ldlm_lock_get(struct ldlm_lock *lock);
772 * Cancel and destroy all locks on a resource.
774 * If flags contains FL_LOCAL_ONLY, don't try to tell the server, just
775 * clean up. This is currently only used for recovery, and we make
776 * certain assumptions as a result--notably, that we shouldn't cancel
779 static void cleanup_resource(struct ldlm_resource *res, struct list_head *q,
782 struct list_head *tmp;
783 int rc = 0, client = ns_is_client(ldlm_res_to_ns(res));
784 bool local_only = !!(flags & LDLM_FL_LOCAL_ONLY);
787 struct ldlm_lock *lock = NULL;
789 /* First, we look for non-cleaned-yet lock
790 * all cleaned locks are marked by CLEANED flag. */
792 list_for_each(tmp, q) {
793 lock = list_entry(tmp, struct ldlm_lock,
795 if (ldlm_is_cleaned(lock)) {
800 ldlm_set_cleaned(lock);
809 /* Set CBPENDING so nothing in the cancellation path
810 * can match this lock. */
811 ldlm_set_cbpending(lock);
812 ldlm_set_failed(lock);
813 lock->l_flags |= flags;
815 /* ... without sending a CANCEL message for local_only. */
817 ldlm_set_local_only(lock);
819 if (local_only && (lock->l_readers || lock->l_writers)) {
820 /* This is a little bit gross, but much better than the
821 * alternative: pretend that we got a blocking AST from
822 * the server, so that when the lock is decref'd, it
823 * will go away ... */
825 LDLM_DEBUG(lock, "setting FL_LOCAL_ONLY");
826 if (lock->l_flags & LDLM_FL_FAIL_LOC) {
827 set_current_state(TASK_UNINTERRUPTIBLE);
828 schedule_timeout(cfs_time_seconds(4));
829 set_current_state(TASK_RUNNING);
831 if (lock->l_completion_ast)
832 lock->l_completion_ast(lock,
833 LDLM_FL_FAILED, NULL);
834 LDLM_LOCK_RELEASE(lock);
839 struct lustre_handle lockh;
842 ldlm_lock2handle(lock, &lockh);
843 rc = ldlm_cli_cancel(&lockh, LCF_LOCAL);
845 CERROR("ldlm_cli_cancel: %d\n", rc);
848 LDLM_DEBUG(lock, "Freeing a lock still held by a "
850 ldlm_lock_cancel(lock);
852 LDLM_LOCK_RELEASE(lock);
856 static int ldlm_resource_clean(struct cfs_hash *hs, struct cfs_hash_bd *bd,
857 struct hlist_node *hnode, void *arg)
859 struct ldlm_resource *res = cfs_hash_object(hs, hnode);
860 __u64 flags = *(__u64 *)arg;
862 cleanup_resource(res, &res->lr_granted, flags);
863 cleanup_resource(res, &res->lr_converting, flags);
864 cleanup_resource(res, &res->lr_waiting, flags);
869 static int ldlm_resource_complain(struct cfs_hash *hs, struct cfs_hash_bd *bd,
870 struct hlist_node *hnode, void *arg)
872 struct ldlm_resource *res = cfs_hash_object(hs, hnode);
875 CERROR("%s: namespace resource "DLDLMRES" (%p) refcount nonzero "
876 "(%d) after lock cleanup; forcing cleanup.\n",
877 ldlm_ns_name(ldlm_res_to_ns(res)), PLDLMRES(res), res,
878 atomic_read(&res->lr_refcount) - 1);
880 ldlm_resource_dump(D_ERROR, res);
886 * Cancel and destroy all locks in the namespace.
888 * Typically used during evictions when server notified client that it was
889 * evicted and all of its state needs to be destroyed.
890 * Also used during shutdown.
892 int ldlm_namespace_cleanup(struct ldlm_namespace *ns, __u64 flags)
895 CDEBUG(D_INFO, "NULL ns, skipping cleanup\n");
899 cfs_hash_for_each_nolock(ns->ns_rs_hash, ldlm_resource_clean,
901 cfs_hash_for_each_nolock(ns->ns_rs_hash, ldlm_resource_complain,
905 EXPORT_SYMBOL(ldlm_namespace_cleanup);
908 * Attempts to free namespace.
910 * Only used when namespace goes away, like during an unmount.
912 static int __ldlm_namespace_free(struct ldlm_namespace *ns, int force)
916 /* At shutdown time, don't call the cancellation callback */
917 ldlm_namespace_cleanup(ns, force ? LDLM_FL_LOCAL_ONLY : 0);
919 if (atomic_read(&ns->ns_bref) > 0) {
920 struct l_wait_info lwi = LWI_INTR(LWI_ON_SIGNAL_NOOP, NULL);
923 "dlm namespace %s free waiting on refcount %d\n",
924 ldlm_ns_name(ns), atomic_read(&ns->ns_bref));
927 lwi = LWI_TIMEOUT(msecs_to_jiffies(obd_timeout *
928 MSEC_PER_SEC) / 4, NULL, NULL);
930 rc = l_wait_event(ns->ns_waitq,
931 atomic_read(&ns->ns_bref) == 0, &lwi);
933 /* Forced cleanups should be able to reclaim all references,
934 * so it's safe to wait forever... we can't leak locks... */
935 if (force && rc == -ETIMEDOUT) {
936 LCONSOLE_ERROR("Forced cleanup waiting for %s "
937 "namespace with %d resources in use, "
938 "(rc=%d)\n", ldlm_ns_name(ns),
939 atomic_read(&ns->ns_bref), rc);
940 GOTO(force_wait, rc);
943 if (atomic_read(&ns->ns_bref)) {
944 LCONSOLE_ERROR("Cleanup waiting for %s namespace "
945 "with %d resources in use, (rc=%d)\n",
947 atomic_read(&ns->ns_bref), rc);
948 RETURN(ELDLM_NAMESPACE_EXISTS);
950 CDEBUG(D_DLMTRACE, "dlm namespace %s free done waiting\n",
958 * Performs various cleanups for passed \a ns to make it drop refc and be
959 * ready for freeing. Waits for refc == 0.
961 * The following is done:
962 * (0) Unregister \a ns from its list to make inaccessible for potential
963 * users like pools thread and others;
964 * (1) Clear all locks in \a ns.
966 void ldlm_namespace_free_prior(struct ldlm_namespace *ns,
967 struct obd_import *imp,
977 spin_lock(&ns->ns_lock);
979 spin_unlock(&ns->ns_lock);
982 * Can fail with -EINTR when force == 0 in which case try harder.
984 rc = __ldlm_namespace_free(ns, force);
985 if (rc != ELDLM_OK) {
987 ptlrpc_disconnect_import(imp, 0);
988 ptlrpc_invalidate_import(imp);
992 * With all requests dropped and the import inactive
993 * we are gaurenteed all reference will be dropped.
995 rc = __ldlm_namespace_free(ns, 1);
1000 EXPORT_SYMBOL(ldlm_namespace_free_prior);
1003 * Performs freeing memory structures related to \a ns. This is only done
1004 * when ldlm_namespce_free_prior() successfully removed all resources
1005 * referencing \a ns and its refc == 0.
1007 void ldlm_namespace_free_post(struct ldlm_namespace *ns)
1015 /* Make sure that nobody can find this ns in its list. */
1016 ldlm_namespace_unregister(ns, ns->ns_client);
1017 /* Fini pool _before_ parent proc dir is removed. This is important as
1018 * ldlm_pool_fini() removes own proc dir which is child to @dir.
1019 * Removing it after @dir may cause oops. */
1020 ldlm_pool_fini(&ns->ns_pool);
1022 ldlm_namespace_proc_unregister(ns);
1023 cfs_hash_putref(ns->ns_rs_hash);
1024 /* Namespace \a ns should be not on list at this time, otherwise
1025 * this will cause issues related to using freed \a ns in poold
1027 LASSERT(list_empty(&ns->ns_list_chain));
1032 EXPORT_SYMBOL(ldlm_namespace_free_post);
1035 * Cleanup the resource, and free namespace.
1038 * proc1: destroy import
1039 * class_disconnect_export(grab cl_sem) ->
1040 * -> ldlm_namespace_free ->
1041 * -> lprocfs_remove(grab _lprocfs_lock).
1042 * proc2: read proc info
1043 * lprocfs_fops_read(grab _lprocfs_lock) ->
1044 * -> osc_rd_active, etc(grab cl_sem).
1046 * So that I have to split the ldlm_namespace_free into two parts - the first
1047 * part ldlm_namespace_free_prior is used to cleanup the resource which is
1048 * being used; the 2nd part ldlm_namespace_free_post is used to unregister the
1049 * lprocfs entries, and then free memory. It will be called w/o cli->cl_sem
1052 void ldlm_namespace_free(struct ldlm_namespace *ns,
1053 struct obd_import *imp,
1056 ldlm_namespace_free_prior(ns, imp, force);
1057 ldlm_namespace_free_post(ns);
1059 EXPORT_SYMBOL(ldlm_namespace_free);
1061 void ldlm_namespace_get(struct ldlm_namespace *ns)
1063 atomic_inc(&ns->ns_bref);
1066 /* This is only for callers that care about refcount */
1067 static int ldlm_namespace_get_return(struct ldlm_namespace *ns)
1069 return atomic_inc_return(&ns->ns_bref);
1072 void ldlm_namespace_put(struct ldlm_namespace *ns)
1074 if (atomic_dec_and_lock(&ns->ns_bref, &ns->ns_lock)) {
1075 wake_up(&ns->ns_waitq);
1076 spin_unlock(&ns->ns_lock);
1080 /** Register \a ns in the list of namespaces */
1081 void ldlm_namespace_register(struct ldlm_namespace *ns, enum ldlm_side client)
1083 mutex_lock(ldlm_namespace_lock(client));
1084 LASSERT(list_empty(&ns->ns_list_chain));
1085 list_add(&ns->ns_list_chain, ldlm_namespace_inactive_list(client));
1086 ldlm_namespace_nr_inc(client);
1087 mutex_unlock(ldlm_namespace_lock(client));
1090 /** Unregister \a ns from the list of namespaces. */
1091 void ldlm_namespace_unregister(struct ldlm_namespace *ns, enum ldlm_side client)
1093 mutex_lock(ldlm_namespace_lock(client));
1094 LASSERT(!list_empty(&ns->ns_list_chain));
1095 /* Some asserts and possibly other parts of the code are still
1096 * using list_empty(&ns->ns_list_chain). This is why it is
1097 * important to use list_del_init() here. */
1098 list_del_init(&ns->ns_list_chain);
1099 ldlm_namespace_nr_dec(client);
1100 mutex_unlock(ldlm_namespace_lock(client));
1103 /** Should be called with ldlm_namespace_lock(client) taken. */
1104 void ldlm_namespace_move_to_active_locked(struct ldlm_namespace *ns,
1105 enum ldlm_side client)
1107 LASSERT(!list_empty(&ns->ns_list_chain));
1108 LASSERT(mutex_is_locked(ldlm_namespace_lock(client)));
1109 list_move_tail(&ns->ns_list_chain, ldlm_namespace_list(client));
1112 /** Should be called with ldlm_namespace_lock(client) taken. */
1113 void ldlm_namespace_move_to_inactive_locked(struct ldlm_namespace *ns,
1114 enum ldlm_side client)
1116 LASSERT(!list_empty(&ns->ns_list_chain));
1117 LASSERT(mutex_is_locked(ldlm_namespace_lock(client)));
1118 list_move_tail(&ns->ns_list_chain,
1119 ldlm_namespace_inactive_list(client));
1122 /** Should be called with ldlm_namespace_lock(client) taken. */
1123 struct ldlm_namespace *ldlm_namespace_first_locked(enum ldlm_side client)
1125 LASSERT(mutex_is_locked(ldlm_namespace_lock(client)));
1126 LASSERT(!list_empty(ldlm_namespace_list(client)));
1127 return container_of(ldlm_namespace_list(client)->next,
1128 struct ldlm_namespace, ns_list_chain);
1131 /** Create and initialize new resource. */
1132 static struct ldlm_resource *ldlm_resource_new(enum ldlm_type ldlm_type)
1134 struct ldlm_resource *res;
1137 OBD_SLAB_ALLOC_PTR_GFP(res, ldlm_resource_slab, GFP_NOFS);
1141 if (ldlm_type == LDLM_EXTENT) {
1142 OBD_SLAB_ALLOC(res->lr_itree, ldlm_interval_tree_slab,
1143 sizeof(*res->lr_itree) * LCK_MODE_NUM);
1144 if (res->lr_itree == NULL) {
1145 OBD_SLAB_FREE_PTR(res, ldlm_resource_slab);
1148 /* Initialize interval trees for each lock mode. */
1149 for (idx = 0; idx < LCK_MODE_NUM; idx++) {
1150 res->lr_itree[idx].lit_size = 0;
1151 res->lr_itree[idx].lit_mode = 1 << idx;
1152 res->lr_itree[idx].lit_root = NULL;
1156 INIT_LIST_HEAD(&res->lr_granted);
1157 INIT_LIST_HEAD(&res->lr_converting);
1158 INIT_LIST_HEAD(&res->lr_waiting);
1160 atomic_set(&res->lr_refcount, 1);
1161 spin_lock_init(&res->lr_lock);
1162 lu_ref_init(&res->lr_reference);
1164 /* Since LVB init can be delayed now, there is no longer need to
1165 * immediatelly acquire mutex here. */
1166 mutex_init(&res->lr_lvb_mutex);
1167 res->lr_lvb_initialized = false;
1173 * Return a reference to resource with given name, creating it if necessary.
1174 * Args: namespace with ns_lock unlocked
1175 * Locks: takes and releases NS hash-lock and res->lr_lock
1176 * Returns: referenced, unlocked ldlm_resource or NULL
1178 struct ldlm_resource *
1179 ldlm_resource_get(struct ldlm_namespace *ns, struct ldlm_resource *parent,
1180 const struct ldlm_res_id *name, enum ldlm_type type,
1183 struct hlist_node *hnode;
1184 struct ldlm_resource *res = NULL;
1185 struct cfs_hash_bd bd;
1187 int ns_refcount = 0;
1189 LASSERT(ns != NULL);
1190 LASSERT(parent == NULL);
1191 LASSERT(ns->ns_rs_hash != NULL);
1192 LASSERT(name->name[0] != 0);
1194 cfs_hash_bd_get_and_lock(ns->ns_rs_hash, (void *)name, &bd, 0);
1195 hnode = cfs_hash_bd_lookup_locked(ns->ns_rs_hash, &bd, (void *)name);
1196 if (hnode != NULL) {
1197 cfs_hash_bd_unlock(ns->ns_rs_hash, &bd, 0);
1201 version = cfs_hash_bd_version_get(&bd);
1202 cfs_hash_bd_unlock(ns->ns_rs_hash, &bd, 0);
1205 return ERR_PTR(-ENOENT);
1207 LASSERTF(type >= LDLM_MIN_TYPE && type < LDLM_MAX_TYPE,
1208 "type: %d\n", type);
1209 res = ldlm_resource_new(type);
1211 return ERR_PTR(-ENOMEM);
1213 res->lr_ns_bucket = cfs_hash_bd_extra_get(ns->ns_rs_hash, &bd);
1214 res->lr_name = *name;
1215 res->lr_type = type;
1217 cfs_hash_bd_lock(ns->ns_rs_hash, &bd, 1);
1218 hnode = (version == cfs_hash_bd_version_get(&bd)) ? NULL :
1219 cfs_hash_bd_lookup_locked(ns->ns_rs_hash, &bd, (void *)name);
1221 if (hnode != NULL) {
1222 /* Someone won the race and already added the resource. */
1223 cfs_hash_bd_unlock(ns->ns_rs_hash, &bd, 1);
1224 /* Clean lu_ref for failed resource. */
1225 lu_ref_fini(&res->lr_reference);
1226 if (res->lr_itree != NULL)
1227 OBD_SLAB_FREE(res->lr_itree, ldlm_interval_tree_slab,
1228 sizeof(*res->lr_itree) * LCK_MODE_NUM);
1229 OBD_SLAB_FREE(res, ldlm_resource_slab, sizeof *res);
1231 res = hlist_entry(hnode, struct ldlm_resource, lr_hash);
1234 /* We won! Let's add the resource. */
1235 cfs_hash_bd_add_locked(ns->ns_rs_hash, &bd, &res->lr_hash);
1236 if (cfs_hash_bd_count_get(&bd) == 1)
1237 ns_refcount = ldlm_namespace_get_return(ns);
1239 cfs_hash_bd_unlock(ns->ns_rs_hash, &bd, 1);
1241 OBD_FAIL_TIMEOUT(OBD_FAIL_LDLM_CREATE_RESOURCE, 2);
1243 /* Let's see if we happened to be the very first resource in this
1244 * namespace. If so, and this is a client namespace, we need to move
1245 * the namespace into the active namespaces list to be patrolled by
1246 * the ldlm_poold. */
1247 if (ns_is_client(ns) && ns_refcount == 1) {
1248 mutex_lock(ldlm_namespace_lock(LDLM_NAMESPACE_CLIENT));
1249 ldlm_namespace_move_to_active_locked(ns, LDLM_NAMESPACE_CLIENT);
1250 mutex_unlock(ldlm_namespace_lock(LDLM_NAMESPACE_CLIENT));
1255 EXPORT_SYMBOL(ldlm_resource_get);
1257 struct ldlm_resource *ldlm_resource_getref(struct ldlm_resource *res)
1259 LASSERT(res != NULL);
1260 LASSERT(res != LP_POISON);
1261 atomic_inc(&res->lr_refcount);
1262 CDEBUG(D_INFO, "getref res: %p count: %d\n", res,
1263 atomic_read(&res->lr_refcount));
1267 static void __ldlm_resource_putref_final(struct cfs_hash_bd *bd,
1268 struct ldlm_resource *res)
1270 struct ldlm_ns_bucket *nsb = res->lr_ns_bucket;
1272 if (!list_empty(&res->lr_granted)) {
1273 ldlm_resource_dump(D_ERROR, res);
1277 if (!list_empty(&res->lr_converting)) {
1278 ldlm_resource_dump(D_ERROR, res);
1282 if (!list_empty(&res->lr_waiting)) {
1283 ldlm_resource_dump(D_ERROR, res);
1287 cfs_hash_bd_del_locked(nsb->nsb_namespace->ns_rs_hash,
1289 lu_ref_fini(&res->lr_reference);
1290 if (cfs_hash_bd_count_get(bd) == 0)
1291 ldlm_namespace_put(nsb->nsb_namespace);
1294 /* Returns 1 if the resource was freed, 0 if it remains. */
1295 int ldlm_resource_putref(struct ldlm_resource *res)
1297 struct ldlm_namespace *ns = ldlm_res_to_ns(res);
1298 struct cfs_hash_bd bd;
1300 LASSERT_ATOMIC_GT_LT(&res->lr_refcount, 0, LI_POISON);
1301 CDEBUG(D_INFO, "putref res: %p count: %d\n",
1302 res, atomic_read(&res->lr_refcount) - 1);
1304 cfs_hash_bd_get(ns->ns_rs_hash, &res->lr_name, &bd);
1305 if (cfs_hash_bd_dec_and_lock(ns->ns_rs_hash, &bd, &res->lr_refcount)) {
1306 __ldlm_resource_putref_final(&bd, res);
1307 cfs_hash_bd_unlock(ns->ns_rs_hash, &bd, 1);
1308 if (ns->ns_lvbo && ns->ns_lvbo->lvbo_free)
1309 ns->ns_lvbo->lvbo_free(res);
1310 if (res->lr_itree != NULL)
1311 OBD_SLAB_FREE(res->lr_itree, ldlm_interval_tree_slab,
1312 sizeof(*res->lr_itree) * LCK_MODE_NUM);
1313 OBD_SLAB_FREE(res, ldlm_resource_slab, sizeof *res);
1318 EXPORT_SYMBOL(ldlm_resource_putref);
1321 * Add a lock into a given resource into specified lock list.
1323 void ldlm_resource_add_lock(struct ldlm_resource *res, struct list_head *head,
1324 struct ldlm_lock *lock)
1326 check_res_locked(res);
1328 LDLM_DEBUG(lock, "About to add this lock");
1330 if (ldlm_is_destroyed(lock)) {
1331 CDEBUG(D_OTHER, "Lock destroyed, not adding to resource\n");
1335 LASSERT(list_empty(&lock->l_res_link));
1337 list_add_tail(&lock->l_res_link, head);
1341 * Insert a lock into resource after specified lock.
1343 * Obtain resource description from the lock we are inserting after.
1345 void ldlm_resource_insert_lock_after(struct ldlm_lock *original,
1346 struct ldlm_lock *new)
1348 struct ldlm_resource *res = original->l_resource;
1350 check_res_locked(res);
1352 ldlm_resource_dump(D_INFO, res);
1353 LDLM_DEBUG(new, "About to insert this lock after %p: ", original);
1355 if (ldlm_is_destroyed(new)) {
1356 CDEBUG(D_OTHER, "Lock destroyed, not adding to resource\n");
1360 LASSERT(list_empty(&new->l_res_link));
1362 list_add(&new->l_res_link, &original->l_res_link);
1366 void ldlm_resource_unlink_lock(struct ldlm_lock *lock)
1368 int type = lock->l_resource->lr_type;
1370 check_res_locked(lock->l_resource);
1371 if (type == LDLM_IBITS || type == LDLM_PLAIN)
1372 ldlm_unlink_lock_skiplist(lock);
1373 else if (type == LDLM_EXTENT)
1374 ldlm_extent_unlink_lock(lock);
1375 list_del_init(&lock->l_res_link);
1377 EXPORT_SYMBOL(ldlm_resource_unlink_lock);
1379 void ldlm_res2desc(struct ldlm_resource *res, struct ldlm_resource_desc *desc)
1381 desc->lr_type = res->lr_type;
1382 desc->lr_name = res->lr_name;
1386 * Print information about all locks in all namespaces on this node to debug
1389 void ldlm_dump_all_namespaces(enum ldlm_side client, int level)
1391 struct list_head *tmp;
1393 if (!((libcfs_debug | D_ERROR) & level))
1396 mutex_lock(ldlm_namespace_lock(client));
1398 list_for_each(tmp, ldlm_namespace_list(client)) {
1399 struct ldlm_namespace *ns;
1401 ns = list_entry(tmp, struct ldlm_namespace, ns_list_chain);
1402 ldlm_namespace_dump(level, ns);
1405 mutex_unlock(ldlm_namespace_lock(client));
1408 static int ldlm_res_hash_dump(struct cfs_hash *hs, struct cfs_hash_bd *bd,
1409 struct hlist_node *hnode, void *arg)
1411 struct ldlm_resource *res = cfs_hash_object(hs, hnode);
1412 int level = (int)(unsigned long)arg;
1415 ldlm_resource_dump(level, res);
1422 * Print information about all locks in this namespace on this node to debug
1425 void ldlm_namespace_dump(int level, struct ldlm_namespace *ns)
1427 if (!((libcfs_debug | D_ERROR) & level))
1430 CDEBUG(level, "--- Namespace: %s (rc: %d, side: %s)\n",
1431 ldlm_ns_name(ns), atomic_read(&ns->ns_bref),
1432 ns_is_client(ns) ? "client" : "server");
1434 if (cfs_time_before(cfs_time_current(), ns->ns_next_dump))
1437 cfs_hash_for_each_nolock(ns->ns_rs_hash,
1439 (void *)(unsigned long)level, 0);
1440 spin_lock(&ns->ns_lock);
1441 ns->ns_next_dump = cfs_time_shift(10);
1442 spin_unlock(&ns->ns_lock);
1446 * Print information about all locks in this resource to debug log.
1448 void ldlm_resource_dump(int level, struct ldlm_resource *res)
1450 struct ldlm_lock *lock;
1451 unsigned int granted = 0;
1453 CLASSERT(RES_NAME_SIZE == 4);
1455 if (!((libcfs_debug | D_ERROR) & level))
1458 CDEBUG(level, "--- Resource: "DLDLMRES" (%p) refcount = %d\n",
1459 PLDLMRES(res), res, atomic_read(&res->lr_refcount));
1461 if (!list_empty(&res->lr_granted)) {
1462 CDEBUG(level, "Granted locks (in reverse order):\n");
1463 list_for_each_entry_reverse(lock, &res->lr_granted,
1465 LDLM_DEBUG_LIMIT(level, lock, "###");
1466 if (!(level & D_CANTMASK) &&
1467 ++granted > ldlm_dump_granted_max) {
1468 CDEBUG(level, "only dump %d granted locks to "
1469 "avoid DDOS.\n", granted);
1474 if (!list_empty(&res->lr_converting)) {
1475 CDEBUG(level, "Converting locks:\n");
1476 list_for_each_entry(lock, &res->lr_converting, l_res_link)
1477 LDLM_DEBUG_LIMIT(level, lock, "###");
1479 if (!list_empty(&res->lr_waiting)) {
1480 CDEBUG(level, "Waiting locks:\n");
1481 list_for_each_entry(lock, &res->lr_waiting, l_res_link)
1482 LDLM_DEBUG_LIMIT(level, lock, "###");
1485 EXPORT_SYMBOL(ldlm_resource_dump);