int ldlm_del_waiting_lock(struct ldlm_lock *lock);
int ldlm_get_ref(void);
void ldlm_put_ref(int force);
-#ifndef __KERNEL__
-void liblustre_ldlm_handle_bl_callback(struct ldlm_namespace *ns,
- struct ldlm_lock_desc *ld,
- struct ldlm_lock *lock);
-#endif
/* ldlm_lock.c */
ldlm_processing_policy ldlm_get_processing_policy(struct ldlm_resource *res);
/* ldlm_request.c */
-int ldlm_cancel_lru(struct ldlm_namespace *ns);
+typedef enum {
+ LDLM_ASYNC,
+ LDLM_SYNC,
+} ldlm_sync_t;
+
+int ldlm_cancel_lru(struct ldlm_namespace *ns, ldlm_sync_t sync);
/* ldlm_resource.c */
void ldlm_resource_insert_lock_after(struct ldlm_lock *original,
/* ldlm_lockd.c */
int ldlm_bl_to_thread(struct ldlm_namespace *ns, struct ldlm_lock_desc *ld,
struct ldlm_lock *lock);
+void ldlm_handle_bl_callback(struct ldlm_namespace *ns,
+ struct ldlm_lock_desc *ld,
+ struct ldlm_lock *lock);
/* ldlm_plain.c */
int ldlm_process_plain_lock(struct ldlm_lock *lock, int *flags, int first_enq,
l_unlock(&ns->ns_lock);
#else
l_unlock(&ns->ns_lock);
- liblustre_ldlm_handle_bl_callback(ns, NULL, lock);
+ ldlm_handle_bl_callback(ns, NULL, lock);
#endif
} else if (ns->ns_client == LDLM_NAMESPACE_CLIENT &&
!lock->l_readers && !lock->l_writers) {
list_add_tail(&lock->l_lru, &ns->ns_unused_list);
ns->ns_nr_unused++;
l_unlock(&ns->ns_lock);
- ldlm_cancel_lru(ns);
+ ldlm_cancel_lru(ns, LDLM_ASYNC);
} else {
l_unlock(&ns->ns_lock);
}
RETURN(0);
}
-static void ldlm_handle_bl_callback(struct ldlm_namespace *ns,
- struct ldlm_lock_desc *ld,
- struct ldlm_lock *lock)
+void ldlm_handle_bl_callback(struct ldlm_namespace *ns,
+ struct ldlm_lock_desc *ld, struct ldlm_lock *lock)
{
int do_ast;
ENTRY;
return ptlrpc_reply(req);
}
-#ifdef __KERNEL__
int ldlm_bl_to_thread(struct ldlm_namespace *ns, struct ldlm_lock_desc *ld,
struct ldlm_lock *lock)
{
+#ifdef __KERNEL__
struct ldlm_bl_pool *blp = ldlm_state->ldlm_bl_pool;
struct ldlm_bl_work_item *blwi;
ENTRY;
list_add_tail(&blwi->blwi_entry, &blp->blp_list);
wake_up(&blp->blp_waitq);
spin_unlock(&blp->blp_lock);
+#else
+ LBUG();
+#endif
RETURN(0);
}
-#else
-/* XXX */
-void liblustre_ldlm_handle_bl_callback(struct ldlm_namespace *ns,
- struct ldlm_lock_desc *ld,
- struct ldlm_lock *lock)
-{
- ldlm_handle_bl_callback(ns, ld, lock);
-}
-#endif
static int ldlm_callback_handler(struct ptlrpc_request *req)
{
return rc;
}
-int ldlm_cancel_lru(struct ldlm_namespace *ns)
+/* when called with LDLM_ASYNC the blocking callback will be handled
+ * in a thread and this function will return after the thread has been
+ * asked to call the callback. when called with LDLM_SYNC the blocking
+ * callback will be performed in this function. */
+int ldlm_cancel_lru(struct ldlm_namespace *ns, ldlm_sync_t sync)
{
struct list_head *tmp, *next;
-#ifndef __KERNEL__
- LIST_HEAD(cblist);
-#endif
+ struct ldlm_lock *lock;
int count, rc = 0;
+ LIST_HEAD(cblist);
ENTRY;
l_lock(&ns->ns_lock);
}
list_for_each_safe(tmp, next, &ns->ns_unused_list) {
- struct ldlm_lock *lock;
+
lock = list_entry(tmp, struct ldlm_lock, l_lru);
LASSERT(!lock->l_readers && !lock->l_writers);
LDLM_LOCK_GET(lock); /* dropped by bl thread */
ldlm_lock_remove_from_lru(lock);
-#if __KERNEL__
- ldlm_bl_to_thread(ns, NULL, lock);
-#else
- list_add(&lock->l_lru, &cblist);
-#endif
+ if (sync == LDLM_ASYNC)
+ ldlm_bl_to_thread(ns, NULL, lock);
+ else
+ list_add(&lock->l_lru, &cblist);
if (--count == 0)
break;
}
l_unlock(&ns->ns_lock);
-#ifndef __KERNEL__
- while (!list_empty(&cblist)) {
- struct ldlm_lock *lock;
- lock = list_entry(cblist.next, struct ldlm_lock, l_lru);
+ list_for_each_safe(tmp, next, &cblist) {
+ lock = list_entry(tmp, struct ldlm_lock, l_lru);
list_del_init(&lock->l_lru);
- liblustre_ldlm_handle_bl_callback(ns, NULL, lock);
+ ldlm_handle_bl_callback(ns, NULL, lock);
}
-#endif
RETURN(rc);
}
ns->ns_name);
tmp = ns->ns_max_unused;
ns->ns_max_unused = 0;
- ldlm_cancel_lru(ns);
+ ldlm_cancel_lru(ns, LDLM_SYNC);
ns->ns_max_unused = tmp;
return count;
}
ns->ns_name, ns->ns_max_unused, (unsigned int)tmp);
ns->ns_max_unused = (unsigned int)tmp;
- ldlm_cancel_lru(ns);
+ ldlm_cancel_lru(ns, LDLM_ASYNC);
return count;
}