X-Git-Url: http://pileus.org/git/?a=blobdiff_plain;f=fs%2Fdlm%2Flockspace.c;h=109333c8ecb9136cd09cd3b87ae4ec3b2d68f015;hb=7c2aed4b5632fb536721b8494d1a4a65852ffb49;hp=d2ff505d51cd45650e456c65b8cc4b69cf0e274f;hpb=9a21247181d93fdf99255911845ecdb041d21583;p=~andy%2Flinux diff --git a/fs/dlm/lockspace.c b/fs/dlm/lockspace.c index d2ff505d51c..109333c8ecb 100644 --- a/fs/dlm/lockspace.c +++ b/fs/dlm/lockspace.c @@ -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); @@ -65,7 +66,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) @@ -74,6 +75,17 @@ 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 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 { struct attribute attr; ssize_t (*show)(struct dlm_ls *, char *); @@ -96,10 +108,22 @@ 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 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, }; @@ -257,12 +281,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 = id; + struct dlm_ls *ls; spin_lock(&lslist_lock); - ls->ls_count++; + 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; + + spin_lock(&lslist_lock); + 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 +457,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 +472,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,22 +481,24 @@ 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); 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); @@ -468,11 +520,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);