aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
Diffstat (limited to 'fs')
-rw-r--r--fs/dlm/lock.c54
1 files changed, 31 insertions, 23 deletions
diff --git a/fs/dlm/lock.c b/fs/dlm/lock.c
index 80487703d582..85a0e73ba808 100644
--- a/fs/dlm/lock.c
+++ b/fs/dlm/lock.c
@@ -591,9 +591,11 @@ static void kill_lkb(struct kref *kref)
591 DLM_ASSERT(!lkb->lkb_status, dlm_print_lkb(lkb);); 591 DLM_ASSERT(!lkb->lkb_status, dlm_print_lkb(lkb););
592} 592}
593 593
594static int put_lkb(struct dlm_lkb *lkb) 594/* __put_lkb() is used when an lkb may not have an rsb attached to
595 it so we need to provide the lockspace explicitly */
596
597static int __put_lkb(struct dlm_ls *ls, struct dlm_lkb *lkb)
595{ 598{
596 struct dlm_ls *ls = lkb->lkb_resource->res_ls;
597 uint16_t bucket = lkb->lkb_id & 0xFFFF; 599 uint16_t bucket = lkb->lkb_id & 0xFFFF;
598 600
599 write_lock(&ls->ls_lkbtbl[bucket].lock); 601 write_lock(&ls->ls_lkbtbl[bucket].lock);
@@ -616,7 +618,13 @@ static int put_lkb(struct dlm_lkb *lkb)
616 618
617int dlm_put_lkb(struct dlm_lkb *lkb) 619int dlm_put_lkb(struct dlm_lkb *lkb)
618{ 620{
619 return put_lkb(lkb); 621 struct dlm_ls *ls;
622
623 DLM_ASSERT(lkb->lkb_resource, dlm_print_lkb(lkb););
624 DLM_ASSERT(lkb->lkb_resource->res_ls, dlm_print_lkb(lkb););
625
626 ls = lkb->lkb_resource->res_ls;
627 return __put_lkb(ls, lkb);
620} 628}
621 629
622/* This is only called to add a reference when the code already holds 630/* This is only called to add a reference when the code already holds
@@ -1949,7 +1957,7 @@ int dlm_lock(dlm_lockspace_t *lockspace,
1949 error = 0; 1957 error = 0;
1950 out_put: 1958 out_put:
1951 if (convert || error) 1959 if (convert || error)
1952 put_lkb(lkb); 1960 __put_lkb(ls, lkb);
1953 if (error == -EAGAIN) 1961 if (error == -EAGAIN)
1954 error = 0; 1962 error = 0;
1955 out: 1963 out:
@@ -1991,7 +1999,7 @@ int dlm_unlock(dlm_lockspace_t *lockspace,
1991 if (error == -DLM_EUNLOCK || error == -DLM_ECANCEL) 1999 if (error == -DLM_EUNLOCK || error == -DLM_ECANCEL)
1992 error = 0; 2000 error = 0;
1993 out_put: 2001 out_put:
1994 put_lkb(lkb); 2002 dlm_put_lkb(lkb);
1995 out: 2003 out:
1996 unlock_recovery(ls); 2004 unlock_recovery(ls);
1997 dlm_put_lockspace(ls); 2005 dlm_put_lockspace(ls);
@@ -2442,7 +2450,7 @@ static void receive_request(struct dlm_ls *ls, struct dlm_message *ms)
2442 lkb->lkb_flags |= DLM_IFL_MSTCPY; 2450 lkb->lkb_flags |= DLM_IFL_MSTCPY;
2443 error = receive_request_args(ls, lkb, ms); 2451 error = receive_request_args(ls, lkb, ms);
2444 if (error) { 2452 if (error) {
2445 put_lkb(lkb); 2453 __put_lkb(ls, lkb);
2446 goto fail; 2454 goto fail;
2447 } 2455 }
2448 2456
@@ -2450,7 +2458,7 @@ static void receive_request(struct dlm_ls *ls, struct dlm_message *ms)
2450 2458
2451 error = find_rsb(ls, ms->m_extra, namelen, R_MASTER, &r); 2459 error = find_rsb(ls, ms->m_extra, namelen, R_MASTER, &r);
2452 if (error) { 2460 if (error) {
2453 put_lkb(lkb); 2461 __put_lkb(ls, lkb);
2454 goto fail; 2462 goto fail;
2455 } 2463 }
2456 2464
@@ -2466,7 +2474,7 @@ static void receive_request(struct dlm_ls *ls, struct dlm_message *ms)
2466 if (error == -EINPROGRESS) 2474 if (error == -EINPROGRESS)
2467 error = 0; 2475 error = 0;
2468 if (error) 2476 if (error)
2469 put_lkb(lkb); 2477 dlm_put_lkb(lkb);
2470 return; 2478 return;
2471 2479
2472 fail: 2480 fail:
@@ -2502,7 +2510,7 @@ static void receive_convert(struct dlm_ls *ls, struct dlm_message *ms)
2502 2510
2503 unlock_rsb(r); 2511 unlock_rsb(r);
2504 put_rsb(r); 2512 put_rsb(r);
2505 put_lkb(lkb); 2513 dlm_put_lkb(lkb);
2506 return; 2514 return;
2507 2515
2508 fail: 2516 fail:
@@ -2536,7 +2544,7 @@ static void receive_unlock(struct dlm_ls *ls, struct dlm_message *ms)
2536 2544
2537 unlock_rsb(r); 2545 unlock_rsb(r);
2538 put_rsb(r); 2546 put_rsb(r);
2539 put_lkb(lkb); 2547 dlm_put_lkb(lkb);
2540 return; 2548 return;
2541 2549
2542 fail: 2550 fail:
@@ -2566,7 +2574,7 @@ static void receive_cancel(struct dlm_ls *ls, struct dlm_message *ms)
2566 2574
2567 unlock_rsb(r); 2575 unlock_rsb(r);
2568 put_rsb(r); 2576 put_rsb(r);
2569 put_lkb(lkb); 2577 dlm_put_lkb(lkb);
2570 return; 2578 return;
2571 2579
2572 fail: 2580 fail:
@@ -2598,7 +2606,7 @@ static void receive_grant(struct dlm_ls *ls, struct dlm_message *ms)
2598 2606
2599 unlock_rsb(r); 2607 unlock_rsb(r);
2600 put_rsb(r); 2608 put_rsb(r);
2601 put_lkb(lkb); 2609 dlm_put_lkb(lkb);
2602} 2610}
2603 2611
2604static void receive_bast(struct dlm_ls *ls, struct dlm_message *ms) 2612static void receive_bast(struct dlm_ls *ls, struct dlm_message *ms)
@@ -2623,7 +2631,7 @@ static void receive_bast(struct dlm_ls *ls, struct dlm_message *ms)
2623 2631
2624 unlock_rsb(r); 2632 unlock_rsb(r);
2625 put_rsb(r); 2633 put_rsb(r);
2626 put_lkb(lkb); 2634 dlm_put_lkb(lkb);
2627} 2635}
2628 2636
2629static void receive_lookup(struct dlm_ls *ls, struct dlm_message *ms) 2637static void receive_lookup(struct dlm_ls *ls, struct dlm_message *ms)
@@ -2746,7 +2754,7 @@ static void receive_request_reply(struct dlm_ls *ls, struct dlm_message *ms)
2746 unlock_rsb(r); 2754 unlock_rsb(r);
2747 put_rsb(r); 2755 put_rsb(r);
2748 out: 2756 out:
2749 put_lkb(lkb); 2757 dlm_put_lkb(lkb);
2750} 2758}
2751 2759
2752static void __receive_convert_reply(struct dlm_rsb *r, struct dlm_lkb *lkb, 2760static void __receive_convert_reply(struct dlm_rsb *r, struct dlm_lkb *lkb,
@@ -2813,7 +2821,7 @@ static void receive_convert_reply(struct dlm_ls *ls, struct dlm_message *ms)
2813 2821
2814 _receive_convert_reply(lkb, ms); 2822 _receive_convert_reply(lkb, ms);
2815 out: 2823 out:
2816 put_lkb(lkb); 2824 dlm_put_lkb(lkb);
2817} 2825}
2818 2826
2819static void _receive_unlock_reply(struct dlm_lkb *lkb, struct dlm_message *ms) 2827static void _receive_unlock_reply(struct dlm_lkb *lkb, struct dlm_message *ms)
@@ -2860,7 +2868,7 @@ static void receive_unlock_reply(struct dlm_ls *ls, struct dlm_message *ms)
2860 2868
2861 _receive_unlock_reply(lkb, ms); 2869 _receive_unlock_reply(lkb, ms);
2862 out: 2870 out:
2863 put_lkb(lkb); 2871 dlm_put_lkb(lkb);
2864} 2872}
2865 2873
2866static void _receive_cancel_reply(struct dlm_lkb *lkb, struct dlm_message *ms) 2874static void _receive_cancel_reply(struct dlm_lkb *lkb, struct dlm_message *ms)
@@ -2907,7 +2915,7 @@ static void receive_cancel_reply(struct dlm_ls *ls, struct dlm_message *ms)
2907 2915
2908 _receive_cancel_reply(lkb, ms); 2916 _receive_cancel_reply(lkb, ms);
2909 out: 2917 out:
2910 put_lkb(lkb); 2918 dlm_put_lkb(lkb);
2911} 2919}
2912 2920
2913static void receive_lookup_reply(struct dlm_ls *ls, struct dlm_message *ms) 2921static void receive_lookup_reply(struct dlm_ls *ls, struct dlm_message *ms)
@@ -2954,7 +2962,7 @@ static void receive_lookup_reply(struct dlm_ls *ls, struct dlm_message *ms)
2954 unlock_rsb(r); 2962 unlock_rsb(r);
2955 put_rsb(r); 2963 put_rsb(r);
2956 out: 2964 out:
2957 put_lkb(lkb); 2965 dlm_put_lkb(lkb);
2958} 2966}
2959 2967
2960int dlm_receive_message(struct dlm_header *hd, int nodeid, int recovery) 2968int dlm_receive_message(struct dlm_header *hd, int nodeid, int recovery)
@@ -3159,7 +3167,7 @@ void dlm_recover_waiters_pre(struct dlm_ls *ls)
3159 ls->ls_stub_ms.m_result = -DLM_EUNLOCK; 3167 ls->ls_stub_ms.m_result = -DLM_EUNLOCK;
3160 _remove_from_waiters(lkb); 3168 _remove_from_waiters(lkb);
3161 _receive_unlock_reply(lkb, &ls->ls_stub_ms); 3169 _receive_unlock_reply(lkb, &ls->ls_stub_ms);
3162 put_lkb(lkb); 3170 dlm_put_lkb(lkb);
3163 break; 3171 break;
3164 3172
3165 case DLM_MSG_CANCEL: 3173 case DLM_MSG_CANCEL:
@@ -3167,7 +3175,7 @@ void dlm_recover_waiters_pre(struct dlm_ls *ls)
3167 ls->ls_stub_ms.m_result = -DLM_ECANCEL; 3175 ls->ls_stub_ms.m_result = -DLM_ECANCEL;
3168 _remove_from_waiters(lkb); 3176 _remove_from_waiters(lkb);
3169 _receive_cancel_reply(lkb, &ls->ls_stub_ms); 3177 _receive_cancel_reply(lkb, &ls->ls_stub_ms);
3170 put_lkb(lkb); 3178 dlm_put_lkb(lkb);
3171 break; 3179 break;
3172 3180
3173 default: 3181 default:
@@ -3272,7 +3280,7 @@ static void purge_queue(struct dlm_rsb *r, struct list_head *queue,
3272 if (test(ls, lkb)) { 3280 if (test(ls, lkb)) {
3273 del_lkb(r, lkb); 3281 del_lkb(r, lkb);
3274 /* this put should free the lkb */ 3282 /* this put should free the lkb */
3275 if (!put_lkb(lkb)) 3283 if (!dlm_put_lkb(lkb))
3276 log_error(ls, "purged lkb not released"); 3284 log_error(ls, "purged lkb not released");
3277 } 3285 }
3278 } 3286 }
@@ -3456,7 +3464,7 @@ int dlm_recover_master_copy(struct dlm_ls *ls, struct dlm_rcom *rc)
3456 3464
3457 error = receive_rcom_lock_args(ls, lkb, r, rc); 3465 error = receive_rcom_lock_args(ls, lkb, r, rc);
3458 if (error) { 3466 if (error) {
3459 put_lkb(lkb); 3467 __put_lkb(ls, lkb);
3460 goto out_unlock; 3468 goto out_unlock;
3461 } 3469 }
3462 3470
@@ -3518,7 +3526,7 @@ int dlm_recover_process_copy(struct dlm_ls *ls, struct dlm_rcom *rc)
3518 3526
3519 unlock_rsb(r); 3527 unlock_rsb(r);
3520 put_rsb(r); 3528 put_rsb(r);
3521 put_lkb(lkb); 3529 dlm_put_lkb(lkb);
3522 3530
3523 return 0; 3531 return 0;
3524} 3532}