aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ocfs2/dlm
diff options
context:
space:
mode:
authorDong Fang <yp.fangdong@gmail.com>2013-09-11 17:19:50 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2013-09-11 18:56:36 -0400
commitdf53cd3b70712cd136f10ef79457623c5c3764a4 (patch)
tree426988282de0ac3ff6d00a51dc8f299e47dfeefc /fs/ocfs2/dlm
parent8dd7903e48df3779bc424196c22dc73b66d0643e (diff)
ocfs2: use list_for_each_entry() instead of list_for_each()
[dan.carpenter@oracle.com: fix up some NULL dereference bugs] Signed-off-by: Dong Fang <yp.fangdong@gmail.com> Cc: Mark Fasheh <mfasheh@suse.com> Cc: Joel Becker <jlbec@evilplan.org> Cc: Jeff Liu <jeff.liu@oracle.com> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'fs/ocfs2/dlm')
-rw-r--r--fs/ocfs2/dlm/dlmast.c8
-rw-r--r--fs/ocfs2/dlm/dlmcommon.h4
-rw-r--r--fs/ocfs2/dlm/dlmconvert.c18
-rw-r--r--fs/ocfs2/dlm/dlmdebug.c15
-rw-r--r--fs/ocfs2/dlm/dlmdomain.c35
-rw-r--r--fs/ocfs2/dlm/dlmlock.c9
-rw-r--r--fs/ocfs2/dlm/dlmmaster.c18
-rw-r--r--fs/ocfs2/dlm/dlmthread.c19
-rw-r--r--fs/ocfs2/dlm/dlmunlock.c4
9 files changed, 40 insertions, 90 deletions
diff --git a/fs/ocfs2/dlm/dlmast.c b/fs/ocfs2/dlm/dlmast.c
index fbec0be62326..b46278f9ae44 100644
--- a/fs/ocfs2/dlm/dlmast.c
+++ b/fs/ocfs2/dlm/dlmast.c
@@ -292,7 +292,7 @@ int dlm_proxy_ast_handler(struct o2net_msg *msg, u32 len, void *data,
292 struct dlm_lock *lock = NULL; 292 struct dlm_lock *lock = NULL;
293 struct dlm_proxy_ast *past = (struct dlm_proxy_ast *) msg->buf; 293 struct dlm_proxy_ast *past = (struct dlm_proxy_ast *) msg->buf;
294 char *name; 294 char *name;
295 struct list_head *iter, *head=NULL; 295 struct list_head *head = NULL;
296 __be64 cookie; 296 __be64 cookie;
297 u32 flags; 297 u32 flags;
298 u8 node; 298 u8 node;
@@ -373,8 +373,7 @@ int dlm_proxy_ast_handler(struct o2net_msg *msg, u32 len, void *data,
373 /* try convert queue for both ast/bast */ 373 /* try convert queue for both ast/bast */
374 head = &res->converting; 374 head = &res->converting;
375 lock = NULL; 375 lock = NULL;
376 list_for_each(iter, head) { 376 list_for_each_entry(lock, head, list) {
377 lock = list_entry (iter, struct dlm_lock, list);
378 if (lock->ml.cookie == cookie) 377 if (lock->ml.cookie == cookie)
379 goto do_ast; 378 goto do_ast;
380 } 379 }
@@ -385,8 +384,7 @@ int dlm_proxy_ast_handler(struct o2net_msg *msg, u32 len, void *data,
385 else 384 else
386 head = &res->granted; 385 head = &res->granted;
387 386
388 list_for_each(iter, head) { 387 list_for_each_entry(lock, head, list) {
389 lock = list_entry (iter, struct dlm_lock, list);
390 if (lock->ml.cookie == cookie) 388 if (lock->ml.cookie == cookie)
391 goto do_ast; 389 goto do_ast;
392 } 390 }
diff --git a/fs/ocfs2/dlm/dlmcommon.h b/fs/ocfs2/dlm/dlmcommon.h
index de854cca12a2..e0517762fcc0 100644
--- a/fs/ocfs2/dlm/dlmcommon.h
+++ b/fs/ocfs2/dlm/dlmcommon.h
@@ -1079,11 +1079,9 @@ static inline int dlm_lock_compatible(int existing, int request)
1079static inline int dlm_lock_on_list(struct list_head *head, 1079static inline int dlm_lock_on_list(struct list_head *head,
1080 struct dlm_lock *lock) 1080 struct dlm_lock *lock)
1081{ 1081{
1082 struct list_head *iter;
1083 struct dlm_lock *tmplock; 1082 struct dlm_lock *tmplock;
1084 1083
1085 list_for_each(iter, head) { 1084 list_for_each_entry(tmplock, head, list) {
1086 tmplock = list_entry(iter, struct dlm_lock, list);
1087 if (tmplock == lock) 1085 if (tmplock == lock)
1088 return 1; 1086 return 1;
1089 } 1087 }
diff --git a/fs/ocfs2/dlm/dlmconvert.c b/fs/ocfs2/dlm/dlmconvert.c
index 29a886d1e82c..e36d63ff1783 100644
--- a/fs/ocfs2/dlm/dlmconvert.c
+++ b/fs/ocfs2/dlm/dlmconvert.c
@@ -123,7 +123,6 @@ static enum dlm_status __dlmconvert_master(struct dlm_ctxt *dlm,
123 int *kick_thread) 123 int *kick_thread)
124{ 124{
125 enum dlm_status status = DLM_NORMAL; 125 enum dlm_status status = DLM_NORMAL;
126 struct list_head *iter;
127 struct dlm_lock *tmplock=NULL; 126 struct dlm_lock *tmplock=NULL;
128 127
129 assert_spin_locked(&res->spinlock); 128 assert_spin_locked(&res->spinlock);
@@ -185,16 +184,14 @@ static enum dlm_status __dlmconvert_master(struct dlm_ctxt *dlm,
185 184
186 /* upconvert from here on */ 185 /* upconvert from here on */
187 status = DLM_NORMAL; 186 status = DLM_NORMAL;
188 list_for_each(iter, &res->granted) { 187 list_for_each_entry(tmplock, &res->granted, list) {
189 tmplock = list_entry(iter, struct dlm_lock, list);
190 if (tmplock == lock) 188 if (tmplock == lock)
191 continue; 189 continue;
192 if (!dlm_lock_compatible(tmplock->ml.type, type)) 190 if (!dlm_lock_compatible(tmplock->ml.type, type))
193 goto switch_queues; 191 goto switch_queues;
194 } 192 }
195 193
196 list_for_each(iter, &res->converting) { 194 list_for_each_entry(tmplock, &res->converting, list) {
197 tmplock = list_entry(iter, struct dlm_lock, list);
198 if (!dlm_lock_compatible(tmplock->ml.type, type)) 195 if (!dlm_lock_compatible(tmplock->ml.type, type))
199 goto switch_queues; 196 goto switch_queues;
200 /* existing conversion requests take precedence */ 197 /* existing conversion requests take precedence */
@@ -424,8 +421,8 @@ int dlm_convert_lock_handler(struct o2net_msg *msg, u32 len, void *data,
424 struct dlm_ctxt *dlm = data; 421 struct dlm_ctxt *dlm = data;
425 struct dlm_convert_lock *cnv = (struct dlm_convert_lock *)msg->buf; 422 struct dlm_convert_lock *cnv = (struct dlm_convert_lock *)msg->buf;
426 struct dlm_lock_resource *res = NULL; 423 struct dlm_lock_resource *res = NULL;
427 struct list_head *iter;
428 struct dlm_lock *lock = NULL; 424 struct dlm_lock *lock = NULL;
425 struct dlm_lock *tmp_lock;
429 struct dlm_lockstatus *lksb; 426 struct dlm_lockstatus *lksb;
430 enum dlm_status status = DLM_NORMAL; 427 enum dlm_status status = DLM_NORMAL;
431 u32 flags; 428 u32 flags;
@@ -471,14 +468,13 @@ int dlm_convert_lock_handler(struct o2net_msg *msg, u32 len, void *data,
471 dlm_error(status); 468 dlm_error(status);
472 goto leave; 469 goto leave;
473 } 470 }
474 list_for_each(iter, &res->granted) { 471 list_for_each_entry(tmp_lock, &res->granted, list) {
475 lock = list_entry(iter, struct dlm_lock, list); 472 if (tmp_lock->ml.cookie == cnv->cookie &&
476 if (lock->ml.cookie == cnv->cookie && 473 tmp_lock->ml.node == cnv->node_idx) {
477 lock->ml.node == cnv->node_idx) { 474 lock = tmp_lock;
478 dlm_lock_get(lock); 475 dlm_lock_get(lock);
479 break; 476 break;
480 } 477 }
481 lock = NULL;
482 } 478 }
483 spin_unlock(&res->spinlock); 479 spin_unlock(&res->spinlock);
484 if (!lock) { 480 if (!lock) {
diff --git a/fs/ocfs2/dlm/dlmdebug.c b/fs/ocfs2/dlm/dlmdebug.c
index 0e28e242226d..e33cd7a3c582 100644
--- a/fs/ocfs2/dlm/dlmdebug.c
+++ b/fs/ocfs2/dlm/dlmdebug.c
@@ -96,7 +96,6 @@ static void __dlm_print_lock(struct dlm_lock *lock)
96 96
97void __dlm_print_one_lock_resource(struct dlm_lock_resource *res) 97void __dlm_print_one_lock_resource(struct dlm_lock_resource *res)
98{ 98{
99 struct list_head *iter2;
100 struct dlm_lock *lock; 99 struct dlm_lock *lock;
101 char buf[DLM_LOCKID_NAME_MAX]; 100 char buf[DLM_LOCKID_NAME_MAX];
102 101
@@ -118,18 +117,15 @@ void __dlm_print_one_lock_resource(struct dlm_lock_resource *res)
118 res->inflight_locks, atomic_read(&res->asts_reserved)); 117 res->inflight_locks, atomic_read(&res->asts_reserved));
119 dlm_print_lockres_refmap(res); 118 dlm_print_lockres_refmap(res);
120 printk(" granted queue:\n"); 119 printk(" granted queue:\n");
121 list_for_each(iter2, &res->granted) { 120 list_for_each_entry(lock, &res->granted, list) {
122 lock = list_entry(iter2, struct dlm_lock, list);
123 __dlm_print_lock(lock); 121 __dlm_print_lock(lock);
124 } 122 }
125 printk(" converting queue:\n"); 123 printk(" converting queue:\n");
126 list_for_each(iter2, &res->converting) { 124 list_for_each_entry(lock, &res->converting, list) {
127 lock = list_entry(iter2, struct dlm_lock, list);
128 __dlm_print_lock(lock); 125 __dlm_print_lock(lock);
129 } 126 }
130 printk(" blocked queue:\n"); 127 printk(" blocked queue:\n");
131 list_for_each(iter2, &res->blocked) { 128 list_for_each_entry(lock, &res->blocked, list) {
132 lock = list_entry(iter2, struct dlm_lock, list);
133 __dlm_print_lock(lock); 129 __dlm_print_lock(lock);
134 } 130 }
135} 131}
@@ -446,7 +442,6 @@ static int debug_mle_print(struct dlm_ctxt *dlm, char *buf, int len)
446{ 442{
447 struct dlm_master_list_entry *mle; 443 struct dlm_master_list_entry *mle;
448 struct hlist_head *bucket; 444 struct hlist_head *bucket;
449 struct hlist_node *list;
450 int i, out = 0; 445 int i, out = 0;
451 unsigned long total = 0, longest = 0, bucket_count = 0; 446 unsigned long total = 0, longest = 0, bucket_count = 0;
452 447
@@ -456,9 +451,7 @@ static int debug_mle_print(struct dlm_ctxt *dlm, char *buf, int len)
456 spin_lock(&dlm->master_lock); 451 spin_lock(&dlm->master_lock);
457 for (i = 0; i < DLM_HASH_BUCKETS; i++) { 452 for (i = 0; i < DLM_HASH_BUCKETS; i++) {
458 bucket = dlm_master_hash(dlm, i); 453 bucket = dlm_master_hash(dlm, i);
459 hlist_for_each(list, bucket) { 454 hlist_for_each_entry(mle, bucket, master_hash_node) {
460 mle = hlist_entry(list, struct dlm_master_list_entry,
461 master_hash_node);
462 ++total; 455 ++total;
463 ++bucket_count; 456 ++bucket_count;
464 if (len - out < 200) 457 if (len - out < 200)
diff --git a/fs/ocfs2/dlm/dlmdomain.c b/fs/ocfs2/dlm/dlmdomain.c
index dbb17c07656a..8b3382abf840 100644
--- a/fs/ocfs2/dlm/dlmdomain.c
+++ b/fs/ocfs2/dlm/dlmdomain.c
@@ -193,7 +193,7 @@ struct dlm_lock_resource * __dlm_lookup_lockres_full(struct dlm_ctxt *dlm,
193 unsigned int hash) 193 unsigned int hash)
194{ 194{
195 struct hlist_head *bucket; 195 struct hlist_head *bucket;
196 struct hlist_node *list; 196 struct dlm_lock_resource *res;
197 197
198 mlog(0, "%.*s\n", len, name); 198 mlog(0, "%.*s\n", len, name);
199 199
@@ -201,9 +201,7 @@ struct dlm_lock_resource * __dlm_lookup_lockres_full(struct dlm_ctxt *dlm,
201 201
202 bucket = dlm_lockres_hash(dlm, hash); 202 bucket = dlm_lockres_hash(dlm, hash);
203 203
204 hlist_for_each(list, bucket) { 204 hlist_for_each_entry(res, bucket, hash_node) {
205 struct dlm_lock_resource *res = hlist_entry(list,
206 struct dlm_lock_resource, hash_node);
207 if (res->lockname.name[0] != name[0]) 205 if (res->lockname.name[0] != name[0])
208 continue; 206 continue;
209 if (unlikely(res->lockname.len != len)) 207 if (unlikely(res->lockname.len != len))
@@ -262,22 +260,19 @@ struct dlm_lock_resource * dlm_lookup_lockres(struct dlm_ctxt *dlm,
262 260
263static struct dlm_ctxt * __dlm_lookup_domain_full(const char *domain, int len) 261static struct dlm_ctxt * __dlm_lookup_domain_full(const char *domain, int len)
264{ 262{
265 struct dlm_ctxt *tmp = NULL; 263 struct dlm_ctxt *tmp;
266 struct list_head *iter;
267 264
268 assert_spin_locked(&dlm_domain_lock); 265 assert_spin_locked(&dlm_domain_lock);
269 266
270 /* tmp->name here is always NULL terminated, 267 /* tmp->name here is always NULL terminated,
271 * but domain may not be! */ 268 * but domain may not be! */
272 list_for_each(iter, &dlm_domains) { 269 list_for_each_entry(tmp, &dlm_domains, list) {
273 tmp = list_entry (iter, struct dlm_ctxt, list);
274 if (strlen(tmp->name) == len && 270 if (strlen(tmp->name) == len &&
275 memcmp(tmp->name, domain, len)==0) 271 memcmp(tmp->name, domain, len)==0)
276 break; 272 return tmp;
277 tmp = NULL;
278 } 273 }
279 274
280 return tmp; 275 return NULL;
281} 276}
282 277
283/* For null terminated domain strings ONLY */ 278/* For null terminated domain strings ONLY */
@@ -366,25 +361,22 @@ static void __dlm_get(struct dlm_ctxt *dlm)
366 * you shouldn't trust your pointer. */ 361 * you shouldn't trust your pointer. */
367struct dlm_ctxt *dlm_grab(struct dlm_ctxt *dlm) 362struct dlm_ctxt *dlm_grab(struct dlm_ctxt *dlm)
368{ 363{
369 struct list_head *iter; 364 struct dlm_ctxt *target;
370 struct dlm_ctxt *target = NULL; 365 struct dlm_ctxt *ret = NULL;
371 366
372 spin_lock(&dlm_domain_lock); 367 spin_lock(&dlm_domain_lock);
373 368
374 list_for_each(iter, &dlm_domains) { 369 list_for_each_entry(target, &dlm_domains, list) {
375 target = list_entry (iter, struct dlm_ctxt, list);
376
377 if (target == dlm) { 370 if (target == dlm) {
378 __dlm_get(target); 371 __dlm_get(target);
372 ret = target;
379 break; 373 break;
380 } 374 }
381
382 target = NULL;
383 } 375 }
384 376
385 spin_unlock(&dlm_domain_lock); 377 spin_unlock(&dlm_domain_lock);
386 378
387 return target; 379 return ret;
388} 380}
389 381
390int dlm_domain_fully_joined(struct dlm_ctxt *dlm) 382int dlm_domain_fully_joined(struct dlm_ctxt *dlm)
@@ -2296,13 +2288,10 @@ static DECLARE_RWSEM(dlm_callback_sem);
2296void dlm_fire_domain_eviction_callbacks(struct dlm_ctxt *dlm, 2288void dlm_fire_domain_eviction_callbacks(struct dlm_ctxt *dlm,
2297 int node_num) 2289 int node_num)
2298{ 2290{
2299 struct list_head *iter;
2300 struct dlm_eviction_cb *cb; 2291 struct dlm_eviction_cb *cb;
2301 2292
2302 down_read(&dlm_callback_sem); 2293 down_read(&dlm_callback_sem);
2303 list_for_each(iter, &dlm->dlm_eviction_callbacks) { 2294 list_for_each_entry(cb, &dlm->dlm_eviction_callbacks, ec_item) {
2304 cb = list_entry(iter, struct dlm_eviction_cb, ec_item);
2305
2306 cb->ec_func(node_num, cb->ec_data); 2295 cb->ec_func(node_num, cb->ec_data);
2307 } 2296 }
2308 up_read(&dlm_callback_sem); 2297 up_read(&dlm_callback_sem);
diff --git a/fs/ocfs2/dlm/dlmlock.c b/fs/ocfs2/dlm/dlmlock.c
index 47e67c2d228f..5d32f7511f74 100644
--- a/fs/ocfs2/dlm/dlmlock.c
+++ b/fs/ocfs2/dlm/dlmlock.c
@@ -91,19 +91,14 @@ void dlm_destroy_lock_cache(void)
91static int dlm_can_grant_new_lock(struct dlm_lock_resource *res, 91static int dlm_can_grant_new_lock(struct dlm_lock_resource *res,
92 struct dlm_lock *lock) 92 struct dlm_lock *lock)
93{ 93{
94 struct list_head *iter;
95 struct dlm_lock *tmplock; 94 struct dlm_lock *tmplock;
96 95
97 list_for_each(iter, &res->granted) { 96 list_for_each_entry(tmplock, &res->granted, list) {
98 tmplock = list_entry(iter, struct dlm_lock, list);
99
100 if (!dlm_lock_compatible(tmplock->ml.type, lock->ml.type)) 97 if (!dlm_lock_compatible(tmplock->ml.type, lock->ml.type))
101 return 0; 98 return 0;
102 } 99 }
103 100
104 list_for_each(iter, &res->converting) { 101 list_for_each_entry(tmplock, &res->converting, list) {
105 tmplock = list_entry(iter, struct dlm_lock, list);
106
107 if (!dlm_lock_compatible(tmplock->ml.type, lock->ml.type)) 102 if (!dlm_lock_compatible(tmplock->ml.type, lock->ml.type))
108 return 0; 103 return 0;
109 if (!dlm_lock_compatible(tmplock->ml.convert_type, 104 if (!dlm_lock_compatible(tmplock->ml.convert_type,
diff --git a/fs/ocfs2/dlm/dlmmaster.c b/fs/ocfs2/dlm/dlmmaster.c
index 33ecbe0e6734..cf0f103963b1 100644
--- a/fs/ocfs2/dlm/dlmmaster.c
+++ b/fs/ocfs2/dlm/dlmmaster.c
@@ -342,16 +342,13 @@ static int dlm_find_mle(struct dlm_ctxt *dlm,
342{ 342{
343 struct dlm_master_list_entry *tmpmle; 343 struct dlm_master_list_entry *tmpmle;
344 struct hlist_head *bucket; 344 struct hlist_head *bucket;
345 struct hlist_node *list;
346 unsigned int hash; 345 unsigned int hash;
347 346
348 assert_spin_locked(&dlm->master_lock); 347 assert_spin_locked(&dlm->master_lock);
349 348
350 hash = dlm_lockid_hash(name, namelen); 349 hash = dlm_lockid_hash(name, namelen);
351 bucket = dlm_master_hash(dlm, hash); 350 bucket = dlm_master_hash(dlm, hash);
352 hlist_for_each(list, bucket) { 351 hlist_for_each_entry(tmpmle, bucket, master_hash_node) {
353 tmpmle = hlist_entry(list, struct dlm_master_list_entry,
354 master_hash_node);
355 if (!dlm_mle_equal(dlm, tmpmle, name, namelen)) 352 if (!dlm_mle_equal(dlm, tmpmle, name, namelen))
356 continue; 353 continue;
357 dlm_get_mle(tmpmle); 354 dlm_get_mle(tmpmle);
@@ -3183,7 +3180,7 @@ void dlm_clean_master_list(struct dlm_ctxt *dlm, u8 dead_node)
3183 struct dlm_master_list_entry *mle; 3180 struct dlm_master_list_entry *mle;
3184 struct dlm_lock_resource *res; 3181 struct dlm_lock_resource *res;
3185 struct hlist_head *bucket; 3182 struct hlist_head *bucket;
3186 struct hlist_node *list; 3183 struct hlist_node *tmp;
3187 unsigned int i; 3184 unsigned int i;
3188 3185
3189 mlog(0, "dlm=%s, dead node=%u\n", dlm->name, dead_node); 3186 mlog(0, "dlm=%s, dead node=%u\n", dlm->name, dead_node);
@@ -3194,10 +3191,7 @@ top:
3194 spin_lock(&dlm->master_lock); 3191 spin_lock(&dlm->master_lock);
3195 for (i = 0; i < DLM_HASH_BUCKETS; i++) { 3192 for (i = 0; i < DLM_HASH_BUCKETS; i++) {
3196 bucket = dlm_master_hash(dlm, i); 3193 bucket = dlm_master_hash(dlm, i);
3197 hlist_for_each(list, bucket) { 3194 hlist_for_each_entry_safe(mle, tmp, bucket, master_hash_node) {
3198 mle = hlist_entry(list, struct dlm_master_list_entry,
3199 master_hash_node);
3200
3201 BUG_ON(mle->type != DLM_MLE_BLOCK && 3195 BUG_ON(mle->type != DLM_MLE_BLOCK &&
3202 mle->type != DLM_MLE_MASTER && 3196 mle->type != DLM_MLE_MASTER &&
3203 mle->type != DLM_MLE_MIGRATION); 3197 mle->type != DLM_MLE_MIGRATION);
@@ -3378,7 +3372,7 @@ void dlm_force_free_mles(struct dlm_ctxt *dlm)
3378 int i; 3372 int i;
3379 struct hlist_head *bucket; 3373 struct hlist_head *bucket;
3380 struct dlm_master_list_entry *mle; 3374 struct dlm_master_list_entry *mle;
3381 struct hlist_node *tmp, *list; 3375 struct hlist_node *tmp;
3382 3376
3383 /* 3377 /*
3384 * We notified all other nodes that we are exiting the domain and 3378 * We notified all other nodes that we are exiting the domain and
@@ -3394,9 +3388,7 @@ void dlm_force_free_mles(struct dlm_ctxt *dlm)
3394 3388
3395 for (i = 0; i < DLM_HASH_BUCKETS; i++) { 3389 for (i = 0; i < DLM_HASH_BUCKETS; i++) {
3396 bucket = dlm_master_hash(dlm, i); 3390 bucket = dlm_master_hash(dlm, i);
3397 hlist_for_each_safe(list, tmp, bucket) { 3391 hlist_for_each_entry_safe(mle, tmp, bucket, master_hash_node) {
3398 mle = hlist_entry(list, struct dlm_master_list_entry,
3399 master_hash_node);
3400 if (mle->type != DLM_MLE_BLOCK) { 3392 if (mle->type != DLM_MLE_BLOCK) {
3401 mlog(ML_ERROR, "bad mle: %p\n", mle); 3393 mlog(ML_ERROR, "bad mle: %p\n", mle);
3402 dlm_print_one_mle(mle); 3394 dlm_print_one_mle(mle);
diff --git a/fs/ocfs2/dlm/dlmthread.c b/fs/ocfs2/dlm/dlmthread.c
index e73c833fc2a1..9db869de829d 100644
--- a/fs/ocfs2/dlm/dlmthread.c
+++ b/fs/ocfs2/dlm/dlmthread.c
@@ -286,8 +286,6 @@ static void dlm_shuffle_lists(struct dlm_ctxt *dlm,
286 struct dlm_lock_resource *res) 286 struct dlm_lock_resource *res)
287{ 287{
288 struct dlm_lock *lock, *target; 288 struct dlm_lock *lock, *target;
289 struct list_head *iter;
290 struct list_head *head;
291 int can_grant = 1; 289 int can_grant = 1;
292 290
293 /* 291 /*
@@ -314,9 +312,7 @@ converting:
314 dlm->name, res->lockname.len, res->lockname.name); 312 dlm->name, res->lockname.len, res->lockname.name);
315 BUG(); 313 BUG();
316 } 314 }
317 head = &res->granted; 315 list_for_each_entry(lock, &res->granted, list) {
318 list_for_each(iter, head) {
319 lock = list_entry(iter, struct dlm_lock, list);
320 if (lock==target) 316 if (lock==target)
321 continue; 317 continue;
322 if (!dlm_lock_compatible(lock->ml.type, 318 if (!dlm_lock_compatible(lock->ml.type,
@@ -333,9 +329,8 @@ converting:
333 target->ml.convert_type; 329 target->ml.convert_type;
334 } 330 }
335 } 331 }
336 head = &res->converting; 332
337 list_for_each(iter, head) { 333 list_for_each_entry(lock, &res->converting, list) {
338 lock = list_entry(iter, struct dlm_lock, list);
339 if (lock==target) 334 if (lock==target)
340 continue; 335 continue;
341 if (!dlm_lock_compatible(lock->ml.type, 336 if (!dlm_lock_compatible(lock->ml.type,
@@ -384,9 +379,7 @@ blocked:
384 goto leave; 379 goto leave;
385 target = list_entry(res->blocked.next, struct dlm_lock, list); 380 target = list_entry(res->blocked.next, struct dlm_lock, list);
386 381
387 head = &res->granted; 382 list_for_each_entry(lock, &res->granted, list) {
388 list_for_each(iter, head) {
389 lock = list_entry(iter, struct dlm_lock, list);
390 if (lock==target) 383 if (lock==target)
391 continue; 384 continue;
392 if (!dlm_lock_compatible(lock->ml.type, target->ml.type)) { 385 if (!dlm_lock_compatible(lock->ml.type, target->ml.type)) {
@@ -400,9 +393,7 @@ blocked:
400 } 393 }
401 } 394 }
402 395
403 head = &res->converting; 396 list_for_each_entry(lock, &res->converting, list) {
404 list_for_each(iter, head) {
405 lock = list_entry(iter, struct dlm_lock, list);
406 if (lock==target) 397 if (lock==target)
407 continue; 398 continue;
408 if (!dlm_lock_compatible(lock->ml.type, target->ml.type)) { 399 if (!dlm_lock_compatible(lock->ml.type, target->ml.type)) {
diff --git a/fs/ocfs2/dlm/dlmunlock.c b/fs/ocfs2/dlm/dlmunlock.c
index 850aa7e87537..5698b52cf5c9 100644
--- a/fs/ocfs2/dlm/dlmunlock.c
+++ b/fs/ocfs2/dlm/dlmunlock.c
@@ -388,7 +388,6 @@ int dlm_unlock_lock_handler(struct o2net_msg *msg, u32 len, void *data,
388 struct dlm_ctxt *dlm = data; 388 struct dlm_ctxt *dlm = data;
389 struct dlm_unlock_lock *unlock = (struct dlm_unlock_lock *)msg->buf; 389 struct dlm_unlock_lock *unlock = (struct dlm_unlock_lock *)msg->buf;
390 struct dlm_lock_resource *res = NULL; 390 struct dlm_lock_resource *res = NULL;
391 struct list_head *iter;
392 struct dlm_lock *lock = NULL; 391 struct dlm_lock *lock = NULL;
393 enum dlm_status status = DLM_NORMAL; 392 enum dlm_status status = DLM_NORMAL;
394 int found = 0, i; 393 int found = 0, i;
@@ -458,8 +457,7 @@ int dlm_unlock_lock_handler(struct o2net_msg *msg, u32 len, void *data,
458 } 457 }
459 458
460 for (i=0; i<3; i++) { 459 for (i=0; i<3; i++) {
461 list_for_each(iter, queue) { 460 list_for_each_entry(lock, queue, list) {
462 lock = list_entry(iter, struct dlm_lock, list);
463 if (lock->ml.cookie == unlock->cookie && 461 if (lock->ml.cookie == unlock->cookie &&
464 lock->ml.node == unlock->node_idx) { 462 lock->ml.node == unlock->node_idx) {
465 dlm_lock_get(lock); 463 dlm_lock_get(lock);