]> git.ipfire.org Git - people/pmueller/ipfire-2.x.git/blame - src/patches/suse-2.6.27.25/patches.fixes/ocfs2-dlm-activate-dlm-master_hash-for-master-list.patch
Reenabled linux-xen and xen-image build
[people/pmueller/ipfire-2.x.git] / src / patches / suse-2.6.27.25 / patches.fixes / ocfs2-dlm-activate-dlm-master_hash-for-master-list.patch
CommitLineData
00e5a55c
BS
1From: Sunil Mushran <sunil.mushran@oracle.com>
2Date: Thu, 26 Feb 2009 15:00:41 -0800
3Subject: ocfs2/dlm: Activate dlm->master_hash for master list entries
4Patch-mainline: 2.6.30
5References: bnc#408304
6
7With this patch, the mles are stored in a hash and not a simple list.
8This should improve the mle lookup time when the number of outstanding
9masteries is large.
10
11Signed-off-by: Sunil Mushran <sunil.mushran@oracle.com>
12Signed-off-by: Mark Fasheh <mfasheh@suse.com>
13---
14 fs/ocfs2/dlm/dlmcommon.h | 4 +-
15 fs/ocfs2/dlm/dlmdebug.c | 24 +++++++++++-------
16 fs/ocfs2/dlm/dlmdomain.c | 1 -
17 fs/ocfs2/dlm/dlmmaster.c | 61 ++++++++++++++++++++++++++++++++-------------
18 4 files changed, 60 insertions(+), 30 deletions(-)
19
20Index: linux-2.6.27-sle11_ocfs2_update/fs/ocfs2/dlm/dlmcommon.h
21===================================================================
22--- linux-2.6.27-sle11_ocfs2_update.orig/fs/ocfs2/dlm/dlmcommon.h
23+++ linux-2.6.27-sle11_ocfs2_update/fs/ocfs2/dlm/dlmcommon.h
24@@ -56,12 +56,13 @@ enum dlm_mle_type {
25 };
26
27 struct dlm_lock_name {
28+ unsigned int hash;
29 unsigned int len;
30 unsigned char name[DLM_LOCKID_NAME_MAX];
31 };
32
33 struct dlm_master_list_entry {
34- struct list_head list;
35+ struct hlist_node master_hash_node;
36 struct list_head hb_events;
37 struct dlm_ctxt *dlm;
38 spinlock_t spinlock;
39@@ -152,7 +153,6 @@ struct dlm_ctxt
40 struct dlm_recovery_ctxt reco;
41 spinlock_t master_lock;
42 struct hlist_head **master_hash;
43- struct list_head master_list;
44 struct list_head mle_hb_events;
45
46 /* these give a really vague idea of the system load */
47Index: linux-2.6.27-sle11_ocfs2_update/fs/ocfs2/dlm/dlmdebug.c
48===================================================================
49--- linux-2.6.27-sle11_ocfs2_update.orig/fs/ocfs2/dlm/dlmdebug.c
50+++ linux-2.6.27-sle11_ocfs2_update/fs/ocfs2/dlm/dlmdebug.c
51@@ -501,18 +501,25 @@ static struct file_operations debug_purg
52 static int debug_mle_print(struct dlm_ctxt *dlm, struct debug_buffer *db)
53 {
54 struct dlm_master_list_entry *mle;
55- int out = 0;
56+ struct hlist_head *bucket;
57+ struct hlist_node *list;
58+ int i, out = 0;
59 unsigned long total = 0;
60
61 out += snprintf(db->buf + out, db->len - out,
62 "Dumping MLEs for Domain: %s\n", dlm->name);
63
64 spin_lock(&dlm->master_lock);
65- list_for_each_entry(mle, &dlm->master_list, list) {
66- ++total;
67- if (db->len - out < 200)
68- continue;
69- out += dump_mle(mle, db->buf + out, db->len - out);
70+ for (i = 0; i < DLM_HASH_BUCKETS; i++) {
71+ bucket = dlm_master_hash(dlm, i);
72+ hlist_for_each(list, bucket) {
73+ mle = hlist_entry(list, struct dlm_master_list_entry,
74+ master_hash_node);
75+ ++total;
76+ if (db->len - out < 200)
77+ continue;
78+ out += dump_mle(mle, db->buf + out, db->len - out);
79+ }
80 }
81 spin_unlock(&dlm->master_lock);
82
83@@ -813,12 +820,11 @@ static int debug_state_print(struct dlm_
84 /* Lists: Dirty=Empty Purge=InUse PendingASTs=Empty ... */
85 out += snprintf(db->buf + out, db->len - out,
86 "Lists: Dirty=%s Purge=%s PendingASTs=%s "
87- "PendingBASTs=%s Master=%s\n",
88+ "PendingBASTs=%s\n",
89 (list_empty(&dlm->dirty_list) ? "Empty" : "InUse"),
90 (list_empty(&dlm->purge_list) ? "Empty" : "InUse"),
91 (list_empty(&dlm->pending_asts) ? "Empty" : "InUse"),
92- (list_empty(&dlm->pending_basts) ? "Empty" : "InUse"),
93- (list_empty(&dlm->master_list) ? "Empty" : "InUse"));
94+ (list_empty(&dlm->pending_basts) ? "Empty" : "InUse"));
95
96 /* Purge Count: xxx Refs: xxx */
97 out += snprintf(db->buf + out, db->len - out,
98Index: linux-2.6.27-sle11_ocfs2_update/fs/ocfs2/dlm/dlmdomain.c
99===================================================================
100--- linux-2.6.27-sle11_ocfs2_update.orig/fs/ocfs2/dlm/dlmdomain.c
101+++ linux-2.6.27-sle11_ocfs2_update/fs/ocfs2/dlm/dlmdomain.c
102@@ -1597,7 +1597,6 @@ static struct dlm_ctxt *dlm_alloc_ctxt(c
103 init_waitqueue_head(&dlm->reco.event);
104 init_waitqueue_head(&dlm->ast_wq);
105 init_waitqueue_head(&dlm->migration_wq);
106- INIT_LIST_HEAD(&dlm->master_list);
107 INIT_LIST_HEAD(&dlm->mle_hb_events);
108
109 dlm->joining_node = DLM_LOCK_RES_OWNER_UNKNOWN;
110Index: linux-2.6.27-sle11_ocfs2_update/fs/ocfs2/dlm/dlmmaster.c
111===================================================================
112--- linux-2.6.27-sle11_ocfs2_update.orig/fs/ocfs2/dlm/dlmmaster.c
113+++ linux-2.6.27-sle11_ocfs2_update/fs/ocfs2/dlm/dlmmaster.c
114@@ -69,7 +69,8 @@ static int dlm_do_assert_master(struct d
115 static void dlm_deref_lockres_worker(struct dlm_work_item *item, void *data);
116
117 static inline void __dlm_mle_name(struct dlm_master_list_entry *mle,
118- unsigned char **name, unsigned int *namelen)
119+ unsigned char **name, unsigned int *namelen,
120+ unsigned int *namehash)
121 {
122 BUG_ON(mle->type != DLM_MLE_BLOCK &&
123 mle->type != DLM_MLE_MASTER &&
124@@ -78,9 +79,13 @@ static inline void __dlm_mle_name(struct
125 if (mle->type != DLM_MLE_MASTER) {
126 *name = mle->u.mlename.name;
127 *namelen = mle->u.mlename.len;
128+ if (namehash)
129+ *namehash = mle->u.mlename.hash;
130 } else {
131 *name = (unsigned char *)mle->u.mleres->lockname.name;
132 *namelen = mle->u.mleres->lockname.len;
133+ if (namehash)
134+ *namehash = mle->u.mleres->lockname.hash;
135 }
136 }
137
138@@ -95,7 +100,7 @@ static inline int dlm_mle_equal(struct d
139 if (dlm != mle->dlm)
140 return 0;
141
142- __dlm_mle_name(mle, &mlename, &mlelen);
143+ __dlm_mle_name(mle, &mlename, &mlelen, NULL);
144
145 if (namelen != mlelen || memcmp(name, mlename, namelen) != 0)
146 return 0;
147@@ -294,7 +299,7 @@ static void dlm_init_mle(struct dlm_mast
148
149 mle->dlm = dlm;
150 mle->type = type;
151- INIT_LIST_HEAD(&mle->list);
152+ INIT_HLIST_NODE(&mle->master_hash_node);
153 INIT_LIST_HEAD(&mle->hb_events);
154 memset(mle->maybe_map, 0, sizeof(mle->maybe_map));
155 spin_lock_init(&mle->spinlock);
156@@ -317,6 +322,7 @@ static void dlm_init_mle(struct dlm_mast
157 BUG_ON(!name);
158 memcpy(mle->u.mlename.name, name, namelen);
159 mle->u.mlename.len = namelen;
160+ mle->u.mlename.hash = dlm_lockid_hash(name, namelen);
161 }
162
163 /* copy off the node_map and register hb callbacks on our copy */
164@@ -334,15 +340,21 @@ void __dlm_unlink_mle(struct dlm_ctxt *d
165 assert_spin_locked(&dlm->spinlock);
166 assert_spin_locked(&dlm->master_lock);
167
168- if (!list_empty(&mle->list))
169- list_del_init(&mle->list);
170+ if (!hlist_unhashed(&mle->master_hash_node))
171+ hlist_del_init(&mle->master_hash_node);
172 }
173
174 void __dlm_insert_mle(struct dlm_ctxt *dlm, struct dlm_master_list_entry *mle)
175 {
176+ struct hlist_head *bucket;
177+ unsigned char *mname;
178+ unsigned int mlen, hash;
179+
180 assert_spin_locked(&dlm->master_lock);
181
182- list_add(&mle->list, &dlm->master_list);
183+ __dlm_mle_name(mle, &mname, &mlen, &hash);
184+ bucket = dlm_master_hash(dlm, hash);
185+ hlist_add_head(&mle->master_hash_node, bucket);
186 }
187
188 /* returns 1 if found, 0 if not */
189@@ -351,10 +363,17 @@ static int dlm_find_mle(struct dlm_ctxt
190 char *name, unsigned int namelen)
191 {
192 struct dlm_master_list_entry *tmpmle;
193+ struct hlist_head *bucket;
194+ struct hlist_node *list;
195+ unsigned int hash;
196
197 assert_spin_locked(&dlm->master_lock);
198
199- list_for_each_entry(tmpmle, &dlm->master_list, list) {
200+ hash = dlm_lockid_hash(name, namelen);
201+ bucket = dlm_master_hash(dlm, hash);
202+ hlist_for_each(list, bucket) {
203+ tmpmle = hlist_entry(list, struct dlm_master_list_entry,
204+ master_hash_node);
205 if (!dlm_mle_equal(dlm, tmpmle, name, namelen))
206 continue;
207 dlm_get_mle(tmpmle);
208@@ -428,23 +447,20 @@ static void dlm_mle_release(struct kref
209 {
210 struct dlm_master_list_entry *mle;
211 struct dlm_ctxt *dlm;
212+ unsigned char *mname;
213+ unsigned int mlen;
214
215 mlog_entry_void();
216
217 mle = container_of(kref, struct dlm_master_list_entry, mle_refs);
218 dlm = mle->dlm;
219
220- if (mle->type != DLM_MLE_MASTER) {
221- mlog(0, "calling mle_release for %.*s, type %d\n",
222- mle->u.mlename.len, mle->u.mlename.name, mle->type);
223- } else {
224- mlog(0, "calling mle_release for %.*s, type %d\n",
225- mle->u.mleres->lockname.len,
226- mle->u.mleres->lockname.name, mle->type);
227- }
228 assert_spin_locked(&dlm->spinlock);
229 assert_spin_locked(&dlm->master_lock);
230
231+ __dlm_mle_name(mle, &mname, &mlen, NULL);
232+ mlog(0, "Releasing mle for %.*s, type %d\n", mlen, mname, mle->type);
233+
234 /* remove from list if not already */
235 __dlm_unlink_mle(dlm, mle);
236
237@@ -1335,7 +1351,7 @@ static int dlm_do_master_request(struct
238
239 BUG_ON(mle->type == DLM_MLE_MIGRATION);
240
241- __dlm_mle_name(mle, &mlename, &mlenamelen);
242+ __dlm_mle_name(mle, &mlename, &mlenamelen, NULL);
243
244 request.namelen = (u8)mlenamelen;
245 memcpy(request.name, mlename, request.namelen);
246@@ -3264,8 +3280,11 @@ static void dlm_clean_block_mle(struct d
247
248 void dlm_clean_master_list(struct dlm_ctxt *dlm, u8 dead_node)
249 {
250- struct dlm_master_list_entry *mle, *next;
251+ struct dlm_master_list_entry *mle;
252 struct dlm_lock_resource *res;
253+ struct hlist_head *bucket;
254+ struct hlist_node *list;
255+ unsigned int i;
256
257 mlog_entry("dlm=%s, dead node=%u\n", dlm->name, dead_node);
258 top:
259@@ -3273,7 +3292,12 @@ top:
260
261 /* clean the master list */
262 spin_lock(&dlm->master_lock);
263- list_for_each_entry_safe(mle, next, &dlm->master_list, list) {
264+ for (i = 0; i < DLM_HASH_BUCKETS; i++) {
265+ bucket = dlm_master_hash(dlm, i);
266+ hlist_for_each(list, bucket) {
267+ mle = hlist_entry(list, struct dlm_master_list_entry,
268+ master_hash_node);
269+
270 BUG_ON(mle->type != DLM_MLE_BLOCK &&
271 mle->type != DLM_MLE_MASTER &&
272 mle->type != DLM_MLE_MIGRATION);
273@@ -3329,6 +3353,7 @@ top:
274 /* this may be the last reference */
275 __dlm_put_mle(mle);
276 }
277+ }
278 spin_unlock(&dlm->master_lock);
279 }
280