1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2 * vim:expandtab:shiftwidth=8:tabstop=8:
4 * Copyright (C) 2002, 2003 Cluster File Systems, Inc.
5 * Author: Peter Braam <braam@clusterfs.com>
6 * Author: Phil Schwan <phil@clusterfs.com>
8 * This file is part of Lustre, http://www.lustre.org.
10 * Lustre is free software; you can redistribute it and/or
11 * modify it under the terms of version 2 of the GNU General Public
12 * License as published by the Free Software Foundation.
14 * Lustre is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with Lustre; if not, write to the Free Software
21 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
25 # define EXPORT_SYMTAB
27 #define DEBUG_SUBSYSTEM S_LDLM
30 # include <linux/module.h>
31 # include <linux/slab.h>
32 # include <linux/init.h>
33 # include <linux/wait.h>
35 # include <liblustre.h>
38 #include <linux/lustre_dlm.h>
39 #include <linux/obd_class.h>
40 #include <portals/list.h>
41 #include "ldlm_internal.h"
43 extern kmem_cache_t *ldlm_resource_slab;
44 extern kmem_cache_t *ldlm_lock_slab;
45 extern struct lustre_lock ldlm_handle_lock;
46 extern struct list_head ldlm_namespace_list;
47 extern int (*mds_reint_p)(int offset, struct ptlrpc_request *req);
48 extern int (*mds_getattr_name_p)(int offset, struct ptlrpc_request *req);
50 static DECLARE_MUTEX(ldlm_ref_sem);
51 static int ldlm_refcount = 0;
55 static struct ldlm_state *ldlm_state;
57 inline unsigned long round_timeout(unsigned long timeout)
59 return ((timeout / HZ) + 1) * HZ;
63 /* XXX should this be per-ldlm? */
64 static struct list_head waiting_locks_list;
65 static spinlock_t waiting_locks_spinlock;
66 static struct timer_list waiting_locks_timer;
68 static struct expired_lock_thread {
69 wait_queue_head_t elt_waitq;
71 struct list_head elt_expired_locks;
73 } expired_lock_thread;
78 #define ELT_TERMINATE 2
82 struct list_head blp_list;
83 wait_queue_head_t blp_waitq;
84 atomic_t blp_num_threads;
85 struct completion blp_comp;
88 struct ldlm_bl_work_item {
89 struct list_head blwi_entry;
90 struct ldlm_namespace *blwi_ns;
91 struct ldlm_lock_desc blwi_ld;
92 struct ldlm_lock *blwi_lock;
97 static inline int have_expired_locks(void)
101 spin_lock_bh(&expired_lock_thread.elt_lock);
102 need_to_run = !list_empty(&expired_lock_thread.elt_expired_locks);
103 spin_unlock_bh(&expired_lock_thread.elt_lock);
108 static int expired_lock_main(void *arg)
110 struct list_head *expired = &expired_lock_thread.elt_expired_locks;
111 struct l_wait_info lwi = { 0 };
116 kportal_daemonize("ldlm_elt");
118 SIGNAL_MASK_LOCK(current, flags);
119 sigfillset(¤t->blocked);
121 SIGNAL_MASK_UNLOCK(current, flags);
125 expired_lock_thread.elt_state = ELT_READY;
126 wake_up(&expired_lock_thread.elt_waitq);
129 l_wait_event(expired_lock_thread.elt_waitq,
130 have_expired_locks() ||
131 expired_lock_thread.elt_state == ELT_TERMINATE,
134 spin_lock_bh(&expired_lock_thread.elt_lock);
135 while (!list_empty(expired)) {
136 struct obd_export *export;
137 struct ldlm_lock *lock;
139 lock = list_entry(expired->next, struct ldlm_lock,
141 if ((void *)lock < LP_POISON + PAGE_SIZE &&
142 (void *)lock >= LP_POISON) {
143 CERROR("free lock on elt list %p\n", lock);
146 list_del_init(&lock->l_pending_chain);
147 if ((void *)lock->l_export < LP_POISON + PAGE_SIZE &&
148 (void *)lock->l_export >= LP_POISON + PAGE_SIZE) {
149 CERROR("lock with free export on elt list %p\n",
151 lock->l_export = NULL;
152 LDLM_ERROR(lock, "free export\n");
155 export = class_export_get(lock->l_export);
156 spin_unlock_bh(&expired_lock_thread.elt_lock);
158 ptlrpc_fail_export(export);
159 class_export_put(export);
160 spin_lock_bh(&expired_lock_thread.elt_lock);
162 spin_unlock_bh(&expired_lock_thread.elt_lock);
164 if (expired_lock_thread.elt_state == ELT_TERMINATE)
168 expired_lock_thread.elt_state = ELT_STOPPED;
169 wake_up(&expired_lock_thread.elt_waitq);
173 static void waiting_locks_callback(unsigned long unused)
175 struct ldlm_lock *lock;
176 char str[PTL_NALFMT_SIZE];
178 spin_lock_bh(&waiting_locks_spinlock);
179 while (!list_empty(&waiting_locks_list)) {
180 lock = list_entry(waiting_locks_list.next, struct ldlm_lock,
183 if ((lock->l_callback_timeout > jiffies) ||
184 (lock->l_req_mode == LCK_GROUP))
187 LDLM_ERROR(lock, "lock callback timer expired: evicting client "
188 "%s@%s nid "LPX64" (%s) ",
189 lock->l_export->exp_client_uuid.uuid,
190 lock->l_export->exp_connection->c_remote_uuid.uuid,
191 lock->l_export->exp_connection->c_peer.peer_nid,
192 portals_nid2str(lock->l_export->exp_connection->c_peer.peer_ni->pni_number,
193 lock->l_export->exp_connection->c_peer.peer_nid,
196 spin_lock_bh(&expired_lock_thread.elt_lock);
197 list_del(&lock->l_pending_chain);
198 list_add(&lock->l_pending_chain,
199 &expired_lock_thread.elt_expired_locks);
200 spin_unlock_bh(&expired_lock_thread.elt_lock);
201 wake_up(&expired_lock_thread.elt_waitq);
205 * Make sure the timer will fire again if we have any locks
208 if (!list_empty(&waiting_locks_list)) {
209 unsigned long timeout_rounded;
210 lock = list_entry(waiting_locks_list.next, struct ldlm_lock,
212 timeout_rounded = round_timeout(lock->l_callback_timeout);
213 mod_timer(&waiting_locks_timer, timeout_rounded);
215 spin_unlock_bh(&waiting_locks_spinlock);
219 * Indicate that we're waiting for a client to call us back cancelling a given
220 * lock. We add it to the pending-callback chain, and schedule the lock-timeout
221 * timer to fire appropriately. (We round up to the next second, to avoid
222 * floods of timer firings during periods of high lock contention and traffic).
224 static int ldlm_add_waiting_lock(struct ldlm_lock *lock)
226 unsigned long timeout_rounded;
228 spin_lock_bh(&waiting_locks_spinlock);
229 if (!list_empty(&lock->l_pending_chain)) {
230 LDLM_DEBUG(lock, "not re-adding to wait list");
231 spin_unlock_bh(&waiting_locks_spinlock);
234 LDLM_DEBUG(lock, "adding to wait list");
236 lock->l_callback_timeout = jiffies + (obd_timeout * HZ / 2);
238 timeout_rounded = round_timeout(lock->l_callback_timeout);
240 if (timeout_rounded < waiting_locks_timer.expires ||
241 !timer_pending(&waiting_locks_timer)) {
242 mod_timer(&waiting_locks_timer, timeout_rounded);
244 list_add_tail(&lock->l_pending_chain, &waiting_locks_list); /* FIFO */
245 spin_unlock_bh(&waiting_locks_spinlock);
250 * Remove a lock from the pending list, likely because it had its cancellation
251 * callback arrive without incident. This adjusts the lock-timeout timer if
252 * needed. Returns 0 if the lock wasn't pending after all, 1 if it was.
254 int ldlm_del_waiting_lock(struct ldlm_lock *lock)
256 struct list_head *list_next;
258 if (lock->l_export == NULL) {
259 /* We don't have a "waiting locks list" on clients. */
260 LDLM_DEBUG(lock, "client lock: no-op");
264 spin_lock_bh(&waiting_locks_spinlock);
266 if (list_empty(&lock->l_pending_chain)) {
267 spin_unlock_bh(&waiting_locks_spinlock);
268 LDLM_DEBUG(lock, "wasn't waiting");
272 list_next = lock->l_pending_chain.next;
273 if (lock->l_pending_chain.prev == &waiting_locks_list) {
274 /* Removing the head of the list, adjust timer. */
275 if (list_next == &waiting_locks_list) {
276 /* No more, just cancel. */
277 del_timer(&waiting_locks_timer);
279 struct ldlm_lock *next;
280 next = list_entry(list_next, struct ldlm_lock,
282 mod_timer(&waiting_locks_timer,
283 round_timeout(next->l_callback_timeout));
287 spin_lock_bh(&expired_lock_thread.elt_lock);
288 list_del_init(&lock->l_pending_chain);
289 spin_unlock_bh(&expired_lock_thread.elt_lock);
291 spin_unlock_bh(&waiting_locks_spinlock);
292 LDLM_DEBUG(lock, "removed");
296 #else /* !__KERNEL__ */
298 static int ldlm_add_waiting_lock(struct ldlm_lock *lock)
303 int ldlm_del_waiting_lock(struct ldlm_lock *lock)
308 #endif /* __KERNEL__ */
310 static void ldlm_failed_ast(struct ldlm_lock *lock, int rc, char *ast_type)
312 const struct ptlrpc_connection *conn = lock->l_export->exp_connection;
313 char str[PTL_NALFMT_SIZE];
315 CERROR("%s AST failed (%d) for res "LPU64"/"LPU64
316 ", mode %s: evicting client %s@%s NID "LPX64" (%s)\n",
318 lock->l_resource->lr_name.name[0],
319 lock->l_resource->lr_name.name[1],
320 ldlm_lockname[lock->l_granted_mode],
321 lock->l_export->exp_client_uuid.uuid,
322 conn->c_remote_uuid.uuid, conn->c_peer.peer_nid,
323 portals_nid2str(conn->c_peer.peer_ni->pni_number,
324 conn->c_peer.peer_nid, str));
325 ptlrpc_fail_export(lock->l_export);
328 int ldlm_server_blocking_ast(struct ldlm_lock *lock,
329 struct ldlm_lock_desc *desc,
330 void *data, int flag)
332 struct ldlm_request *body;
333 struct ptlrpc_request *req;
334 int rc = 0, size = sizeof(*body);
337 if (flag == LDLM_CB_CANCELING) {
338 /* Don't need to do anything here. */
344 l_lock(&lock->l_resource->lr_namespace->ns_lock);
345 if (lock->l_granted_mode != lock->l_req_mode) {
346 /* this blocking AST will be communicated as part of the
347 * completion AST instead */
348 l_unlock(&lock->l_resource->lr_namespace->ns_lock);
349 LDLM_DEBUG(lock, "lock not granted, not sending blocking AST"); RETURN(0);
352 if (lock->l_destroyed) {
353 /* What's the point? */
354 l_unlock(&lock->l_resource->lr_namespace->ns_lock);
359 if (LTIME_S(CURRENT_TIME) - lock->l_export->exp_last_request_time > 30){
360 ldlm_failed_ast(lock, -ETIMEDOUT, "Not-attempted blocking");
361 l_unlock(&lock->l_resource->lr_namespace->ns_lock);
366 req = ptlrpc_prep_req(lock->l_export->exp_imp_reverse,
367 LDLM_BL_CALLBACK, 1, &size, NULL);
369 l_unlock(&lock->l_resource->lr_namespace->ns_lock);
373 body = lustre_msg_buf(req->rq_reqmsg, 0, sizeof (*body));
374 memcpy(&body->lock_handle1, &lock->l_remote_handle,
375 sizeof(body->lock_handle1));
376 memcpy(&body->lock_desc, desc, sizeof(*desc));
377 body->lock_flags |= (lock->l_flags & LDLM_AST_FLAGS);
379 LDLM_DEBUG(lock, "server preparing blocking AST");
380 req->rq_replen = lustre_msg_size(0, NULL);
382 if (lock->l_granted_mode == lock->l_req_mode)
383 ldlm_add_waiting_lock(lock);
384 l_unlock(&lock->l_resource->lr_namespace->ns_lock);
386 req->rq_send_state = LUSTRE_IMP_FULL;
387 req->rq_timeout = 2; /* 2 second timeout for initial AST reply */
388 rc = ptlrpc_queue_wait(req);
389 if (rc == -ETIMEDOUT || rc == -EINTR || rc == -ENOTCONN) {
390 LASSERT(lock->l_export);
391 if (lock->l_export->exp_libclient) {
392 CDEBUG(D_HA, "BLOCKING AST to liblustre client (nid "
393 LPU64") timeout, simply cancel lock 0x%p\n",
394 req->rq_peer.peer_nid, lock);
395 ldlm_lock_cancel(lock);
398 ldlm_del_waiting_lock(lock);
399 ldlm_failed_ast(lock, rc, "blocking");
403 CDEBUG(D_DLMTRACE, "client (nid "LPU64") returned %d "
404 "from blocking AST for lock %p--normal race\n",
405 req->rq_peer.peer_nid,
406 req->rq_repmsg->status, lock);
407 else if (rc == -ENOTCONN)
408 CDEBUG(D_DLMTRACE, "client (nid "LPU64") returned %d "
409 "from blocking AST for lock %p--this client was "
410 "probably rebooted while it held a lock, nothing"
411 " serious\n",req->rq_peer.peer_nid,
412 req->rq_repmsg->status, lock);
414 CDEBUG(D_ERROR, "client (nid "LPU64") returned %d "
415 "from blocking AST for lock %p\n",
416 req->rq_peer.peer_nid,
417 (req->rq_repmsg != NULL)?
418 req->rq_repmsg->status : 0,
420 LDLM_DEBUG(lock, "client sent rc %d rq_status %d from blocking "
421 "AST", rc, req->rq_status);
422 ldlm_lock_cancel(lock);
423 /* Server-side AST functions are called from ldlm_reprocess_all,
424 * which needs to be told to please restart its reprocessing. */
428 ptlrpc_req_finished(req);
433 /* XXX copied from ptlrpc/service.c */
434 static long timeval_sub(struct timeval *large, struct timeval *small)
436 return (large->tv_sec - small->tv_sec) * 1000000 +
437 (large->tv_usec - small->tv_usec);
440 int ldlm_server_completion_ast(struct ldlm_lock *lock, int flags, void *data)
442 struct ldlm_request *body;
443 struct ptlrpc_request *req;
444 struct timeval granted_time;
445 long total_enqueue_wait;
446 int rc = 0, size[2] = {sizeof(*body)}, buffers = 1;
449 LASSERT(lock != NULL);
451 do_gettimeofday(&granted_time);
452 total_enqueue_wait = timeval_sub(&granted_time, &lock->l_enqueued_time);
454 if (total_enqueue_wait / 1000000 > obd_timeout)
455 LDLM_ERROR(lock, "enqueue wait took %ldus", total_enqueue_wait);
457 if (lock->l_resource->lr_lvb_len) {
459 size[1] = lock->l_resource->lr_lvb_len;
462 req = ptlrpc_prep_req(lock->l_export->exp_imp_reverse,
463 LDLM_CP_CALLBACK, buffers, size, NULL);
467 body = lustre_msg_buf(req->rq_reqmsg, 0, sizeof (*body));
468 memcpy(&body->lock_handle1, &lock->l_remote_handle,
469 sizeof(body->lock_handle1));
470 body->lock_flags = flags;
471 ldlm_lock2desc(lock, &body->lock_desc);
474 void *lvb = lustre_msg_buf(req->rq_reqmsg, 1,
475 lock->l_resource->lr_lvb_len);
476 memcpy(lvb, lock->l_resource->lr_lvb_data,
477 lock->l_resource->lr_lvb_len);
480 LDLM_DEBUG(lock, "server preparing completion AST (after %ldus wait)",
482 req->rq_replen = lustre_msg_size(0, NULL);
484 req->rq_send_state = LUSTRE_IMP_FULL;
485 req->rq_timeout = 2; /* 2 second timeout for initial AST reply */
487 /* We only send real blocking ASTs after the lock is granted */
488 l_lock(&lock->l_resource->lr_namespace->ns_lock);
489 if (lock->l_flags & LDLM_FL_AST_SENT) {
490 body->lock_flags |= LDLM_FL_AST_SENT;
491 ldlm_add_waiting_lock(lock); /* start the lock-timeout clock */
493 l_unlock(&lock->l_resource->lr_namespace->ns_lock);
495 rc = ptlrpc_queue_wait(req);
496 if ((rc == -ETIMEDOUT || rc == -EINTR || rc == -ENOTCONN) &&
497 !lock->l_export->exp_libclient) {
498 ldlm_del_waiting_lock(lock);
499 ldlm_failed_ast(lock, rc, "completion");
500 } else if (rc == -EINVAL) {
501 LDLM_DEBUG(lock, "lost the race -- client no longer has this "
504 LDLM_ERROR(lock, "client sent rc %d rq_status %d from "
505 "completion AST", rc, req->rq_status);
506 ldlm_lock_cancel(lock);
507 /* Server-side AST functions are called from ldlm_reprocess_all,
508 * which needs to be told to please restart its reprocessing. */
511 ptlrpc_req_finished(req);
516 int ldlm_server_glimpse_ast(struct ldlm_lock *lock, void *data)
518 struct ldlm_resource *res = lock->l_resource;
519 struct ldlm_request *body;
520 struct ptlrpc_request *req;
521 int rc = 0, size = sizeof(*body);
524 LASSERT(lock != NULL);
526 req = ptlrpc_prep_req(lock->l_export->exp_imp_reverse,
527 LDLM_GL_CALLBACK, 1, &size, NULL);
531 body = lustre_msg_buf(req->rq_reqmsg, 0, sizeof(*body));
532 memcpy(&body->lock_handle1, &lock->l_remote_handle,
533 sizeof(body->lock_handle1));
534 ldlm_lock2desc(lock, &body->lock_desc);
536 size = lock->l_resource->lr_lvb_len;
537 req->rq_replen = lustre_msg_size(1, &size);
539 req->rq_send_state = LUSTRE_IMP_FULL;
540 req->rq_timeout = 2; /* 2 second timeout for initial AST reply */
542 rc = ptlrpc_queue_wait(req);
543 if ((rc == -ETIMEDOUT || rc == -EINTR || rc == -ENOTCONN) &&
544 !lock->l_export->exp_libclient) {
545 ldlm_del_waiting_lock(lock);
546 ldlm_failed_ast(lock, rc, "glimpse");
547 } else if (rc == -EINVAL) {
548 LDLM_DEBUG(lock, "lost the race -- client no longer has this "
550 } else if (rc == -ELDLM_NO_LOCK_DATA) {
551 LDLM_DEBUG(lock, "lost a race -- client has a lock, but no "
554 LDLM_ERROR(lock, "client sent rc %d rq_status %d from "
555 "glimpse AST", rc, req->rq_status);
557 rc = res->lr_namespace->ns_lvbo->lvbo_update
558 (res, req->rq_repmsg, 0, 1);
560 ptlrpc_req_finished(req);
564 int ldlm_handle_enqueue(struct ptlrpc_request *req,
565 ldlm_completion_callback completion_callback,
566 ldlm_blocking_callback blocking_callback,
567 ldlm_glimpse_callback glimpse_callback)
569 struct obd_device *obddev = req->rq_export->exp_obd;
570 struct ldlm_reply *dlm_rep;
571 struct ldlm_request *dlm_req;
572 int rc = 0, size[2] = {sizeof(*dlm_rep)};
574 ldlm_error_t err = ELDLM_OK;
575 struct ldlm_lock *lock = NULL;
579 LDLM_DEBUG_NOLOCK("server-side enqueue handler START");
581 dlm_req = lustre_swab_reqbuf (req, 0, sizeof (*dlm_req),
582 lustre_swab_ldlm_request);
583 if (dlm_req == NULL) {
584 CERROR ("Can't unpack dlm_req\n");
585 GOTO(out, rc = -EFAULT);
588 flags = dlm_req->lock_flags;
590 /* The lock's callback data might be set in the policy function */
591 lock = ldlm_lock_create(obddev->obd_namespace, &dlm_req->lock_handle2,
592 dlm_req->lock_desc.l_resource.lr_name,
593 dlm_req->lock_desc.l_resource.lr_type,
594 dlm_req->lock_desc.l_req_mode,
595 blocking_callback, completion_callback,
596 glimpse_callback, NULL, 0);
598 GOTO(out, rc = -ENOMEM);
600 do_gettimeofday(&lock->l_enqueued_time);
601 memcpy(&lock->l_remote_handle, &dlm_req->lock_handle1,
602 sizeof(lock->l_remote_handle));
603 LDLM_DEBUG(lock, "server-side enqueue handler, new lock created");
605 LASSERT(req->rq_export);
606 lock->l_export = class_export_get(req->rq_export);
607 l_lock(&lock->l_resource->lr_namespace->ns_lock);
608 list_add(&lock->l_export_chain,
609 &lock->l_export->exp_ldlm_data.led_held_locks);
610 l_unlock(&lock->l_resource->lr_namespace->ns_lock);
612 if (flags & LDLM_FL_HAS_INTENT) {
613 /* In this case, the reply buffer is allocated deep in
614 * local_lock_enqueue by the policy function. */
618 if (lock->l_resource->lr_lvb_len) {
619 size[1] = lock->l_resource->lr_lvb_len;
623 if (OBD_FAIL_CHECK_ONCE(OBD_FAIL_LDLM_ENQUEUE_EXTENT_ERR))
624 GOTO(out, rc = -ENOMEM);
626 rc = lustre_pack_reply(req, buffers, size, NULL);
631 if (dlm_req->lock_desc.l_resource.lr_type != LDLM_PLAIN)
632 memcpy(&lock->l_policy_data, &dlm_req->lock_desc.l_policy_data,
633 sizeof(ldlm_policy_data_t));
634 if (dlm_req->lock_desc.l_resource.lr_type == LDLM_EXTENT)
635 memcpy(&lock->l_req_extent, &lock->l_policy_data.l_extent,
636 sizeof(lock->l_req_extent));
638 err = ldlm_lock_enqueue(obddev->obd_namespace, &lock, cookie, &flags);
642 dlm_rep = lustre_msg_buf(req->rq_repmsg, 0, sizeof (*dlm_rep));
643 dlm_rep->lock_flags = flags;
645 ldlm_lock2desc(lock, &dlm_rep->lock_desc);
646 ldlm_lock2handle(lock, &dlm_rep->lock_handle);
648 /* We never send a blocking AST until the lock is granted, but
649 * we can tell it right now */
650 l_lock(&lock->l_resource->lr_namespace->ns_lock);
651 if (lock->l_flags & LDLM_FL_AST_SENT) {
652 dlm_rep->lock_flags |= LDLM_FL_AST_SENT;
653 if (lock->l_granted_mode == lock->l_req_mode)
654 ldlm_add_waiting_lock(lock);
656 l_unlock(&lock->l_resource->lr_namespace->ns_lock);
660 req->rq_status = err;
661 if (req->rq_reply_state == NULL) {
662 err = lustre_pack_reply(req, 0, NULL, NULL);
668 /* The LOCK_CHANGED code in ldlm_lock_enqueue depends on this
669 * ldlm_reprocess_all. If this moves, revisit that code. -phil */
671 LDLM_DEBUG(lock, "server-side enqueue handler, sending reply"
672 "(err=%d, rc=%d)", err, rc);
674 if (lock->l_resource->lr_lvb_len > 0 && rc == 0) {
675 void *lvb = lustre_msg_buf(req->rq_repmsg, 1,
676 lock->l_resource->lr_lvb_len);
677 LASSERT(lvb != NULL);
678 memcpy(lvb, lock->l_resource->lr_lvb_data,
679 lock->l_resource->lr_lvb_len);
682 if (!err && dlm_req->lock_desc.l_resource.lr_type != LDLM_FLOCK)
683 ldlm_reprocess_all(lock->l_resource);
686 LDLM_DEBUG_NOLOCK("server-side enqueue handler END (lock %p, rc %d)",
692 int ldlm_handle_convert(struct ptlrpc_request *req)
694 struct ldlm_request *dlm_req;
695 struct ldlm_reply *dlm_rep;
696 struct ldlm_lock *lock;
697 int rc, size = sizeof(*dlm_rep);
700 dlm_req = lustre_swab_reqbuf (req, 0, sizeof (*dlm_req),
701 lustre_swab_ldlm_request);
702 if (dlm_req == NULL) {
703 CERROR ("Can't unpack dlm_req\n");
707 rc = lustre_pack_reply(req, 1, &size, NULL);
709 CERROR("out of memory\n");
712 dlm_rep = lustre_msg_buf(req->rq_repmsg, 0, sizeof (*dlm_rep));
713 dlm_rep->lock_flags = dlm_req->lock_flags;
715 lock = ldlm_handle2lock(&dlm_req->lock_handle1);
717 req->rq_status = EINVAL;
719 LDLM_DEBUG(lock, "server-side convert handler START");
720 ldlm_lock_convert(lock, dlm_req->lock_desc.l_req_mode,
721 &dlm_rep->lock_flags);
722 if (ldlm_del_waiting_lock(lock))
723 CDEBUG(D_DLMTRACE, "converted waiting lock %p\n", lock);
728 ldlm_reprocess_all(lock->l_resource);
729 LDLM_DEBUG(lock, "server-side convert handler END");
732 LDLM_DEBUG_NOLOCK("server-side convert handler END");
737 int ldlm_handle_cancel(struct ptlrpc_request *req)
739 struct ldlm_request *dlm_req;
740 struct ldlm_lock *lock;
741 struct ldlm_resource *res;
742 char str[PTL_NALFMT_SIZE];
746 dlm_req = lustre_swab_reqbuf(req, 0, sizeof (*dlm_req),
747 lustre_swab_ldlm_request);
748 if (dlm_req == NULL) {
749 CERROR("bad request buffer for cancel\n");
753 rc = lustre_pack_reply(req, 0, NULL, NULL);
755 CERROR("out of memory\n");
759 lock = ldlm_handle2lock(&dlm_req->lock_handle1);
761 CERROR("received cancel for unknown lock cookie "LPX64
762 " from client %s nid "LPX64" (%s)\n",
763 dlm_req->lock_handle1.cookie,
764 req->rq_export->exp_client_uuid.uuid,
765 req->rq_peer.peer_nid,
766 portals_nid2str(req->rq_peer.peer_ni->pni_number,
767 req->rq_peer.peer_nid, str));
768 LDLM_DEBUG_NOLOCK("server-side cancel handler stale lock "
770 dlm_req->lock_handle1.cookie);
771 req->rq_status = ESTALE;
773 LDLM_DEBUG(lock, "server-side cancel handler START");
774 res = lock->l_resource;
775 if (res && res->lr_namespace->ns_lvbo &&
776 res->lr_namespace->ns_lvbo->lvbo_update) {
777 (void)res->lr_namespace->ns_lvbo->lvbo_update
779 //(res, req->rq_reqmsg, 1);
782 ldlm_lock_cancel(lock);
783 if (ldlm_del_waiting_lock(lock))
784 CDEBUG(D_DLMTRACE, "cancelled waiting lock %p\n", lock);
788 if (ptlrpc_reply(req) != 0)
792 ldlm_reprocess_all(lock->l_resource);
793 LDLM_DEBUG(lock, "server-side cancel handler END");
800 void ldlm_handle_bl_callback(struct ldlm_namespace *ns,
801 struct ldlm_lock_desc *ld, struct ldlm_lock *lock)
806 l_lock(&ns->ns_lock);
807 LDLM_DEBUG(lock, "client blocking AST callback handler START");
809 lock->l_flags |= LDLM_FL_CBPENDING;
810 do_ast = (!lock->l_readers && !lock->l_writers);
813 LDLM_DEBUG(lock, "already unused, calling "
814 "callback (%p)", lock->l_blocking_ast);
815 if (lock->l_blocking_ast != NULL) {
816 l_unlock(&ns->ns_lock);
817 l_check_no_ns_lock(ns);
818 lock->l_blocking_ast(lock, ld, lock->l_ast_data,
820 l_lock(&ns->ns_lock);
823 LDLM_DEBUG(lock, "Lock still has references, will be"
827 LDLM_DEBUG(lock, "client blocking callback handler END");
828 l_unlock(&ns->ns_lock);
833 static void ldlm_handle_cp_callback(struct ptlrpc_request *req,
834 struct ldlm_namespace *ns,
835 struct ldlm_request *dlm_req,
836 struct ldlm_lock *lock)
841 l_lock(&ns->ns_lock);
842 LDLM_DEBUG(lock, "client completion callback handler START");
844 /* If we receive the completion AST before the actual enqueue returned,
845 * then we might need to switch lock modes, resources, or extents. */
846 if (dlm_req->lock_desc.l_granted_mode != lock->l_req_mode) {
847 lock->l_req_mode = dlm_req->lock_desc.l_granted_mode;
848 LDLM_DEBUG(lock, "completion AST, new lock mode");
851 if (lock->l_resource->lr_type != LDLM_PLAIN) {
852 memcpy(&lock->l_policy_data, &dlm_req->lock_desc.l_policy_data,
853 sizeof(lock->l_policy_data));
854 LDLM_DEBUG(lock, "completion AST, new policy data");
857 ldlm_resource_unlink_lock(lock);
858 if (memcmp(&dlm_req->lock_desc.l_resource.lr_name,
859 &lock->l_resource->lr_name,
860 sizeof(lock->l_resource->lr_name)) != 0) {
861 ldlm_lock_change_resource(ns, lock,
862 dlm_req->lock_desc.l_resource.lr_name);
863 LDLM_DEBUG(lock, "completion AST, new resource");
866 if (dlm_req->lock_flags & LDLM_FL_AST_SENT) {
867 lock->l_flags |= LDLM_FL_CBPENDING;
868 LDLM_DEBUG(lock, "completion AST includes blocking AST");
871 if (lock->l_lvb_len) {
873 lvb = lustre_swab_reqbuf(req, 1, lock->l_lvb_len,
874 lock->l_lvb_swabber);
876 LDLM_ERROR(lock, "completion AST did not contain "
879 memcpy(lock->l_lvb_data, lvb, lock->l_lvb_len);
883 lock->l_resource->lr_tmp = &ast_list;
884 ldlm_grant_lock(lock, req, sizeof(*req), 1);
885 lock->l_resource->lr_tmp = NULL;
886 LDLM_DEBUG(lock, "callback handler finished, about to run_ast_work");
887 l_unlock(&ns->ns_lock);
890 ldlm_run_ast_work(ns, &ast_list);
892 LDLM_DEBUG_NOLOCK("client completion callback handler END (lock %p)",
897 static void ldlm_handle_gl_callback(struct ptlrpc_request *req,
898 struct ldlm_namespace *ns,
899 struct ldlm_request *dlm_req,
900 struct ldlm_lock *lock)
905 l_lock(&ns->ns_lock);
906 LDLM_DEBUG(lock, "client glimpse AST callback handler");
908 if (lock->l_glimpse_ast != NULL) {
909 l_unlock(&ns->ns_lock);
910 l_check_no_ns_lock(ns);
911 rc = lock->l_glimpse_ast(lock, req);
912 l_lock(&ns->ns_lock);
915 if (req->rq_repmsg != NULL) {
922 if (lock->l_granted_mode == LCK_PW &&
923 !lock->l_readers && !lock->l_writers &&
924 time_after(jiffies, lock->l_last_used + 10 * HZ)) {
925 l_unlock(&ns->ns_lock);
926 ldlm_handle_bl_callback(ns, NULL, lock);
931 l_unlock(&ns->ns_lock);
936 static int ldlm_callback_reply(struct ptlrpc_request *req, int rc)
939 if (req->rq_reply_state == NULL) {
940 rc = lustre_pack_reply(req, 0, NULL, NULL);
944 return ptlrpc_reply(req);
947 int ldlm_bl_to_thread(struct ldlm_namespace *ns, struct ldlm_lock_desc *ld,
948 struct ldlm_lock *lock)
951 struct ldlm_bl_pool *blp = ldlm_state->ldlm_bl_pool;
952 struct ldlm_bl_work_item *blwi;
955 OBD_ALLOC(blwi, sizeof(*blwi));
962 blwi->blwi_lock = lock;
964 spin_lock(&blp->blp_lock);
965 list_add_tail(&blwi->blwi_entry, &blp->blp_list);
966 wake_up(&blp->blp_waitq);
967 spin_unlock(&blp->blp_lock);
975 static int ldlm_callback_handler(struct ptlrpc_request *req)
977 struct ldlm_namespace *ns;
978 struct ldlm_request *dlm_req;
979 struct ldlm_lock *lock;
980 char str[PTL_NALFMT_SIZE];
984 /* Requests arrive in sender's byte order. The ptlrpc service
985 * handler has already checked and, if necessary, byte-swapped the
986 * incoming request message body, but I am responsible for the
987 * message buffers. */
989 if (req->rq_export == NULL) {
990 struct ldlm_request *dlm_req;
992 CDEBUG(D_RPCTRACE, "operation %d from nid "LPX64" (%s) with bad "
993 "export cookie "LPX64" (ptl req %d/rep %d); this is "
994 "normal if this node rebooted with a lock held\n",
995 req->rq_reqmsg->opc, req->rq_peer.peer_nid,
996 portals_nid2str(req->rq_peer.peer_ni->pni_number,
997 req->rq_peer.peer_nid, str),
998 req->rq_reqmsg->handle.cookie,
999 req->rq_request_portal, req->rq_reply_portal);
1001 dlm_req = lustre_swab_reqbuf(req, 0, sizeof (*dlm_req),
1002 lustre_swab_ldlm_request);
1003 if (dlm_req != NULL)
1004 CDEBUG(D_RPCTRACE, "--> lock cookie: "LPX64"\n",
1005 dlm_req->lock_handle1.cookie);
1007 ldlm_callback_reply(req, -ENOTCONN);
1011 LASSERT(req->rq_export != NULL);
1012 LASSERT(req->rq_export->exp_obd != NULL);
1014 switch(req->rq_reqmsg->opc) {
1015 case LDLM_BL_CALLBACK:
1016 OBD_FAIL_RETURN(OBD_FAIL_LDLM_BL_CALLBACK, 0);
1018 case LDLM_CP_CALLBACK:
1019 OBD_FAIL_RETURN(OBD_FAIL_LDLM_CP_CALLBACK, 0);
1021 case LDLM_GL_CALLBACK:
1022 OBD_FAIL_RETURN(OBD_FAIL_LDLM_GL_CALLBACK, 0);
1024 case OBD_LOG_CANCEL:
1025 OBD_FAIL_RETURN(OBD_FAIL_OBD_LOG_CANCEL_NET, 0);
1026 rc = llog_origin_handle_cancel(req);
1027 ldlm_callback_reply(req, rc);
1029 case LLOG_ORIGIN_HANDLE_CREATE:
1030 OBD_FAIL_RETURN(OBD_FAIL_OBD_LOGD_NET, 0);
1031 rc = llog_origin_handle_create(req);
1032 ldlm_callback_reply(req, rc);
1034 case LLOG_ORIGIN_HANDLE_NEXT_BLOCK:
1035 OBD_FAIL_RETURN(OBD_FAIL_OBD_LOGD_NET, 0);
1036 rc = llog_origin_handle_next_block(req);
1037 ldlm_callback_reply(req, rc);
1039 case LLOG_ORIGIN_HANDLE_READ_HEADER:
1040 OBD_FAIL_RETURN(OBD_FAIL_OBD_LOGD_NET, 0);
1041 rc = llog_origin_handle_read_header(req);
1042 ldlm_callback_reply(req, rc);
1044 case LLOG_ORIGIN_HANDLE_CLOSE:
1045 OBD_FAIL_RETURN(OBD_FAIL_OBD_LOGD_NET, 0);
1046 rc = llog_origin_handle_close(req);
1047 ldlm_callback_reply(req, rc);
1050 CERROR("unknown opcode %u\n", req->rq_reqmsg->opc);
1051 ldlm_callback_reply(req, -EPROTO);
1055 ns = req->rq_export->exp_obd->obd_namespace;
1056 LASSERT(ns != NULL);
1058 dlm_req = lustre_swab_reqbuf (req, 0, sizeof (*dlm_req),
1059 lustre_swab_ldlm_request);
1060 if (dlm_req == NULL) {
1061 CERROR ("can't unpack dlm_req\n");
1062 ldlm_callback_reply (req, -EPROTO);
1066 lock = ldlm_handle2lock_ns(ns, &dlm_req->lock_handle1);
1068 CDEBUG(D_INODE, "callback on lock "LPX64" - lock disappeared\n",
1069 dlm_req->lock_handle1.cookie);
1070 ldlm_callback_reply(req, -EINVAL);
1074 /* Copy hints/flags (e.g. LDLM_FL_DISCARD_DATA) from AST. */
1075 lock->l_flags |= (dlm_req->lock_flags & LDLM_AST_FLAGS);
1077 /* We want the ost thread to get this reply so that it can respond
1078 * to ost requests (write cache writeback) that might be triggered
1081 * But we'd also like to be able to indicate in the reply that we're
1082 * cancelling right now, because it's unused, or have an intent result
1083 * in the reply, so we might have to push the responsibility for sending
1084 * the reply down into the AST handlers, alas. */
1086 switch (req->rq_reqmsg->opc) {
1087 case LDLM_BL_CALLBACK:
1088 CDEBUG(D_INODE, "blocking ast\n");
1090 rc = ldlm_bl_to_thread(ns, &dlm_req->lock_desc, lock);
1091 ldlm_callback_reply(req, rc);
1094 ldlm_callback_reply(req, rc);
1095 ldlm_handle_bl_callback(ns, &dlm_req->lock_desc, lock);
1098 case LDLM_CP_CALLBACK:
1099 CDEBUG(D_INODE, "completion ast\n");
1100 ldlm_callback_reply(req, 0);
1101 ldlm_handle_cp_callback(req, ns, dlm_req, lock);
1103 case LDLM_GL_CALLBACK:
1104 CDEBUG(D_INODE, "glimpse ast\n");
1105 ldlm_handle_gl_callback(req, ns, dlm_req, lock);
1108 LBUG(); /* checked above */
1114 static int ldlm_cancel_handler(struct ptlrpc_request *req)
1119 /* Requests arrive in sender's byte order. The ptlrpc service
1120 * handler has already checked and, if necessary, byte-swapped the
1121 * incoming request message body, but I am responsible for the
1122 * message buffers. */
1124 if (req->rq_export == NULL) {
1125 struct ldlm_request *dlm_req;
1126 CERROR("operation %d with bad export (ptl req %d/rep %d)\n",
1127 req->rq_reqmsg->opc, req->rq_request_portal,
1128 req->rq_reply_portal);
1129 CERROR("--> export cookie: "LPX64"\n",
1130 req->rq_reqmsg->handle.cookie);
1131 dlm_req = lustre_swab_reqbuf(req, 0, sizeof (*dlm_req),
1132 lustre_swab_ldlm_request);
1133 if (dlm_req != NULL)
1134 ldlm_lock_dump_handle(D_ERROR, &dlm_req->lock_handle1);
1138 switch (req->rq_reqmsg->opc) {
1140 /* XXX FIXME move this back to mds/handler.c, bug 249 */
1142 CDEBUG(D_INODE, "cancel\n");
1143 OBD_FAIL_RETURN(OBD_FAIL_LDLM_CANCEL, 0);
1144 rc = ldlm_handle_cancel(req);
1150 CERROR("invalid opcode %d\n", req->rq_reqmsg->opc);
1158 static struct ldlm_bl_work_item *ldlm_bl_get_work(struct ldlm_bl_pool *blp)
1160 struct ldlm_bl_work_item *blwi = NULL;
1162 spin_lock(&blp->blp_lock);
1163 if (!list_empty(&blp->blp_list)) {
1164 blwi = list_entry(blp->blp_list.next, struct ldlm_bl_work_item,
1166 list_del(&blwi->blwi_entry);
1168 spin_unlock(&blp->blp_lock);
1173 struct ldlm_bl_thread_data {
1175 struct ldlm_bl_pool *bltd_blp;
1178 static int ldlm_bl_thread_main(void *arg)
1180 struct ldlm_bl_thread_data *bltd = arg;
1181 struct ldlm_bl_pool *blp = bltd->bltd_blp;
1182 unsigned long flags;
1185 /* XXX boiler-plate */
1187 char name[sizeof(current->comm)];
1188 snprintf(name, sizeof(name) - 1, "ldlm_bl_%02d",
1190 kportal_daemonize(name);
1192 SIGNAL_MASK_LOCK(current, flags);
1193 sigfillset(¤t->blocked);
1195 SIGNAL_MASK_UNLOCK(current, flags);
1197 atomic_inc(&blp->blp_num_threads);
1198 complete(&blp->blp_comp);
1201 struct l_wait_info lwi = { 0 };
1202 struct ldlm_bl_work_item *blwi = NULL;
1204 l_wait_event_exclusive(blp->blp_waitq,
1205 (blwi = ldlm_bl_get_work(blp)) != NULL,
1208 if (blwi->blwi_ns == NULL)
1211 ldlm_handle_bl_callback(blwi->blwi_ns, &blwi->blwi_ld,
1213 OBD_FREE(blwi, sizeof(*blwi));
1216 atomic_dec(&blp->blp_num_threads);
1217 complete(&blp->blp_comp);
1223 static int ldlm_setup(void);
1224 static int ldlm_cleanup(int force);
1226 int ldlm_get_ref(void)
1229 down(&ldlm_ref_sem);
1230 if (++ldlm_refcount == 1) {
1240 void ldlm_put_ref(int force)
1242 down(&ldlm_ref_sem);
1243 if (ldlm_refcount == 1) {
1244 int rc = ldlm_cleanup(force);
1246 CERROR("ldlm_cleanup failed: %d\n", rc);
1257 static int ldlm_setup(void)
1259 struct ldlm_bl_pool *blp;
1266 if (ldlm_state != NULL)
1269 OBD_ALLOC(ldlm_state, sizeof(*ldlm_state));
1270 if (ldlm_state == NULL)
1274 rc = ldlm_proc_setup();
1279 ldlm_state->ldlm_cb_service =
1280 ptlrpc_init_svc(LDLM_NBUFS, LDLM_BUFSIZE, LDLM_MAXREQSIZE,
1281 LDLM_CB_REQUEST_PORTAL, LDLM_CB_REPLY_PORTAL,
1282 ldlm_callback_handler, "ldlm_cbd",
1285 if (!ldlm_state->ldlm_cb_service) {
1286 CERROR("failed to start service\n");
1287 GOTO(out_proc, rc = -ENOMEM);
1290 ldlm_state->ldlm_cancel_service =
1291 ptlrpc_init_svc(LDLM_NBUFS, LDLM_BUFSIZE, LDLM_MAXREQSIZE,
1292 LDLM_CANCEL_REQUEST_PORTAL,
1293 LDLM_CANCEL_REPLY_PORTAL,
1294 ldlm_cancel_handler, "ldlm_canceld",
1297 if (!ldlm_state->ldlm_cancel_service) {
1298 CERROR("failed to start service\n");
1299 GOTO(out_proc, rc = -ENOMEM);
1302 OBD_ALLOC(blp, sizeof(*blp));
1304 GOTO(out_proc, rc = -ENOMEM);
1305 ldlm_state->ldlm_bl_pool = blp;
1307 atomic_set(&blp->blp_num_threads, 0);
1308 init_waitqueue_head(&blp->blp_waitq);
1309 spin_lock_init(&blp->blp_lock);
1311 INIT_LIST_HEAD(&blp->blp_list);
1314 for (i = 0; i < LDLM_NUM_THREADS; i++) {
1315 struct ldlm_bl_thread_data bltd = {
1319 init_completion(&blp->blp_comp);
1320 rc = kernel_thread(ldlm_bl_thread_main, &bltd, 0);
1322 CERROR("cannot start LDLM thread #%d: rc %d\n", i, rc);
1324 GOTO(out_thread, rc);
1326 wait_for_completion(&blp->blp_comp);
1329 rc = ptlrpc_start_n_threads(NULL, ldlm_state->ldlm_cancel_service,
1330 LDLM_NUM_THREADS, "ldlm_cn");
1333 GOTO(out_thread, rc);
1336 rc = ptlrpc_start_n_threads(NULL, ldlm_state->ldlm_cb_service,
1337 LDLM_NUM_THREADS, "ldlm_cb");
1340 GOTO(out_thread, rc);
1343 INIT_LIST_HEAD(&expired_lock_thread.elt_expired_locks);
1344 spin_lock_init(&expired_lock_thread.elt_lock);
1345 expired_lock_thread.elt_state = ELT_STOPPED;
1346 init_waitqueue_head(&expired_lock_thread.elt_waitq);
1348 rc = kernel_thread(expired_lock_main, NULL, CLONE_VM | CLONE_FS);
1350 CERROR("Cannot start ldlm expired-lock thread: %d\n", rc);
1351 GOTO(out_thread, rc);
1354 wait_event(expired_lock_thread.elt_waitq,
1355 expired_lock_thread.elt_state == ELT_READY);
1357 INIT_LIST_HEAD(&waiting_locks_list);
1358 spin_lock_init(&waiting_locks_spinlock);
1359 waiting_locks_timer.function = waiting_locks_callback;
1360 waiting_locks_timer.data = 0;
1361 init_timer(&waiting_locks_timer);
1368 ptlrpc_unregister_service(ldlm_state->ldlm_cancel_service);
1369 ptlrpc_unregister_service(ldlm_state->ldlm_cb_service);
1374 ldlm_proc_cleanup();
1377 OBD_FREE(ldlm_state, sizeof(*ldlm_state));
1382 static int ldlm_cleanup(int force)
1385 struct ldlm_bl_pool *blp = ldlm_state->ldlm_bl_pool;
1389 if (!list_empty(&ldlm_namespace_list)) {
1390 CERROR("ldlm still has namespaces; clean these up first.\n");
1391 ldlm_dump_all_namespaces();
1396 while (atomic_read(&blp->blp_num_threads) > 0) {
1397 struct ldlm_bl_work_item blwi = { .blwi_ns = NULL };
1399 init_completion(&blp->blp_comp);
1401 spin_lock(&blp->blp_lock);
1402 list_add_tail(&blwi.blwi_entry, &blp->blp_list);
1403 wake_up(&blp->blp_waitq);
1404 spin_unlock(&blp->blp_lock);
1406 wait_for_completion(&blp->blp_comp);
1408 OBD_FREE(blp, sizeof(*blp));
1410 ptlrpc_stop_all_threads(ldlm_state->ldlm_cb_service);
1411 ptlrpc_unregister_service(ldlm_state->ldlm_cb_service);
1412 ptlrpc_stop_all_threads(ldlm_state->ldlm_cancel_service);
1413 ptlrpc_unregister_service(ldlm_state->ldlm_cancel_service);
1414 ldlm_proc_cleanup();
1416 expired_lock_thread.elt_state = ELT_TERMINATE;
1417 wake_up(&expired_lock_thread.elt_waitq);
1418 wait_event(expired_lock_thread.elt_waitq,
1419 expired_lock_thread.elt_state == ELT_STOPPED);
1423 OBD_FREE(ldlm_state, sizeof(*ldlm_state));
1429 int __init ldlm_init(void)
1431 ldlm_resource_slab = kmem_cache_create("ldlm_resources",
1432 sizeof(struct ldlm_resource), 0,
1433 SLAB_HWCACHE_ALIGN, NULL, NULL);
1434 if (ldlm_resource_slab == NULL)
1437 ldlm_lock_slab = kmem_cache_create("ldlm_locks",
1438 sizeof(struct ldlm_lock), 0,
1439 SLAB_HWCACHE_ALIGN, NULL, NULL);
1440 if (ldlm_lock_slab == NULL) {
1441 kmem_cache_destroy(ldlm_resource_slab);
1445 l_lock_init(&ldlm_handle_lock);
1450 void __exit ldlm_exit(void)
1452 if ( ldlm_refcount )
1453 CERROR("ldlm_refcount is %d in ldlm_exit!\n", ldlm_refcount);
1454 if (kmem_cache_destroy(ldlm_resource_slab) != 0)
1455 CERROR("couldn't free ldlm resource slab\n");
1456 if (kmem_cache_destroy(ldlm_lock_slab) != 0)
1457 CERROR("couldn't free ldlm lock slab\n");
1461 EXPORT_SYMBOL(ldlm_flock_completion_ast);
1464 EXPORT_SYMBOL(ldlm_extent_shift_kms);
1467 EXPORT_SYMBOL(ldlm_get_processing_policy);
1468 EXPORT_SYMBOL(ldlm_lock2desc);
1469 EXPORT_SYMBOL(ldlm_register_intent);
1470 EXPORT_SYMBOL(ldlm_lockname);
1471 EXPORT_SYMBOL(ldlm_typename);
1472 EXPORT_SYMBOL(ldlm_lock2handle);
1473 EXPORT_SYMBOL(__ldlm_handle2lock);
1474 EXPORT_SYMBOL(ldlm_lock_get);
1475 EXPORT_SYMBOL(ldlm_lock_put);
1476 EXPORT_SYMBOL(ldlm_lock_match);
1477 EXPORT_SYMBOL(ldlm_lock_cancel);
1478 EXPORT_SYMBOL(ldlm_lock_addref);
1479 EXPORT_SYMBOL(ldlm_lock_decref);
1480 EXPORT_SYMBOL(ldlm_lock_decref_and_cancel);
1481 EXPORT_SYMBOL(ldlm_lock_change_resource);
1482 EXPORT_SYMBOL(ldlm_lock_set_data);
1483 EXPORT_SYMBOL(ldlm_it2str);
1484 EXPORT_SYMBOL(ldlm_lock_dump);
1485 EXPORT_SYMBOL(ldlm_lock_dump_handle);
1486 EXPORT_SYMBOL(ldlm_cancel_locks_for_export);
1487 EXPORT_SYMBOL(ldlm_reprocess_all_ns);
1488 EXPORT_SYMBOL(ldlm_lock_allow_match);
1490 /* ldlm_request.c */
1491 EXPORT_SYMBOL(ldlm_completion_ast);
1492 EXPORT_SYMBOL(ldlm_expired_completion_wait);
1493 EXPORT_SYMBOL(ldlm_cli_convert);
1494 EXPORT_SYMBOL(ldlm_cli_enqueue);
1495 EXPORT_SYMBOL(ldlm_cli_cancel);
1496 EXPORT_SYMBOL(ldlm_cli_cancel_unused);
1497 EXPORT_SYMBOL(ldlm_replay_locks);
1498 EXPORT_SYMBOL(ldlm_resource_foreach);
1499 EXPORT_SYMBOL(ldlm_namespace_foreach);
1500 EXPORT_SYMBOL(ldlm_namespace_foreach_res);
1501 EXPORT_SYMBOL(ldlm_change_cbdata);
1504 EXPORT_SYMBOL(ldlm_server_blocking_ast);
1505 EXPORT_SYMBOL(ldlm_server_completion_ast);
1506 EXPORT_SYMBOL(ldlm_server_glimpse_ast);
1507 EXPORT_SYMBOL(ldlm_handle_enqueue);
1508 EXPORT_SYMBOL(ldlm_handle_cancel);
1509 EXPORT_SYMBOL(ldlm_handle_convert);
1510 EXPORT_SYMBOL(ldlm_del_waiting_lock);
1511 EXPORT_SYMBOL(ldlm_get_ref);
1512 EXPORT_SYMBOL(ldlm_put_ref);
1516 EXPORT_SYMBOL(ldlm_test);
1517 EXPORT_SYMBOL(ldlm_regression_start);
1518 EXPORT_SYMBOL(ldlm_regression_stop);
1521 /* ldlm_resource.c */
1522 EXPORT_SYMBOL(ldlm_namespace_new);
1523 EXPORT_SYMBOL(ldlm_namespace_cleanup);
1524 EXPORT_SYMBOL(ldlm_namespace_free);
1525 EXPORT_SYMBOL(ldlm_namespace_dump);
1526 EXPORT_SYMBOL(ldlm_dump_all_namespaces);
1527 EXPORT_SYMBOL(ldlm_resource_get);
1528 EXPORT_SYMBOL(ldlm_resource_putref);
1531 EXPORT_SYMBOL(l_lock);
1532 EXPORT_SYMBOL(l_unlock);
1535 EXPORT_SYMBOL(client_obd_setup);
1536 EXPORT_SYMBOL(client_obd_cleanup);
1537 EXPORT_SYMBOL(client_connect_import);
1538 EXPORT_SYMBOL(client_disconnect_export);
1539 EXPORT_SYMBOL(target_abort_recovery);
1540 EXPORT_SYMBOL(target_handle_connect);
1541 EXPORT_SYMBOL(target_destroy_export);
1542 EXPORT_SYMBOL(target_cancel_recovery_timer);
1543 EXPORT_SYMBOL(target_send_reply);
1544 EXPORT_SYMBOL(target_queue_recovery_request);
1545 EXPORT_SYMBOL(target_handle_ping);
1546 EXPORT_SYMBOL(target_handle_disconnect);
1547 EXPORT_SYMBOL(target_queue_final_reply);