[DLM] more info through debugfs
[powerpc.git] / fs / dlm / lockspace.c
index d2ff505..31ed0fe 100644 (file)
@@ -21,6 +21,7 @@
 #include "config.h"
 #include "memory.h"
 #include "lock.h"
+#include "recover.h"
 
 #ifdef CONFIG_DLM_DEBUG
 int dlm_create_debug_file(struct dlm_ls *ls);
@@ -74,6 +75,12 @@ static ssize_t dlm_id_store(struct dlm_ls *ls, const char *buf, size_t len)
        return len;
 }
 
+static ssize_t dlm_recover_status_show(struct dlm_ls *ls, char *buf)
+{
+       uint32_t status = dlm_recover_status(ls);
+       return sprintf(buf, "%x\n", status);
+}
+
 struct dlm_attr {
        struct attribute attr;
        ssize_t (*show)(struct dlm_ls *, char *);
@@ -96,10 +103,16 @@ static struct dlm_attr dlm_attr_id = {
        .store = dlm_id_store
 };
 
+static struct dlm_attr dlm_attr_recover_status = {
+       .attr  = {.name = "recover_status", .mode = S_IRUGO},
+       .show  = dlm_recover_status_show
+};
+
 static struct attribute *dlm_attrs[] = {
        &dlm_attr_control.attr,
        &dlm_attr_event.attr,
        &dlm_attr_id.attr,
+       &dlm_attr_recover_status.attr,
        NULL,
 };
 
@@ -257,12 +270,36 @@ struct dlm_ls *dlm_find_lockspace_global(uint32_t id)
        return ls;
 }
 
-struct dlm_ls *dlm_find_lockspace_local(void *id)
+struct dlm_ls *dlm_find_lockspace_local(dlm_lockspace_t *lockspace)
+{
+       struct dlm_ls *ls;
+
+       spin_lock(&lslist_lock);
+       list_for_each_entry(ls, &lslist, ls_list) {
+               if (ls->ls_local_handle == lockspace) {
+                       ls->ls_count++;
+                       goto out;
+               }
+       }
+       ls = NULL;
+ out:
+       spin_unlock(&lslist_lock);
+       return ls;
+}
+
+struct dlm_ls *dlm_find_lockspace_device(int minor)
 {
-       struct dlm_ls *ls = id;
+       struct dlm_ls *ls;
 
        spin_lock(&lslist_lock);
-       ls->ls_count++;
+       list_for_each_entry(ls, &lslist, ls_list) {
+               if (ls->ls_device.minor == minor) {
+                       ls->ls_count++;
+                       goto out;
+               }
+       }
+       ls = NULL;
+ out:
        spin_unlock(&lslist_lock);
        return ls;
 }
@@ -409,7 +446,8 @@ static int new_lockspace(char *name, int namelen, void **lockspace,
        memset(&ls->ls_stub_rsb, 0, sizeof(struct dlm_rsb));
        ls->ls_stub_rsb.res_ls = ls;
 
-       ls->ls_debug_dentry = NULL;
+       ls->ls_debug_rsb_dentry = NULL;
+       ls->ls_debug_waiters_dentry = NULL;
 
        init_waitqueue_head(&ls->ls_uevent_wait);
        ls->ls_uevent_result = 0;
@@ -423,6 +461,7 @@ static int new_lockspace(char *name, int namelen, void **lockspace,
        init_rwsem(&ls->ls_in_recovery);
        INIT_LIST_HEAD(&ls->ls_requestqueue);
        mutex_init(&ls->ls_requestqueue_mutex);
+       mutex_init(&ls->ls_clear_proc_locks);
 
        ls->ls_recover_buf = kmalloc(dlm_config.buffer_size, GFP_KERNEL);
        if (!ls->ls_recover_buf)
@@ -431,6 +470,7 @@ static int new_lockspace(char *name, int namelen, void **lockspace,
        INIT_LIST_HEAD(&ls->ls_recover_list);
        spin_lock_init(&ls->ls_recover_list_lock);
        ls->ls_recover_list_count = 0;
+       ls->ls_local_handle = ls;
        init_waitqueue_head(&ls->ls_wait_general);
        INIT_LIST_HEAD(&ls->ls_root_list);
        init_rwsem(&ls->ls_root_sem);