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, 2013, 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
44 # include <lustre_dlm.h>
46 # include <liblustre.h>
49 #include <lustre_fid.h>
50 #include <obd_class.h>
51 #include "ldlm_internal.h"
53 struct kmem_cache *ldlm_resource_slab, *ldlm_lock_slab;
55 int ldlm_srv_namespace_nr = 0;
56 int ldlm_cli_namespace_nr = 0;
58 struct mutex ldlm_srv_namespace_lock;
59 CFS_LIST_HEAD(ldlm_srv_namespace_list);
61 struct mutex ldlm_cli_namespace_lock;
62 /* Client Namespaces that have active resources in them.
63 * Once all resources go away, ldlm_poold moves such namespaces to the
65 CFS_LIST_HEAD(ldlm_cli_active_namespace_list);
66 /* Client namespaces that don't have any locks in them */
67 CFS_LIST_HEAD(ldlm_cli_inactive_namespace_list);
69 struct proc_dir_entry *ldlm_type_proc_dir = NULL;
70 struct proc_dir_entry *ldlm_ns_proc_dir = NULL;
71 struct proc_dir_entry *ldlm_svc_proc_dir = NULL;
73 extern unsigned int ldlm_cancel_unused_locks_before_replay;
75 /* during debug dump certain amount of granted locks for one resource to avoid
77 unsigned int ldlm_dump_granted_max = 256;
81 lprocfs_dump_ns_seq_write(struct file *file, const char *buffer,
82 size_t count, loff_t *off)
84 ldlm_dump_all_namespaces(LDLM_NAMESPACE_SERVER, D_DLMTRACE);
85 ldlm_dump_all_namespaces(LDLM_NAMESPACE_CLIENT, D_DLMTRACE);
88 LPROC_SEQ_FOPS_WO_TYPE(ldlm, dump_ns);
90 LPROC_SEQ_FOPS_RW_TYPE(ldlm_rw, uint);
91 LPROC_SEQ_FOPS_RO_TYPE(ldlm, uint);
93 int ldlm_proc_setup(void)
96 struct lprocfs_seq_vars list[] = {
97 { .name = "dump_namespaces",
98 .fops = &ldlm_dump_ns_fops,
100 { .name = "dump_granted_max",
101 .fops = &ldlm_rw_uint_fops,
102 .data = &ldlm_dump_granted_max },
103 { .name = "cancel_unused_locks_before_replay",
104 .fops = &ldlm_rw_uint_fops,
105 .data = &ldlm_cancel_unused_locks_before_replay },
108 LASSERT(ldlm_ns_proc_dir == NULL);
110 ldlm_type_proc_dir = lprocfs_seq_register(OBD_LDLM_DEVICENAME,
113 if (IS_ERR(ldlm_type_proc_dir)) {
114 CERROR("LProcFS failed in ldlm-init\n");
115 rc = PTR_ERR(ldlm_type_proc_dir);
119 ldlm_ns_proc_dir = lprocfs_seq_register("namespaces",
122 if (IS_ERR(ldlm_ns_proc_dir)) {
123 CERROR("LProcFS failed in ldlm-init\n");
124 rc = PTR_ERR(ldlm_ns_proc_dir);
128 ldlm_svc_proc_dir = lprocfs_seq_register("services",
131 if (IS_ERR(ldlm_svc_proc_dir)) {
132 CERROR("LProcFS failed in ldlm-init\n");
133 rc = PTR_ERR(ldlm_svc_proc_dir);
137 rc = lprocfs_seq_add_vars(ldlm_type_proc_dir, list, NULL);
139 CERROR("LProcFS failed in ldlm-init\n");
146 lprocfs_remove(&ldlm_svc_proc_dir);
148 lprocfs_remove(&ldlm_ns_proc_dir);
150 lprocfs_remove(&ldlm_type_proc_dir);
152 ldlm_svc_proc_dir = NULL;
156 void ldlm_proc_cleanup(void)
158 if (ldlm_svc_proc_dir)
159 lprocfs_remove(&ldlm_svc_proc_dir);
161 if (ldlm_ns_proc_dir)
162 lprocfs_remove(&ldlm_ns_proc_dir);
164 if (ldlm_type_proc_dir)
165 lprocfs_remove(&ldlm_type_proc_dir);
168 static int lprocfs_ns_resources_seq_show(struct seq_file *m, void *v)
170 struct ldlm_namespace *ns = m->private;
175 /* result is not strictly consistant */
176 cfs_hash_for_each_bucket(ns->ns_rs_hash, &bd, i)
177 res += cfs_hash_bd_count_get(&bd);
178 return lprocfs_u64_seq_show(m, &res);
180 LPROC_SEQ_FOPS_RO(lprocfs_ns_resources);
182 static int lprocfs_ns_locks_seq_show(struct seq_file *m, void *v)
184 struct ldlm_namespace *ns = m->private;
187 locks = lprocfs_stats_collector(ns->ns_stats, LDLM_NSS_LOCKS,
188 LPROCFS_FIELDS_FLAGS_SUM);
189 return lprocfs_u64_seq_show(m, &locks);
191 LPROC_SEQ_FOPS_RO(lprocfs_ns_locks);
193 static int lprocfs_lru_size_seq_show(struct seq_file *m, void *v)
195 struct ldlm_namespace *ns = m->private;
196 __u32 *nr = &ns->ns_max_unused;
198 if (ns_connect_lru_resize(ns))
199 nr = &ns->ns_nr_unused;
200 return lprocfs_uint_seq_show(m, nr);
203 static ssize_t lprocfs_lru_size_seq_write(struct file *file, const char *buffer,
204 size_t count, loff_t *off)
206 struct ldlm_namespace *ns = ((struct seq_file *)file->private_data)->private;
207 char dummy[MAX_STRING_SIZE + 1], *end;
211 dummy[MAX_STRING_SIZE] = '\0';
212 if (copy_from_user(dummy, buffer, MAX_STRING_SIZE))
215 if (strncmp(dummy, "clear", 5) == 0) {
217 "dropping all unused locks from namespace %s\n",
219 if (ns_connect_lru_resize(ns)) {
220 int canceled, unused = ns->ns_nr_unused;
222 /* Try to cancel all @ns_nr_unused locks. */
223 canceled = ldlm_cancel_lru(ns, unused, 0,
225 if (canceled < unused) {
227 "not all requested locks are canceled, "
228 "requested: %d, canceled: %d\n", unused,
233 tmp = ns->ns_max_unused;
234 ns->ns_max_unused = 0;
235 ldlm_cancel_lru(ns, 0, 0, LDLM_CANCEL_PASSED);
236 ns->ns_max_unused = tmp;
241 tmp = simple_strtoul(dummy, &end, 0);
243 CERROR("invalid value written\n");
246 lru_resize = (tmp == 0);
248 if (ns_connect_lru_resize(ns)) {
250 ns->ns_max_unused = (unsigned int)tmp;
252 if (tmp > ns->ns_nr_unused)
253 tmp = ns->ns_nr_unused;
254 tmp = ns->ns_nr_unused - tmp;
257 "changing namespace %s unused locks from %u to %u\n",
258 ldlm_ns_name(ns), ns->ns_nr_unused,
260 ldlm_cancel_lru(ns, tmp, LCF_ASYNC, LDLM_CANCEL_PASSED);
264 "disable lru_resize for namespace %s\n",
266 ns->ns_connect_flags &= ~OBD_CONNECT_LRU_RESIZE;
270 "changing namespace %s max_unused from %u to %u\n",
271 ldlm_ns_name(ns), ns->ns_max_unused,
273 ns->ns_max_unused = (unsigned int)tmp;
274 ldlm_cancel_lru(ns, 0, LCF_ASYNC, LDLM_CANCEL_PASSED);
276 /* Make sure that LRU resize was originally supported before
277 * turning it on here. */
279 (ns->ns_orig_connect_flags & OBD_CONNECT_LRU_RESIZE)) {
281 "enable lru_resize for namespace %s\n",
283 ns->ns_connect_flags |= OBD_CONNECT_LRU_RESIZE;
289 LPROC_SEQ_FOPS(lprocfs_lru_size);
291 static int lprocfs_elc_seq_show(struct seq_file *m, void *v)
293 struct ldlm_namespace *ns = m->private;
294 unsigned int supp = ns_connect_cancelset(ns);
296 return lprocfs_uint_seq_show(m, &supp);
299 static ssize_t lprocfs_elc_seq_write(struct file *file, const char *buffer,
300 size_t count, loff_t *off)
302 struct ldlm_namespace *ns = ((struct seq_file *)file->private_data)->private;
303 unsigned int supp = -1;
306 rc = lprocfs_wr_uint(file, buffer, count, &supp);
311 ns->ns_connect_flags &= ~OBD_CONNECT_CANCELSET;
312 else if (ns->ns_orig_connect_flags & OBD_CONNECT_CANCELSET)
313 ns->ns_connect_flags |= OBD_CONNECT_CANCELSET;
316 LPROC_SEQ_FOPS(lprocfs_elc);
318 void ldlm_namespace_proc_unregister(struct ldlm_namespace *ns)
320 if (ns->ns_proc_dir_entry == NULL)
321 CERROR("dlm namespace %s has no procfs dir?\n",
324 lprocfs_remove(&ns->ns_proc_dir_entry);
326 if (ns->ns_stats != NULL)
327 lprocfs_free_stats(&ns->ns_stats);
330 int ldlm_namespace_proc_register(struct ldlm_namespace *ns)
332 struct lprocfs_seq_vars lock_vars[2];
333 char lock_name[MAX_STRING_SIZE + 1];
334 struct proc_dir_entry *ns_pde;
337 LASSERT(ns->ns_rs_hash != NULL);
339 if (ns->ns_proc_dir_entry != NULL) {
340 ns_pde = ns->ns_proc_dir_entry;
342 ns_pde = proc_mkdir(ldlm_ns_name(ns), ldlm_ns_proc_dir);
345 ns->ns_proc_dir_entry = ns_pde;
348 ns->ns_stats = lprocfs_alloc_stats(LDLM_NSS_LAST, 0);
349 if (ns->ns_stats == NULL)
352 lprocfs_counter_init(ns->ns_stats, LDLM_NSS_LOCKS,
353 LPROCFS_CNTR_AVGMINMAX, "locks", "locks");
355 lock_name[MAX_STRING_SIZE] = '\0';
357 memset(lock_vars, 0, sizeof(lock_vars));
358 lock_vars[0].name = lock_name;
360 ldlm_add_var(&lock_vars[0], ns_pde, "resource_count", ns,
361 &lprocfs_ns_resources_fops);
362 ldlm_add_var(&lock_vars[0], ns_pde, "lock_count", ns,
363 &lprocfs_ns_locks_fops);
365 if (ns_is_client(ns)) {
366 ldlm_add_var(&lock_vars[0], ns_pde, "lock_unused_count",
367 &ns->ns_nr_unused, &ldlm_uint_fops);
368 ldlm_add_var(&lock_vars[0], ns_pde, "lru_size", ns,
369 &lprocfs_lru_size_fops);
370 ldlm_add_var(&lock_vars[0], ns_pde, "lru_max_age",
371 &ns->ns_max_age, &ldlm_rw_uint_fops);
372 ldlm_add_var(&lock_vars[0], ns_pde, "early_lock_cancel",
373 ns, &lprocfs_elc_fops);
375 ldlm_add_var(&lock_vars[0], ns_pde, "ctime_age_limit",
376 &ns->ns_ctime_age_limit, &ldlm_rw_uint_fops);
377 ldlm_add_var(&lock_vars[0], ns_pde, "lock_timeouts",
378 &ns->ns_timeouts, &ldlm_uint_fops);
379 ldlm_add_var(&lock_vars[0], ns_pde, "max_nolock_bytes",
380 &ns->ns_max_nolock_size, &ldlm_rw_uint_fops);
381 ldlm_add_var(&lock_vars[0], ns_pde, "contention_seconds",
382 &ns->ns_contention_time, &ldlm_rw_uint_fops);
383 ldlm_add_var(&lock_vars[0], ns_pde, "contended_locks",
384 &ns->ns_contended_locks, &ldlm_rw_uint_fops);
385 ldlm_add_var(&lock_vars[0], ns_pde, "max_parallel_ast",
386 &ns->ns_max_parallel_ast, &ldlm_rw_uint_fops);
390 #undef MAX_STRING_SIZE
393 #define ldlm_namespace_proc_unregister(ns) ({;})
394 #define ldlm_namespace_proc_register(ns) ({0;})
398 static unsigned ldlm_res_hop_hash(cfs_hash_t *hs,
399 const void *key, unsigned mask)
401 const struct ldlm_res_id *id = key;
405 for (i = 0; i < RES_NAME_SIZE; i++)
410 static unsigned ldlm_res_hop_fid_hash(cfs_hash_t *hs,
411 const void *key, unsigned mask)
413 const struct ldlm_res_id *id = key;
418 fid.f_seq = id->name[LUSTRE_RES_ID_SEQ_OFF];
419 fid.f_oid = (__u32)id->name[LUSTRE_RES_ID_VER_OID_OFF];
420 fid.f_ver = (__u32)(id->name[LUSTRE_RES_ID_VER_OID_OFF] >> 32);
422 hash = fid_flatten32(&fid);
423 hash += (hash >> 4) + (hash << 12); /* mixing oid and seq */
424 if (id->name[LUSTRE_RES_ID_HSH_OFF] != 0) {
425 val = id->name[LUSTRE_RES_ID_HSH_OFF];
426 hash += (val >> 5) + (val << 11);
430 hash = hash_long(hash, hs->hs_bkt_bits);
431 /* give me another random factor */
432 hash -= hash_long((unsigned long)hs, val % 11 + 3);
434 hash <<= hs->hs_cur_bits - hs->hs_bkt_bits;
435 hash |= ldlm_res_hop_hash(hs, key, CFS_HASH_NBKT(hs) - 1);
440 static void *ldlm_res_hop_key(cfs_hlist_node_t *hnode)
442 struct ldlm_resource *res;
444 res = cfs_hlist_entry(hnode, struct ldlm_resource, lr_hash);
445 return &res->lr_name;
448 static int ldlm_res_hop_keycmp(const void *key, cfs_hlist_node_t *hnode)
450 struct ldlm_resource *res;
452 res = cfs_hlist_entry(hnode, struct ldlm_resource, lr_hash);
453 return ldlm_res_eq((const struct ldlm_res_id *)key,
454 (const struct ldlm_res_id *)&res->lr_name);
457 static void *ldlm_res_hop_object(cfs_hlist_node_t *hnode)
459 return cfs_hlist_entry(hnode, struct ldlm_resource, lr_hash);
462 static void ldlm_res_hop_get_locked(cfs_hash_t *hs, cfs_hlist_node_t *hnode)
464 struct ldlm_resource *res;
466 res = cfs_hlist_entry(hnode, struct ldlm_resource, lr_hash);
467 ldlm_resource_getref(res);
470 static void ldlm_res_hop_put_locked(cfs_hash_t *hs, cfs_hlist_node_t *hnode)
472 struct ldlm_resource *res;
474 res = cfs_hlist_entry(hnode, struct ldlm_resource, lr_hash);
475 /* cfs_hash_for_each_nolock is the only chance we call it */
476 ldlm_resource_putref_locked(res);
479 static void ldlm_res_hop_put(cfs_hash_t *hs, cfs_hlist_node_t *hnode)
481 struct ldlm_resource *res;
483 res = cfs_hlist_entry(hnode, struct ldlm_resource, lr_hash);
484 ldlm_resource_putref(res);
487 cfs_hash_ops_t ldlm_ns_hash_ops = {
488 .hs_hash = ldlm_res_hop_hash,
489 .hs_key = ldlm_res_hop_key,
490 .hs_keycmp = ldlm_res_hop_keycmp,
492 .hs_object = ldlm_res_hop_object,
493 .hs_get = ldlm_res_hop_get_locked,
494 .hs_put_locked = ldlm_res_hop_put_locked,
495 .hs_put = ldlm_res_hop_put
498 cfs_hash_ops_t ldlm_ns_fid_hash_ops = {
499 .hs_hash = ldlm_res_hop_fid_hash,
500 .hs_key = ldlm_res_hop_key,
501 .hs_keycmp = ldlm_res_hop_keycmp,
503 .hs_object = ldlm_res_hop_object,
504 .hs_get = ldlm_res_hop_get_locked,
505 .hs_put_locked = ldlm_res_hop_put_locked,
506 .hs_put = ldlm_res_hop_put
510 ldlm_ns_type_t nsd_type;
511 /** hash bucket bits */
512 unsigned nsd_bkt_bits;
514 unsigned nsd_all_bits;
515 /** hash operations */
516 cfs_hash_ops_t *nsd_hops;
517 } ldlm_ns_hash_def_t;
519 ldlm_ns_hash_def_t ldlm_ns_hash_defs[] =
522 .nsd_type = LDLM_NS_TYPE_MDC,
525 .nsd_hops = &ldlm_ns_fid_hash_ops,
528 .nsd_type = LDLM_NS_TYPE_MDT,
531 .nsd_hops = &ldlm_ns_fid_hash_ops,
534 .nsd_type = LDLM_NS_TYPE_OSC,
537 .nsd_hops = &ldlm_ns_hash_ops,
540 .nsd_type = LDLM_NS_TYPE_OST,
543 .nsd_hops = &ldlm_ns_hash_ops,
546 .nsd_type = LDLM_NS_TYPE_MGC,
549 .nsd_hops = &ldlm_ns_hash_ops,
552 .nsd_type = LDLM_NS_TYPE_MGT,
555 .nsd_hops = &ldlm_ns_hash_ops,
558 .nsd_type = LDLM_NS_TYPE_UNKNOWN,
563 * Create and initialize new empty namespace.
565 struct ldlm_namespace *ldlm_namespace_new(struct obd_device *obd, char *name,
568 ldlm_ns_type_t ns_type)
570 struct ldlm_namespace *ns = NULL;
571 struct ldlm_ns_bucket *nsb;
572 ldlm_ns_hash_def_t *nsd;
578 LASSERT(obd != NULL);
582 CERROR("ldlm_get_ref failed: %d\n", rc);
586 for (idx = 0;;idx++) {
587 nsd = &ldlm_ns_hash_defs[idx];
588 if (nsd->nsd_type == LDLM_NS_TYPE_UNKNOWN) {
589 CERROR("Unknown type %d for ns %s\n", ns_type, name);
593 if (nsd->nsd_type == ns_type)
601 ns->ns_rs_hash = cfs_hash_create(name,
602 nsd->nsd_all_bits, nsd->nsd_all_bits,
603 nsd->nsd_bkt_bits, sizeof(*nsb),
609 CFS_HASH_SPIN_BKTLOCK |
610 CFS_HASH_NO_ITEMREF);
611 if (ns->ns_rs_hash == NULL)
614 cfs_hash_for_each_bucket(ns->ns_rs_hash, &bd, idx) {
615 nsb = cfs_hash_bd_extra_get(ns->ns_rs_hash, &bd);
616 at_init(&nsb->nsb_at_estimate, ldlm_enqueue_min, 0);
617 nsb->nsb_namespace = ns;
621 ns->ns_appetite = apt;
622 ns->ns_client = client;
624 CFS_INIT_LIST_HEAD(&ns->ns_list_chain);
625 CFS_INIT_LIST_HEAD(&ns->ns_unused_list);
626 spin_lock_init(&ns->ns_lock);
627 atomic_set(&ns->ns_bref, 0);
628 init_waitqueue_head(&ns->ns_waitq);
630 ns->ns_max_nolock_size = NS_DEFAULT_MAX_NOLOCK_BYTES;
631 ns->ns_contention_time = NS_DEFAULT_CONTENTION_SECONDS;
632 ns->ns_contended_locks = NS_DEFAULT_CONTENDED_LOCKS;
634 ns->ns_max_parallel_ast = LDLM_DEFAULT_PARALLEL_AST_LIMIT;
635 ns->ns_nr_unused = 0;
636 ns->ns_max_unused = LDLM_DEFAULT_LRU_SIZE;
637 ns->ns_max_age = LDLM_DEFAULT_MAX_ALIVE;
638 ns->ns_ctime_age_limit = LDLM_CTIME_AGE_LIMIT;
640 ns->ns_orig_connect_flags = 0;
641 ns->ns_connect_flags = 0;
643 rc = ldlm_namespace_proc_register(ns);
645 CERROR("Can't initialize ns proc, rc %d\n", rc);
649 idx = ldlm_namespace_nr_read(client);
650 rc = ldlm_pool_init(&ns->ns_pool, ns, idx, client);
652 CERROR("Can't initialize lock pool, rc %d\n", rc);
656 ldlm_namespace_register(ns, client);
659 ldlm_namespace_proc_unregister(ns);
660 ldlm_namespace_cleanup(ns, 0);
662 cfs_hash_putref(ns->ns_rs_hash);
669 EXPORT_SYMBOL(ldlm_namespace_new);
671 extern struct ldlm_lock *ldlm_lock_get(struct ldlm_lock *lock);
674 * Cancel and destroy all locks on a resource.
676 * If flags contains FL_LOCAL_ONLY, don't try to tell the server, just
677 * clean up. This is currently only used for recovery, and we make
678 * certain assumptions as a result--notably, that we shouldn't cancel
681 static void cleanup_resource(struct ldlm_resource *res, cfs_list_t *q,
685 int rc = 0, client = ns_is_client(ldlm_res_to_ns(res));
686 bool local_only = !!(flags & LDLM_FL_LOCAL_ONLY);
689 struct ldlm_lock *lock = NULL;
691 /* First, we look for non-cleaned-yet lock
692 * all cleaned locks are marked by CLEANED flag. */
694 cfs_list_for_each(tmp, q) {
695 lock = cfs_list_entry(tmp, struct ldlm_lock,
697 if (ldlm_is_cleaned(lock)) {
702 ldlm_set_cleaned(lock);
711 /* Set CBPENDING so nothing in the cancellation path
712 * can match this lock. */
713 ldlm_set_cbpending(lock);
714 ldlm_set_failed(lock);
715 lock->l_flags |= flags;
717 /* ... without sending a CANCEL message for local_only. */
719 ldlm_set_local_only(lock);
721 if (local_only && (lock->l_readers || lock->l_writers)) {
722 /* This is a little bit gross, but much better than the
723 * alternative: pretend that we got a blocking AST from
724 * the server, so that when the lock is decref'd, it
725 * will go away ... */
727 LDLM_DEBUG(lock, "setting FL_LOCAL_ONLY");
728 if (lock->l_flags & LDLM_FL_FAIL_LOC) {
729 schedule_timeout_and_set_state(
730 TASK_UNINTERRUPTIBLE,
731 cfs_time_seconds(4));
732 set_current_state(TASK_RUNNING);
734 if (lock->l_completion_ast)
735 lock->l_completion_ast(lock,
736 LDLM_FL_FAILED, NULL);
737 LDLM_LOCK_RELEASE(lock);
742 struct lustre_handle lockh;
745 ldlm_lock2handle(lock, &lockh);
746 rc = ldlm_cli_cancel(&lockh, LCF_ASYNC);
748 CERROR("ldlm_cli_cancel: %d\n", rc);
750 ldlm_resource_unlink_lock(lock);
752 LDLM_DEBUG(lock, "Freeing a lock still held by a "
754 ldlm_lock_destroy(lock);
756 LDLM_LOCK_RELEASE(lock);
760 static int ldlm_resource_clean(cfs_hash_t *hs, cfs_hash_bd_t *bd,
761 cfs_hlist_node_t *hnode, void *arg)
763 struct ldlm_resource *res = cfs_hash_object(hs, hnode);
764 __u64 flags = *(__u64 *)arg;
766 cleanup_resource(res, &res->lr_granted, flags);
767 cleanup_resource(res, &res->lr_converting, flags);
768 cleanup_resource(res, &res->lr_waiting, flags);
773 static int ldlm_resource_complain(cfs_hash_t *hs, cfs_hash_bd_t *bd,
774 cfs_hlist_node_t *hnode, void *arg)
776 struct ldlm_resource *res = cfs_hash_object(hs, hnode);
779 CERROR("%s: namespace resource "DLDLMRES" (%p) refcount nonzero "
780 "(%d) after lock cleanup; forcing cleanup.\n",
781 ldlm_ns_name(ldlm_res_to_ns(res)), PLDLMRES(res), res,
782 atomic_read(&res->lr_refcount) - 1);
784 ldlm_resource_dump(D_ERROR, res);
790 * Cancel and destroy all locks in the namespace.
792 * Typically used during evictions when server notified client that it was
793 * evicted and all of its state needs to be destroyed.
794 * Also used during shutdown.
796 int ldlm_namespace_cleanup(struct ldlm_namespace *ns, __u64 flags)
799 CDEBUG(D_INFO, "NULL ns, skipping cleanup\n");
803 cfs_hash_for_each_nolock(ns->ns_rs_hash, ldlm_resource_clean, &flags);
804 cfs_hash_for_each_nolock(ns->ns_rs_hash, ldlm_resource_complain, NULL);
807 EXPORT_SYMBOL(ldlm_namespace_cleanup);
810 * Attempts to free namespace.
812 * Only used when namespace goes away, like during an unmount.
814 static int __ldlm_namespace_free(struct ldlm_namespace *ns, int force)
818 /* At shutdown time, don't call the cancellation callback */
819 ldlm_namespace_cleanup(ns, force ? LDLM_FL_LOCAL_ONLY : 0);
821 if (atomic_read(&ns->ns_bref) > 0) {
822 struct l_wait_info lwi = LWI_INTR(LWI_ON_SIGNAL_NOOP, NULL);
825 "dlm namespace %s free waiting on refcount %d\n",
826 ldlm_ns_name(ns), atomic_read(&ns->ns_bref));
829 lwi = LWI_TIMEOUT(obd_timeout * HZ / 4, NULL, NULL);
831 rc = l_wait_event(ns->ns_waitq,
832 atomic_read(&ns->ns_bref) == 0, &lwi);
834 /* Forced cleanups should be able to reclaim all references,
835 * so it's safe to wait forever... we can't leak locks... */
836 if (force && rc == -ETIMEDOUT) {
837 LCONSOLE_ERROR("Forced cleanup waiting for %s "
838 "namespace with %d resources in use, "
839 "(rc=%d)\n", ldlm_ns_name(ns),
840 atomic_read(&ns->ns_bref), rc);
841 GOTO(force_wait, rc);
844 if (atomic_read(&ns->ns_bref)) {
845 LCONSOLE_ERROR("Cleanup waiting for %s namespace "
846 "with %d resources in use, (rc=%d)\n",
848 atomic_read(&ns->ns_bref), rc);
849 RETURN(ELDLM_NAMESPACE_EXISTS);
851 CDEBUG(D_DLMTRACE, "dlm namespace %s free done waiting\n",
859 * Performs various cleanups for passed \a ns to make it drop refc and be
860 * ready for freeing. Waits for refc == 0.
862 * The following is done:
863 * (0) Unregister \a ns from its list to make inaccessible for potential
864 * users like pools thread and others;
865 * (1) Clear all locks in \a ns.
867 void ldlm_namespace_free_prior(struct ldlm_namespace *ns,
868 struct obd_import *imp,
878 spin_lock(&ns->ns_lock);
880 spin_unlock(&ns->ns_lock);
883 * Can fail with -EINTR when force == 0 in which case try harder.
885 rc = __ldlm_namespace_free(ns, force);
886 if (rc != ELDLM_OK) {
888 ptlrpc_disconnect_import(imp, 0);
889 ptlrpc_invalidate_import(imp);
893 * With all requests dropped and the import inactive
894 * we are gaurenteed all reference will be dropped.
896 rc = __ldlm_namespace_free(ns, 1);
903 * Performs freeing memory structures related to \a ns. This is only done
904 * when ldlm_namespce_free_prior() successfully removed all resources
905 * referencing \a ns and its refc == 0.
907 void ldlm_namespace_free_post(struct ldlm_namespace *ns)
915 /* Make sure that nobody can find this ns in its list. */
916 ldlm_namespace_unregister(ns, ns->ns_client);
917 /* Fini pool _before_ parent proc dir is removed. This is important as
918 * ldlm_pool_fini() removes own proc dir which is child to @dir.
919 * Removing it after @dir may cause oops. */
920 ldlm_pool_fini(&ns->ns_pool);
922 ldlm_namespace_proc_unregister(ns);
923 cfs_hash_putref(ns->ns_rs_hash);
924 /* Namespace \a ns should be not on list at this time, otherwise
925 * this will cause issues related to using freed \a ns in poold
927 LASSERT(cfs_list_empty(&ns->ns_list_chain));
934 * Cleanup the resource, and free namespace.
937 * proc1: destroy import
938 * class_disconnect_export(grab cl_sem) ->
939 * -> ldlm_namespace_free ->
940 * -> lprocfs_remove(grab _lprocfs_lock).
941 * proc2: read proc info
942 * lprocfs_fops_read(grab _lprocfs_lock) ->
943 * -> osc_rd_active, etc(grab cl_sem).
945 * So that I have to split the ldlm_namespace_free into two parts - the first
946 * part ldlm_namespace_free_prior is used to cleanup the resource which is
947 * being used; the 2nd part ldlm_namespace_free_post is used to unregister the
948 * lprocfs entries, and then free memory. It will be called w/o cli->cl_sem
951 void ldlm_namespace_free(struct ldlm_namespace *ns,
952 struct obd_import *imp,
955 ldlm_namespace_free_prior(ns, imp, force);
956 ldlm_namespace_free_post(ns);
958 EXPORT_SYMBOL(ldlm_namespace_free);
960 void ldlm_namespace_get(struct ldlm_namespace *ns)
962 atomic_inc(&ns->ns_bref);
964 EXPORT_SYMBOL(ldlm_namespace_get);
966 /* This is only for callers that care about refcount */
967 int ldlm_namespace_get_return(struct ldlm_namespace *ns)
969 return atomic_inc_return(&ns->ns_bref);
972 void ldlm_namespace_put(struct ldlm_namespace *ns)
974 if (atomic_dec_and_lock(&ns->ns_bref, &ns->ns_lock)) {
975 wake_up(&ns->ns_waitq);
976 spin_unlock(&ns->ns_lock);
979 EXPORT_SYMBOL(ldlm_namespace_put);
981 /** Register \a ns in the list of namespaces */
982 void ldlm_namespace_register(struct ldlm_namespace *ns, ldlm_side_t client)
984 mutex_lock(ldlm_namespace_lock(client));
985 LASSERT(cfs_list_empty(&ns->ns_list_chain));
986 cfs_list_add(&ns->ns_list_chain, ldlm_namespace_inactive_list(client));
987 ldlm_namespace_nr_inc(client);
988 mutex_unlock(ldlm_namespace_lock(client));
991 /** Unregister \a ns from the list of namespaces. */
992 void ldlm_namespace_unregister(struct ldlm_namespace *ns, ldlm_side_t client)
994 mutex_lock(ldlm_namespace_lock(client));
995 LASSERT(!cfs_list_empty(&ns->ns_list_chain));
996 /* Some asserts and possibly other parts of the code are still
997 * using list_empty(&ns->ns_list_chain). This is why it is
998 * important to use list_del_init() here. */
999 cfs_list_del_init(&ns->ns_list_chain);
1000 ldlm_namespace_nr_dec(client);
1001 mutex_unlock(ldlm_namespace_lock(client));
1004 /** Should be called with ldlm_namespace_lock(client) taken. */
1005 void ldlm_namespace_move_to_active_locked(struct ldlm_namespace *ns,
1008 LASSERT(!cfs_list_empty(&ns->ns_list_chain));
1009 LASSERT(mutex_is_locked(ldlm_namespace_lock(client)));
1010 cfs_list_move_tail(&ns->ns_list_chain, ldlm_namespace_list(client));
1013 /** Should be called with ldlm_namespace_lock(client) taken. */
1014 void ldlm_namespace_move_to_inactive_locked(struct ldlm_namespace *ns,
1017 LASSERT(!cfs_list_empty(&ns->ns_list_chain));
1018 LASSERT(mutex_is_locked(ldlm_namespace_lock(client)));
1019 cfs_list_move_tail(&ns->ns_list_chain,
1020 ldlm_namespace_inactive_list(client));
1023 /** Should be called with ldlm_namespace_lock(client) taken. */
1024 struct ldlm_namespace *ldlm_namespace_first_locked(ldlm_side_t client)
1026 LASSERT(mutex_is_locked(ldlm_namespace_lock(client)));
1027 LASSERT(!cfs_list_empty(ldlm_namespace_list(client)));
1028 return container_of(ldlm_namespace_list(client)->next,
1029 struct ldlm_namespace, ns_list_chain);
1032 /** Create and initialize new resource. */
1033 static struct ldlm_resource *ldlm_resource_new(void)
1035 struct ldlm_resource *res;
1038 OBD_SLAB_ALLOC_PTR_GFP(res, ldlm_resource_slab, GFP_NOFS);
1042 CFS_INIT_LIST_HEAD(&res->lr_granted);
1043 CFS_INIT_LIST_HEAD(&res->lr_converting);
1044 CFS_INIT_LIST_HEAD(&res->lr_waiting);
1046 /* Initialize interval trees for each lock mode. */
1047 for (idx = 0; idx < LCK_MODE_NUM; idx++) {
1048 res->lr_itree[idx].lit_size = 0;
1049 res->lr_itree[idx].lit_mode = 1 << idx;
1050 res->lr_itree[idx].lit_root = NULL;
1053 atomic_set(&res->lr_refcount, 1);
1054 spin_lock_init(&res->lr_lock);
1055 lu_ref_init(&res->lr_reference);
1057 /* The creator of the resource must unlock the mutex after LVB
1058 * initialization. */
1059 mutex_init(&res->lr_lvb_mutex);
1060 mutex_lock(&res->lr_lvb_mutex);
1066 * Return a reference to resource with given name, creating it if necessary.
1067 * Args: namespace with ns_lock unlocked
1068 * Locks: takes and releases NS hash-lock and res->lr_lock
1069 * Returns: referenced, unlocked ldlm_resource or NULL
1071 struct ldlm_resource *
1072 ldlm_resource_get(struct ldlm_namespace *ns, struct ldlm_resource *parent,
1073 const struct ldlm_res_id *name, ldlm_type_t type, int create)
1075 cfs_hlist_node_t *hnode;
1076 struct ldlm_resource *res;
1079 int ns_refcount = 0;
1081 LASSERT(ns != NULL);
1082 LASSERT(parent == NULL);
1083 LASSERT(ns->ns_rs_hash != NULL);
1084 LASSERT(name->name[0] != 0);
1086 cfs_hash_bd_get_and_lock(ns->ns_rs_hash, (void *)name, &bd, 0);
1087 hnode = cfs_hash_bd_lookup_locked(ns->ns_rs_hash, &bd, (void *)name);
1088 if (hnode != NULL) {
1089 cfs_hash_bd_unlock(ns->ns_rs_hash, &bd, 0);
1090 res = cfs_hlist_entry(hnode, struct ldlm_resource, lr_hash);
1091 /* Synchronize with regard to resource creation. */
1092 if (ns->ns_lvbo && ns->ns_lvbo->lvbo_init) {
1093 mutex_lock(&res->lr_lvb_mutex);
1094 mutex_unlock(&res->lr_lvb_mutex);
1097 if (unlikely(res->lr_lvb_len < 0)) {
1098 ldlm_resource_putref(res);
1104 version = cfs_hash_bd_version_get(&bd);
1105 cfs_hash_bd_unlock(ns->ns_rs_hash, &bd, 0);
1110 LASSERTF(type >= LDLM_MIN_TYPE && type < LDLM_MAX_TYPE,
1111 "type: %d\n", type);
1112 res = ldlm_resource_new();
1116 res->lr_ns_bucket = cfs_hash_bd_extra_get(ns->ns_rs_hash, &bd);
1117 res->lr_name = *name;
1118 res->lr_type = type;
1119 res->lr_most_restr = LCK_NL;
1121 cfs_hash_bd_lock(ns->ns_rs_hash, &bd, 1);
1122 hnode = (version == cfs_hash_bd_version_get(&bd)) ? NULL :
1123 cfs_hash_bd_lookup_locked(ns->ns_rs_hash, &bd, (void *)name);
1125 if (hnode != NULL) {
1126 /* Someone won the race and already added the resource. */
1127 cfs_hash_bd_unlock(ns->ns_rs_hash, &bd, 1);
1128 /* Clean lu_ref for failed resource. */
1129 lu_ref_fini(&res->lr_reference);
1130 /* We have taken lr_lvb_mutex. Drop it. */
1131 mutex_unlock(&res->lr_lvb_mutex);
1132 OBD_SLAB_FREE(res, ldlm_resource_slab, sizeof *res);
1134 res = cfs_hlist_entry(hnode, struct ldlm_resource, lr_hash);
1135 /* Synchronize with regard to resource creation. */
1136 if (ns->ns_lvbo && ns->ns_lvbo->lvbo_init) {
1137 mutex_lock(&res->lr_lvb_mutex);
1138 mutex_unlock(&res->lr_lvb_mutex);
1141 if (unlikely(res->lr_lvb_len < 0)) {
1142 ldlm_resource_putref(res);
1147 /* We won! Let's add the resource. */
1148 cfs_hash_bd_add_locked(ns->ns_rs_hash, &bd, &res->lr_hash);
1149 if (cfs_hash_bd_count_get(&bd) == 1)
1150 ns_refcount = ldlm_namespace_get_return(ns);
1152 cfs_hash_bd_unlock(ns->ns_rs_hash, &bd, 1);
1153 if (ns->ns_lvbo && ns->ns_lvbo->lvbo_init) {
1156 OBD_FAIL_TIMEOUT(OBD_FAIL_LDLM_CREATE_RESOURCE, 2);
1157 rc = ns->ns_lvbo->lvbo_init(res);
1159 CERROR("%s: lvbo_init failed for resource "LPX64":"
1160 LPX64": rc = %d\n", ns->ns_obd->obd_name,
1161 name->name[0], name->name[1], rc);
1162 if (res->lr_lvb_data) {
1163 OBD_FREE(res->lr_lvb_data, res->lr_lvb_len);
1164 res->lr_lvb_data = NULL;
1166 res->lr_lvb_len = rc;
1167 mutex_unlock(&res->lr_lvb_mutex);
1168 ldlm_resource_putref(res);
1173 /* We create resource with locked lr_lvb_mutex. */
1174 mutex_unlock(&res->lr_lvb_mutex);
1176 /* Let's see if we happened to be the very first resource in this
1177 * namespace. If so, and this is a client namespace, we need to move
1178 * the namespace into the active namespaces list to be patrolled by
1179 * the ldlm_poold. */
1180 if (ns_is_client(ns) && ns_refcount == 1) {
1181 mutex_lock(ldlm_namespace_lock(LDLM_NAMESPACE_CLIENT));
1182 ldlm_namespace_move_to_active_locked(ns, LDLM_NAMESPACE_CLIENT);
1183 mutex_unlock(ldlm_namespace_lock(LDLM_NAMESPACE_CLIENT));
1188 EXPORT_SYMBOL(ldlm_resource_get);
1190 struct ldlm_resource *ldlm_resource_getref(struct ldlm_resource *res)
1192 LASSERT(res != NULL);
1193 LASSERT(res != LP_POISON);
1194 atomic_inc(&res->lr_refcount);
1195 CDEBUG(D_INFO, "getref res: %p count: %d\n", res,
1196 atomic_read(&res->lr_refcount));
1200 static void __ldlm_resource_putref_final(cfs_hash_bd_t *bd,
1201 struct ldlm_resource *res)
1203 struct ldlm_ns_bucket *nsb = res->lr_ns_bucket;
1205 if (!cfs_list_empty(&res->lr_granted)) {
1206 ldlm_resource_dump(D_ERROR, res);
1210 if (!cfs_list_empty(&res->lr_converting)) {
1211 ldlm_resource_dump(D_ERROR, res);
1215 if (!cfs_list_empty(&res->lr_waiting)) {
1216 ldlm_resource_dump(D_ERROR, res);
1220 cfs_hash_bd_del_locked(nsb->nsb_namespace->ns_rs_hash,
1222 lu_ref_fini(&res->lr_reference);
1223 if (cfs_hash_bd_count_get(bd) == 0)
1224 ldlm_namespace_put(nsb->nsb_namespace);
1227 /* Returns 1 if the resource was freed, 0 if it remains. */
1228 int ldlm_resource_putref(struct ldlm_resource *res)
1230 struct ldlm_namespace *ns = ldlm_res_to_ns(res);
1233 LASSERT_ATOMIC_GT_LT(&res->lr_refcount, 0, LI_POISON);
1234 CDEBUG(D_INFO, "putref res: %p count: %d\n",
1235 res, atomic_read(&res->lr_refcount) - 1);
1237 cfs_hash_bd_get(ns->ns_rs_hash, &res->lr_name, &bd);
1238 if (cfs_hash_bd_dec_and_lock(ns->ns_rs_hash, &bd, &res->lr_refcount)) {
1239 __ldlm_resource_putref_final(&bd, res);
1240 cfs_hash_bd_unlock(ns->ns_rs_hash, &bd, 1);
1241 if (ns->ns_lvbo && ns->ns_lvbo->lvbo_free)
1242 ns->ns_lvbo->lvbo_free(res);
1243 OBD_SLAB_FREE(res, ldlm_resource_slab, sizeof *res);
1248 EXPORT_SYMBOL(ldlm_resource_putref);
1250 /* Returns 1 if the resource was freed, 0 if it remains. */
1251 int ldlm_resource_putref_locked(struct ldlm_resource *res)
1253 struct ldlm_namespace *ns = ldlm_res_to_ns(res);
1255 LASSERT_ATOMIC_GT_LT(&res->lr_refcount, 0, LI_POISON);
1256 CDEBUG(D_INFO, "putref res: %p count: %d\n",
1257 res, atomic_read(&res->lr_refcount) - 1);
1259 if (atomic_dec_and_test(&res->lr_refcount)) {
1262 cfs_hash_bd_get(ldlm_res_to_ns(res)->ns_rs_hash,
1263 &res->lr_name, &bd);
1264 __ldlm_resource_putref_final(&bd, res);
1265 cfs_hash_bd_unlock(ns->ns_rs_hash, &bd, 1);
1266 /* NB: ns_rs_hash is created with CFS_HASH_NO_ITEMREF,
1267 * so we should never be here while calling cfs_hash_del,
1268 * cfs_hash_for_each_nolock is the only case we can get
1269 * here, which is safe to release cfs_hash_bd_lock.
1271 if (ns->ns_lvbo && ns->ns_lvbo->lvbo_free)
1272 ns->ns_lvbo->lvbo_free(res);
1273 OBD_SLAB_FREE(res, ldlm_resource_slab, sizeof *res);
1275 cfs_hash_bd_lock(ns->ns_rs_hash, &bd, 1);
1282 * Add a lock into a given resource into specified lock list.
1284 void ldlm_resource_add_lock(struct ldlm_resource *res, cfs_list_t *head,
1285 struct ldlm_lock *lock)
1287 check_res_locked(res);
1289 LDLM_DEBUG(lock, "About to add this lock:\n");
1291 if (ldlm_is_destroyed(lock)) {
1292 CDEBUG(D_OTHER, "Lock destroyed, not adding to resource\n");
1296 LASSERT(cfs_list_empty(&lock->l_res_link));
1298 cfs_list_add_tail(&lock->l_res_link, head);
1302 * Insert a lock into resource after specified lock.
1304 * Obtain resource description from the lock we are inserting after.
1306 void ldlm_resource_insert_lock_after(struct ldlm_lock *original,
1307 struct ldlm_lock *new)
1309 struct ldlm_resource *res = original->l_resource;
1311 check_res_locked(res);
1313 ldlm_resource_dump(D_INFO, res);
1314 LDLM_DEBUG(new, "About to insert this lock after %p:\n", original);
1316 if (ldlm_is_destroyed(new)) {
1317 CDEBUG(D_OTHER, "Lock destroyed, not adding to resource\n");
1321 LASSERT(cfs_list_empty(&new->l_res_link));
1323 cfs_list_add(&new->l_res_link, &original->l_res_link);
1327 void ldlm_resource_unlink_lock(struct ldlm_lock *lock)
1329 int type = lock->l_resource->lr_type;
1331 check_res_locked(lock->l_resource);
1332 if (type == LDLM_IBITS || type == LDLM_PLAIN)
1333 ldlm_unlink_lock_skiplist(lock);
1334 else if (type == LDLM_EXTENT)
1335 ldlm_extent_unlink_lock(lock);
1336 cfs_list_del_init(&lock->l_res_link);
1338 EXPORT_SYMBOL(ldlm_resource_unlink_lock);
1340 void ldlm_res2desc(struct ldlm_resource *res, struct ldlm_resource_desc *desc)
1342 desc->lr_type = res->lr_type;
1343 desc->lr_name = res->lr_name;
1347 * Print information about all locks in all namespaces on this node to debug
1350 void ldlm_dump_all_namespaces(ldlm_side_t client, int level)
1354 if (!((libcfs_debug | D_ERROR) & level))
1357 mutex_lock(ldlm_namespace_lock(client));
1359 cfs_list_for_each(tmp, ldlm_namespace_list(client)) {
1360 struct ldlm_namespace *ns;
1361 ns = cfs_list_entry(tmp, struct ldlm_namespace, ns_list_chain);
1362 ldlm_namespace_dump(level, ns);
1365 mutex_unlock(ldlm_namespace_lock(client));
1367 EXPORT_SYMBOL(ldlm_dump_all_namespaces);
1369 static int ldlm_res_hash_dump(cfs_hash_t *hs, cfs_hash_bd_t *bd,
1370 cfs_hlist_node_t *hnode, void *arg)
1372 struct ldlm_resource *res = cfs_hash_object(hs, hnode);
1373 int level = (int)(unsigned long)arg;
1376 ldlm_resource_dump(level, res);
1383 * Print information about all locks in this namespace on this node to debug
1386 void ldlm_namespace_dump(int level, struct ldlm_namespace *ns)
1388 if (!((libcfs_debug | D_ERROR) & level))
1391 CDEBUG(level, "--- Namespace: %s (rc: %d, side: %s)\n",
1392 ldlm_ns_name(ns), atomic_read(&ns->ns_bref),
1393 ns_is_client(ns) ? "client" : "server");
1395 if (cfs_time_before(cfs_time_current(), ns->ns_next_dump))
1398 cfs_hash_for_each_nolock(ns->ns_rs_hash,
1400 (void *)(unsigned long)level);
1401 spin_lock(&ns->ns_lock);
1402 ns->ns_next_dump = cfs_time_shift(10);
1403 spin_unlock(&ns->ns_lock);
1405 EXPORT_SYMBOL(ldlm_namespace_dump);
1408 * Print information about all locks in this resource to debug log.
1410 void ldlm_resource_dump(int level, struct ldlm_resource *res)
1412 struct ldlm_lock *lock;
1413 unsigned int granted = 0;
1415 CLASSERT(RES_NAME_SIZE == 4);
1417 if (!((libcfs_debug | D_ERROR) & level))
1420 CDEBUG(level, "--- Resource: "DLDLMRES" (%p) refcount = %d\n",
1421 PLDLMRES(res), res, atomic_read(&res->lr_refcount));
1423 if (!cfs_list_empty(&res->lr_granted)) {
1424 CDEBUG(level, "Granted locks (in reverse order):\n");
1425 cfs_list_for_each_entry_reverse(lock, &res->lr_granted,
1427 LDLM_DEBUG_LIMIT(level, lock, "###");
1428 if (!(level & D_CANTMASK) &&
1429 ++granted > ldlm_dump_granted_max) {
1430 CDEBUG(level, "only dump %d granted locks to "
1431 "avoid DDOS.\n", granted);
1436 if (!cfs_list_empty(&res->lr_converting)) {
1437 CDEBUG(level, "Converting locks:\n");
1438 cfs_list_for_each_entry(lock, &res->lr_converting, l_res_link)
1439 LDLM_DEBUG_LIMIT(level, lock, "###");
1441 if (!cfs_list_empty(&res->lr_waiting)) {
1442 CDEBUG(level, "Waiting locks:\n");
1443 cfs_list_for_each_entry(lock, &res->lr_waiting, l_res_link)
1444 LDLM_DEBUG_LIMIT(level, lock, "###");