1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2 * vim:expandtab:shiftwidth=8:tabstop=8:
4 * Copyright (C) 2002 Cluster File Systems, Inc.
6 * This code is issued under the GNU General Public License.
7 * See the file COPYING in this distribution
9 * by Cluster File Systems, Inc.
10 * authors, Peter Braam <braam@clusterfs.com> &
11 * Phil Schwan <phil@clusterfs.com>
14 #define DEBUG_SUBSYSTEM S_LDLM
16 #include <linux/slab.h>
17 #include <linux/module.h>
18 #include <linux/random.h>
19 #include <linux/lustre_dlm.h>
20 #include <linux/lustre_mds.h>
23 char *ldlm_lockname[] = {
32 char *ldlm_typename[] = {
35 [LDLM_MDSINTENT] "INT"
38 extern kmem_cache_t *ldlm_lock_slab;
39 int (*mds_reint_p)(int offset, struct ptlrpc_request *req) = NULL;
40 int (*mds_getattr_name_p)(int offset, struct ptlrpc_request *req) = NULL;
42 static int ldlm_plain_compat(struct ldlm_lock *a, struct ldlm_lock *b);
43 static int ldlm_intent_policy(struct ldlm_lock *lock, void *req_cookie,
44 ldlm_mode_t mode, void *data);
46 ldlm_res_compat ldlm_res_compat_table [] = {
47 [LDLM_PLAIN] ldlm_plain_compat,
48 [LDLM_EXTENT] ldlm_extent_compat,
49 [LDLM_MDSINTENT] ldlm_plain_compat
52 ldlm_res_policy ldlm_res_policy_table [] = {
54 [LDLM_EXTENT] ldlm_extent_policy,
55 [LDLM_MDSINTENT] ldlm_intent_policy
60 * REFCOUNTED LOCK OBJECTS
65 * Lock refcounts, during creation:
66 * - one special one for allocation, dec'd only once in destroy
67 * - one for being a lock that's in-use
68 * - one for the addref associated with a new lock
70 struct ldlm_lock *ldlm_lock_get(struct ldlm_lock *lock)
72 l_lock(&lock->l_resource->lr_namespace->ns_lock);
74 ldlm_resource_getref(lock->l_resource);
75 l_unlock(&lock->l_resource->lr_namespace->ns_lock);
79 void ldlm_lock_put(struct ldlm_lock *lock)
81 struct lustre_lock *nslock = &lock->l_resource->lr_namespace->ns_lock;
89 ldlm_resource_put(lock->l_resource);
91 ldlm_lock_put(lock->l_parent);
93 if (lock->l_refc == 0 && (lock->l_flags & LDLM_FL_DESTROYED)) {
94 if (lock->l_connection)
95 ptlrpc_put_connection(lock->l_connection);
96 CDEBUG(D_MALLOC, "kfreed 'lock': %d at %p (tot 1).\n",
98 kmem_cache_free(ldlm_lock_slab, lock);
104 void ldlm_lock_destroy(struct ldlm_lock *lock)
107 l_lock(&lock->l_resource->lr_namespace->ns_lock);
109 if (!list_empty(&lock->l_children)) {
110 CERROR("lock %p still has children (%p)!\n", lock,
111 lock->l_children.next);
112 ldlm_lock_dump(lock);
115 if (lock->l_readers || lock->l_writers) {
116 CDEBUG(D_INFO, "lock still has references (%d readers, %d "
117 "writers)\n", lock->l_readers, lock->l_writers);
121 if (!list_empty(&lock->l_res_link))
124 if (lock->l_flags & LDLM_FL_DESTROYED) {
125 l_unlock(&lock->l_resource->lr_namespace->ns_lock);
130 lock->l_flags = LDLM_FL_DESTROYED;
131 l_unlock(&lock->l_resource->lr_namespace->ns_lock);
137 usage: pass in a resource on which you have done get
138 pass in a parent lock on which you have done a get
139 do not put the resource or the parent
140 returns: lock with refcount 1
142 static struct ldlm_lock *ldlm_lock_new(struct ldlm_lock *parent,
143 struct ldlm_resource *resource)
145 struct ldlm_lock *lock;
148 if (resource == NULL)
151 lock = kmem_cache_alloc(ldlm_lock_slab, SLAB_KERNEL);
154 CDEBUG(D_MALLOC, "kmalloced 'lock': %d at "
155 "%p (tot %d).\n", sizeof(*lock), lock, 1);
157 memset(lock, 0, sizeof(*lock));
158 get_random_bytes(&lock->l_random, sizeof(__u64));
160 lock->l_resource = resource;
161 /* this refcount matches the one of the resource passed
162 in which is not being put away */
164 INIT_LIST_HEAD(&lock->l_children);
165 INIT_LIST_HEAD(&lock->l_res_link);
166 init_waitqueue_head(&lock->l_waitq);
168 if (parent != NULL) {
169 l_lock(&parent->l_resource->lr_namespace->ns_lock);
170 lock->l_parent = parent;
171 list_add(&lock->l_childof, &parent->l_children);
172 l_unlock(&parent->l_resource->lr_namespace->ns_lock);
174 /* this is the extra refcount, to prevent the lock
180 int ldlm_lock_change_resource(struct ldlm_lock *lock, __u64 new_resid[3])
182 struct ldlm_namespace *ns = lock->l_resource->lr_namespace;
183 struct ldlm_resource *oldres = lock->l_resource;
187 l_lock(&ns->ns_lock);
188 type = lock->l_resource->lr_type;
190 lock->l_resource = ldlm_resource_get(ns, NULL, new_resid, type, 1);
191 if (lock->l_resource == NULL) {
196 /* move references over */
197 for (i = 0; i < lock->l_refc; i++) {
199 ldlm_resource_getref(lock->l_resource);
200 rc = ldlm_resource_put(oldres);
201 if (rc == 1 && i != lock->l_refc - 1)
204 /* compensate for the initial get above.. */
205 ldlm_resource_put(lock->l_resource);
207 l_unlock(&ns->ns_lock);
215 void ldlm_lock2handle(struct ldlm_lock *lock, struct lustre_handle *lockh)
217 lockh->addr = (__u64)(unsigned long)lock;
218 lockh->cookie = lock->l_random;
222 struct ldlm_lock *ldlm_handle2lock(struct lustre_handle *handle)
224 struct ldlm_lock *lock = NULL;
227 if (!handle || !handle->addr)
230 lock = (struct ldlm_lock *)(unsigned long)(handle->addr);
231 if (!kmem_cache_validate(ldlm_lock_slab, (void *)lock))
234 l_lock(&lock->l_resource->lr_namespace->ns_lock);
235 if (lock->l_random != handle->cookie)
236 GOTO(out, handle = NULL);
238 if (lock->l_flags & LDLM_FL_DESTROYED)
239 GOTO(out, handle = NULL);
244 l_unlock(&lock->l_resource->lr_namespace->ns_lock);
250 static int ldlm_intent_policy(struct ldlm_lock *lock, void *req_cookie,
251 ldlm_mode_t mode, void *data)
253 struct ptlrpc_request *req = req_cookie;
260 if (req->rq_reqmsg->bufcount > 1) {
261 /* an intent needs to be considered */
262 struct ldlm_intent *it = lustre_msg_buf(req->rq_reqmsg, 1);
263 struct mds_body *mds_rep;
264 struct ldlm_reply *rep;
265 __u64 new_resid[3] = {0, 0, 0}, old_res;
266 int bufcount = -1, rc, size[3] = {sizeof(struct ldlm_reply),
267 sizeof(struct mds_body),
268 sizeof(struct obdo)};
270 it->opc = NTOH__u64(it->opc);
272 LDLM_DEBUG(lock, "intent policy, opc: %Ld", it->opc);
277 /* Note that in the negative case you may be returning
278 * a file and its obdo */
280 case IT_CREAT|IT_OPEN:
291 size[1] = sizeof(struct obdo);
300 rc = lustre_pack_msg(bufcount, size, NULL, &req->rq_replen,
303 rc = req->rq_status = -ENOMEM;
307 rep = lustre_msg_buf(req->rq_repmsg, 0);
308 rep->lock_policy_res1 = 1;
313 case IT_CREAT|IT_OPEN:
322 if (mds_reint_p == NULL)
324 inter_module_get_request
325 ("mds_reint", "mds");
326 if (IS_ERR(mds_reint_p)) {
327 CERROR("MDSINTENT locks require the MDS "
332 rc = mds_reint_p(2, req);
340 if (mds_getattr_name_p == NULL)
342 inter_module_get_request
343 ("mds_getattr_name", "mds");
344 if (IS_ERR(mds_getattr_name_p)) {
345 CERROR("MDSINTENT locks require the MDS "
350 rc = mds_getattr_name_p(2, req);
351 /* FIXME: we need to sit down and decide on who should
352 * set req->rq_status, who should return negative and
353 * positive return values, and what they all mean. */
354 if (rc || req->rq_status != 0) {
355 mds_rep = lustre_msg_buf(req->rq_repmsg, 1);
356 rep->lock_policy_res2 = req->rq_status;
357 RETURN(ELDLM_LOCK_ABORTED);
360 case IT_READDIR|IT_OPEN:
364 CERROR("Unhandled intent\n");
368 if (it->opc == IT_UNLINK || it->opc == IT_RMDIR)
369 RETURN(ELDLM_LOCK_ABORTED);
371 mds_rep = lustre_msg_buf(req->rq_repmsg, 1);
372 rep->lock_policy_res2 = req->rq_status;
373 new_resid[0] = NTOH__u32(mds_rep->ino);
374 if (new_resid[0] == 0)
376 old_res = lock->l_resource->lr_name[0];
378 CDEBUG(D_INFO, "remote intent: locking %d instead of"
379 "%ld\n", mds_rep->ino, (long)old_res);
381 ldlm_lock_change_resource(lock, new_resid);
382 if (lock->l_resource == NULL) {
386 LDLM_DEBUG(lock, "intent policy, old res %ld",
388 RETURN(ELDLM_LOCK_CHANGED);
390 int size = sizeof(struct ldlm_reply);
391 rc = lustre_pack_msg(1, &size, NULL, &req->rq_replen,
394 CERROR("out of memory\n");
402 static int ldlm_plain_compat(struct ldlm_lock *a, struct ldlm_lock *b)
404 return lockmode_compat(a->l_req_mode, b->l_req_mode);
407 void ldlm_lock2desc(struct ldlm_lock *lock, struct ldlm_lock_desc *desc)
409 ldlm_res2desc(lock->l_resource, &desc->l_resource);
410 desc->l_req_mode = lock->l_req_mode;
411 desc->l_granted_mode = lock->l_granted_mode;
412 memcpy(&desc->l_extent, &lock->l_extent, sizeof(desc->l_extent));
413 memcpy(desc->l_version, lock->l_version, sizeof(desc->l_version));
416 static void ldlm_add_ast_work_item(struct ldlm_lock *lock,
417 struct ldlm_lock *new)
419 struct ldlm_ast_work *w;
422 l_lock(&lock->l_resource->lr_namespace->ns_lock);
423 if (new && (lock->l_flags & LDLM_FL_AST_SENT))
426 OBD_ALLOC(w, sizeof(*w));
433 lock->l_flags |= LDLM_FL_AST_SENT;
435 ldlm_lock2desc(new, &w->w_desc);
438 w->w_lock = ldlm_lock_get(lock);
439 list_add(&w->w_list, lock->l_resource->lr_tmp);
441 l_unlock(&lock->l_resource->lr_namespace->ns_lock);
445 void ldlm_lock_addref(struct lustre_handle *lockh, __u32 mode)
447 struct ldlm_lock *lock;
449 lock = ldlm_handle2lock(lockh);
450 ldlm_lock_addref_internal(lock, mode);
454 /* only called for local locks */
455 void ldlm_lock_addref_internal(struct ldlm_lock *lock, __u32 mode)
457 l_lock(&lock->l_resource->lr_namespace->ns_lock);
458 if (mode == LCK_NL || mode == LCK_CR || mode == LCK_PR)
462 l_unlock(&lock->l_resource->lr_namespace->ns_lock);
464 LDLM_DEBUG(lock, "ldlm_lock_addref(%s)", ldlm_lockname[mode]);
467 /* Args: unlocked lock */
468 void ldlm_lock_decref(struct lustre_handle *lockh, __u32 mode)
470 struct ldlm_lock *lock = ldlm_handle2lock(lockh);
476 LDLM_DEBUG(lock, "ldlm_lock_decref(%s)", ldlm_lockname[mode]);
477 l_lock(&lock->l_resource->lr_namespace->ns_lock);
478 if (mode == LCK_NL || mode == LCK_CR || mode == LCK_PR)
483 /* If we received a blocked AST and this was the last reference,
484 * run the callback. */
485 if (!lock->l_readers && !lock->l_writers &&
486 (lock->l_flags & LDLM_FL_CBPENDING)) {
487 struct lustre_handle lockh;
489 if (!lock->l_resource->lr_namespace->ns_client) {
490 CERROR("LDLM_FL_CBPENDING set on non-local lock!\n");
494 LDLM_DEBUG(lock, "final decref done on cbpending lock");
495 l_unlock(&lock->l_resource->lr_namespace->ns_lock);
497 ldlm_lock2handle(lock, &lockh);
498 /* FIXME: -1 is a really, really bad 'desc' */
499 lock->l_blocking_ast(&lockh, (void *)-1, lock->l_data,
502 l_unlock(&lock->l_resource->lr_namespace->ns_lock);
504 ldlm_lock_put(lock); /* matches the ldlm_lock_get in addref */
505 ldlm_lock_put(lock); /* matches the handle2lock above */
510 static int ldlm_lock_compat_list(struct ldlm_lock *lock, int send_cbs,
511 struct list_head *queue)
513 struct list_head *tmp, *pos;
516 list_for_each_safe(tmp, pos, queue) {
517 struct ldlm_lock *child;
518 ldlm_res_compat compat;
520 child = list_entry(tmp, struct ldlm_lock, l_res_link);
524 compat = ldlm_res_compat_table[child->l_resource->lr_type];
525 if (compat && compat(child, lock)) {
526 CDEBUG(D_OTHER, "compat function succeded, next.\n");
529 if (lockmode_compat(child->l_granted_mode, lock->l_req_mode)) {
530 CDEBUG(D_OTHER, "lock modes are compatible, next.\n");
536 if (send_cbs && child->l_blocking_ast != NULL) {
537 CDEBUG(D_OTHER, "incompatible; sending blocking "
539 ldlm_add_ast_work_item(child, lock);
546 static int ldlm_lock_compat(struct ldlm_lock *lock, int send_cbs)
551 l_lock(&lock->l_resource->lr_namespace->ns_lock);
552 rc = ldlm_lock_compat_list(lock, send_cbs,
553 &lock->l_resource->lr_granted);
554 /* FIXME: should we be sending ASTs to converting? */
556 rc = ldlm_lock_compat_list
557 (lock, send_cbs, &lock->l_resource->lr_converting);
559 l_unlock(&lock->l_resource->lr_namespace->ns_lock);
564 - ldlm_handle_enqueuque - resource
566 void ldlm_grant_lock(struct ldlm_lock *lock)
568 struct ldlm_resource *res = lock->l_resource;
571 l_lock(&lock->l_resource->lr_namespace->ns_lock);
572 ldlm_resource_add_lock(res, &res->lr_granted, lock);
573 lock->l_granted_mode = lock->l_req_mode;
575 if (lock->l_granted_mode < res->lr_most_restr)
576 res->lr_most_restr = lock->l_granted_mode;
578 if (lock->l_completion_ast) {
579 ldlm_add_ast_work_item(lock, NULL);
581 l_unlock(&lock->l_resource->lr_namespace->ns_lock);
585 static struct ldlm_lock *search_queue(struct list_head *queue, ldlm_mode_t mode,
586 struct ldlm_extent *extent)
588 struct ldlm_lock *lock;
589 struct list_head *tmp;
591 list_for_each(tmp, queue) {
592 lock = list_entry(tmp, struct ldlm_lock, l_res_link);
594 if (lock->l_flags & LDLM_FL_CBPENDING)
597 /* lock_convert() takes the resource lock, so we're sure that
598 * req_mode, lr_type, and l_cookie won't change beneath us */
599 if (lock->l_req_mode != mode)
602 if (lock->l_resource->lr_type == LDLM_EXTENT &&
603 (lock->l_extent.start > extent->start ||
604 lock->l_extent.end < extent->end))
607 ldlm_lock_addref_internal(lock, mode);
614 /* Must be called with no resource or lock locks held.
616 * Returns 1 if it finds an already-existing lock that is compatible; in this
617 * case, lockh is filled in with a addref()ed lock */
618 int ldlm_lock_match(struct ldlm_namespace *ns, __u64 *res_id, __u32 type,
619 void *cookie, int cookielen, ldlm_mode_t mode,
620 struct lustre_handle *lockh)
622 struct ldlm_resource *res;
623 struct ldlm_lock *lock;
627 res = ldlm_resource_get(ns, NULL, res_id, type, 0);
631 ns = res->lr_namespace;
632 l_lock(&ns->ns_lock);
634 if ((lock = search_queue(&res->lr_granted, mode, cookie)))
636 if ((lock = search_queue(&res->lr_converting, mode, cookie)))
638 if ((lock = search_queue(&res->lr_waiting, mode, cookie)))
643 ldlm_resource_put(res);
644 l_unlock(&ns->ns_lock);
647 ldlm_lock2handle(lock, lockh);
648 wait_event_interruptible(lock->l_waitq, lock->l_req_mode ==
649 lock->l_granted_mode);
652 LDLM_DEBUG(lock, "matched");
654 LDLM_DEBUG_NOLOCK("not matched");
658 /* Returns a referenced, lock */
659 struct ldlm_lock *ldlm_lock_create(struct ldlm_namespace *ns,
660 struct lustre_handle *parent_lock_handle,
661 __u64 *res_id, __u32 type,
666 struct ldlm_resource *res, *parent_res = NULL;
667 struct ldlm_lock *lock, *parent_lock;
669 parent_lock = ldlm_handle2lock(parent_lock_handle);
671 parent_res = parent_lock->l_resource;
673 res = ldlm_resource_get(ns, parent_res, res_id, type, 1);
677 lock = ldlm_lock_new(parent_lock, res);
679 ldlm_resource_put(res);
683 lock->l_req_mode = mode;
685 lock->l_data_len = data_len;
690 /* Must be called with lock->l_lock and lock->l_resource->lr_lock not held */
691 ldlm_error_t ldlm_lock_enqueue(struct ldlm_lock *lock,
692 void *cookie, int cookie_len,
694 ldlm_lock_callback completion,
695 ldlm_lock_callback blocking)
697 struct ldlm_resource *res;
699 ldlm_res_policy policy;
702 res = lock->l_resource;
703 lock->l_blocking_ast = blocking;
705 if (res->lr_type == LDLM_EXTENT)
706 memcpy(&lock->l_extent, cookie, sizeof(lock->l_extent));
708 /* policies are not executed on the client */
709 local = res->lr_namespace->ns_client;
710 if (!local && (policy = ldlm_res_policy_table[res->lr_type])) {
712 rc = policy(lock, cookie, lock->l_req_mode, NULL);
714 if (rc == ELDLM_LOCK_CHANGED) {
715 res = lock->l_resource;
716 *flags |= LDLM_FL_LOCK_CHANGED;
717 } else if (rc == ELDLM_LOCK_ABORTED) {
718 ldlm_lock_destroy(lock);
723 lock->l_cookie = cookie;
724 lock->l_cookie_len = cookie_len;
726 if (local && lock->l_req_mode == lock->l_granted_mode) {
727 /* The server returned a blocked lock, but it was granted before
728 * we got a chance to actually enqueue it. We don't need to do
733 /* If this is a local resource, put it on the appropriate list. */
734 /* FIXME: don't like this: can we call ldlm_resource_unlink_lock? */
735 list_del_init(&lock->l_res_link);
737 if (*flags & LDLM_FL_BLOCK_CONV)
738 ldlm_resource_add_lock(res, res->lr_converting.prev,
740 else if (*flags & (LDLM_FL_BLOCK_WAIT | LDLM_FL_BLOCK_GRANTED))
741 ldlm_resource_add_lock(res, res->lr_waiting.prev, lock);
743 ldlm_grant_lock(lock);
747 /* FIXME: We may want to optimize by checking lr_most_restr */
748 if (!list_empty(&res->lr_converting)) {
749 ldlm_resource_add_lock(res, res->lr_waiting.prev, lock);
750 *flags |= LDLM_FL_BLOCK_CONV;
753 if (!list_empty(&res->lr_waiting)) {
754 ldlm_resource_add_lock(res, res->lr_waiting.prev, lock);
755 *flags |= LDLM_FL_BLOCK_WAIT;
758 if (!ldlm_lock_compat(lock,0)) {
759 ldlm_resource_add_lock(res, res->lr_waiting.prev, lock);
760 *flags |= LDLM_FL_BLOCK_GRANTED;
764 ldlm_grant_lock(lock);
767 /* Don't set 'completion_ast' until here so that if the lock is granted
768 * immediately we don't do an unnecessary completion call. */
769 lock->l_completion_ast = completion;
773 /* Must be called with namespace taken: queue is waiting or converting. */
774 static int ldlm_reprocess_queue(struct ldlm_resource *res,
775 struct list_head *queue)
777 struct list_head *tmp, *pos;
780 list_for_each_safe(tmp, pos, queue) {
781 struct ldlm_lock *pending;
782 pending = list_entry(tmp, struct ldlm_lock, l_res_link);
784 CDEBUG(D_INFO, "Reprocessing lock %p\n", pending);
786 if (!ldlm_lock_compat(pending, 1))
789 list_del_init(&pending->l_res_link);
790 ldlm_grant_lock(pending);
796 void ldlm_run_ast_work(struct list_head *rpc_list)
798 struct list_head *tmp, *pos;
802 list_for_each_safe(tmp, pos, rpc_list) {
803 struct ldlm_ast_work *w =
804 list_entry(tmp, struct ldlm_ast_work, w_list);
805 struct lustre_handle lockh;
807 ldlm_lock2handle(w->w_lock, &lockh);
809 rc = w->w_lock->l_blocking_ast
810 (&lockh, &w->w_desc, w->w_data, w->w_datalen);
812 rc = w->w_lock->l_completion_ast
813 (&lockh, NULL, w->w_data, w->w_datalen);
815 CERROR("Failed AST - should clean & disconnect "
817 ldlm_lock_put(w->w_lock);
818 list_del(&w->w_list);
819 OBD_FREE(w, sizeof(*w));
824 /* Must be called with resource->lr_lock not taken. */
825 void ldlm_reprocess_all(struct ldlm_resource *res)
827 struct list_head rpc_list = LIST_HEAD_INIT(rpc_list);
830 /* Local lock trees don't get reprocessed. */
831 if (res->lr_namespace->ns_client) {
836 l_lock(&res->lr_namespace->ns_lock);
837 res->lr_tmp = &rpc_list;
839 ldlm_reprocess_queue(res, &res->lr_converting);
840 if (list_empty(&res->lr_converting))
841 ldlm_reprocess_queue(res, &res->lr_waiting);
844 l_unlock(&res->lr_namespace->ns_lock);
846 ldlm_run_ast_work(&rpc_list);
850 /* Must be called with lock and lock->l_resource unlocked */
851 void ldlm_lock_cancel(struct ldlm_lock *lock)
853 struct ldlm_resource *res;
854 struct ldlm_namespace *ns;
857 res = lock->l_resource;
858 ns = res->lr_namespace;
860 l_lock(&ns->ns_lock);
861 if (lock->l_readers || lock->l_writers)
862 CDEBUG(D_INFO, "lock still has references (%d readers, %d "
863 "writers)\n", lock->l_readers, lock->l_writers);
865 ldlm_resource_unlink_lock(lock);
866 ldlm_lock_destroy(lock);
867 l_unlock(&ns->ns_lock);
870 /* Must be called with lock and lock->l_resource unlocked */
871 struct ldlm_resource *ldlm_lock_convert(struct ldlm_lock *lock, int new_mode,
874 struct list_head rpc_list = LIST_HEAD_INIT(rpc_list);
875 struct ldlm_resource *res;
876 struct ldlm_namespace *ns;
880 res = lock->l_resource;
881 ns = res->lr_namespace;
883 l_lock(&ns->ns_lock);
885 lock->l_req_mode = new_mode;
886 ldlm_resource_unlink_lock(lock);
888 /* If this is a local resource, put it on the appropriate list. */
889 if (res->lr_namespace->ns_client) {
890 if (*flags & (LDLM_FL_BLOCK_CONV | LDLM_FL_BLOCK_GRANTED))
891 ldlm_resource_add_lock(res, res->lr_converting.prev,
894 res->lr_tmp = &rpc_list;
895 ldlm_grant_lock(lock);
898 /* FIXME: completion handling not with ns_lock held ! */
899 wake_up(&lock->l_waitq);
902 list_add(&lock->l_res_link, res->lr_converting.prev);
904 l_unlock(&ns->ns_lock);
907 ldlm_run_ast_work(&rpc_list);
911 void ldlm_lock_dump(struct ldlm_lock *lock)
915 if (!(portal_debug & D_OTHER))
918 if (RES_VERSION_SIZE != 4)
922 CDEBUG(D_OTHER, " NULL LDLM lock\n");
926 snprintf(ver, sizeof(ver), "%x %x %x %x",
927 lock->l_version[0], lock->l_version[1],
928 lock->l_version[2], lock->l_version[3]);
930 CDEBUG(D_OTHER, " -- Lock dump: %p (%s)\n", lock, ver);
931 CDEBUG(D_OTHER, " Parent: %p\n", lock->l_parent);
932 CDEBUG(D_OTHER, " Resource: %p (%Ld)\n", lock->l_resource,
933 lock->l_resource->lr_name[0]);
934 CDEBUG(D_OTHER, " Requested mode: %d, granted mode: %d\n",
935 (int)lock->l_req_mode, (int)lock->l_granted_mode);
936 CDEBUG(D_OTHER, " Readers: %u ; Writers; %u\n",
937 lock->l_readers, lock->l_writers);
938 if (lock->l_resource->lr_type == LDLM_EXTENT)
939 CDEBUG(D_OTHER, " Extent: %Lu -> %Lu\n",
940 (unsigned long long)lock->l_extent.start,
941 (unsigned long long)lock->l_extent.end);