diff options
author | Dave Kleikamp <shaggy@austin.ibm.com> | 2006-03-14 18:05:45 -0500 |
---|---|---|
committer | Dave Kleikamp <shaggy@austin.ibm.com> | 2006-03-14 18:05:45 -0500 |
commit | c5111f504d2a9b0d258d7c4752b4093523315989 (patch) | |
tree | 6a52864aff79691689aea21cb0cb928327d5de5b /fs/ocfs2/dlm/dlmdomain.c | |
parent | 69eb66d7da7dba2696281981347698e1693c2340 (diff) | |
parent | a488edc914aa1d766a4e2c982b5ae03d5657ec1b (diff) |
Merge with /home/shaggy/git/linus-clean/
Diffstat (limited to 'fs/ocfs2/dlm/dlmdomain.c')
-rw-r--r-- | fs/ocfs2/dlm/dlmdomain.c | 57 |
1 files changed, 36 insertions, 21 deletions
diff --git a/fs/ocfs2/dlm/dlmdomain.c b/fs/ocfs2/dlm/dlmdomain.c index da3c22045f89..8f3a9e3106fd 100644 --- a/fs/ocfs2/dlm/dlmdomain.c +++ b/fs/ocfs2/dlm/dlmdomain.c | |||
@@ -77,26 +77,26 @@ static void dlm_unregister_domain_handlers(struct dlm_ctxt *dlm); | |||
77 | 77 | ||
78 | void __dlm_unhash_lockres(struct dlm_lock_resource *lockres) | 78 | void __dlm_unhash_lockres(struct dlm_lock_resource *lockres) |
79 | { | 79 | { |
80 | list_del_init(&lockres->list); | 80 | hlist_del_init(&lockres->hash_node); |
81 | dlm_lockres_put(lockres); | 81 | dlm_lockres_put(lockres); |
82 | } | 82 | } |
83 | 83 | ||
84 | void __dlm_insert_lockres(struct dlm_ctxt *dlm, | 84 | void __dlm_insert_lockres(struct dlm_ctxt *dlm, |
85 | struct dlm_lock_resource *res) | 85 | struct dlm_lock_resource *res) |
86 | { | 86 | { |
87 | struct list_head *bucket; | 87 | struct hlist_head *bucket; |
88 | struct qstr *q; | 88 | struct qstr *q; |
89 | 89 | ||
90 | assert_spin_locked(&dlm->spinlock); | 90 | assert_spin_locked(&dlm->spinlock); |
91 | 91 | ||
92 | q = &res->lockname; | 92 | q = &res->lockname; |
93 | q->hash = full_name_hash(q->name, q->len); | 93 | q->hash = full_name_hash(q->name, q->len); |
94 | bucket = &(dlm->resources[q->hash & DLM_HASH_MASK]); | 94 | bucket = &(dlm->lockres_hash[q->hash % DLM_HASH_BUCKETS]); |
95 | 95 | ||
96 | /* get a reference for our hashtable */ | 96 | /* get a reference for our hashtable */ |
97 | dlm_lockres_get(res); | 97 | dlm_lockres_get(res); |
98 | 98 | ||
99 | list_add_tail(&res->list, bucket); | 99 | hlist_add_head(&res->hash_node, bucket); |
100 | } | 100 | } |
101 | 101 | ||
102 | struct dlm_lock_resource * __dlm_lookup_lockres(struct dlm_ctxt *dlm, | 102 | struct dlm_lock_resource * __dlm_lookup_lockres(struct dlm_ctxt *dlm, |
@@ -104,9 +104,9 @@ struct dlm_lock_resource * __dlm_lookup_lockres(struct dlm_ctxt *dlm, | |||
104 | unsigned int len) | 104 | unsigned int len) |
105 | { | 105 | { |
106 | unsigned int hash; | 106 | unsigned int hash; |
107 | struct list_head *iter; | 107 | struct hlist_node *iter; |
108 | struct dlm_lock_resource *tmpres=NULL; | 108 | struct dlm_lock_resource *tmpres=NULL; |
109 | struct list_head *bucket; | 109 | struct hlist_head *bucket; |
110 | 110 | ||
111 | mlog_entry("%.*s\n", len, name); | 111 | mlog_entry("%.*s\n", len, name); |
112 | 112 | ||
@@ -114,11 +114,11 @@ struct dlm_lock_resource * __dlm_lookup_lockres(struct dlm_ctxt *dlm, | |||
114 | 114 | ||
115 | hash = full_name_hash(name, len); | 115 | hash = full_name_hash(name, len); |
116 | 116 | ||
117 | bucket = &(dlm->resources[hash & DLM_HASH_MASK]); | 117 | bucket = &(dlm->lockres_hash[hash % DLM_HASH_BUCKETS]); |
118 | 118 | ||
119 | /* check for pre-existing lock */ | 119 | /* check for pre-existing lock */ |
120 | list_for_each(iter, bucket) { | 120 | hlist_for_each(iter, bucket) { |
121 | tmpres = list_entry(iter, struct dlm_lock_resource, list); | 121 | tmpres = hlist_entry(iter, struct dlm_lock_resource, hash_node); |
122 | if (tmpres->lockname.len == len && | 122 | if (tmpres->lockname.len == len && |
123 | memcmp(tmpres->lockname.name, name, len) == 0) { | 123 | memcmp(tmpres->lockname.name, name, len) == 0) { |
124 | dlm_lockres_get(tmpres); | 124 | dlm_lockres_get(tmpres); |
@@ -193,8 +193,8 @@ static int dlm_wait_on_domain_helper(const char *domain) | |||
193 | 193 | ||
194 | static void dlm_free_ctxt_mem(struct dlm_ctxt *dlm) | 194 | static void dlm_free_ctxt_mem(struct dlm_ctxt *dlm) |
195 | { | 195 | { |
196 | if (dlm->resources) | 196 | if (dlm->lockres_hash) |
197 | free_page((unsigned long) dlm->resources); | 197 | free_page((unsigned long) dlm->lockres_hash); |
198 | 198 | ||
199 | if (dlm->name) | 199 | if (dlm->name) |
200 | kfree(dlm->name); | 200 | kfree(dlm->name); |
@@ -303,10 +303,10 @@ static void dlm_migrate_all_locks(struct dlm_ctxt *dlm) | |||
303 | mlog(0, "Migrating locks from domain %s\n", dlm->name); | 303 | mlog(0, "Migrating locks from domain %s\n", dlm->name); |
304 | restart: | 304 | restart: |
305 | spin_lock(&dlm->spinlock); | 305 | spin_lock(&dlm->spinlock); |
306 | for (i=0; i<DLM_HASH_SIZE; i++) { | 306 | for (i = 0; i < DLM_HASH_BUCKETS; i++) { |
307 | while (!list_empty(&dlm->resources[i])) { | 307 | while (!hlist_empty(&dlm->lockres_hash[i])) { |
308 | res = list_entry(dlm->resources[i].next, | 308 | res = hlist_entry(dlm->lockres_hash[i].first, |
309 | struct dlm_lock_resource, list); | 309 | struct dlm_lock_resource, hash_node); |
310 | /* need reference when manually grabbing lockres */ | 310 | /* need reference when manually grabbing lockres */ |
311 | dlm_lockres_get(res); | 311 | dlm_lockres_get(res); |
312 | /* this should unhash the lockres | 312 | /* this should unhash the lockres |
@@ -573,8 +573,11 @@ static int dlm_query_join_handler(struct o2net_msg *msg, u32 len, void *data) | |||
573 | spin_lock(&dlm_domain_lock); | 573 | spin_lock(&dlm_domain_lock); |
574 | dlm = __dlm_lookup_domain_full(query->domain, query->name_len); | 574 | dlm = __dlm_lookup_domain_full(query->domain, query->name_len); |
575 | /* Once the dlm ctxt is marked as leaving then we don't want | 575 | /* Once the dlm ctxt is marked as leaving then we don't want |
576 | * to be put in someone's domain map. */ | 576 | * to be put in someone's domain map. |
577 | * Also, explicitly disallow joining at certain troublesome | ||
578 | * times (ie. during recovery). */ | ||
577 | if (dlm && dlm->dlm_state != DLM_CTXT_LEAVING) { | 579 | if (dlm && dlm->dlm_state != DLM_CTXT_LEAVING) { |
580 | int bit = query->node_idx; | ||
578 | spin_lock(&dlm->spinlock); | 581 | spin_lock(&dlm->spinlock); |
579 | 582 | ||
580 | if (dlm->dlm_state == DLM_CTXT_NEW && | 583 | if (dlm->dlm_state == DLM_CTXT_NEW && |
@@ -586,6 +589,19 @@ static int dlm_query_join_handler(struct o2net_msg *msg, u32 len, void *data) | |||
586 | } else if (dlm->joining_node != DLM_LOCK_RES_OWNER_UNKNOWN) { | 589 | } else if (dlm->joining_node != DLM_LOCK_RES_OWNER_UNKNOWN) { |
587 | /* Disallow parallel joins. */ | 590 | /* Disallow parallel joins. */ |
588 | response = JOIN_DISALLOW; | 591 | response = JOIN_DISALLOW; |
592 | } else if (dlm->reco.state & DLM_RECO_STATE_ACTIVE) { | ||
593 | mlog(ML_NOTICE, "node %u trying to join, but recovery " | ||
594 | "is ongoing.\n", bit); | ||
595 | response = JOIN_DISALLOW; | ||
596 | } else if (test_bit(bit, dlm->recovery_map)) { | ||
597 | mlog(ML_NOTICE, "node %u trying to join, but it " | ||
598 | "still needs recovery.\n", bit); | ||
599 | response = JOIN_DISALLOW; | ||
600 | } else if (test_bit(bit, dlm->domain_map)) { | ||
601 | mlog(ML_NOTICE, "node %u trying to join, but it " | ||
602 | "is still in the domain! needs recovery?\n", | ||
603 | bit); | ||
604 | response = JOIN_DISALLOW; | ||
589 | } else { | 605 | } else { |
590 | /* Alright we're fully a part of this domain | 606 | /* Alright we're fully a part of this domain |
591 | * so we keep some state as to who's joining | 607 | * so we keep some state as to who's joining |
@@ -1175,18 +1191,17 @@ static struct dlm_ctxt *dlm_alloc_ctxt(const char *domain, | |||
1175 | goto leave; | 1191 | goto leave; |
1176 | } | 1192 | } |
1177 | 1193 | ||
1178 | dlm->resources = (struct list_head *) __get_free_page(GFP_KERNEL); | 1194 | dlm->lockres_hash = (struct hlist_head *) __get_free_page(GFP_KERNEL); |
1179 | if (!dlm->resources) { | 1195 | if (!dlm->lockres_hash) { |
1180 | mlog_errno(-ENOMEM); | 1196 | mlog_errno(-ENOMEM); |
1181 | kfree(dlm->name); | 1197 | kfree(dlm->name); |
1182 | kfree(dlm); | 1198 | kfree(dlm); |
1183 | dlm = NULL; | 1199 | dlm = NULL; |
1184 | goto leave; | 1200 | goto leave; |
1185 | } | 1201 | } |
1186 | memset(dlm->resources, 0, PAGE_SIZE); | ||
1187 | 1202 | ||
1188 | for (i=0; i<DLM_HASH_SIZE; i++) | 1203 | for (i=0; i<DLM_HASH_BUCKETS; i++) |
1189 | INIT_LIST_HEAD(&dlm->resources[i]); | 1204 | INIT_HLIST_HEAD(&dlm->lockres_hash[i]); |
1190 | 1205 | ||
1191 | strcpy(dlm->name, domain); | 1206 | strcpy(dlm->name, domain); |
1192 | dlm->key = key; | 1207 | dlm->key = key; |