1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2 * vim:expandtab:shiftwidth=8:tabstop=8:
4 * Copyright (C) 2002-2004 Cluster File Systems, Inc.
5 * Author: Peter Braam <braam@clusterfs.com>
6 * Author: Phil Schwan <phil@clusterfs.com>
8 * This file is part of the Lustre file system, http://www.lustre.org
9 * Lustre is a trademark of Cluster File Systems, Inc.
11 * You may have signed or agreed to another license before downloading
12 * this software. If so, you are bound by the terms and conditions
13 * of that agreement, and the following does not apply to you. See the
14 * LICENSE file included with this distribution for more information.
16 * If you did not agree to a different license, then this copy of Lustre
17 * is open source software; you can redistribute it and/or modify it
18 * under the terms of version 2 of the GNU General Public License as
19 * published by the Free Software Foundation.
21 * In either case, Lustre is distributed in the hope that it will be
22 * useful, but WITHOUT ANY WARRANTY; without even the implied warranty
23 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 * license text for more details.
28 # define EXPORT_SYMTAB
30 #define DEBUG_SUBSYSTEM S_LDLM
33 # include <libcfs/libcfs.h>
35 # include <liblustre.h>
38 #include <lustre_dlm.h>
39 #include <obd_class.h>
40 #include <libcfs/list.h>
41 #include "ldlm_internal.h"
43 extern cfs_mem_cache_t *ldlm_resource_slab;
44 extern cfs_mem_cache_t *ldlm_lock_slab;
45 static struct semaphore ldlm_ref_sem;
46 static int ldlm_refcount;
50 static struct ldlm_state *ldlm_state;
52 inline cfs_time_t round_timeout(cfs_time_t timeout)
54 return cfs_time_seconds((int)cfs_duration_sec(cfs_time_sub(timeout, 0)) + 1);
57 /* timeout for initial callback (AST) reply */
58 static inline unsigned int ldlm_get_rq_timeout(unsigned int ldlm_timeout,
59 unsigned int obd_timeout)
61 unsigned int timeout = min(ldlm_timeout, obd_timeout / 3);
63 return timeout < 1 ? 1 : timeout;
67 /* w_l_spinlock protects both waiting_locks_list and expired_lock_thread */
68 static spinlock_t waiting_locks_spinlock; /* BH lock (timer) */
69 static struct list_head waiting_locks_list;
70 static cfs_timer_t waiting_locks_timer;
72 static struct expired_lock_thread {
73 cfs_waitq_t elt_waitq;
76 struct list_head elt_expired_locks;
77 } expired_lock_thread;
82 #define ELT_TERMINATE 2
86 struct list_head blp_list;
87 cfs_waitq_t blp_waitq;
88 atomic_t blp_num_threads;
89 struct completion blp_comp;
92 struct ldlm_bl_work_item {
93 struct list_head blwi_entry;
94 struct ldlm_namespace *blwi_ns;
95 struct ldlm_lock_desc blwi_ld;
96 struct ldlm_lock *blwi_lock;
97 struct list_head blwi_head;
103 static inline int have_expired_locks(void)
108 spin_lock_bh(&waiting_locks_spinlock);
109 need_to_run = !list_empty(&expired_lock_thread.elt_expired_locks);
110 spin_unlock_bh(&waiting_locks_spinlock);
115 static int expired_lock_main(void *arg)
117 struct list_head *expired = &expired_lock_thread.elt_expired_locks;
118 struct l_wait_info lwi = { 0 };
122 cfs_daemonize("ldlm_elt");
124 expired_lock_thread.elt_state = ELT_READY;
125 cfs_waitq_signal(&expired_lock_thread.elt_waitq);
128 l_wait_event(expired_lock_thread.elt_waitq,
129 have_expired_locks() ||
130 expired_lock_thread.elt_state == ELT_TERMINATE,
133 spin_lock_bh(&waiting_locks_spinlock);
134 if (expired_lock_thread.elt_dump) {
135 spin_unlock_bh(&waiting_locks_spinlock);
137 /* from waiting_locks_callback, but not in timer */
138 libcfs_debug_dumplog();
139 libcfs_run_lbug_upcall(__FILE__,
140 "waiting_locks_callback",
141 expired_lock_thread.elt_dump);
143 spin_lock_bh(&waiting_locks_spinlock);
144 expired_lock_thread.elt_dump = 0;
149 while (!list_empty(expired)) {
150 struct obd_export *export;
151 struct ldlm_lock *lock;
153 lock = list_entry(expired->next, struct ldlm_lock,
155 if ((void *)lock < LP_POISON + CFS_PAGE_SIZE &&
156 (void *)lock >= LP_POISON) {
157 spin_unlock_bh(&waiting_locks_spinlock);
158 CERROR("free lock on elt list %p\n", lock);
161 list_del_init(&lock->l_pending_chain);
162 if ((void *)lock->l_export < LP_POISON + CFS_PAGE_SIZE &&
163 (void *)lock->l_export >= LP_POISON) {
164 CERROR("lock with free export on elt list %p\n",
166 lock->l_export = NULL;
167 LDLM_ERROR(lock, "free export");
170 export = class_export_get(lock->l_export);
171 spin_unlock_bh(&waiting_locks_spinlock);
174 class_fail_export(export);
175 class_export_put(export);
176 spin_lock_bh(&waiting_locks_spinlock);
178 spin_unlock_bh(&waiting_locks_spinlock);
180 if (do_dump && obd_dump_on_eviction) {
181 CERROR("dump the log upon eviction\n");
182 libcfs_debug_dumplog();
185 if (expired_lock_thread.elt_state == ELT_TERMINATE)
189 expired_lock_thread.elt_state = ELT_STOPPED;
190 cfs_waitq_signal(&expired_lock_thread.elt_waitq);
194 static int ldlm_add_waiting_lock(struct ldlm_lock *lock);
196 /* This is called from within a timer interrupt and cannot schedule */
197 static void waiting_locks_callback(unsigned long unused)
199 struct ldlm_lock *lock, *last = NULL;
202 spin_lock_bh(&waiting_locks_spinlock);
203 while (!list_empty(&waiting_locks_list)) {
204 lock = list_entry(waiting_locks_list.next, struct ldlm_lock,
207 if (cfs_time_after(lock->l_callback_timeout, cfs_time_current()) ||
208 (lock->l_req_mode == LCK_GROUP))
211 if (ptlrpc_check_suspend()) {
212 /* there is a case when we talk to one mds, holding
213 * lock from another mds. this way we easily can get
214 * here, if second mds is being recovered. so, we
215 * suspend timeouts. bug 6019 */
217 LDLM_ERROR(lock, "recharge timeout: %s@%s nid %s ",
218 lock->l_export->exp_client_uuid.uuid,
219 lock->l_export->exp_connection->c_remote_uuid.uuid,
220 libcfs_nid2str(lock->l_export->exp_connection->c_peer.nid));
222 list_del_init(&lock->l_pending_chain);
223 spin_unlock_bh(&waiting_locks_spinlock);
224 ldlm_add_waiting_lock(lock);
228 /* if timeout overlaps the activation time of suspended timeouts
229 * then extend it to give a chance for client to reconnect */
230 if (cfs_time_before(cfs_time_sub(lock->l_callback_timeout,
231 cfs_time_seconds(obd_timeout)/2),
232 ptlrpc_suspend_wakeup_time())) {
233 LDLM_ERROR(lock, "extend timeout due to recovery: %s@%s nid %s ",
234 lock->l_export->exp_client_uuid.uuid,
235 lock->l_export->exp_connection->c_remote_uuid.uuid,
236 libcfs_nid2str(lock->l_export->exp_connection->c_peer.nid));
238 list_del_init(&lock->l_pending_chain);
239 spin_unlock_bh(&waiting_locks_spinlock);
240 ldlm_add_waiting_lock(lock);
244 LDLM_ERROR(lock, "lock callback timer expired: evicting client "
246 lock->l_export->exp_client_uuid.uuid,
247 lock->l_export->exp_connection->c_remote_uuid.uuid,
248 libcfs_nid2str(lock->l_export->exp_connection->c_peer.nid));
252 list_del(&lock->l_pending_chain);
253 list_add(&lock->l_pending_chain,
254 &expired_lock_thread.elt_expired_locks);
257 if (!list_empty(&expired_lock_thread.elt_expired_locks)) {
258 if (obd_dump_on_timeout)
259 expired_lock_thread.elt_dump = __LINE__;
261 cfs_waitq_signal(&expired_lock_thread.elt_waitq);
265 * Make sure the timer will fire again if we have any locks
268 if (!list_empty(&waiting_locks_list)) {
269 cfs_time_t timeout_rounded;
270 lock = list_entry(waiting_locks_list.next, struct ldlm_lock,
272 timeout_rounded = (cfs_time_t)round_timeout(lock->l_callback_timeout);
273 cfs_timer_arm(&waiting_locks_timer, timeout_rounded);
275 spin_unlock_bh(&waiting_locks_spinlock);
279 * Indicate that we're waiting for a client to call us back cancelling a given
280 * lock. We add it to the pending-callback chain, and schedule the lock-timeout
281 * timer to fire appropriately. (We round up to the next second, to avoid
282 * floods of timer firings during periods of high lock contention and traffic).
284 * Called with the namespace lock held.
286 static int __ldlm_add_waiting_lock(struct ldlm_lock *lock)
288 cfs_time_t timeout_rounded;
290 if (!list_empty(&lock->l_pending_chain))
293 lock->l_callback_timeout =cfs_time_add(cfs_time_current(),
294 cfs_time_seconds(obd_timeout)/2);
296 timeout_rounded = round_timeout(lock->l_callback_timeout);
298 if (cfs_time_before(timeout_rounded, cfs_timer_deadline(&waiting_locks_timer)) ||
299 !cfs_timer_is_armed(&waiting_locks_timer)) {
300 cfs_timer_arm(&waiting_locks_timer, timeout_rounded);
303 list_add_tail(&lock->l_pending_chain, &waiting_locks_list); /* FIFO */
307 static int ldlm_add_waiting_lock(struct ldlm_lock *lock)
311 LASSERT(!(lock->l_flags & LDLM_FL_CANCEL_ON_BLOCK));
313 spin_lock_bh(&waiting_locks_spinlock);
314 if (lock->l_destroyed) {
315 static cfs_time_t next;
316 spin_unlock_bh(&waiting_locks_spinlock);
317 LDLM_ERROR(lock, "not waiting on destroyed lock (bug 5653)");
318 if (cfs_time_after(cfs_time_current(), next)) {
319 next = cfs_time_shift(14400);
320 libcfs_debug_dumpstack(NULL);
325 ret = __ldlm_add_waiting_lock(lock);
326 spin_unlock_bh(&waiting_locks_spinlock);
328 LDLM_DEBUG(lock, "%sadding to wait list",
329 ret == 0 ? "not re-" : "");
334 * Remove a lock from the pending list, likely because it had its cancellation
335 * callback arrive without incident. This adjusts the lock-timeout timer if
336 * needed. Returns 0 if the lock wasn't pending after all, 1 if it was.
338 * Called with namespace lock held.
340 int __ldlm_del_waiting_lock(struct ldlm_lock *lock)
342 struct list_head *list_next;
344 if (list_empty(&lock->l_pending_chain))
347 list_next = lock->l_pending_chain.next;
348 if (lock->l_pending_chain.prev == &waiting_locks_list) {
349 /* Removing the head of the list, adjust timer. */
350 if (list_next == &waiting_locks_list) {
351 /* No more, just cancel. */
352 cfs_timer_disarm(&waiting_locks_timer);
354 struct ldlm_lock *next;
355 next = list_entry(list_next, struct ldlm_lock,
357 cfs_timer_arm(&waiting_locks_timer,
358 round_timeout(next->l_callback_timeout));
361 list_del_init(&lock->l_pending_chain);
366 int ldlm_del_waiting_lock(struct ldlm_lock *lock)
370 if (lock->l_export == NULL) {
371 /* We don't have a "waiting locks list" on clients. */
372 LDLM_DEBUG(lock, "client lock: no-op");
376 spin_lock_bh(&waiting_locks_spinlock);
377 ret = __ldlm_del_waiting_lock(lock);
378 spin_unlock_bh(&waiting_locks_spinlock);
380 LDLM_DEBUG(lock, "%s", ret == 0 ? "wasn't waiting" : "removed");
387 * Called with namespace lock held.
389 int ldlm_refresh_waiting_lock(struct ldlm_lock *lock)
391 if (lock->l_export == NULL) {
392 /* We don't have a "waiting locks list" on clients. */
393 LDLM_DEBUG(lock, "client lock: no-op");
397 spin_lock_bh(&waiting_locks_spinlock);
399 if (list_empty(&lock->l_pending_chain)) {
400 spin_unlock_bh(&waiting_locks_spinlock);
401 LDLM_DEBUG(lock, "wasn't waiting");
405 __ldlm_del_waiting_lock(lock);
406 __ldlm_add_waiting_lock(lock);
407 spin_unlock_bh(&waiting_locks_spinlock);
409 LDLM_DEBUG(lock, "refreshed");
413 #else /* !__KERNEL__ */
415 static int ldlm_add_waiting_lock(struct ldlm_lock *lock)
417 LASSERT(!(lock->l_flags & LDLM_FL_CANCEL_ON_BLOCK));
421 int ldlm_del_waiting_lock(struct ldlm_lock *lock)
426 int ldlm_refresh_waiting_lock(struct ldlm_lock *lock)
430 #endif /* __KERNEL__ */
432 static void ldlm_failed_ast(struct ldlm_lock *lock, int rc,
433 const char *ast_type)
435 struct ptlrpc_connection *conn = lock->l_export->exp_connection;
436 char *str = libcfs_nid2str(conn->c_peer.nid);
438 LCONSOLE_ERROR_MSG(0x138, "A client on nid %s was evicted from "
439 "service %s.\n", str,
440 lock->l_export->exp_obd->obd_name);
442 LCONSOLE_ERROR_MSG(0x012, "Lock %s callback to %s timed out for "
443 "resource %d\n", ast_type,
444 obd_export_nid2str(lock->l_export), rc);
446 if (obd_dump_on_timeout)
447 libcfs_debug_dumplog();
448 class_fail_export(lock->l_export);
451 static int ldlm_handle_ast_error(struct ldlm_lock *lock,
452 struct ptlrpc_request *req, int rc,
453 const char *ast_type)
455 lnet_process_id_t peer = req->rq_import->imp_connection->c_peer;
457 if (rc == -ETIMEDOUT || rc == -EINTR || rc == -ENOTCONN) {
458 LASSERT(lock->l_export);
459 if (lock->l_export->exp_libclient) {
460 LDLM_DEBUG(lock, "%s AST to liblustre client (nid %s)"
461 " timeout, just cancelling lock", ast_type,
462 libcfs_nid2str(peer.nid));
463 ldlm_lock_cancel(lock);
465 } else if (lock->l_flags & LDLM_FL_CANCEL) {
466 LDLM_DEBUG(lock, "%s AST timeout from nid %s, but "
467 "cancel was received (AST reply lost?)",
468 ast_type, libcfs_nid2str(peer.nid));
469 ldlm_lock_cancel(lock);
472 ldlm_del_waiting_lock(lock);
473 ldlm_failed_ast(lock, rc, ast_type);
477 LDLM_DEBUG(lock, "client (nid %s) returned %d"
478 " from %s AST - normal race",
479 libcfs_nid2str(peer.nid),
481 lustre_msg_get_status(req->rq_repmsg) : -1,
484 LDLM_ERROR(lock, "client (nid %s) returned %d "
485 "from %s AST", libcfs_nid2str(peer.nid),
486 (req->rq_repmsg != NULL) ?
487 lustre_msg_get_status(req->rq_repmsg) : 0,
489 ldlm_lock_cancel(lock);
490 /* Server-side AST functions are called from ldlm_reprocess_all,
491 * which needs to be told to please restart its reprocessing. */
498 static int ldlm_cb_interpret(struct ptlrpc_request *req, void *data, int rc)
500 struct ldlm_cb_set_arg *arg;
501 struct ldlm_lock *lock;
504 LASSERT(data != NULL);
506 arg = req->rq_async_args.pointer_arg[0];
507 lock = req->rq_async_args.pointer_arg[1];
508 LASSERT(lock != NULL);
510 /* If client canceled the lock but the cancel has not
511 * been recieved yet, we need to update lvbo to have the
512 * proper attributes cached. */
513 if (rc == -EINVAL && arg->type == LDLM_BL_CALLBACK)
514 ldlm_res_lvbo_update(lock->l_resource, NULL,
516 rc = ldlm_handle_ast_error(lock, req, rc,
517 arg->type == LDLM_BL_CALLBACK
518 ? "blocking" : "completion");
524 atomic_set(&arg->restart, 1);
529 static inline int ldlm_bl_and_cp_ast_fini(struct ptlrpc_request *req,
530 struct ldlm_cb_set_arg *arg,
531 struct ldlm_lock *lock,
537 if (unlikely(instant_cancel)) {
538 rc = ptl_send_rpc(req, 1);
539 ptlrpc_req_finished(req);
541 /* If we cancelled the lock, we need to restart
542 * ldlm_reprocess_queue */
543 atomic_set(&arg->restart, 1);
546 ptlrpc_set_add_req(arg->set, req);
553 * ->l_blocking_ast() method for server-side locks. This is invoked when newly
554 * enqueued server lock conflicts with given one.
556 * Sends blocking ast rpc to the client owning that lock; arms timeout timer
557 * to wait for client response.
559 int ldlm_server_blocking_ast(struct ldlm_lock *lock,
560 struct ldlm_lock_desc *desc,
561 void *data, int flag)
563 struct ldlm_cb_set_arg *arg = data;
564 struct ldlm_request *body;
565 struct ptlrpc_request *req;
566 int size[] = { [MSG_PTLRPC_BODY_OFF] = sizeof(struct ptlrpc_body),
567 [DLM_LOCKREQ_OFF] = sizeof(*body) };
568 int instant_cancel = 0, rc;
571 if (flag == LDLM_CB_CANCELING) {
572 /* Don't need to do anything here. */
577 LASSERT(data != NULL);
578 if (lock->l_export->exp_obd->obd_recovering != 0) {
579 LDLM_ERROR(lock, "BUG 6063: lock collide during recovery");
580 ldlm_lock_dump(D_ERROR, lock, 0);
583 req = ptlrpc_prep_req(lock->l_export->exp_imp_reverse,
584 LUSTRE_DLM_VERSION, LDLM_BL_CALLBACK, 2, size,
589 req->rq_async_args.pointer_arg[0] = arg;
590 req->rq_async_args.pointer_arg[1] = lock;
591 req->rq_interpret_reply = ldlm_cb_interpret;
592 req->rq_no_resend = 1;
594 lock_res(lock->l_resource);
595 if (lock->l_granted_mode != lock->l_req_mode) {
596 /* this blocking AST will be communicated as part of the
597 * completion AST instead */
598 unlock_res(lock->l_resource);
599 ptlrpc_req_finished(req);
600 LDLM_DEBUG(lock, "lock not granted, not sending blocking AST");
604 if (lock->l_destroyed) {
605 /* What's the point? */
606 unlock_res(lock->l_resource);
607 ptlrpc_req_finished(req);
611 if (lock->l_flags & LDLM_FL_CANCEL_ON_BLOCK)
614 body = lustre_msg_buf(req->rq_reqmsg, DLM_LOCKREQ_OFF, sizeof(*body));
615 body->lock_handle[0] = lock->l_remote_handle;
616 body->lock_desc = *desc;
617 body->lock_flags |= (lock->l_flags & LDLM_AST_FLAGS);
619 LDLM_DEBUG(lock, "server preparing blocking AST");
621 ptlrpc_req_set_repsize(req, 1, NULL);
622 if (instant_cancel) {
623 unlock_res(lock->l_resource);
624 ldlm_lock_cancel(lock);
626 LASSERT(lock->l_granted_mode == lock->l_req_mode);
627 ldlm_add_waiting_lock(lock);
628 unlock_res(lock->l_resource);
631 req->rq_send_state = LUSTRE_IMP_FULL;
632 req->rq_timeout = ldlm_get_rq_timeout(ldlm_timeout, obd_timeout);
634 if (lock->l_export && lock->l_export->exp_ldlm_stats)
635 lprocfs_counter_incr(lock->l_export->exp_ldlm_stats,
636 LDLM_BL_CALLBACK - LDLM_FIRST_OPC);
638 rc = ldlm_bl_and_cp_ast_fini(req, arg, lock, instant_cancel);
643 int ldlm_server_completion_ast(struct ldlm_lock *lock, int flags, void *data)
645 struct ldlm_cb_set_arg *arg = data;
646 struct ldlm_request *body;
647 struct ptlrpc_request *req;
648 struct timeval granted_time;
649 long total_enqueue_wait;
650 int size[3] = { [MSG_PTLRPC_BODY_OFF] = sizeof(struct ptlrpc_body),
651 [DLM_LOCKREQ_OFF] = sizeof(*body) };
652 int rc, buffers = 2, instant_cancel = 0;
655 LASSERT(lock != NULL);
656 LASSERT(data != NULL);
658 do_gettimeofday(&granted_time);
659 total_enqueue_wait = cfs_timeval_sub(&granted_time,
660 &lock->l_enqueued_time, NULL);
662 if (total_enqueue_wait / 1000000 > obd_timeout)
663 LDLM_ERROR(lock, "enqueue wait took %luus from %lu",
664 total_enqueue_wait, lock->l_enqueued_time.tv_sec);
666 lock_res_and_lock(lock);
667 if (lock->l_resource->lr_lvb_len) {
668 size[DLM_REQ_REC_OFF] = lock->l_resource->lr_lvb_len;
671 unlock_res_and_lock(lock);
673 req = ptlrpc_prep_req(lock->l_export->exp_imp_reverse,
674 LUSTRE_DLM_VERSION, LDLM_CP_CALLBACK, buffers,
679 req->rq_async_args.pointer_arg[0] = arg;
680 req->rq_async_args.pointer_arg[1] = lock;
681 req->rq_interpret_reply = ldlm_cb_interpret;
682 req->rq_no_resend = 1;
684 body = lustre_msg_buf(req->rq_reqmsg, DLM_LOCKREQ_OFF, sizeof(*body));
685 body->lock_handle[0] = lock->l_remote_handle;
686 body->lock_flags = flags;
687 ldlm_lock2desc(lock, &body->lock_desc);
692 lvb = lustre_msg_buf(req->rq_reqmsg, DLM_REQ_REC_OFF,
693 lock->l_resource->lr_lvb_len);
694 lock_res_and_lock(lock);
695 memcpy(lvb, lock->l_resource->lr_lvb_data,
696 lock->l_resource->lr_lvb_len);
697 unlock_res_and_lock(lock);
700 LDLM_DEBUG(lock, "server preparing completion AST (after %ldus wait)",
703 ptlrpc_req_set_repsize(req, 1, NULL);
705 req->rq_send_state = LUSTRE_IMP_FULL;
706 req->rq_timeout = ldlm_get_rq_timeout(ldlm_timeout, obd_timeout);
708 /* We only send real blocking ASTs after the lock is granted */
709 lock_res_and_lock(lock);
710 if (lock->l_flags & LDLM_FL_AST_SENT) {
711 body->lock_flags |= LDLM_FL_AST_SENT;
713 /* We might get here prior to ldlm_handle_enqueue setting
714 * LDLM_FL_CANCEL_ON_BLOCK flag. Then we will put this lock
715 * into waiting list, but this is safe and similar code in
716 * ldlm_handle_enqueue will call ldlm_lock_cancel() still,
717 * that would not only cancel the lock, but will also remove
718 * it from waiting list */
719 if (lock->l_flags & LDLM_FL_CANCEL_ON_BLOCK) {
720 unlock_res_and_lock(lock);
721 ldlm_lock_cancel(lock);
723 lock_res_and_lock(lock);
725 /* start the lock-timeout clock */
726 ldlm_add_waiting_lock(lock);
729 unlock_res_and_lock(lock);
731 if (lock->l_export && lock->l_export->exp_ldlm_stats)
732 lprocfs_counter_incr(lock->l_export->exp_ldlm_stats,
733 LDLM_CP_CALLBACK - LDLM_FIRST_OPC);
735 rc = ldlm_bl_and_cp_ast_fini(req, arg, lock, instant_cancel);
740 int ldlm_server_glimpse_ast(struct ldlm_lock *lock, void *data)
742 struct ldlm_resource *res = lock->l_resource;
743 struct ldlm_request *body;
744 struct ptlrpc_request *req;
745 int size[] = { [MSG_PTLRPC_BODY_OFF] = sizeof(struct ptlrpc_body),
746 [DLM_LOCKREQ_OFF] = sizeof(*body) };
750 LASSERT(lock != NULL);
752 req = ptlrpc_prep_req(lock->l_export->exp_imp_reverse,
753 LUSTRE_DLM_VERSION, LDLM_GL_CALLBACK, 2, size,
758 body = lustre_msg_buf(req->rq_reqmsg, DLM_LOCKREQ_OFF, sizeof(*body));
759 body->lock_handle[0] = lock->l_remote_handle;
760 ldlm_lock2desc(lock, &body->lock_desc);
762 lock_res_and_lock(lock);
763 size[REPLY_REC_OFF] = lock->l_resource->lr_lvb_len;
764 unlock_res_and_lock(lock);
765 res = lock->l_resource;
766 ptlrpc_req_set_repsize(req, 2, size);
768 req->rq_send_state = LUSTRE_IMP_FULL;
769 req->rq_timeout = ldlm_get_rq_timeout(ldlm_timeout, obd_timeout);
771 if (lock->l_export && lock->l_export->exp_ldlm_stats)
772 lprocfs_counter_incr(lock->l_export->exp_ldlm_stats,
773 LDLM_GL_CALLBACK - LDLM_FIRST_OPC);
775 rc = ptlrpc_queue_wait(req);
776 if (rc == -ELDLM_NO_LOCK_DATA)
777 LDLM_DEBUG(lock, "lost race - client has a lock but no inode");
779 rc = ldlm_handle_ast_error(lock, req, rc, "glimpse");
781 rc = ldlm_res_lvbo_update(res, req->rq_repmsg,
783 ptlrpc_req_finished(req);
787 static struct ldlm_lock *
788 find_existing_lock(struct obd_export *exp,
789 const struct lustre_handle *remote_hdl)
791 struct list_head *iter;
793 spin_lock(&exp->exp_ldlm_data.led_lock);
794 list_for_each(iter, &exp->exp_ldlm_data.led_held_locks) {
795 struct ldlm_lock *lock;
796 lock = list_entry(iter, struct ldlm_lock, l_export_chain);
797 if (lock->l_remote_handle.cookie == remote_hdl->cookie) {
799 spin_unlock(&exp->exp_ldlm_data.led_lock);
803 spin_unlock(&exp->exp_ldlm_data.led_lock);
808 extern unsigned long long lu_time_stamp_get(void);
810 #define lu_time_stamp_get() time(NULL)
814 * Main server-side entry point into LDLM. This is called by ptlrpc service
815 * threads to carry out client lock enqueueing requests.
817 int ldlm_handle_enqueue0(struct ldlm_namespace *ns,
818 struct ptlrpc_request *req,
819 const struct ldlm_request *dlm_req,
820 const struct ldlm_callback_suite *cbs)
822 struct ldlm_reply *dlm_rep;
823 int size[3] = { [MSG_PTLRPC_BODY_OFF] = sizeof(struct ptlrpc_body),
824 [DLM_LOCKREPLY_OFF] = sizeof(*dlm_rep) };
827 ldlm_error_t err = ELDLM_OK;
828 struct ldlm_lock *lock = NULL;
832 LDLM_DEBUG_NOLOCK("server-side enqueue handler START");
834 ldlm_request_cancel(req, dlm_req, LDLM_ENQUEUE_CANCEL_OFF);
835 flags = dlm_req->lock_flags;
837 LASSERT(req->rq_export);
839 if (req->rq_export->exp_ldlm_stats)
840 lprocfs_counter_incr(req->rq_export->exp_ldlm_stats,
841 LDLM_ENQUEUE - LDLM_FIRST_OPC);
843 if (unlikely(dlm_req->lock_desc.l_resource.lr_type < LDLM_MIN_TYPE ||
844 dlm_req->lock_desc.l_resource.lr_type >= LDLM_MAX_TYPE)) {
845 DEBUG_REQ(D_ERROR, req, "invalid lock request type %d",
846 dlm_req->lock_desc.l_resource.lr_type);
847 GOTO(out, rc = -EFAULT);
850 if (unlikely(dlm_req->lock_desc.l_req_mode <= LCK_MINMODE ||
851 dlm_req->lock_desc.l_req_mode >= LCK_MAXMODE ||
852 dlm_req->lock_desc.l_req_mode &
853 (dlm_req->lock_desc.l_req_mode-1))) {
854 DEBUG_REQ(D_ERROR, req, "invalid lock request mode %d",
855 dlm_req->lock_desc.l_req_mode);
856 GOTO(out, rc = -EFAULT);
859 if (req->rq_export->exp_connect_flags & OBD_CONNECT_IBITS) {
860 if (unlikely(dlm_req->lock_desc.l_resource.lr_type ==
862 DEBUG_REQ(D_ERROR, req,
863 "PLAIN lock request from IBITS client?");
864 GOTO(out, rc = -EPROTO);
866 } else if (unlikely(dlm_req->lock_desc.l_resource.lr_type ==
868 DEBUG_REQ(D_ERROR, req,
869 "IBITS lock request from unaware client?");
870 GOTO(out, rc = -EPROTO);
874 /* FIXME this makes it impossible to use LDLM_PLAIN locks -- check
875 against server's _CONNECT_SUPPORTED flags? (I don't want to use
876 ibits for mgc/mgs) */
878 /* INODEBITS_INTEROP: Perform conversion from plain lock to
879 * inodebits lock if client does not support them. */
880 if (!(req->rq_export->exp_connect_flags & OBD_CONNECT_IBITS) &&
881 (dlm_req->lock_desc.l_resource.lr_type == LDLM_PLAIN)) {
882 dlm_req->lock_desc.l_resource.lr_type = LDLM_IBITS;
883 dlm_req->lock_desc.l_policy_data.l_inodebits.bits =
884 MDS_INODELOCK_LOOKUP | MDS_INODELOCK_UPDATE;
885 if (dlm_req->lock_desc.l_req_mode == LCK_PR)
886 dlm_req->lock_desc.l_req_mode = LCK_CR;
890 if (unlikely(flags & LDLM_FL_REPLAY)) {
891 lock = find_existing_lock(req->rq_export,
892 &dlm_req->lock_handle[0]);
894 DEBUG_REQ(D_DLMTRACE, req, "found existing lock cookie "
895 LPX64, lock->l_handle.h_cookie);
896 GOTO(existing_lock, rc = 0);
900 /* The lock's callback data might be set in the policy function */
901 lock = ldlm_lock_create(ns, &dlm_req->lock_desc.l_resource.lr_name,
902 dlm_req->lock_desc.l_resource.lr_type,
903 dlm_req->lock_desc.l_req_mode,
904 cbs->lcs_blocking, cbs->lcs_completion,
905 cbs->lcs_glimpse, NULL, 0);
908 GOTO(out, rc = -ENOMEM);
910 do_gettimeofday(&lock->l_enqueued_time);
911 lock->l_remote_handle = dlm_req->lock_handle[0];
912 LDLM_DEBUG(lock, "server-side enqueue handler, new lock created");
914 OBD_FAIL_TIMEOUT(OBD_FAIL_LDLM_ENQUEUE_BLOCKED, obd_timeout * 2);
915 /* Don't enqueue a lock onto the export if it has already
916 * been evicted. Cancel it now instead. (bug 3822) */
917 if (req->rq_export->exp_failed) {
918 LDLM_ERROR(lock, "lock on destroyed export %p", req->rq_export);
919 GOTO(out, rc = -ENOTCONN);
921 lock->l_export = class_export_get(req->rq_export);
922 spin_lock(&lock->l_export->exp_ldlm_data.led_lock);
923 list_add(&lock->l_export_chain,
924 &lock->l_export->exp_ldlm_data.led_held_locks);
925 spin_unlock(&lock->l_export->exp_ldlm_data.led_lock);
929 if (flags & LDLM_FL_HAS_INTENT) {
930 /* In this case, the reply buffer is allocated deep in
931 * local_lock_enqueue by the policy function. */
936 lock_res_and_lock(lock);
937 if (lock->l_resource->lr_lvb_len) {
938 size[DLM_REPLY_REC_OFF] = lock->l_resource->lr_lvb_len;
941 unlock_res_and_lock(lock);
943 if (OBD_FAIL_CHECK_ONCE(OBD_FAIL_LDLM_ENQUEUE_EXTENT_ERR))
944 GOTO(out, rc = -ENOMEM);
946 rc = lustre_pack_reply(req, buffers, size, NULL);
951 if (dlm_req->lock_desc.l_resource.lr_type != LDLM_PLAIN)
952 lock->l_policy_data = dlm_req->lock_desc.l_policy_data;
953 if (dlm_req->lock_desc.l_resource.lr_type == LDLM_EXTENT)
954 lock->l_req_extent = lock->l_policy_data.l_extent;
956 err = ldlm_lock_enqueue(ns, &lock, cookie, &flags);
960 dlm_rep = lustre_msg_buf(req->rq_repmsg, DLM_LOCKREPLY_OFF,
962 dlm_rep->lock_flags = flags;
964 ldlm_lock2desc(lock, &dlm_rep->lock_desc);
965 ldlm_lock2handle(lock, &dlm_rep->lock_handle);
967 /* We never send a blocking AST until the lock is granted, but
968 * we can tell it right now */
969 lock_res_and_lock(lock);
971 /* Now take into account flags to be inherited from original lock
972 request both in reply to client and in our own lock flags. */
973 dlm_rep->lock_flags |= dlm_req->lock_flags & LDLM_INHERIT_FLAGS;
974 lock->l_flags |= dlm_req->lock_flags & LDLM_INHERIT_FLAGS;
976 /* Don't move a pending lock onto the export if it has already
977 * been evicted. Cancel it now instead. (bug 5683) */
978 if (unlikely(req->rq_export->exp_failed ||
979 OBD_FAIL_CHECK_ONCE(OBD_FAIL_LDLM_ENQUEUE_OLD_EXPORT))) {
980 LDLM_ERROR(lock, "lock on destroyed export %p", req->rq_export);
982 } else if (lock->l_flags & LDLM_FL_AST_SENT) {
983 dlm_rep->lock_flags |= LDLM_FL_AST_SENT;
984 if (lock->l_granted_mode == lock->l_req_mode) {
986 * Only cancel lock if it was granted, because it would
987 * be destroyed immediatelly and would never be granted
988 * in the future, causing timeouts on client. Not
989 * granted lock will be cancelled immediatelly after
990 * sending completion AST.
992 if (dlm_rep->lock_flags & LDLM_FL_CANCEL_ON_BLOCK) {
993 unlock_res_and_lock(lock);
994 ldlm_lock_cancel(lock);
995 lock_res_and_lock(lock);
997 ldlm_add_waiting_lock(lock);
1000 /* Make sure we never ever grant usual metadata locks to liblustre
1002 if ((dlm_req->lock_desc.l_resource.lr_type == LDLM_PLAIN ||
1003 dlm_req->lock_desc.l_resource.lr_type == LDLM_IBITS) &&
1004 req->rq_export->exp_libclient) {
1005 if (unlikely(!(lock->l_flags & LDLM_FL_CANCEL_ON_BLOCK) ||
1006 !(dlm_rep->lock_flags & LDLM_FL_CANCEL_ON_BLOCK))){
1007 CERROR("Granting sync lock to libclient. "
1008 "req fl %d, rep fl %d, lock fl %d\n",
1009 dlm_req->lock_flags, dlm_rep->lock_flags,
1011 LDLM_ERROR(lock, "sync lock");
1012 if (dlm_req->lock_flags & LDLM_FL_HAS_INTENT) {
1013 struct ldlm_intent *it;
1014 it = lustre_msg_buf(req->rq_reqmsg,
1018 CERROR("This is intent %s ("LPU64")\n",
1019 ldlm_it2str(it->opc), it->opc);
1025 unlock_res_and_lock(lock);
1029 req->rq_status = err;
1030 if (req->rq_reply_state == NULL) {
1031 err = lustre_pack_reply(req, 1, NULL, NULL);
1034 req->rq_status = rc;
1037 /* The LOCK_CHANGED code in ldlm_lock_enqueue depends on this
1038 * ldlm_reprocess_all. If this moves, revisit that code. -phil */
1040 LDLM_DEBUG(lock, "server-side enqueue handler, sending reply"
1041 "(err=%d, rc=%d)", err, rc);
1043 lock_res_and_lock(lock);
1045 size[DLM_REPLY_REC_OFF] = lock->l_resource->lr_lvb_len;
1046 if (size[DLM_REPLY_REC_OFF] > 0) {
1047 void *lvb = lustre_msg_buf(req->rq_repmsg,
1049 size[DLM_REPLY_REC_OFF]);
1050 LASSERTF(lvb != NULL, "req %p, lock %p\n",
1053 memcpy(lvb, lock->l_resource->lr_lvb_data,
1054 size[DLM_REPLY_REC_OFF]);
1057 ldlm_resource_unlink_lock(lock);
1058 ldlm_lock_destroy_nolock(lock);
1060 unlock_res_and_lock(lock);
1062 if (!err && dlm_req->lock_desc.l_resource.lr_type != LDLM_FLOCK)
1063 ldlm_reprocess_all(lock->l_resource);
1065 LDLM_LOCK_PUT(lock);
1068 LDLM_DEBUG_NOLOCK("server-side enqueue handler END (lock %p, rc %d)",
1074 int ldlm_handle_enqueue(struct ptlrpc_request *req,
1075 ldlm_completion_callback completion_callback,
1076 ldlm_blocking_callback blocking_callback,
1077 ldlm_glimpse_callback glimpse_callback)
1080 struct ldlm_request *dlm_req;
1081 struct ldlm_callback_suite cbs = {
1082 .lcs_completion = completion_callback,
1083 .lcs_blocking = blocking_callback,
1084 .lcs_glimpse = glimpse_callback
1088 dlm_req = lustre_swab_reqbuf(req, DLM_LOCKREQ_OFF,
1089 sizeof *dlm_req, lustre_swab_ldlm_request);
1090 if (dlm_req != NULL) {
1091 rc = ldlm_handle_enqueue0(req->rq_export->exp_obd->obd_namespace,
1092 req, dlm_req, &cbs);
1094 CERROR ("Can't unpack dlm_req\n");
1100 int ldlm_handle_convert0(struct ptlrpc_request *req,
1101 const struct ldlm_request *dlm_req)
1103 struct ldlm_reply *dlm_rep;
1104 struct ldlm_lock *lock;
1106 int size[2] = { [MSG_PTLRPC_BODY_OFF] = sizeof(struct ptlrpc_body),
1107 [DLM_LOCKREPLY_OFF] = sizeof(*dlm_rep) };
1110 if (req->rq_export && req->rq_export->exp_ldlm_stats)
1111 lprocfs_counter_incr(req->rq_export->exp_ldlm_stats,
1112 LDLM_CONVERT - LDLM_FIRST_OPC);
1114 rc = lustre_pack_reply(req, 2, size, NULL);
1118 dlm_rep = lustre_msg_buf(req->rq_repmsg, DLM_LOCKREPLY_OFF,
1120 dlm_rep->lock_flags = dlm_req->lock_flags;
1122 lock = ldlm_handle2lock(&dlm_req->lock_handle[0]);
1124 req->rq_status = EINVAL;
1128 LDLM_DEBUG(lock, "server-side convert handler START");
1130 do_gettimeofday(&lock->l_enqueued_time);
1131 res = ldlm_lock_convert(lock, dlm_req->lock_desc.l_req_mode,
1132 &dlm_rep->lock_flags);
1134 if (ldlm_del_waiting_lock(lock))
1135 LDLM_DEBUG(lock, "converted waiting lock");
1138 req->rq_status = EDEADLOCK;
1143 if (!req->rq_status)
1144 ldlm_reprocess_all(lock->l_resource);
1145 LDLM_DEBUG(lock, "server-side convert handler END");
1146 LDLM_LOCK_PUT(lock);
1148 LDLM_DEBUG_NOLOCK("server-side convert handler END");
1153 int ldlm_handle_convert(struct ptlrpc_request *req)
1156 struct ldlm_request *dlm_req;
1158 dlm_req = lustre_swab_reqbuf(req, DLM_LOCKREQ_OFF, sizeof *dlm_req,
1159 lustre_swab_ldlm_request);
1160 if (dlm_req != NULL) {
1161 rc = ldlm_handle_convert0(req, dlm_req);
1163 CERROR ("Can't unpack dlm_req\n");
1169 /* Cancel all the locks, which handles are packed into ldlm_request */
1170 int ldlm_request_cancel(struct ptlrpc_request *req,
1171 const struct ldlm_request *dlm_req, int first)
1173 struct ldlm_resource *res, *pres = NULL;
1174 struct ldlm_lock *lock;
1175 int i, count, done = 0;
1178 count = dlm_req->lock_count ? dlm_req->lock_count : 1;
1182 /* There is no lock on the server at the replay time,
1183 * skip lock cancelling to make replay tests to pass. */
1184 if (lustre_msg_get_flags(req->rq_reqmsg) & MSG_REPLAY)
1187 LDLM_DEBUG_NOLOCK("server-side cancel handler START: %d locks, "
1188 "starting at %d", count, first);
1190 for (i = first; i < count; i++) {
1191 lock = ldlm_handle2lock(&dlm_req->lock_handle[i]);
1193 LDLM_DEBUG_NOLOCK("server-side cancel handler stale "
1194 "lock (cookie "LPU64")",
1195 dlm_req->lock_handle[i].cookie);
1199 res = lock->l_resource;
1204 ldlm_reprocess_all(pres);
1205 ldlm_resource_putref(pres);
1208 ldlm_resource_getref(res);
1209 ldlm_res_lvbo_update(res, NULL, 0, 1);
1213 ldlm_lock_cancel(lock);
1214 LDLM_LOCK_PUT(lock);
1217 ldlm_reprocess_all(pres);
1218 ldlm_resource_putref(pres);
1220 LDLM_DEBUG_NOLOCK("server-side cancel handler END");
1224 int ldlm_handle_cancel(struct ptlrpc_request *req)
1226 struct ldlm_request *dlm_req;
1230 dlm_req = lustre_swab_reqbuf(req, DLM_LOCKREQ_OFF, sizeof(*dlm_req),
1231 lustre_swab_ldlm_request);
1232 if (dlm_req == NULL) {
1233 CERROR("bad request buffer for cancel\n");
1237 if (req->rq_export && req->rq_export->exp_ldlm_stats)
1238 lprocfs_counter_incr(req->rq_export->exp_ldlm_stats,
1239 LDLM_CANCEL - LDLM_FIRST_OPC);
1241 rc = lustre_pack_reply(req, 1, NULL, NULL);
1245 if (!ldlm_request_cancel(req, dlm_req, 0))
1246 req->rq_status = ESTALE;
1248 if (ptlrpc_reply(req) != 0)
1254 void ldlm_handle_bl_callback(struct ldlm_namespace *ns,
1255 struct ldlm_lock_desc *ld, struct ldlm_lock *lock)
1260 LDLM_DEBUG(lock, "client blocking AST callback handler START");
1262 lock_res_and_lock(lock);
1263 lock->l_flags |= LDLM_FL_CBPENDING;
1265 if (lock->l_flags & LDLM_FL_CANCEL_ON_BLOCK)
1266 lock->l_flags |= LDLM_FL_CANCEL;
1268 do_ast = (!lock->l_readers && !lock->l_writers);
1269 unlock_res_and_lock(lock);
1272 LDLM_DEBUG(lock, "already unused, calling "
1273 "callback (%p)", lock->l_blocking_ast);
1274 if (lock->l_blocking_ast != NULL)
1275 lock->l_blocking_ast(lock, ld, lock->l_ast_data,
1278 LDLM_DEBUG(lock, "Lock still has references, will be"
1279 " cancelled later");
1282 LDLM_DEBUG(lock, "client blocking callback handler END");
1283 LDLM_LOCK_PUT(lock);
1287 static void ldlm_handle_cp_callback(struct ptlrpc_request *req,
1288 struct ldlm_namespace *ns,
1289 struct ldlm_request *dlm_req,
1290 struct ldlm_lock *lock)
1292 CFS_LIST_HEAD(ast_list);
1295 LDLM_DEBUG(lock, "client completion callback handler START");
1297 lock_res_and_lock(lock);
1299 /* If we receive the completion AST before the actual enqueue returned,
1300 * then we might need to switch lock modes, resources, or extents. */
1301 if (dlm_req->lock_desc.l_granted_mode != lock->l_req_mode) {
1302 lock->l_req_mode = dlm_req->lock_desc.l_granted_mode;
1303 LDLM_DEBUG(lock, "completion AST, new lock mode");
1306 if (lock->l_resource->lr_type != LDLM_PLAIN) {
1307 lock->l_policy_data = dlm_req->lock_desc.l_policy_data;
1308 LDLM_DEBUG(lock, "completion AST, new policy data");
1311 ldlm_resource_unlink_lock(lock);
1312 if (memcmp(&dlm_req->lock_desc.l_resource.lr_name,
1313 &lock->l_resource->lr_name,
1314 sizeof(lock->l_resource->lr_name)) != 0) {
1315 unlock_res_and_lock(lock);
1316 ldlm_lock_change_resource(ns, lock,
1317 &dlm_req->lock_desc.l_resource.lr_name);
1318 LDLM_DEBUG(lock, "completion AST, new resource");
1319 CERROR("change resource!\n");
1320 lock_res_and_lock(lock);
1323 if (dlm_req->lock_flags & LDLM_FL_AST_SENT) {
1324 lock->l_flags |= LDLM_FL_CBPENDING;
1325 LDLM_DEBUG(lock, "completion AST includes blocking AST");
1328 if (lock->l_lvb_len) {
1330 lvb = lustre_swab_reqbuf(req, DLM_REQ_REC_OFF, lock->l_lvb_len,
1331 lock->l_lvb_swabber);
1333 LDLM_ERROR(lock, "completion AST did not contain "
1336 memcpy(lock->l_lvb_data, lvb, lock->l_lvb_len);
1340 ldlm_grant_lock(lock, &ast_list);
1341 unlock_res_and_lock(lock);
1343 LDLM_DEBUG(lock, "callback handler finished, about to run_ast_work");
1345 ldlm_run_cp_ast_work(&ast_list);
1347 LDLM_DEBUG_NOLOCK("client completion callback handler END (lock %p)",
1349 LDLM_LOCK_PUT(lock);
1353 static void ldlm_handle_gl_callback(struct ptlrpc_request *req,
1354 struct ldlm_namespace *ns,
1355 struct ldlm_request *dlm_req,
1356 struct ldlm_lock *lock)
1361 LDLM_DEBUG(lock, "client glimpse AST callback handler");
1363 if (lock->l_glimpse_ast != NULL)
1364 rc = lock->l_glimpse_ast(lock, req);
1366 if (req->rq_repmsg != NULL) {
1369 req->rq_status = rc;
1373 lock_res_and_lock(lock);
1374 if (lock->l_granted_mode == LCK_PW &&
1375 !lock->l_readers && !lock->l_writers &&
1376 cfs_time_after(cfs_time_current(),
1377 cfs_time_add(lock->l_last_used,
1378 cfs_time_seconds(10)))) {
1379 unlock_res_and_lock(lock);
1380 if (ldlm_bl_to_thread_lock(ns, NULL, lock))
1381 ldlm_handle_bl_callback(ns, NULL, lock);
1386 unlock_res_and_lock(lock);
1387 LDLM_LOCK_PUT(lock);
1391 static int ldlm_callback_reply(struct ptlrpc_request *req, int rc)
1393 req->rq_status = rc;
1394 if (req->rq_reply_state == NULL) {
1395 rc = lustre_pack_reply(req, 1, NULL, NULL);
1399 return ptlrpc_reply(req);
1403 static int ldlm_bl_to_thread(struct ldlm_namespace *ns,
1404 struct ldlm_lock_desc *ld, struct ldlm_lock *lock,
1405 struct list_head *cancels, int count)
1407 struct ldlm_bl_pool *blp = ldlm_state->ldlm_bl_pool;
1408 struct ldlm_bl_work_item *blwi;
1411 if (cancels && count == 0)
1414 OBD_ALLOC(blwi, sizeof(*blwi));
1420 blwi->blwi_ld = *ld;
1422 list_add(&blwi->blwi_head, cancels);
1423 list_del_init(cancels);
1424 blwi->blwi_count = count;
1426 blwi->blwi_lock = lock;
1428 spin_lock(&blp->blp_lock);
1429 list_add_tail(&blwi->blwi_entry, &blp->blp_list);
1430 cfs_waitq_signal(&blp->blp_waitq);
1431 spin_unlock(&blp->blp_lock);
1437 int ldlm_bl_to_thread_lock(struct ldlm_namespace *ns, struct ldlm_lock_desc *ld,
1438 struct ldlm_lock *lock)
1441 RETURN(ldlm_bl_to_thread(ns, ld, lock, NULL, 0));
1447 int ldlm_bl_to_thread_list(struct ldlm_namespace *ns, struct ldlm_lock_desc *ld,
1448 struct list_head *cancels, int count)
1451 RETURN(ldlm_bl_to_thread(ns, ld, NULL, cancels, count));
1457 static int ldlm_callback_handler(struct ptlrpc_request *req)
1459 struct ldlm_namespace *ns;
1460 struct ldlm_request *dlm_req;
1461 struct ldlm_lock *lock;
1465 /* Requests arrive in sender's byte order. The ptlrpc service
1466 * handler has already checked and, if necessary, byte-swapped the
1467 * incoming request message body, but I am responsible for the
1468 * message buffers. */
1470 if (req->rq_export == NULL) {
1471 struct ldlm_request *dlm_req;
1473 CDEBUG(D_RPCTRACE, "operation %d from %s with bad "
1474 "export cookie "LPX64"; this is "
1475 "normal if this node rebooted with a lock held\n",
1476 lustre_msg_get_opc(req->rq_reqmsg),
1477 libcfs_id2str(req->rq_peer),
1478 lustre_msg_get_handle(req->rq_reqmsg)->cookie);
1480 dlm_req = lustre_swab_reqbuf(req, DLM_LOCKREQ_OFF,
1482 lustre_swab_ldlm_request);
1483 if (dlm_req != NULL)
1484 CDEBUG(D_RPCTRACE, "--> lock cookie: "LPX64"\n",
1485 dlm_req->lock_handle[0].cookie);
1487 ldlm_callback_reply(req, -ENOTCONN);
1491 LASSERT(req->rq_export != NULL);
1492 LASSERT(req->rq_export->exp_obd != NULL);
1494 switch (lustre_msg_get_opc(req->rq_reqmsg)) {
1495 case LDLM_BL_CALLBACK:
1496 OBD_FAIL_RETURN(OBD_FAIL_LDLM_BL_CALLBACK, 0);
1498 case LDLM_CP_CALLBACK:
1499 OBD_FAIL_RETURN(OBD_FAIL_LDLM_CP_CALLBACK, 0);
1501 case LDLM_GL_CALLBACK:
1502 OBD_FAIL_RETURN(OBD_FAIL_LDLM_GL_CALLBACK, 0);
1504 case OBD_LOG_CANCEL: /* remove this eventually - for 1.4.0 compat */
1505 OBD_FAIL_RETURN(OBD_FAIL_OBD_LOG_CANCEL_NET, 0);
1506 rc = llog_origin_handle_cancel(req);
1507 ldlm_callback_reply(req, rc);
1509 case OBD_QC_CALLBACK:
1510 OBD_FAIL_RETURN(OBD_FAIL_OBD_QC_CALLBACK_NET, 0);
1511 rc = target_handle_qc_callback(req);
1512 ldlm_callback_reply(req, rc);
1516 /* reply in handler */
1517 rc = target_handle_dqacq_callback(req);
1519 case LLOG_ORIGIN_HANDLE_CREATE:
1520 OBD_FAIL_RETURN(OBD_FAIL_OBD_LOGD_NET, 0);
1521 rc = llog_origin_handle_create(req);
1522 ldlm_callback_reply(req, rc);
1524 case LLOG_ORIGIN_HANDLE_NEXT_BLOCK:
1525 OBD_FAIL_RETURN(OBD_FAIL_OBD_LOGD_NET, 0);
1526 rc = llog_origin_handle_next_block(req);
1527 ldlm_callback_reply(req, rc);
1529 case LLOG_ORIGIN_HANDLE_READ_HEADER:
1530 OBD_FAIL_RETURN(OBD_FAIL_OBD_LOGD_NET, 0);
1531 rc = llog_origin_handle_read_header(req);
1532 ldlm_callback_reply(req, rc);
1534 case LLOG_ORIGIN_HANDLE_CLOSE:
1535 OBD_FAIL_RETURN(OBD_FAIL_OBD_LOGD_NET, 0);
1536 rc = llog_origin_handle_close(req);
1537 ldlm_callback_reply(req, rc);
1543 CERROR("unknown opcode %u\n",
1544 lustre_msg_get_opc(req->rq_reqmsg));
1545 ldlm_callback_reply(req, -EPROTO);
1549 ns = req->rq_export->exp_obd->obd_namespace;
1550 LASSERT(ns != NULL);
1552 dlm_req = lustre_swab_reqbuf(req, DLM_LOCKREQ_OFF, sizeof(*dlm_req),
1553 lustre_swab_ldlm_request);
1554 if (dlm_req == NULL) {
1555 CERROR ("can't unpack dlm_req\n");
1556 ldlm_callback_reply(req, -EPROTO);
1560 lock = ldlm_handle2lock_ns(ns, &dlm_req->lock_handle[0]);
1562 CDEBUG(D_DLMTRACE, "callback on lock "LPX64" - lock "
1563 "disappeared\n", dlm_req->lock_handle[0].cookie);
1564 ldlm_callback_reply(req, -EINVAL);
1568 /* Copy hints/flags (e.g. LDLM_FL_DISCARD_DATA) from AST. */
1569 lock_res_and_lock(lock);
1570 lock->l_flags |= (dlm_req->lock_flags & LDLM_AST_FLAGS);
1571 if (lustre_msg_get_opc(req->rq_reqmsg) == LDLM_BL_CALLBACK) {
1572 /* If somebody cancels locks and cache is already droped,
1573 * we can tell the server we have no lock. Otherwise, we
1574 * should send cancel after dropping the cache. */
1575 if ((lock->l_flags & LDLM_FL_CANCELING) &&
1576 (lock->l_flags & LDLM_FL_BL_DONE)) {
1577 LDLM_DEBUG(lock, "callback on lock "
1578 LPX64" - lock disappeared\n",
1579 dlm_req->lock_handle[0].cookie);
1580 unlock_res_and_lock(lock);
1581 LDLM_LOCK_PUT(lock);
1582 ldlm_callback_reply(req, -EINVAL);
1585 lock->l_flags |= LDLM_FL_BL_AST;
1587 unlock_res_and_lock(lock);
1589 /* We want the ost thread to get this reply so that it can respond
1590 * to ost requests (write cache writeback) that might be triggered
1593 * But we'd also like to be able to indicate in the reply that we're
1594 * cancelling right now, because it's unused, or have an intent result
1595 * in the reply, so we might have to push the responsibility for sending
1596 * the reply down into the AST handlers, alas. */
1598 switch (lustre_msg_get_opc(req->rq_reqmsg)) {
1599 case LDLM_BL_CALLBACK:
1600 CDEBUG(D_INODE, "blocking ast\n");
1601 if (!(lock->l_flags & LDLM_FL_CANCEL_ON_BLOCK))
1602 ldlm_callback_reply(req, 0);
1603 if (ldlm_bl_to_thread_lock(ns, &dlm_req->lock_desc, lock))
1604 ldlm_handle_bl_callback(ns, &dlm_req->lock_desc, lock);
1606 case LDLM_CP_CALLBACK:
1607 CDEBUG(D_INODE, "completion ast\n");
1608 ldlm_callback_reply(req, 0);
1609 ldlm_handle_cp_callback(req, ns, dlm_req, lock);
1611 case LDLM_GL_CALLBACK:
1612 CDEBUG(D_INODE, "glimpse ast\n");
1613 ldlm_handle_gl_callback(req, ns, dlm_req, lock);
1616 LBUG(); /* checked above */
1622 static int ldlm_cancel_handler(struct ptlrpc_request *req)
1627 /* Requests arrive in sender's byte order. The ptlrpc service
1628 * handler has already checked and, if necessary, byte-swapped the
1629 * incoming request message body, but I am responsible for the
1630 * message buffers. */
1632 if (req->rq_export == NULL) {
1633 struct ldlm_request *dlm_req;
1635 CERROR("operation %d from %s with bad export cookie "LPU64"\n",
1636 lustre_msg_get_opc(req->rq_reqmsg),
1637 libcfs_id2str(req->rq_peer),
1638 lustre_msg_get_handle(req->rq_reqmsg)->cookie);
1640 dlm_req = lustre_swab_reqbuf(req, DLM_LOCKREQ_OFF,
1642 lustre_swab_ldlm_request);
1643 if (dlm_req != NULL)
1644 ldlm_lock_dump_handle(D_ERROR,
1645 &dlm_req->lock_handle[0]);
1646 ldlm_callback_reply(req, -ENOTCONN);
1650 switch (lustre_msg_get_opc(req->rq_reqmsg)) {
1652 /* XXX FIXME move this back to mds/handler.c, bug 249 */
1654 CDEBUG(D_INODE, "cancel\n");
1655 OBD_FAIL_RETURN(OBD_FAIL_LDLM_CANCEL, 0);
1656 rc = ldlm_handle_cancel(req);
1660 case OBD_LOG_CANCEL:
1661 OBD_FAIL_RETURN(OBD_FAIL_OBD_LOG_CANCEL_NET, 0);
1662 rc = llog_origin_handle_cancel(req);
1663 ldlm_callback_reply(req, rc);
1666 CERROR("invalid opcode %d\n",
1667 lustre_msg_get_opc(req->rq_reqmsg));
1668 ldlm_callback_reply(req, -EINVAL);
1674 void ldlm_revoke_export_locks(struct obd_export *exp)
1676 struct list_head *locklist = &exp->exp_ldlm_data.led_held_locks;
1677 struct list_head rpc_list;
1678 struct ldlm_lock *lock, *next;
1679 struct ldlm_lock_desc desc;
1682 INIT_LIST_HEAD(&rpc_list);
1684 spin_lock(&exp->exp_ldlm_data.led_lock);
1685 list_for_each_entry_safe(lock, next, locklist, l_export_chain) {
1686 lock_res_and_lock(lock);
1688 if (lock->l_req_mode != lock->l_granted_mode) {
1689 unlock_res_and_lock(lock);
1693 LASSERT(lock->l_resource);
1694 if (lock->l_resource->lr_type != LDLM_IBITS &&
1695 lock->l_resource->lr_type != LDLM_PLAIN) {
1696 unlock_res_and_lock(lock);
1700 if (lock->l_flags & LDLM_FL_AST_SENT) {
1701 unlock_res_and_lock(lock);
1705 LASSERT(lock->l_blocking_ast);
1706 LASSERT(!lock->l_blocking_lock);
1708 lock->l_flags |= LDLM_FL_AST_SENT;
1709 list_move(&lock->l_export_chain, &rpc_list);
1711 unlock_res_and_lock(lock);
1713 spin_unlock(&exp->exp_ldlm_data.led_lock);
1715 while (!list_empty(&rpc_list)) {
1716 lock = list_entry(rpc_list.next, struct ldlm_lock,
1718 list_del_init(&lock->l_export_chain);
1720 /* the desc just pretend to exclusive */
1721 ldlm_lock2desc(lock, &desc);
1722 desc.l_req_mode = LCK_EX;
1723 desc.l_granted_mode = 0;
1725 LDLM_LOCK_GET(lock);
1726 lock->l_blocking_ast(lock, &desc, lock->l_ast_data,
1728 LDLM_LOCK_PUT(lock);
1734 static struct ldlm_bl_work_item *ldlm_bl_get_work(struct ldlm_bl_pool *blp)
1736 struct ldlm_bl_work_item *blwi = NULL;
1738 spin_lock(&blp->blp_lock);
1739 if (!list_empty(&blp->blp_list)) {
1740 blwi = list_entry(blp->blp_list.next, struct ldlm_bl_work_item,
1742 list_del(&blwi->blwi_entry);
1744 spin_unlock(&blp->blp_lock);
1749 struct ldlm_bl_thread_data {
1751 struct ldlm_bl_pool *bltd_blp;
1754 static int ldlm_bl_thread_main(void *arg)
1756 struct ldlm_bl_thread_data *bltd = arg;
1757 struct ldlm_bl_pool *blp = bltd->bltd_blp;
1761 char name[CFS_CURPROC_COMM_MAX];
1762 snprintf(name, sizeof(name) - 1, "ldlm_bl_%02d",
1764 cfs_daemonize(name);
1767 atomic_inc(&blp->blp_num_threads);
1768 complete(&blp->blp_comp);
1771 struct l_wait_info lwi = { 0 };
1772 struct ldlm_bl_work_item *blwi = NULL;
1774 l_wait_event_exclusive(blp->blp_waitq,
1775 (blwi = ldlm_bl_get_work(blp)) != NULL,
1778 if (blwi->blwi_ns == NULL)
1781 if (blwi->blwi_count) {
1782 /* The special case when we cancel locks in lru
1783 * asynchronously, we pass the list of locks here.
1784 * Thus lock is marked LDLM_FL_CANCELING, and already
1785 * canceled locally. */
1786 ldlm_cli_cancel_list(&blwi->blwi_head,
1787 blwi->blwi_count, NULL, 0, 0);
1789 ldlm_handle_bl_callback(blwi->blwi_ns, &blwi->blwi_ld,
1792 OBD_FREE(blwi, sizeof(*blwi));
1795 atomic_dec(&blp->blp_num_threads);
1796 complete(&blp->blp_comp);
1802 static int ldlm_setup(void);
1803 static int ldlm_cleanup(int force);
1805 int ldlm_get_ref(void)
1809 mutex_down(&ldlm_ref_sem);
1810 if (++ldlm_refcount == 1) {
1815 mutex_up(&ldlm_ref_sem);
1820 void ldlm_put_ref(int force)
1823 mutex_down(&ldlm_ref_sem);
1824 if (ldlm_refcount == 1) {
1825 int rc = ldlm_cleanup(force);
1827 CERROR("ldlm_cleanup failed: %d\n", rc);
1833 mutex_up(&ldlm_ref_sem);
1838 static int ldlm_setup(void)
1840 struct ldlm_bl_pool *blp;
1847 if (ldlm_state != NULL)
1850 OBD_ALLOC(ldlm_state, sizeof(*ldlm_state));
1851 if (ldlm_state == NULL)
1855 rc = ldlm_proc_setup();
1860 ldlm_state->ldlm_cb_service =
1861 ptlrpc_init_svc(LDLM_NBUFS, LDLM_BUFSIZE, LDLM_MAXREQSIZE,
1862 LDLM_MAXREPSIZE, LDLM_CB_REQUEST_PORTAL,
1863 LDLM_CB_REPLY_PORTAL, ldlm_timeout * 900,
1864 ldlm_callback_handler, "ldlm_cbd",
1865 ldlm_svc_proc_dir, NULL,
1866 LDLM_THREADS_AUTO_MIN, LDLM_THREADS_AUTO_MAX,
1868 LCT_MD_THREAD|LCT_DT_THREAD);
1870 if (!ldlm_state->ldlm_cb_service) {
1871 CERROR("failed to start service\n");
1872 GOTO(out_proc, rc = -ENOMEM);
1875 ldlm_state->ldlm_cancel_service =
1876 ptlrpc_init_svc(LDLM_NBUFS, LDLM_BUFSIZE, LDLM_MAXREQSIZE,
1877 LDLM_MAXREPSIZE, LDLM_CANCEL_REQUEST_PORTAL,
1878 LDLM_CANCEL_REPLY_PORTAL, ldlm_timeout * 6000,
1879 ldlm_cancel_handler, "ldlm_canceld",
1880 ldlm_svc_proc_dir, NULL,
1881 LDLM_THREADS_AUTO_MIN, LDLM_THREADS_AUTO_MAX,
1883 LCT_MD_THREAD|LCT_DT_THREAD|LCT_CL_THREAD);
1885 if (!ldlm_state->ldlm_cancel_service) {
1886 CERROR("failed to start service\n");
1887 GOTO(out_proc, rc = -ENOMEM);
1890 OBD_ALLOC(blp, sizeof(*blp));
1892 GOTO(out_proc, rc = -ENOMEM);
1893 ldlm_state->ldlm_bl_pool = blp;
1895 atomic_set(&blp->blp_num_threads, 0);
1896 cfs_waitq_init(&blp->blp_waitq);
1897 spin_lock_init(&blp->blp_lock);
1899 CFS_INIT_LIST_HEAD(&blp->blp_list);
1902 for (i = 0; i < LDLM_BL_THREADS; i++) {
1903 struct ldlm_bl_thread_data bltd = {
1907 init_completion(&blp->blp_comp);
1908 rc = cfs_kernel_thread(ldlm_bl_thread_main, &bltd, 0);
1910 CERROR("cannot start LDLM thread #%d: rc %d\n", i, rc);
1911 GOTO(out_thread, rc);
1913 wait_for_completion(&blp->blp_comp);
1916 rc = ptlrpc_start_threads(NULL, ldlm_state->ldlm_cancel_service);
1918 GOTO(out_thread, rc);
1920 rc = ptlrpc_start_threads(NULL, ldlm_state->ldlm_cb_service);
1922 GOTO(out_thread, rc);
1924 CFS_INIT_LIST_HEAD(&expired_lock_thread.elt_expired_locks);
1925 expired_lock_thread.elt_state = ELT_STOPPED;
1926 cfs_waitq_init(&expired_lock_thread.elt_waitq);
1928 CFS_INIT_LIST_HEAD(&waiting_locks_list);
1929 spin_lock_init(&waiting_locks_spinlock);
1930 cfs_timer_init(&waiting_locks_timer, waiting_locks_callback, 0);
1932 rc = cfs_kernel_thread(expired_lock_main, NULL, CLONE_VM | CLONE_FILES);
1934 CERROR("Cannot start ldlm expired-lock thread: %d\n", rc);
1935 GOTO(out_thread, rc);
1938 wait_event(expired_lock_thread.elt_waitq,
1939 expired_lock_thread.elt_state == ELT_READY);
1943 rc = ldlm_pools_init();
1945 GOTO(out_thread, rc);
1951 ptlrpc_unregister_service(ldlm_state->ldlm_cancel_service);
1952 ptlrpc_unregister_service(ldlm_state->ldlm_cb_service);
1957 ldlm_proc_cleanup();
1960 OBD_FREE(ldlm_state, sizeof(*ldlm_state));
1965 static int ldlm_cleanup(int force)
1968 struct ldlm_bl_pool *blp = ldlm_state->ldlm_bl_pool;
1972 if (!list_empty(ldlm_namespace_list(LDLM_NAMESPACE_SERVER)) ||
1973 !list_empty(ldlm_namespace_list(LDLM_NAMESPACE_CLIENT))) {
1974 CERROR("ldlm still has namespaces; clean these up first.\n");
1975 ldlm_dump_all_namespaces(LDLM_NAMESPACE_SERVER, D_DLMTRACE);
1976 ldlm_dump_all_namespaces(LDLM_NAMESPACE_CLIENT, D_DLMTRACE);
1985 while (atomic_read(&blp->blp_num_threads) > 0) {
1986 struct ldlm_bl_work_item blwi = { .blwi_ns = NULL };
1988 init_completion(&blp->blp_comp);
1990 spin_lock(&blp->blp_lock);
1991 list_add_tail(&blwi.blwi_entry, &blp->blp_list);
1992 cfs_waitq_signal(&blp->blp_waitq);
1993 spin_unlock(&blp->blp_lock);
1995 wait_for_completion(&blp->blp_comp);
1997 OBD_FREE(blp, sizeof(*blp));
1999 ptlrpc_unregister_service(ldlm_state->ldlm_cb_service);
2000 ptlrpc_unregister_service(ldlm_state->ldlm_cancel_service);
2001 ldlm_proc_cleanup();
2003 expired_lock_thread.elt_state = ELT_TERMINATE;
2004 cfs_waitq_signal(&expired_lock_thread.elt_waitq);
2005 wait_event(expired_lock_thread.elt_waitq,
2006 expired_lock_thread.elt_state == ELT_STOPPED);
2008 ptlrpc_unregister_service(ldlm_state->ldlm_cb_service);
2009 ptlrpc_unregister_service(ldlm_state->ldlm_cancel_service);
2012 OBD_FREE(ldlm_state, sizeof(*ldlm_state));
2018 int __init ldlm_init(void)
2020 init_mutex(&ldlm_ref_sem);
2021 init_mutex(ldlm_namespace_lock(LDLM_NAMESPACE_SERVER));
2022 init_mutex(ldlm_namespace_lock(LDLM_NAMESPACE_CLIENT));
2023 ldlm_resource_slab = cfs_mem_cache_create("ldlm_resources",
2024 sizeof(struct ldlm_resource), 0,
2025 SLAB_HWCACHE_ALIGN);
2026 if (ldlm_resource_slab == NULL)
2029 ldlm_lock_slab = cfs_mem_cache_create("ldlm_locks",
2030 sizeof(struct ldlm_lock), 0,
2031 SLAB_HWCACHE_ALIGN);
2032 if (ldlm_lock_slab == NULL) {
2033 cfs_mem_cache_destroy(ldlm_resource_slab);
2040 void __exit ldlm_exit(void)
2044 CERROR("ldlm_refcount is %d in ldlm_exit!\n", ldlm_refcount);
2045 rc = cfs_mem_cache_destroy(ldlm_resource_slab);
2046 LASSERTF(rc == 0, "couldn't free ldlm resource slab\n");
2047 rc = cfs_mem_cache_destroy(ldlm_lock_slab);
2048 LASSERTF(rc == 0, "couldn't free ldlm lock slab\n");
2052 EXPORT_SYMBOL(ldlm_extent_shift_kms);
2055 EXPORT_SYMBOL(ldlm_get_processing_policy);
2056 EXPORT_SYMBOL(ldlm_lock2desc);
2057 EXPORT_SYMBOL(ldlm_register_intent);
2058 EXPORT_SYMBOL(ldlm_lockname);
2059 EXPORT_SYMBOL(ldlm_typename);
2060 EXPORT_SYMBOL(ldlm_lock2handle);
2061 EXPORT_SYMBOL(__ldlm_handle2lock);
2062 EXPORT_SYMBOL(ldlm_lock_get);
2063 EXPORT_SYMBOL(ldlm_lock_put);
2064 EXPORT_SYMBOL(ldlm_lock_match);
2065 EXPORT_SYMBOL(ldlm_lock_cancel);
2066 EXPORT_SYMBOL(ldlm_lock_addref);
2067 EXPORT_SYMBOL(ldlm_lock_decref);
2068 EXPORT_SYMBOL(ldlm_lock_decref_and_cancel);
2069 EXPORT_SYMBOL(ldlm_lock_change_resource);
2070 EXPORT_SYMBOL(ldlm_lock_set_data);
2071 EXPORT_SYMBOL(ldlm_it2str);
2072 EXPORT_SYMBOL(ldlm_lock_dump);
2073 EXPORT_SYMBOL(ldlm_lock_dump_handle);
2074 EXPORT_SYMBOL(ldlm_cancel_locks_for_export);
2075 EXPORT_SYMBOL(ldlm_reprocess_all_ns);
2076 EXPORT_SYMBOL(ldlm_lock_allow_match);
2078 /* ldlm_request.c */
2079 EXPORT_SYMBOL(ldlm_completion_ast);
2080 EXPORT_SYMBOL(ldlm_blocking_ast);
2081 EXPORT_SYMBOL(ldlm_glimpse_ast);
2082 EXPORT_SYMBOL(ldlm_expired_completion_wait);
2083 EXPORT_SYMBOL(ldlm_prep_enqueue_req);
2084 EXPORT_SYMBOL(ldlm_cli_convert);
2085 EXPORT_SYMBOL(ldlm_cli_enqueue);
2086 EXPORT_SYMBOL(ldlm_cli_enqueue_fini);
2087 EXPORT_SYMBOL(ldlm_cli_enqueue_local);
2088 EXPORT_SYMBOL(ldlm_cli_cancel);
2089 EXPORT_SYMBOL(ldlm_cli_cancel_unused);
2090 EXPORT_SYMBOL(ldlm_cli_cancel_unused_resource);
2091 EXPORT_SYMBOL(ldlm_cli_cancel_req);
2092 EXPORT_SYMBOL(ldlm_cli_join_lru);
2093 EXPORT_SYMBOL(ldlm_replay_locks);
2094 EXPORT_SYMBOL(ldlm_resource_foreach);
2095 EXPORT_SYMBOL(ldlm_namespace_foreach);
2096 EXPORT_SYMBOL(ldlm_namespace_foreach_res);
2097 EXPORT_SYMBOL(ldlm_resource_iterate);
2098 EXPORT_SYMBOL(ldlm_cancel_resource_local);
2099 EXPORT_SYMBOL(ldlm_cli_cancel_list);
2102 EXPORT_SYMBOL(ldlm_server_blocking_ast);
2103 EXPORT_SYMBOL(ldlm_server_completion_ast);
2104 EXPORT_SYMBOL(ldlm_server_glimpse_ast);
2105 EXPORT_SYMBOL(ldlm_handle_enqueue);
2106 EXPORT_SYMBOL(ldlm_handle_enqueue0);
2107 EXPORT_SYMBOL(ldlm_handle_cancel);
2108 EXPORT_SYMBOL(ldlm_request_cancel);
2109 EXPORT_SYMBOL(ldlm_handle_convert);
2110 EXPORT_SYMBOL(ldlm_handle_convert0);
2111 EXPORT_SYMBOL(ldlm_del_waiting_lock);
2112 EXPORT_SYMBOL(ldlm_get_ref);
2113 EXPORT_SYMBOL(ldlm_put_ref);
2114 EXPORT_SYMBOL(ldlm_refresh_waiting_lock);
2115 EXPORT_SYMBOL(ldlm_revoke_export_locks);
2117 /* ldlm_resource.c */
2118 EXPORT_SYMBOL(ldlm_namespace_new);
2119 EXPORT_SYMBOL(ldlm_namespace_cleanup);
2120 EXPORT_SYMBOL(ldlm_namespace_free);
2121 EXPORT_SYMBOL(ldlm_namespace_dump);
2122 EXPORT_SYMBOL(ldlm_dump_all_namespaces);
2123 EXPORT_SYMBOL(ldlm_resource_get);
2124 EXPORT_SYMBOL(ldlm_resource_putref);
2125 EXPORT_SYMBOL(ldlm_resource_unlink_lock);
2128 EXPORT_SYMBOL(client_import_add_conn);
2129 EXPORT_SYMBOL(client_import_del_conn);
2130 EXPORT_SYMBOL(client_obd_setup);
2131 EXPORT_SYMBOL(client_obd_cleanup);
2132 EXPORT_SYMBOL(client_connect_import);
2133 EXPORT_SYMBOL(client_disconnect_export);
2134 EXPORT_SYMBOL(target_start_recovery_thread);
2135 EXPORT_SYMBOL(target_stop_recovery_thread);
2136 EXPORT_SYMBOL(target_handle_connect);
2137 EXPORT_SYMBOL(target_cleanup_recovery);
2138 EXPORT_SYMBOL(target_destroy_export);
2139 EXPORT_SYMBOL(target_cancel_recovery_timer);
2140 EXPORT_SYMBOL(target_send_reply);
2141 EXPORT_SYMBOL(target_queue_recovery_request);
2142 EXPORT_SYMBOL(target_handle_ping);
2143 EXPORT_SYMBOL(target_pack_pool_reply);
2144 EXPORT_SYMBOL(target_handle_disconnect);
2147 EXPORT_SYMBOL(lock_res_and_lock);
2148 EXPORT_SYMBOL(unlock_res_and_lock);