Lines Matching full:r

251 static void recover_list_add(struct dlm_rsb *r)  in recover_list_add()  argument
253 struct dlm_ls *ls = r->res_ls; in recover_list_add()
256 if (list_empty(&r->res_recover_list)) { in recover_list_add()
257 list_add_tail(&r->res_recover_list, &ls->ls_recover_list); in recover_list_add()
259 dlm_hold_rsb(r); in recover_list_add()
264 static void recover_list_del(struct dlm_rsb *r) in recover_list_del() argument
266 struct dlm_ls *ls = r->res_ls; in recover_list_del()
269 list_del_init(&r->res_recover_list); in recover_list_del()
273 dlm_put_rsb(r); in recover_list_del()
278 struct dlm_rsb *r, *s; in recover_list_clear() local
281 list_for_each_entry_safe(r, s, &ls->ls_recover_list, res_recover_list) { in recover_list_clear()
282 list_del_init(&r->res_recover_list); in recover_list_clear()
283 r->res_recover_locks_count = 0; in recover_list_clear()
284 dlm_put_rsb(r); in recover_list_clear()
308 static int recover_idr_add(struct dlm_rsb *r) in recover_idr_add() argument
310 struct dlm_ls *ls = r->res_ls; in recover_idr_add()
315 if (r->res_id) { in recover_idr_add()
319 rv = idr_alloc(&ls->ls_recover_idr, r, 1, 0, GFP_NOWAIT); in recover_idr_add()
323 r->res_id = rv; in recover_idr_add()
325 dlm_hold_rsb(r); in recover_idr_add()
333 static void recover_idr_del(struct dlm_rsb *r) in recover_idr_del() argument
335 struct dlm_ls *ls = r->res_ls; in recover_idr_del()
338 idr_remove(&ls->ls_recover_idr, r->res_id); in recover_idr_del()
339 r->res_id = 0; in recover_idr_del()
343 dlm_put_rsb(r); in recover_idr_del()
348 struct dlm_rsb *r; in recover_idr_find() local
351 r = idr_find(&ls->ls_recover_idr, (int)id); in recover_idr_find()
353 return r; in recover_idr_find()
358 struct dlm_rsb *r; in recover_idr_clear() local
363 idr_for_each_entry(&ls->ls_recover_idr, r, id) { in recover_idr_clear()
365 r->res_id = 0; in recover_idr_clear()
366 r->res_recover_locks_count = 0; in recover_idr_clear()
369 dlm_put_rsb(r); in recover_idr_clear()
414 static void set_master_lkbs(struct dlm_rsb *r) in set_master_lkbs() argument
416 set_lock_master(&r->res_grantqueue, r->res_nodeid); in set_master_lkbs()
417 set_lock_master(&r->res_convertqueue, r->res_nodeid); in set_master_lkbs()
418 set_lock_master(&r->res_waitqueue, r->res_nodeid); in set_master_lkbs()
428 static void set_new_master(struct dlm_rsb *r) in set_new_master() argument
430 set_master_lkbs(r); in set_new_master()
431 rsb_set_flag(r, RSB_NEW_MASTER); in set_new_master()
432 rsb_set_flag(r, RSB_NEW_MASTER2); in set_new_master()
445 static int recover_master(struct dlm_rsb *r, unsigned int *count, uint64_t seq) in recover_master() argument
447 struct dlm_ls *ls = r->res_ls; in recover_master()
452 if (is_master(r)) in recover_master()
455 is_removed = dlm_is_removed(ls, r->res_nodeid); in recover_master()
457 if (!is_removed && !rsb_flag(r, RSB_NEW_MASTER)) in recover_master()
461 dir_nodeid = dlm_dir_nodeid(r); in recover_master()
465 r->res_master_nodeid = our_nodeid; in recover_master()
466 r->res_nodeid = 0; in recover_master()
472 set_new_master(r); in recover_master()
475 recover_idr_add(r); in recover_master()
476 error = dlm_send_rcom_lookup(r, dir_nodeid, seq); in recover_master()
498 static int recover_master_static(struct dlm_rsb *r, unsigned int *count) in recover_master_static() argument
500 int dir_nodeid = dlm_dir_nodeid(r); in recover_master_static()
506 dlm_purge_mstcpy_locks(r); in recover_master_static()
507 r->res_master_nodeid = dir_nodeid; in recover_master_static()
508 r->res_nodeid = new_master; in recover_master_static()
509 set_new_master(r); in recover_master_static()
526 struct dlm_rsb *r; in dlm_recover_masters() local
535 list_for_each_entry(r, &ls->ls_root_list, res_root_list) { in dlm_recover_masters()
542 lock_rsb(r); in dlm_recover_masters()
544 error = recover_master_static(r, &count); in dlm_recover_masters()
546 error = recover_master(r, &count, seq); in dlm_recover_masters()
547 unlock_rsb(r); in dlm_recover_masters()
569 struct dlm_rsb *r; in dlm_recover_master_reply() local
572 r = recover_idr_find(ls, le64_to_cpu(rc->rc_id)); in dlm_recover_master_reply()
573 if (!r) { in dlm_recover_master_reply()
586 lock_rsb(r); in dlm_recover_master_reply()
587 r->res_master_nodeid = ret_nodeid; in dlm_recover_master_reply()
588 r->res_nodeid = new_master; in dlm_recover_master_reply()
589 set_new_master(r); in dlm_recover_master_reply()
590 unlock_rsb(r); in dlm_recover_master_reply()
591 recover_idr_del(r); in dlm_recover_master_reply()
618 static int recover_locks_queue(struct dlm_rsb *r, struct list_head *head, in recover_locks_queue() argument
625 error = dlm_send_rcom_lock(r, lkb, seq); in recover_locks_queue()
628 r->res_recover_locks_count++; in recover_locks_queue()
634 static int recover_locks(struct dlm_rsb *r, uint64_t seq) in recover_locks() argument
638 lock_rsb(r); in recover_locks()
640 DLM_ASSERT(!r->res_recover_locks_count, dlm_dump_rsb(r);); in recover_locks()
642 error = recover_locks_queue(r, &r->res_grantqueue, seq); in recover_locks()
645 error = recover_locks_queue(r, &r->res_convertqueue, seq); in recover_locks()
648 error = recover_locks_queue(r, &r->res_waitqueue, seq); in recover_locks()
652 if (r->res_recover_locks_count) in recover_locks()
653 recover_list_add(r); in recover_locks()
655 rsb_clear_flag(r, RSB_NEW_MASTER); in recover_locks()
657 unlock_rsb(r); in recover_locks()
663 struct dlm_rsb *r; in dlm_recover_locks() local
667 list_for_each_entry(r, &ls->ls_root_list, res_root_list) { in dlm_recover_locks()
668 if (is_master(r)) { in dlm_recover_locks()
669 rsb_clear_flag(r, RSB_NEW_MASTER); in dlm_recover_locks()
673 if (!rsb_flag(r, RSB_NEW_MASTER)) in dlm_recover_locks()
682 error = recover_locks(r, seq); in dlm_recover_locks()
688 count += r->res_recover_locks_count; in dlm_recover_locks()
701 void dlm_recovered_lock(struct dlm_rsb *r) in dlm_recovered_lock() argument
703 DLM_ASSERT(rsb_flag(r, RSB_NEW_MASTER), dlm_dump_rsb(r);); in dlm_recovered_lock()
705 r->res_recover_locks_count--; in dlm_recovered_lock()
706 if (!r->res_recover_locks_count) { in dlm_recovered_lock()
707 rsb_clear_flag(r, RSB_NEW_MASTER); in dlm_recovered_lock()
708 recover_list_del(r); in dlm_recovered_lock()
711 if (recover_list_empty(r->res_ls)) in dlm_recovered_lock()
712 wake_up(&r->res_ls->ls_wait_general); in dlm_recovered_lock()
735 static void recover_lvb(struct dlm_rsb *r) in recover_lvb() argument
740 int lvblen = r->res_ls->ls_lvblen; in recover_lvb()
742 if (!rsb_flag(r, RSB_NEW_MASTER2) && in recover_lvb()
743 rsb_flag(r, RSB_RECOVER_LVB_INVAL)) { in recover_lvb()
745 rsb_set_flag(r, RSB_VALNOTVALID); in recover_lvb()
749 if (!rsb_flag(r, RSB_NEW_MASTER2)) in recover_lvb()
755 list_for_each_entry(iter, &r->res_grantqueue, lkb_statequeue) { in recover_lvb()
772 list_for_each_entry(iter, &r->res_convertqueue, lkb_statequeue) { in recover_lvb()
795 rsb_set_flag(r, RSB_VALNOTVALID); in recover_lvb()
797 if (!r->res_lvbptr) { in recover_lvb()
798 r->res_lvbptr = dlm_allocate_lvb(r->res_ls); in recover_lvb()
799 if (!r->res_lvbptr) in recover_lvb()
804 r->res_lvbseq = big_lkb->lkb_lvbseq; in recover_lvb()
805 memcpy(r->res_lvbptr, big_lkb->lkb_lvbptr, lvblen); in recover_lvb()
807 r->res_lvbseq = high_lkb->lkb_lvbseq; in recover_lvb()
808 memcpy(r->res_lvbptr, high_lkb->lkb_lvbptr, lvblen); in recover_lvb()
810 r->res_lvbseq = 0; in recover_lvb()
811 memset(r->res_lvbptr, 0, lvblen); in recover_lvb()
820 static void recover_conversion(struct dlm_rsb *r) in recover_conversion() argument
822 struct dlm_ls *ls = r->res_ls; in recover_conversion()
826 list_for_each_entry(lkb, &r->res_grantqueue, lkb_statequeue) { in recover_conversion()
834 list_for_each_entry(lkb, &r->res_convertqueue, lkb_statequeue) { in recover_conversion()
853 static void recover_grant(struct dlm_rsb *r) in recover_grant() argument
855 if (!list_empty(&r->res_waitqueue) || !list_empty(&r->res_convertqueue)) in recover_grant()
856 rsb_set_flag(r, RSB_RECOVER_GRANT); in recover_grant()
861 struct dlm_rsb *r; in dlm_recover_rsbs() local
865 list_for_each_entry(r, &ls->ls_root_list, res_root_list) { in dlm_recover_rsbs()
866 lock_rsb(r); in dlm_recover_rsbs()
867 if (is_master(r)) { in dlm_recover_rsbs()
868 if (rsb_flag(r, RSB_RECOVER_CONVERT)) in dlm_recover_rsbs()
869 recover_conversion(r); in dlm_recover_rsbs()
873 recover_lvb(r); in dlm_recover_rsbs()
875 if (rsb_flag(r, RSB_NEW_MASTER2)) in dlm_recover_rsbs()
876 recover_grant(r); in dlm_recover_rsbs()
879 rsb_clear_flag(r, RSB_VALNOTVALID); in dlm_recover_rsbs()
881 rsb_clear_flag(r, RSB_RECOVER_CONVERT); in dlm_recover_rsbs()
882 rsb_clear_flag(r, RSB_RECOVER_LVB_INVAL); in dlm_recover_rsbs()
883 rsb_clear_flag(r, RSB_NEW_MASTER2); in dlm_recover_rsbs()
884 unlock_rsb(r); in dlm_recover_rsbs()
897 struct dlm_rsb *r; in dlm_create_root_list() local
910 r = rb_entry(n, struct dlm_rsb, res_hashnode); in dlm_create_root_list()
911 list_add(&r->res_root_list, &ls->ls_root_list); in dlm_create_root_list()
912 dlm_hold_rsb(r); in dlm_create_root_list()
926 struct dlm_rsb *r, *safe; in dlm_release_root_list() local
929 list_for_each_entry_safe(r, safe, &ls->ls_root_list, res_root_list) { in dlm_release_root_list()
930 list_del_init(&r->res_root_list); in dlm_release_root_list()
931 dlm_put_rsb(r); in dlm_release_root_list()
939 struct dlm_rsb *r; in dlm_clear_toss() local
947 r = rb_entry(n, struct dlm_rsb, res_hashnode); in dlm_clear_toss()
949 dlm_free_rsb(r); in dlm_clear_toss()