]> err.no Git - linux-2.6/blobdiff - fs/dlm/lockspace.c
Pull error-inject into release branch
[linux-2.6] / fs / dlm / lockspace.c
index 31ed0fe16a3161676732d3cdb03205ce0ceecfeb..f40817b53c6fc33fd39e112a7b3d2a07e7089c16 100644 (file)
@@ -22,6 +22,7 @@
 #include "memory.h"
 #include "lock.h"
 #include "recover.h"
+#include "requestqueue.h"
 
 #ifdef CONFIG_DLM_DEBUG
 int dlm_create_debug_file(struct dlm_ls *ls);
@@ -43,6 +44,10 @@ static ssize_t dlm_control_store(struct dlm_ls *ls, const char *buf, size_t len)
        ssize_t ret = len;
        int n = simple_strtol(buf, NULL, 0);
 
+       ls = dlm_find_lockspace_local(ls->ls_local_handle);
+       if (!ls)
+               return -EINVAL;
+
        switch (n) {
        case 0:
                dlm_ls_stop(ls);
@@ -53,6 +58,7 @@ static ssize_t dlm_control_store(struct dlm_ls *ls, const char *buf, size_t len)
        default:
                ret = -EINVAL;
        }
+       dlm_put_lockspace(ls);
        return ret;
 }
 
@@ -66,7 +72,7 @@ static ssize_t dlm_event_store(struct dlm_ls *ls, const char *buf, size_t len)
 
 static ssize_t dlm_id_show(struct dlm_ls *ls, char *buf)
 {
-       return sprintf(buf, "%u\n", ls->ls_global_id);
+       return snprintf(buf, PAGE_SIZE, "%u\n", ls->ls_global_id);
 }
 
 static ssize_t dlm_id_store(struct dlm_ls *ls, const char *buf, size_t len)
@@ -78,7 +84,12 @@ static ssize_t dlm_id_store(struct dlm_ls *ls, const char *buf, size_t 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);
+       return snprintf(buf, PAGE_SIZE, "%x\n", status);
+}
+
+static ssize_t dlm_recover_nodeid_show(struct dlm_ls *ls, char *buf)
+{
+       return snprintf(buf, PAGE_SIZE, "%d\n", ls->ls_recover_nodeid);
 }
 
 struct dlm_attr {
@@ -108,11 +119,17 @@ static struct dlm_attr dlm_attr_recover_status = {
        .show  = dlm_recover_status_show
 };
 
+static struct dlm_attr dlm_attr_recover_nodeid = {
+       .attr  = {.name = "recover_nodeid", .mode = S_IRUGO},
+       .show  = dlm_recover_nodeid_show
+};
+
 static struct attribute *dlm_attrs[] = {
        &dlm_attr_control.attr,
        &dlm_attr_event.attr,
        &dlm_attr_id.attr,
        &dlm_attr_recover_status.attr,
+       &dlm_attr_recover_nodeid.attr,
        NULL,
 };
 
@@ -132,6 +149,12 @@ static ssize_t dlm_attr_store(struct kobject *kobj, struct attribute *attr,
        return a->store ? a->store(ls, buf, len) : len;
 }
 
+static void lockspace_kobj_release(struct kobject *k)
+{
+       struct dlm_ls *ls  = container_of(k, struct dlm_ls, ls_kobj);
+       kfree(ls);
+}
+
 static struct sysfs_ops dlm_attr_ops = {
        .show  = dlm_attr_show,
        .store = dlm_attr_store,
@@ -140,6 +163,7 @@ static struct sysfs_ops dlm_attr_ops = {
 static struct kobj_type dlm_ktype = {
        .default_attrs = dlm_attrs,
        .sysfs_ops     = &dlm_attr_ops,
+       .release       = lockspace_kobj_release,
 };
 
 static struct kset dlm_kset = {
@@ -212,7 +236,7 @@ static int dlm_scand(void *data)
        while (!kthread_should_stop()) {
                list_for_each_entry(ls, &lslist, ls_list)
                        dlm_scan_rsbs(ls);
-               schedule_timeout_interruptible(dlm_config.scan_secs * HZ);
+               schedule_timeout_interruptible(dlm_config.ci_scan_secs * HZ);
        }
        return 0;
 }
@@ -398,7 +422,7 @@ static int new_lockspace(char *name, int namelen, void **lockspace,
        ls->ls_count = 0;
        ls->ls_flags = 0;
 
-       size = dlm_config.rsbtbl_size;
+       size = dlm_config.ci_rsbtbl_size;
        ls->ls_rsbtbl_size = size;
 
        ls->ls_rsbtbl = kmalloc(sizeof(struct dlm_rsbtable) * size, GFP_KERNEL);
@@ -410,7 +434,7 @@ static int new_lockspace(char *name, int namelen, void **lockspace,
                rwlock_init(&ls->ls_rsbtbl[i].lock);
        }
 
-       size = dlm_config.lkbtbl_size;
+       size = dlm_config.ci_lkbtbl_size;
        ls->ls_lkbtbl_size = size;
 
        ls->ls_lkbtbl = kmalloc(sizeof(struct dlm_lkbtable) * size, GFP_KERNEL);
@@ -422,7 +446,7 @@ static int new_lockspace(char *name, int namelen, void **lockspace,
                ls->ls_lkbtbl[i].counter = 1;
        }
 
-       size = dlm_config.dirtbl_size;
+       size = dlm_config.ci_dirtbl_size;
        ls->ls_dirtbl_size = size;
 
        ls->ls_dirtbl = kmalloc(sizeof(struct dlm_dirtable) * size, GFP_KERNEL);
@@ -455,6 +479,8 @@ static int new_lockspace(char *name, int namelen, void **lockspace,
        ls->ls_recoverd_task = NULL;
        mutex_init(&ls->ls_recoverd_active);
        spin_lock_init(&ls->ls_recover_lock);
+       spin_lock_init(&ls->ls_rcom_spin);
+       get_random_bytes(&ls->ls_rcom_seq, sizeof(uint64_t));
        ls->ls_recover_status = 0;
        ls->ls_recover_seq = 0;
        ls->ls_recover_args = NULL;
@@ -463,7 +489,7 @@ static int new_lockspace(char *name, int namelen, void **lockspace,
        mutex_init(&ls->ls_requestqueue_mutex);
        mutex_init(&ls->ls_clear_proc_locks);
 
-       ls->ls_recover_buf = kmalloc(dlm_config.buffer_size, GFP_KERNEL);
+       ls->ls_recover_buf = kmalloc(dlm_config.ci_buffer_size, GFP_KERNEL);
        if (!ls->ls_recover_buf)
                goto out_dirfree;
 
@@ -477,16 +503,17 @@ static int new_lockspace(char *name, int namelen, void **lockspace,
 
        down_write(&ls->ls_in_recovery);
 
+       spin_lock(&lslist_lock);
+       list_add(&ls->ls_list, &lslist);
+       spin_unlock(&lslist_lock);
+
+       /* needs to find ls in lslist */
        error = dlm_recoverd_start(ls);
        if (error) {
                log_error(ls, "can't start dlm_recoverd %d", error);
                goto out_rcomfree;
        }
 
-       spin_lock(&lslist_lock);
-       list_add(&ls->ls_list, &lslist);
-       spin_unlock(&lslist_lock);
-
        dlm_create_debug_file(ls);
 
        error = kobject_setup(ls);
@@ -508,11 +535,11 @@ static int new_lockspace(char *name, int namelen, void **lockspace,
        kobject_unregister(&ls->ls_kobj);
  out_del:
        dlm_delete_debug_file(ls);
+       dlm_recoverd_stop(ls);
+ out_rcomfree:
        spin_lock(&lslist_lock);
        list_del(&ls->ls_list);
        spin_unlock(&lslist_lock);
-       dlm_recoverd_stop(ls);
- out_rcomfree:
        kfree(ls->ls_recover_buf);
  out_dirfree:
        kfree(ls->ls_dirtbl);
@@ -660,13 +687,14 @@ static int release_lockspace(struct dlm_ls *ls, int force)
         * Free structures on any other lists
         */
 
+       dlm_purge_requestqueue(ls);
        kfree(ls->ls_recover_args);
        dlm_clear_free_entries(ls);
        dlm_clear_members(ls);
        dlm_clear_members_gone(ls);
        kfree(ls->ls_node_array);
        kobject_unregister(&ls->ls_kobj);
-       kfree(ls);
+        /* The ls structure will be freed when the kobject is done with */
 
        mutex_lock(&ls_lock);
        ls_count--;