diff options
Diffstat (limited to 'fs/ocfs2/dlm/dlmmaster.c')
-rw-r--r-- | fs/ocfs2/dlm/dlmmaster.c | 61 |
1 files changed, 43 insertions, 18 deletions
diff --git a/fs/ocfs2/dlm/dlmmaster.c b/fs/ocfs2/dlm/dlmmaster.c index ec6da3c37dc..804558174a7 100644 --- a/fs/ocfs2/dlm/dlmmaster.c +++ b/fs/ocfs2/dlm/dlmmaster.c | |||
@@ -69,7 +69,8 @@ static int dlm_do_assert_master(struct dlm_ctxt *dlm, | |||
69 | static void dlm_deref_lockres_worker(struct dlm_work_item *item, void *data); | 69 | static void dlm_deref_lockres_worker(struct dlm_work_item *item, void *data); |
70 | 70 | ||
71 | static inline void __dlm_mle_name(struct dlm_master_list_entry *mle, | 71 | static inline void __dlm_mle_name(struct dlm_master_list_entry *mle, |
72 | unsigned char **name, unsigned int *namelen) | 72 | unsigned char **name, unsigned int *namelen, |
73 | unsigned int *namehash) | ||
73 | { | 74 | { |
74 | BUG_ON(mle->type != DLM_MLE_BLOCK && | 75 | BUG_ON(mle->type != DLM_MLE_BLOCK && |
75 | mle->type != DLM_MLE_MASTER && | 76 | mle->type != DLM_MLE_MASTER && |
@@ -78,9 +79,13 @@ static inline void __dlm_mle_name(struct dlm_master_list_entry *mle, | |||
78 | if (mle->type != DLM_MLE_MASTER) { | 79 | if (mle->type != DLM_MLE_MASTER) { |
79 | *name = mle->u.mlename.name; | 80 | *name = mle->u.mlename.name; |
80 | *namelen = mle->u.mlename.len; | 81 | *namelen = mle->u.mlename.len; |
82 | if (namehash) | ||
83 | *namehash = mle->u.mlename.hash; | ||
81 | } else { | 84 | } else { |
82 | *name = (unsigned char *)mle->u.mleres->lockname.name; | 85 | *name = (unsigned char *)mle->u.mleres->lockname.name; |
83 | *namelen = mle->u.mleres->lockname.len; | 86 | *namelen = mle->u.mleres->lockname.len; |
87 | if (namehash) | ||
88 | *namehash = mle->u.mleres->lockname.hash; | ||
84 | } | 89 | } |
85 | } | 90 | } |
86 | 91 | ||
@@ -95,7 +100,7 @@ static inline int dlm_mle_equal(struct dlm_ctxt *dlm, | |||
95 | if (dlm != mle->dlm) | 100 | if (dlm != mle->dlm) |
96 | return 0; | 101 | return 0; |
97 | 102 | ||
98 | __dlm_mle_name(mle, &mlename, &mlelen); | 103 | __dlm_mle_name(mle, &mlename, &mlelen, NULL); |
99 | 104 | ||
100 | if (namelen != mlelen || memcmp(name, mlename, namelen) != 0) | 105 | if (namelen != mlelen || memcmp(name, mlename, namelen) != 0) |
101 | return 0; | 106 | return 0; |
@@ -294,7 +299,7 @@ static void dlm_init_mle(struct dlm_master_list_entry *mle, | |||
294 | 299 | ||
295 | mle->dlm = dlm; | 300 | mle->dlm = dlm; |
296 | mle->type = type; | 301 | mle->type = type; |
297 | INIT_LIST_HEAD(&mle->list); | 302 | INIT_HLIST_NODE(&mle->master_hash_node); |
298 | INIT_LIST_HEAD(&mle->hb_events); | 303 | INIT_LIST_HEAD(&mle->hb_events); |
299 | memset(mle->maybe_map, 0, sizeof(mle->maybe_map)); | 304 | memset(mle->maybe_map, 0, sizeof(mle->maybe_map)); |
300 | spin_lock_init(&mle->spinlock); | 305 | spin_lock_init(&mle->spinlock); |
@@ -317,6 +322,7 @@ static void dlm_init_mle(struct dlm_master_list_entry *mle, | |||
317 | BUG_ON(!name); | 322 | BUG_ON(!name); |
318 | memcpy(mle->u.mlename.name, name, namelen); | 323 | memcpy(mle->u.mlename.name, name, namelen); |
319 | mle->u.mlename.len = namelen; | 324 | mle->u.mlename.len = namelen; |
325 | mle->u.mlename.hash = dlm_lockid_hash(name, namelen); | ||
320 | } | 326 | } |
321 | 327 | ||
322 | /* copy off the node_map and register hb callbacks on our copy */ | 328 | /* copy off the node_map and register hb callbacks on our copy */ |
@@ -334,15 +340,21 @@ void __dlm_unlink_mle(struct dlm_ctxt *dlm, struct dlm_master_list_entry *mle) | |||
334 | assert_spin_locked(&dlm->spinlock); | 340 | assert_spin_locked(&dlm->spinlock); |
335 | assert_spin_locked(&dlm->master_lock); | 341 | assert_spin_locked(&dlm->master_lock); |
336 | 342 | ||
337 | if (!list_empty(&mle->list)) | 343 | if (!hlist_unhashed(&mle->master_hash_node)) |
338 | list_del_init(&mle->list); | 344 | hlist_del_init(&mle->master_hash_node); |
339 | } | 345 | } |
340 | 346 | ||
341 | void __dlm_insert_mle(struct dlm_ctxt *dlm, struct dlm_master_list_entry *mle) | 347 | void __dlm_insert_mle(struct dlm_ctxt *dlm, struct dlm_master_list_entry *mle) |
342 | { | 348 | { |
349 | struct hlist_head *bucket; | ||
350 | unsigned char *mname; | ||
351 | unsigned int mlen, hash; | ||
352 | |||
343 | assert_spin_locked(&dlm->master_lock); | 353 | assert_spin_locked(&dlm->master_lock); |
344 | 354 | ||
345 | list_add(&mle->list, &dlm->master_list); | 355 | __dlm_mle_name(mle, &mname, &mlen, &hash); |
356 | bucket = dlm_master_hash(dlm, hash); | ||
357 | hlist_add_head(&mle->master_hash_node, bucket); | ||
346 | } | 358 | } |
347 | 359 | ||
348 | /* returns 1 if found, 0 if not */ | 360 | /* returns 1 if found, 0 if not */ |
@@ -351,10 +363,17 @@ static int dlm_find_mle(struct dlm_ctxt *dlm, | |||
351 | char *name, unsigned int namelen) | 363 | char *name, unsigned int namelen) |
352 | { | 364 | { |
353 | struct dlm_master_list_entry *tmpmle; | 365 | struct dlm_master_list_entry *tmpmle; |
366 | struct hlist_head *bucket; | ||
367 | struct hlist_node *list; | ||
368 | unsigned int hash; | ||
354 | 369 | ||
355 | assert_spin_locked(&dlm->master_lock); | 370 | assert_spin_locked(&dlm->master_lock); |
356 | 371 | ||
357 | list_for_each_entry(tmpmle, &dlm->master_list, list) { | 372 | hash = dlm_lockid_hash(name, namelen); |
373 | bucket = dlm_master_hash(dlm, hash); | ||
374 | hlist_for_each(list, bucket) { | ||
375 | tmpmle = hlist_entry(list, struct dlm_master_list_entry, | ||
376 | master_hash_node); | ||
358 | if (!dlm_mle_equal(dlm, tmpmle, name, namelen)) | 377 | if (!dlm_mle_equal(dlm, tmpmle, name, namelen)) |
359 | continue; | 378 | continue; |
360 | dlm_get_mle(tmpmle); | 379 | dlm_get_mle(tmpmle); |
@@ -428,23 +447,20 @@ static void dlm_mle_release(struct kref *kref) | |||
428 | { | 447 | { |
429 | struct dlm_master_list_entry *mle; | 448 | struct dlm_master_list_entry *mle; |
430 | struct dlm_ctxt *dlm; | 449 | struct dlm_ctxt *dlm; |
450 | unsigned char *mname; | ||
451 | unsigned int mlen; | ||
431 | 452 | ||
432 | mlog_entry_void(); | 453 | mlog_entry_void(); |
433 | 454 | ||
434 | mle = container_of(kref, struct dlm_master_list_entry, mle_refs); | 455 | mle = container_of(kref, struct dlm_master_list_entry, mle_refs); |
435 | dlm = mle->dlm; | 456 | dlm = mle->dlm; |
436 | 457 | ||
437 | if (mle->type != DLM_MLE_MASTER) { | ||
438 | mlog(0, "calling mle_release for %.*s, type %d\n", | ||
439 | mle->u.mlename.len, mle->u.mlename.name, mle->type); | ||
440 | } else { | ||
441 | mlog(0, "calling mle_release for %.*s, type %d\n", | ||
442 | mle->u.mleres->lockname.len, | ||
443 | mle->u.mleres->lockname.name, mle->type); | ||
444 | } | ||
445 | assert_spin_locked(&dlm->spinlock); | 458 | assert_spin_locked(&dlm->spinlock); |
446 | assert_spin_locked(&dlm->master_lock); | 459 | assert_spin_locked(&dlm->master_lock); |
447 | 460 | ||
461 | __dlm_mle_name(mle, &mname, &mlen, NULL); | ||
462 | mlog(0, "Releasing mle for %.*s, type %d\n", mlen, mname, mle->type); | ||
463 | |||
448 | /* remove from list if not already */ | 464 | /* remove from list if not already */ |
449 | __dlm_unlink_mle(dlm, mle); | 465 | __dlm_unlink_mle(dlm, mle); |
450 | 466 | ||
@@ -1342,7 +1358,7 @@ static int dlm_do_master_request(struct dlm_lock_resource *res, | |||
1342 | 1358 | ||
1343 | BUG_ON(mle->type == DLM_MLE_MIGRATION); | 1359 | BUG_ON(mle->type == DLM_MLE_MIGRATION); |
1344 | 1360 | ||
1345 | __dlm_mle_name(mle, &mlename, &mlenamelen); | 1361 | __dlm_mle_name(mle, &mlename, &mlenamelen, NULL); |
1346 | 1362 | ||
1347 | request.namelen = (u8)mlenamelen; | 1363 | request.namelen = (u8)mlenamelen; |
1348 | memcpy(request.name, mlename, request.namelen); | 1364 | memcpy(request.name, mlename, request.namelen); |
@@ -3286,8 +3302,11 @@ static void dlm_clean_block_mle(struct dlm_ctxt *dlm, | |||
3286 | 3302 | ||
3287 | void dlm_clean_master_list(struct dlm_ctxt *dlm, u8 dead_node) | 3303 | void dlm_clean_master_list(struct dlm_ctxt *dlm, u8 dead_node) |
3288 | { | 3304 | { |
3289 | struct dlm_master_list_entry *mle, *next; | 3305 | struct dlm_master_list_entry *mle; |
3290 | struct dlm_lock_resource *res; | 3306 | struct dlm_lock_resource *res; |
3307 | struct hlist_head *bucket; | ||
3308 | struct hlist_node *list; | ||
3309 | unsigned int i; | ||
3291 | 3310 | ||
3292 | mlog_entry("dlm=%s, dead node=%u\n", dlm->name, dead_node); | 3311 | mlog_entry("dlm=%s, dead node=%u\n", dlm->name, dead_node); |
3293 | top: | 3312 | top: |
@@ -3295,7 +3314,12 @@ top: | |||
3295 | 3314 | ||
3296 | /* clean the master list */ | 3315 | /* clean the master list */ |
3297 | spin_lock(&dlm->master_lock); | 3316 | spin_lock(&dlm->master_lock); |
3298 | list_for_each_entry_safe(mle, next, &dlm->master_list, list) { | 3317 | for (i = 0; i < DLM_HASH_BUCKETS; i++) { |
3318 | bucket = dlm_master_hash(dlm, i); | ||
3319 | hlist_for_each(list, bucket) { | ||
3320 | mle = hlist_entry(list, struct dlm_master_list_entry, | ||
3321 | master_hash_node); | ||
3322 | |||
3299 | BUG_ON(mle->type != DLM_MLE_BLOCK && | 3323 | BUG_ON(mle->type != DLM_MLE_BLOCK && |
3300 | mle->type != DLM_MLE_MASTER && | 3324 | mle->type != DLM_MLE_MASTER && |
3301 | mle->type != DLM_MLE_MIGRATION); | 3325 | mle->type != DLM_MLE_MIGRATION); |
@@ -3351,6 +3375,7 @@ top: | |||
3351 | /* this may be the last reference */ | 3375 | /* this may be the last reference */ |
3352 | __dlm_put_mle(mle); | 3376 | __dlm_put_mle(mle); |
3353 | } | 3377 | } |
3378 | } | ||
3354 | spin_unlock(&dlm->master_lock); | 3379 | spin_unlock(&dlm->master_lock); |
3355 | } | 3380 | } |
3356 | 3381 | ||