void ldlm_lock_put(struct ldlm_lock *lock)
{
- struct lustre_lock *nslock = &lock->l_resource->lr_namespace->ns_lock;
+ struct ldlm_namespace *ns = lock->l_resource->lr_namespace;
ENTRY;
- l_lock(nslock);
+ l_lock(&ns->ns_lock);
lock->l_refc--;
//LDLM_DEBUG(lock, "after refc--");
if (lock->l_refc < 0)
LDLM_LOCK_PUT(lock->l_parent);
if (lock->l_refc == 0 && (lock->l_flags & LDLM_FL_DESTROYED)) {
+ spin_lock(&ns->ns_counter_lock);
+ ns->ns_locks--;
+ spin_unlock(&ns->ns_counter_lock);
+
lock->l_resource = NULL;
LDLM_DEBUG(lock, "final lock_put on destroyed lock, freeing");
if (lock->l_export && lock->l_export->exp_connection)
CDEBUG(D_MALLOC, "kfreed 'lock': %d at %p (tot 0).\n",
sizeof(*lock), lock);
}
- l_unlock(nslock);
+ l_unlock(&ns->ns_lock);
EXIT;
}
INIT_LIST_HEAD(&lock->l_pending_chain);
init_waitqueue_head(&lock->l_waitq);
+ spin_lock(&resource->lr_namespace->ns_counter_lock);
+ resource->lr_namespace->ns_locks++;
+ spin_unlock(&resource->lr_namespace->ns_counter_lock);
+
if (parent != NULL) {
l_lock(&parent->l_resource->lr_namespace->ns_lock);
lock->l_parent = parent;
proc_lustre_remove_obd_entry("namespaces", obd);
}
+/* FIXME: This can go away when we start to really use lprocfs */
+static int lprocfs_ll_rd(char *page, char **start, off_t off,
+ int count, int *eof, void *data)
+{
+ int len;
+ __u64 *temp = (__u64 *)data;
+
+ len = snprintf(page, count, "%Lu\n", *temp);
+
+ return len;
+}
+
struct ldlm_namespace *ldlm_namespace_new(char *name, __u32 client)
{
struct ldlm_namespace *ns = NULL;
struct list_head *bucket;
+ struct proc_dir_entry *proc_entry;
OBD_ALLOC(ns, sizeof(*ns));
if (!ns) {
l_lock_init(&ns->ns_lock);
ns->ns_refcount = 0;
ns->ns_client = client;
+ spin_lock_init(&ns->ns_counter_lock);
+ ns->ns_locks = 0;
+ ns->ns_resources = 0;
for (bucket = ns->ns_hash + RES_HASH_SIZE - 1; bucket >= ns->ns_hash;
bucket--)
spin_lock(&ldlm_namespace_lock);
list_add(&ns->ns_list_chain, &ldlm_namespace_list);
+ spin_unlock(&ldlm_namespace_lock);
+
ns->ns_proc_dir = proc_mkdir(ns->ns_name, ldlm_ns_proc_dir);
if (ns->ns_proc_dir == NULL)
CERROR("Unable to create proc directory for namespace.\n");
- spin_unlock(&ldlm_namespace_lock);
+ proc_entry = create_proc_entry("resource_count", 0444, ns->ns_proc_dir);
+ proc_entry->read_proc = lprocfs_ll_rd;
+ proc_entry->data = &ns->ns_resources;
+ proc_entry = create_proc_entry("lock_count", 0444, ns->ns_proc_dir);
+ proc_entry->read_proc = lprocfs_ll_rd;
+ proc_entry->data = &ns->ns_locks;
RETURN(ns);
spin_lock(&ldlm_namespace_lock);
list_del(&ns->ns_list_chain);
+ remove_proc_entry("resource_count", ns->ns_proc_dir);
+ remove_proc_entry("lock_count", ns->ns_proc_dir);
remove_proc_entry(ns->ns_name, ldlm_ns_proc_dir);
spin_unlock(&ldlm_namespace_lock);
RETURN(NULL);
}
+ spin_lock(&ns->ns_counter_lock);
+ ns->ns_resources++;
+ spin_unlock(&ns->ns_counter_lock);
+
memcpy(res->lr_name, name, sizeof(res->lr_name));
res->lr_namespace = ns;
ns->ns_refcount++;
kmem_cache_free(ldlm_resource_slab, res);
l_unlock(&ns->ns_lock);
+
+ spin_lock(&ns->ns_counter_lock);
+ ns->ns_resources--;
+ spin_unlock(&ns->ns_counter_lock);
+
rc = 1;
} else {
ENTRY;