[patch 08/12] dlm: no directory option
Per-lockspace option for dlm to run without using a resource directory. What would be the directory node for a resource is statically assigned to be the master node instead. Signed-off-by: David Teigland <[EMAIL PROTECTED]> Index: linux/drivers/dlm/dir.c === --- linux.orig/drivers/dlm/dir.c +++ linux/drivers/dlm/dir.c @@ -72,15 +72,14 @@ void dlm_clear_free_entries(struct dlm_l * * To give the exact range wanted (0 to num_nodes-1), we apply a modulus of * num_nodes to the hash value. This value in the desired range is used as an - * offset into the sorted list of nodeid's to give the particular nodeid of the - * directory node. + * offset into the sorted list of nodeid's to give the particular nodeid. */ -int dlm_dir_name2nodeid(struct dlm_ls *ls, char *name, int length) +int dlm_hash2nodeid(struct dlm_ls *ls, uint32_t hash) { struct list_head *tmp; struct dlm_member *memb = NULL; - uint32_t hash, node, n = 0; + uint32_t node, n = 0; int nodeid; if (ls->ls_num_nodes == 1) { @@ -88,8 +87,6 @@ int dlm_dir_name2nodeid(struct dlm_ls *l goto out; } - hash = dlm_hash(name, length); - if (ls->ls_node_array) { node = (hash >> 16) % ls->ls_total_weight; nodeid = ls->ls_node_array[node]; @@ -114,9 +111,9 @@ int dlm_dir_name2nodeid(struct dlm_ls *l return nodeid; } -int dlm_dir_nodeid(struct dlm_rsb *rsb) +int dlm_dir_nodeid(struct dlm_rsb *r) { - return dlm_dir_name2nodeid(rsb->res_ls, rsb->res_name, rsb->res_length); + return dlm_hash2nodeid(r->res_ls, r->res_hash); } static inline uint32_t dir_hash(struct dlm_ls *ls, char *name, int len) @@ -202,12 +199,15 @@ int dlm_recover_directory(struct dlm_ls { struct dlm_member *memb; struct dlm_direntry *de; - char *b, *last_name; + char *b, *last_name = NULL; int error = -ENOMEM, last_len, count = 0; uint16_t namelen; log_debug(ls, "dlm_recover_directory"); + if (dlm_no_directory(ls)) + goto out_status; + dlm_dir_clear(ls); last_name = kmalloc(DLM_RESNAME_MAXLEN, GFP_KERNEL); @@ -221,12 +221,12 @@ int dlm_recover_directory(struct dlm_ls for (;;) { error = dlm_recovery_stopped(ls); if (error) - goto free_last; + goto out_free; error = dlm_rcom_names(ls, memb->nodeid, last_name, last_len); if (error) - goto free_last; + goto out_free; schedule(); @@ -253,7 +253,7 @@ int dlm_recover_directory(struct dlm_ls error = -ENOMEM; de = get_free_de(ls, namelen); if (!de) - goto free_last; + goto out_free; de->master_nodeid = memb->nodeid; de->length = namelen; @@ -270,12 +270,11 @@ int dlm_recover_directory(struct dlm_ls ; } - dlm_set_recover_status(ls, DLM_RS_DIR); + out_status: error = 0; - + dlm_set_recover_status(ls, DLM_RS_DIR); log_debug(ls, "dlm_recover_directory %d entries", count); - - free_last: + out_free: kfree(last_name); out: dlm_clear_free_entries(ls); Index: linux/drivers/dlm/dir.h === --- linux.orig/drivers/dlm/dir.h +++ linux/drivers/dlm/dir.h @@ -16,7 +16,7 @@ int dlm_dir_nodeid(struct dlm_rsb *rsb); -int dlm_dir_name2nodeid(struct dlm_ls *ls, char *name, int length); +int dlm_hash2nodeid(struct dlm_ls *ls, uint32_t hash); void dlm_dir_remove_entry(struct dlm_ls *ls, int nodeid, char *name, int len); void dlm_dir_clear(struct dlm_ls *ls); void dlm_clear_free_entries(struct dlm_ls *ls); Index: linux/drivers/dlm/dlm_internal.h === --- linux.orig/drivers/dlm/dlm_internal.h +++ linux/drivers/dlm/dlm_internal.h @@ -270,6 +270,7 @@ struct dlm_rsb { int res_length; /* length of rsb name */ int res_nodeid; uint32_tres_lvbseq; + uint32_tres_hash; uint32_tres_bucket; /* rsbtbl */ unsigned long res_toss_time; uint32_tres_first_lkid; @@ -364,6 +365,7 @@ struct dlm_message { uint32_tm_sbflags; uint32_tm_flags; uint32_tm_lvbseq; + uint32_tm_hash;
[patch 08/12] dlm: no directory option
Per-lockspace option for dlm to run without using a resource directory. What would be the directory node for a resource is statically assigned to be the master node instead. Signed-off-by: David Teigland [EMAIL PROTECTED] Index: linux/drivers/dlm/dir.c === --- linux.orig/drivers/dlm/dir.c +++ linux/drivers/dlm/dir.c @@ -72,15 +72,14 @@ void dlm_clear_free_entries(struct dlm_l * * To give the exact range wanted (0 to num_nodes-1), we apply a modulus of * num_nodes to the hash value. This value in the desired range is used as an - * offset into the sorted list of nodeid's to give the particular nodeid of the - * directory node. + * offset into the sorted list of nodeid's to give the particular nodeid. */ -int dlm_dir_name2nodeid(struct dlm_ls *ls, char *name, int length) +int dlm_hash2nodeid(struct dlm_ls *ls, uint32_t hash) { struct list_head *tmp; struct dlm_member *memb = NULL; - uint32_t hash, node, n = 0; + uint32_t node, n = 0; int nodeid; if (ls-ls_num_nodes == 1) { @@ -88,8 +87,6 @@ int dlm_dir_name2nodeid(struct dlm_ls *l goto out; } - hash = dlm_hash(name, length); - if (ls-ls_node_array) { node = (hash 16) % ls-ls_total_weight; nodeid = ls-ls_node_array[node]; @@ -114,9 +111,9 @@ int dlm_dir_name2nodeid(struct dlm_ls *l return nodeid; } -int dlm_dir_nodeid(struct dlm_rsb *rsb) +int dlm_dir_nodeid(struct dlm_rsb *r) { - return dlm_dir_name2nodeid(rsb-res_ls, rsb-res_name, rsb-res_length); + return dlm_hash2nodeid(r-res_ls, r-res_hash); } static inline uint32_t dir_hash(struct dlm_ls *ls, char *name, int len) @@ -202,12 +199,15 @@ int dlm_recover_directory(struct dlm_ls { struct dlm_member *memb; struct dlm_direntry *de; - char *b, *last_name; + char *b, *last_name = NULL; int error = -ENOMEM, last_len, count = 0; uint16_t namelen; log_debug(ls, dlm_recover_directory); + if (dlm_no_directory(ls)) + goto out_status; + dlm_dir_clear(ls); last_name = kmalloc(DLM_RESNAME_MAXLEN, GFP_KERNEL); @@ -221,12 +221,12 @@ int dlm_recover_directory(struct dlm_ls for (;;) { error = dlm_recovery_stopped(ls); if (error) - goto free_last; + goto out_free; error = dlm_rcom_names(ls, memb-nodeid, last_name, last_len); if (error) - goto free_last; + goto out_free; schedule(); @@ -253,7 +253,7 @@ int dlm_recover_directory(struct dlm_ls error = -ENOMEM; de = get_free_de(ls, namelen); if (!de) - goto free_last; + goto out_free; de-master_nodeid = memb-nodeid; de-length = namelen; @@ -270,12 +270,11 @@ int dlm_recover_directory(struct dlm_ls ; } - dlm_set_recover_status(ls, DLM_RS_DIR); + out_status: error = 0; - + dlm_set_recover_status(ls, DLM_RS_DIR); log_debug(ls, dlm_recover_directory %d entries, count); - - free_last: + out_free: kfree(last_name); out: dlm_clear_free_entries(ls); Index: linux/drivers/dlm/dir.h === --- linux.orig/drivers/dlm/dir.h +++ linux/drivers/dlm/dir.h @@ -16,7 +16,7 @@ int dlm_dir_nodeid(struct dlm_rsb *rsb); -int dlm_dir_name2nodeid(struct dlm_ls *ls, char *name, int length); +int dlm_hash2nodeid(struct dlm_ls *ls, uint32_t hash); void dlm_dir_remove_entry(struct dlm_ls *ls, int nodeid, char *name, int len); void dlm_dir_clear(struct dlm_ls *ls); void dlm_clear_free_entries(struct dlm_ls *ls); Index: linux/drivers/dlm/dlm_internal.h === --- linux.orig/drivers/dlm/dlm_internal.h +++ linux/drivers/dlm/dlm_internal.h @@ -270,6 +270,7 @@ struct dlm_rsb { int res_length; /* length of rsb name */ int res_nodeid; uint32_tres_lvbseq; + uint32_tres_hash; uint32_tres_bucket; /* rsbtbl */ unsigned long res_toss_time; uint32_tres_first_lkid; @@ -364,6 +365,7 @@ struct dlm_message { uint32_tm_sbflags; uint32_tm_flags; uint32_tm_lvbseq; + uint32_tm_hash; int