aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ocfs2/dlm/dlmdomain.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/ocfs2/dlm/dlmdomain.c')
-rw-r--r--fs/ocfs2/dlm/dlmdomain.c41
1 files changed, 33 insertions, 8 deletions
diff --git a/fs/ocfs2/dlm/dlmdomain.c b/fs/ocfs2/dlm/dlmdomain.c
index 595b1c7cbd1f..80b8cce9cf3c 100644
--- a/fs/ocfs2/dlm/dlmdomain.c
+++ b/fs/ocfs2/dlm/dlmdomain.c
@@ -49,6 +49,30 @@
49#define MLOG_MASK_PREFIX (ML_DLM|ML_DLM_DOMAIN) 49#define MLOG_MASK_PREFIX (ML_DLM|ML_DLM_DOMAIN)
50#include "cluster/masklog.h" 50#include "cluster/masklog.h"
51 51
52static void dlm_free_pagevec(void **vec, int pages)
53{
54 while (pages--)
55 free_page((unsigned long)vec[pages]);
56 kfree(vec);
57}
58
59static void **dlm_alloc_pagevec(int pages)
60{
61 void **vec = kmalloc(pages * sizeof(void *), GFP_KERNEL);
62 int i;
63
64 if (!vec)
65 return NULL;
66
67 for (i = 0; i < pages; i++)
68 if (!(vec[i] = (void *)__get_free_page(GFP_KERNEL)))
69 goto out_free;
70 return vec;
71out_free:
72 dlm_free_pagevec(vec, i);
73 return NULL;
74}
75
52/* 76/*
53 * 77 *
54 * spinlock lock ordering: if multiple locks are needed, obey this ordering: 78 * spinlock lock ordering: if multiple locks are needed, obey this ordering:
@@ -90,7 +114,7 @@ void __dlm_insert_lockres(struct dlm_ctxt *dlm,
90 assert_spin_locked(&dlm->spinlock); 114 assert_spin_locked(&dlm->spinlock);
91 115
92 q = &res->lockname; 116 q = &res->lockname;
93 bucket = &(dlm->lockres_hash[q->hash % DLM_HASH_BUCKETS]); 117 bucket = dlm_lockres_hash(dlm, q->hash);
94 118
95 /* get a reference for our hashtable */ 119 /* get a reference for our hashtable */
96 dlm_lockres_get(res); 120 dlm_lockres_get(res);
@@ -110,7 +134,8 @@ struct dlm_lock_resource * __dlm_lookup_lockres(struct dlm_ctxt *dlm,
110 134
111 assert_spin_locked(&dlm->spinlock); 135 assert_spin_locked(&dlm->spinlock);
112 136
113 bucket = dlm->lockres_hash + full_name_hash(name, len) % DLM_HASH_BUCKETS; 137 bucket = dlm_lockres_hash(dlm, hash);
138
114 hlist_for_each(list, bucket) { 139 hlist_for_each(list, bucket) {
115 struct dlm_lock_resource *res = hlist_entry(list, 140 struct dlm_lock_resource *res = hlist_entry(list,
116 struct dlm_lock_resource, hash_node); 141 struct dlm_lock_resource, hash_node);
@@ -191,7 +216,7 @@ static int dlm_wait_on_domain_helper(const char *domain)
191static void dlm_free_ctxt_mem(struct dlm_ctxt *dlm) 216static void dlm_free_ctxt_mem(struct dlm_ctxt *dlm)
192{ 217{
193 if (dlm->lockres_hash) 218 if (dlm->lockres_hash)
194 free_page((unsigned long) dlm->lockres_hash); 219 dlm_free_pagevec((void **)dlm->lockres_hash, DLM_HASH_PAGES);
195 220
196 if (dlm->name) 221 if (dlm->name)
197 kfree(dlm->name); 222 kfree(dlm->name);
@@ -301,8 +326,8 @@ static void dlm_migrate_all_locks(struct dlm_ctxt *dlm)
301restart: 326restart:
302 spin_lock(&dlm->spinlock); 327 spin_lock(&dlm->spinlock);
303 for (i = 0; i < DLM_HASH_BUCKETS; i++) { 328 for (i = 0; i < DLM_HASH_BUCKETS; i++) {
304 while (!hlist_empty(&dlm->lockres_hash[i])) { 329 while (!hlist_empty(dlm_lockres_hash(dlm, i))) {
305 res = hlist_entry(dlm->lockres_hash[i].first, 330 res = hlist_entry(dlm_lockres_hash(dlm, i)->first,
306 struct dlm_lock_resource, hash_node); 331 struct dlm_lock_resource, hash_node);
307 /* need reference when manually grabbing lockres */ 332 /* need reference when manually grabbing lockres */
308 dlm_lockres_get(res); 333 dlm_lockres_get(res);
@@ -1188,7 +1213,7 @@ static struct dlm_ctxt *dlm_alloc_ctxt(const char *domain,
1188 goto leave; 1213 goto leave;
1189 } 1214 }
1190 1215
1191 dlm->lockres_hash = (struct hlist_head *) __get_free_page(GFP_KERNEL); 1216 dlm->lockres_hash = (struct hlist_head **)dlm_alloc_pagevec(DLM_HASH_PAGES);
1192 if (!dlm->lockres_hash) { 1217 if (!dlm->lockres_hash) {
1193 mlog_errno(-ENOMEM); 1218 mlog_errno(-ENOMEM);
1194 kfree(dlm->name); 1219 kfree(dlm->name);
@@ -1197,8 +1222,8 @@ static struct dlm_ctxt *dlm_alloc_ctxt(const char *domain,
1197 goto leave; 1222 goto leave;
1198 } 1223 }
1199 1224
1200 for (i=0; i<DLM_HASH_BUCKETS; i++) 1225 for (i = 0; i < DLM_HASH_BUCKETS; i++)
1201 INIT_HLIST_HEAD(&dlm->lockres_hash[i]); 1226 INIT_HLIST_HEAD(dlm_lockres_hash(dlm, i));
1202 1227
1203 strcpy(dlm->name, domain); 1228 strcpy(dlm->name, domain);
1204 dlm->key = key; 1229 dlm->key = key;