diff options
-rw-r--r-- | fs/ocfs2/dlm/dlmcommon.h | 49 | ||||
-rw-r--r-- | fs/ocfs2/dlm/dlmmaster.c | 88 | ||||
-rw-r--r-- | fs/ocfs2/dlm/dlmrecovery.c | 8 |
3 files changed, 66 insertions, 79 deletions
diff --git a/fs/ocfs2/dlm/dlmcommon.h b/fs/ocfs2/dlm/dlmcommon.h index d602abb51b61..4a5d5804b130 100644 --- a/fs/ocfs2/dlm/dlmcommon.h +++ b/fs/ocfs2/dlm/dlmcommon.h | |||
@@ -902,46 +902,15 @@ struct dlm_lock_resource *dlm_new_lockres(struct dlm_ctxt *dlm, | |||
902 | const char *name, | 902 | const char *name, |
903 | unsigned int namelen); | 903 | unsigned int namelen); |
904 | 904 | ||
905 | #define dlm_lockres_set_refmap_bit(bit,res) \ | 905 | void dlm_lockres_set_refmap_bit(struct dlm_ctxt *dlm, |
906 | __dlm_lockres_set_refmap_bit(bit,res,__FILE__,__LINE__) | 906 | struct dlm_lock_resource *res, int bit); |
907 | #define dlm_lockres_clear_refmap_bit(bit,res) \ | 907 | void dlm_lockres_clear_refmap_bit(struct dlm_ctxt *dlm, |
908 | __dlm_lockres_clear_refmap_bit(bit,res,__FILE__,__LINE__) | 908 | struct dlm_lock_resource *res, int bit); |
909 | 909 | ||
910 | static inline void __dlm_lockres_set_refmap_bit(int bit, | 910 | void dlm_lockres_drop_inflight_ref(struct dlm_ctxt *dlm, |
911 | struct dlm_lock_resource *res, | 911 | struct dlm_lock_resource *res); |
912 | const char *file, | 912 | void dlm_lockres_grab_inflight_ref(struct dlm_ctxt *dlm, |
913 | int line) | 913 | struct dlm_lock_resource *res); |
914 | { | ||
915 | //printk("%s:%d:%.*s: setting bit %d\n", file, line, | ||
916 | // res->lockname.len, res->lockname.name, bit); | ||
917 | set_bit(bit, res->refmap); | ||
918 | } | ||
919 | |||
920 | static inline void __dlm_lockres_clear_refmap_bit(int bit, | ||
921 | struct dlm_lock_resource *res, | ||
922 | const char *file, | ||
923 | int line) | ||
924 | { | ||
925 | //printk("%s:%d:%.*s: clearing bit %d\n", file, line, | ||
926 | // res->lockname.len, res->lockname.name, bit); | ||
927 | clear_bit(bit, res->refmap); | ||
928 | } | ||
929 | |||
930 | void __dlm_lockres_drop_inflight_ref(struct dlm_ctxt *dlm, | ||
931 | struct dlm_lock_resource *res, | ||
932 | const char *file, | ||
933 | int line); | ||
934 | void __dlm_lockres_grab_inflight_ref(struct dlm_ctxt *dlm, | ||
935 | struct dlm_lock_resource *res, | ||
936 | int new_lockres, | ||
937 | const char *file, | ||
938 | int line); | ||
939 | #define dlm_lockres_drop_inflight_ref(d,r) \ | ||
940 | __dlm_lockres_drop_inflight_ref(d,r,__FILE__,__LINE__) | ||
941 | #define dlm_lockres_grab_inflight_ref(d,r) \ | ||
942 | __dlm_lockres_grab_inflight_ref(d,r,0,__FILE__,__LINE__) | ||
943 | #define dlm_lockres_grab_inflight_ref_new(d,r) \ | ||
944 | __dlm_lockres_grab_inflight_ref(d,r,1,__FILE__,__LINE__) | ||
945 | 914 | ||
946 | void dlm_queue_ast(struct dlm_ctxt *dlm, struct dlm_lock *lock); | 915 | void dlm_queue_ast(struct dlm_ctxt *dlm, struct dlm_lock *lock); |
947 | void dlm_queue_bast(struct dlm_ctxt *dlm, struct dlm_lock *lock); | 916 | void dlm_queue_bast(struct dlm_ctxt *dlm, struct dlm_lock *lock); |
diff --git a/fs/ocfs2/dlm/dlmmaster.c b/fs/ocfs2/dlm/dlmmaster.c index 9f3b093b629a..11e446ffb67a 100644 --- a/fs/ocfs2/dlm/dlmmaster.c +++ b/fs/ocfs2/dlm/dlmmaster.c | |||
@@ -631,39 +631,58 @@ error: | |||
631 | return NULL; | 631 | return NULL; |
632 | } | 632 | } |
633 | 633 | ||
634 | void __dlm_lockres_grab_inflight_ref(struct dlm_ctxt *dlm, | 634 | void dlm_lockres_set_refmap_bit(struct dlm_ctxt *dlm, |
635 | struct dlm_lock_resource *res, | 635 | struct dlm_lock_resource *res, int bit) |
636 | int new_lockres, | ||
637 | const char *file, | ||
638 | int line) | ||
639 | { | 636 | { |
640 | if (!new_lockres) | 637 | assert_spin_locked(&res->spinlock); |
641 | assert_spin_locked(&res->spinlock); | 638 | |
639 | mlog(0, "res %.*s, set node %u, %ps()\n", res->lockname.len, | ||
640 | res->lockname.name, bit, __builtin_return_address(0)); | ||
641 | |||
642 | set_bit(bit, res->refmap); | ||
643 | } | ||
644 | |||
645 | void dlm_lockres_clear_refmap_bit(struct dlm_ctxt *dlm, | ||
646 | struct dlm_lock_resource *res, int bit) | ||
647 | { | ||
648 | assert_spin_locked(&res->spinlock); | ||
649 | |||
650 | mlog(0, "res %.*s, clr node %u, %ps()\n", res->lockname.len, | ||
651 | res->lockname.name, bit, __builtin_return_address(0)); | ||
652 | |||
653 | clear_bit(bit, res->refmap); | ||
654 | } | ||
655 | |||
656 | |||
657 | void dlm_lockres_grab_inflight_ref(struct dlm_ctxt *dlm, | ||
658 | struct dlm_lock_resource *res) | ||
659 | { | ||
660 | assert_spin_locked(&res->spinlock); | ||
642 | 661 | ||
643 | if (!test_bit(dlm->node_num, res->refmap)) { | 662 | if (!test_bit(dlm->node_num, res->refmap)) { |
644 | BUG_ON(res->inflight_locks != 0); | 663 | BUG_ON(res->inflight_locks != 0); |
645 | dlm_lockres_set_refmap_bit(dlm->node_num, res); | 664 | dlm_lockres_set_refmap_bit(dlm, res, dlm->node_num); |
646 | } | 665 | } |
647 | res->inflight_locks++; | 666 | res->inflight_locks++; |
648 | mlog(0, "%s:%.*s: inflight++: now %u\n", | 667 | mlog(0, "%s: res %.*s, inflight++: now %u, %ps()\n", dlm->name, |
649 | dlm->name, res->lockname.len, res->lockname.name, | 668 | res->lockname.len, res->lockname.name, res->inflight_locks, |
650 | res->inflight_locks); | 669 | __builtin_return_address(0)); |
651 | } | 670 | } |
652 | 671 | ||
653 | void __dlm_lockres_drop_inflight_ref(struct dlm_ctxt *dlm, | 672 | void dlm_lockres_drop_inflight_ref(struct dlm_ctxt *dlm, |
654 | struct dlm_lock_resource *res, | 673 | struct dlm_lock_resource *res) |
655 | const char *file, | ||
656 | int line) | ||
657 | { | 674 | { |
658 | assert_spin_locked(&res->spinlock); | 675 | assert_spin_locked(&res->spinlock); |
659 | 676 | ||
660 | BUG_ON(res->inflight_locks == 0); | 677 | BUG_ON(res->inflight_locks == 0); |
678 | |||
661 | res->inflight_locks--; | 679 | res->inflight_locks--; |
662 | mlog(0, "%s:%.*s: inflight--: now %u\n", | 680 | mlog(0, "%s: res %.*s, inflight--: now %u, %ps()\n", dlm->name, |
663 | dlm->name, res->lockname.len, res->lockname.name, | 681 | res->lockname.len, res->lockname.name, res->inflight_locks, |
664 | res->inflight_locks); | 682 | __builtin_return_address(0)); |
683 | |||
665 | if (res->inflight_locks == 0) | 684 | if (res->inflight_locks == 0) |
666 | dlm_lockres_clear_refmap_bit(dlm->node_num, res); | 685 | dlm_lockres_clear_refmap_bit(dlm, res, dlm->node_num); |
667 | wake_up(&res->wq); | 686 | wake_up(&res->wq); |
668 | } | 687 | } |
669 | 688 | ||
@@ -843,8 +862,10 @@ lookup: | |||
843 | 862 | ||
844 | /* finally add the lockres to its hash bucket */ | 863 | /* finally add the lockres to its hash bucket */ |
845 | __dlm_insert_lockres(dlm, res); | 864 | __dlm_insert_lockres(dlm, res); |
846 | /* since this lockres is new it doesn't not require the spinlock */ | 865 | |
847 | dlm_lockres_grab_inflight_ref_new(dlm, res); | 866 | spin_lock(&res->spinlock); |
867 | dlm_lockres_grab_inflight_ref(dlm, res); | ||
868 | spin_unlock(&res->spinlock); | ||
848 | 869 | ||
849 | /* if this node does not become the master make sure to drop | 870 | /* if this node does not become the master make sure to drop |
850 | * this inflight reference below */ | 871 | * this inflight reference below */ |
@@ -1426,9 +1447,7 @@ way_up_top: | |||
1426 | } | 1447 | } |
1427 | 1448 | ||
1428 | if (res->owner == dlm->node_num) { | 1449 | if (res->owner == dlm->node_num) { |
1429 | mlog(0, "%s:%.*s: setting bit %u in refmap\n", | 1450 | dlm_lockres_set_refmap_bit(dlm, res, request->node_idx); |
1430 | dlm->name, namelen, name, request->node_idx); | ||
1431 | dlm_lockres_set_refmap_bit(request->node_idx, res); | ||
1432 | spin_unlock(&res->spinlock); | 1451 | spin_unlock(&res->spinlock); |
1433 | response = DLM_MASTER_RESP_YES; | 1452 | response = DLM_MASTER_RESP_YES; |
1434 | if (mle) | 1453 | if (mle) |
@@ -1493,10 +1512,8 @@ way_up_top: | |||
1493 | * go back and clean the mles on any | 1512 | * go back and clean the mles on any |
1494 | * other nodes */ | 1513 | * other nodes */ |
1495 | dispatch_assert = 1; | 1514 | dispatch_assert = 1; |
1496 | dlm_lockres_set_refmap_bit(request->node_idx, res); | 1515 | dlm_lockres_set_refmap_bit(dlm, res, |
1497 | mlog(0, "%s:%.*s: setting bit %u in refmap\n", | 1516 | request->node_idx); |
1498 | dlm->name, namelen, name, | ||
1499 | request->node_idx); | ||
1500 | } else | 1517 | } else |
1501 | response = DLM_MASTER_RESP_NO; | 1518 | response = DLM_MASTER_RESP_NO; |
1502 | } else { | 1519 | } else { |
@@ -1702,7 +1719,7 @@ again: | |||
1702 | "lockres, set the bit in the refmap\n", | 1719 | "lockres, set the bit in the refmap\n", |
1703 | namelen, lockname, to); | 1720 | namelen, lockname, to); |
1704 | spin_lock(&res->spinlock); | 1721 | spin_lock(&res->spinlock); |
1705 | dlm_lockres_set_refmap_bit(to, res); | 1722 | dlm_lockres_set_refmap_bit(dlm, res, to); |
1706 | spin_unlock(&res->spinlock); | 1723 | spin_unlock(&res->spinlock); |
1707 | } | 1724 | } |
1708 | } | 1725 | } |
@@ -2256,7 +2273,7 @@ int dlm_deref_lockres_handler(struct o2net_msg *msg, u32 len, void *data, | |||
2256 | else { | 2273 | else { |
2257 | BUG_ON(res->state & DLM_LOCK_RES_DROPPING_REF); | 2274 | BUG_ON(res->state & DLM_LOCK_RES_DROPPING_REF); |
2258 | if (test_bit(node, res->refmap)) { | 2275 | if (test_bit(node, res->refmap)) { |
2259 | dlm_lockres_clear_refmap_bit(node, res); | 2276 | dlm_lockres_clear_refmap_bit(dlm, res, node); |
2260 | cleared = 1; | 2277 | cleared = 1; |
2261 | } | 2278 | } |
2262 | } | 2279 | } |
@@ -2316,7 +2333,7 @@ static void dlm_deref_lockres_worker(struct dlm_work_item *item, void *data) | |||
2316 | BUG_ON(res->state & DLM_LOCK_RES_DROPPING_REF); | 2333 | BUG_ON(res->state & DLM_LOCK_RES_DROPPING_REF); |
2317 | if (test_bit(node, res->refmap)) { | 2334 | if (test_bit(node, res->refmap)) { |
2318 | __dlm_wait_on_lockres_flags(res, DLM_LOCK_RES_SETREF_INPROG); | 2335 | __dlm_wait_on_lockres_flags(res, DLM_LOCK_RES_SETREF_INPROG); |
2319 | dlm_lockres_clear_refmap_bit(node, res); | 2336 | dlm_lockres_clear_refmap_bit(dlm, res, node); |
2320 | cleared = 1; | 2337 | cleared = 1; |
2321 | } | 2338 | } |
2322 | spin_unlock(&res->spinlock); | 2339 | spin_unlock(&res->spinlock); |
@@ -2798,7 +2815,8 @@ static void dlm_remove_nonlocal_locks(struct dlm_ctxt *dlm, | |||
2798 | BUG_ON(!list_empty(&lock->bast_list)); | 2815 | BUG_ON(!list_empty(&lock->bast_list)); |
2799 | BUG_ON(lock->ast_pending); | 2816 | BUG_ON(lock->ast_pending); |
2800 | BUG_ON(lock->bast_pending); | 2817 | BUG_ON(lock->bast_pending); |
2801 | dlm_lockres_clear_refmap_bit(lock->ml.node, res); | 2818 | dlm_lockres_clear_refmap_bit(dlm, res, |
2819 | lock->ml.node); | ||
2802 | list_del_init(&lock->list); | 2820 | list_del_init(&lock->list); |
2803 | dlm_lock_put(lock); | 2821 | dlm_lock_put(lock); |
2804 | /* In a normal unlock, we would have added a | 2822 | /* In a normal unlock, we would have added a |
@@ -2819,7 +2837,7 @@ static void dlm_remove_nonlocal_locks(struct dlm_ctxt *dlm, | |||
2819 | mlog(0, "%s:%.*s: node %u had a ref to this " | 2837 | mlog(0, "%s:%.*s: node %u had a ref to this " |
2820 | "migrating lockres, clearing\n", dlm->name, | 2838 | "migrating lockres, clearing\n", dlm->name, |
2821 | res->lockname.len, res->lockname.name, bit); | 2839 | res->lockname.len, res->lockname.name, bit); |
2822 | dlm_lockres_clear_refmap_bit(bit, res); | 2840 | dlm_lockres_clear_refmap_bit(dlm, res, bit); |
2823 | } | 2841 | } |
2824 | bit++; | 2842 | bit++; |
2825 | } | 2843 | } |
@@ -2933,7 +2951,7 @@ static int dlm_do_migrate_request(struct dlm_ctxt *dlm, | |||
2933 | dlm->name, res->lockname.len, res->lockname.name, | 2951 | dlm->name, res->lockname.len, res->lockname.name, |
2934 | nodenum); | 2952 | nodenum); |
2935 | spin_lock(&res->spinlock); | 2953 | spin_lock(&res->spinlock); |
2936 | dlm_lockres_set_refmap_bit(nodenum, res); | 2954 | dlm_lockres_set_refmap_bit(dlm, res, nodenum); |
2937 | spin_unlock(&res->spinlock); | 2955 | spin_unlock(&res->spinlock); |
2938 | } | 2956 | } |
2939 | } | 2957 | } |
@@ -3267,7 +3285,7 @@ int dlm_finish_migration(struct dlm_ctxt *dlm, struct dlm_lock_resource *res, | |||
3267 | * mastery reference here since old_master will briefly have | 3285 | * mastery reference here since old_master will briefly have |
3268 | * a reference after the migration completes */ | 3286 | * a reference after the migration completes */ |
3269 | spin_lock(&res->spinlock); | 3287 | spin_lock(&res->spinlock); |
3270 | dlm_lockres_set_refmap_bit(old_master, res); | 3288 | dlm_lockres_set_refmap_bit(dlm, res, old_master); |
3271 | spin_unlock(&res->spinlock); | 3289 | spin_unlock(&res->spinlock); |
3272 | 3290 | ||
3273 | mlog(0, "now time to do a migrate request to other nodes\n"); | 3291 | mlog(0, "now time to do a migrate request to other nodes\n"); |
diff --git a/fs/ocfs2/dlm/dlmrecovery.c b/fs/ocfs2/dlm/dlmrecovery.c index 41e74f0e2d35..f1a3aa84ad89 100644 --- a/fs/ocfs2/dlm/dlmrecovery.c +++ b/fs/ocfs2/dlm/dlmrecovery.c | |||
@@ -1776,7 +1776,7 @@ static int dlm_process_recovery_data(struct dlm_ctxt *dlm, | |||
1776 | dlm->name, mres->lockname_len, mres->lockname, | 1776 | dlm->name, mres->lockname_len, mres->lockname, |
1777 | from); | 1777 | from); |
1778 | spin_lock(&res->spinlock); | 1778 | spin_lock(&res->spinlock); |
1779 | dlm_lockres_set_refmap_bit(from, res); | 1779 | dlm_lockres_set_refmap_bit(dlm, res, from); |
1780 | spin_unlock(&res->spinlock); | 1780 | spin_unlock(&res->spinlock); |
1781 | added++; | 1781 | added++; |
1782 | break; | 1782 | break; |
@@ -1974,7 +1974,7 @@ skip_lvb: | |||
1974 | mlog(0, "%s:%.*s: added lock for node %u, " | 1974 | mlog(0, "%s:%.*s: added lock for node %u, " |
1975 | "setting refmap bit\n", dlm->name, | 1975 | "setting refmap bit\n", dlm->name, |
1976 | res->lockname.len, res->lockname.name, ml->node); | 1976 | res->lockname.len, res->lockname.name, ml->node); |
1977 | dlm_lockres_set_refmap_bit(ml->node, res); | 1977 | dlm_lockres_set_refmap_bit(dlm, res, ml->node); |
1978 | added++; | 1978 | added++; |
1979 | } | 1979 | } |
1980 | spin_unlock(&res->spinlock); | 1980 | spin_unlock(&res->spinlock); |
@@ -2254,12 +2254,12 @@ static void dlm_free_dead_locks(struct dlm_ctxt *dlm, | |||
2254 | res->lockname.len, res->lockname.name, freed, dead_node); | 2254 | res->lockname.len, res->lockname.name, freed, dead_node); |
2255 | __dlm_print_one_lock_resource(res); | 2255 | __dlm_print_one_lock_resource(res); |
2256 | } | 2256 | } |
2257 | dlm_lockres_clear_refmap_bit(dead_node, res); | 2257 | dlm_lockres_clear_refmap_bit(dlm, res, dead_node); |
2258 | } else if (test_bit(dead_node, res->refmap)) { | 2258 | } else if (test_bit(dead_node, res->refmap)) { |
2259 | mlog(0, "%s:%.*s: dead node %u had a ref, but had " | 2259 | mlog(0, "%s:%.*s: dead node %u had a ref, but had " |
2260 | "no locks and had not purged before dying\n", dlm->name, | 2260 | "no locks and had not purged before dying\n", dlm->name, |
2261 | res->lockname.len, res->lockname.name, dead_node); | 2261 | res->lockname.len, res->lockname.name, dead_node); |
2262 | dlm_lockres_clear_refmap_bit(dead_node, res); | 2262 | dlm_lockres_clear_refmap_bit(dlm, res, dead_node); |
2263 | } | 2263 | } |
2264 | 2264 | ||
2265 | /* do not kick thread yet */ | 2265 | /* do not kick thread yet */ |