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_xa_add(struct dlm_rsb *r) in recover_xa_add() argument
310 struct dlm_ls *ls = r->res_ls; in recover_xa_add()
319 if (r->res_id) { in recover_xa_add()
323 rv = xa_alloc(&ls->ls_recover_xa, &id, r, limit, GFP_ATOMIC); in recover_xa_add()
327 r->res_id = id; in recover_xa_add()
329 dlm_hold_rsb(r); in recover_xa_add()
336 static void recover_xa_del(struct dlm_rsb *r) in recover_xa_del() argument
338 struct dlm_ls *ls = r->res_ls; in recover_xa_del()
341 xa_erase_bh(&ls->ls_recover_xa, r->res_id); in recover_xa_del()
342 r->res_id = 0; in recover_xa_del()
346 dlm_put_rsb(r); in recover_xa_del()
351 struct dlm_rsb *r; in recover_xa_find() local
354 r = xa_load(&ls->ls_recover_xa, (int)id); in recover_xa_find()
356 return r; in recover_xa_find()
361 struct dlm_rsb *r; in recover_xa_clear() local
366 xa_for_each(&ls->ls_recover_xa, id, r) { in recover_xa_clear()
368 r->res_id = 0; in recover_xa_clear()
369 r->res_recover_locks_count = 0; in recover_xa_clear()
372 dlm_put_rsb(r); in recover_xa_clear()
417 static void set_master_lkbs(struct dlm_rsb *r) in set_master_lkbs() argument
419 set_lock_master(&r->res_grantqueue, r->res_nodeid); in set_master_lkbs()
420 set_lock_master(&r->res_convertqueue, r->res_nodeid); in set_master_lkbs()
421 set_lock_master(&r->res_waitqueue, r->res_nodeid); in set_master_lkbs()
431 static void set_new_master(struct dlm_rsb *r) in set_new_master() argument
433 set_master_lkbs(r); in set_new_master()
434 rsb_set_flag(r, RSB_NEW_MASTER); in set_new_master()
435 rsb_set_flag(r, RSB_NEW_MASTER2); in set_new_master()
448 static int recover_master(struct dlm_rsb *r, unsigned int *count, uint64_t seq) in recover_master() argument
450 struct dlm_ls *ls = r->res_ls; in recover_master()
455 if (r->res_nodeid != -1 && is_master(r)) in recover_master()
458 if (r->res_nodeid != -1) in recover_master()
459 is_removed = dlm_is_removed(ls, r->res_nodeid); in recover_master()
461 if (!is_removed && !rsb_flag(r, RSB_NEW_MASTER)) in recover_master()
465 dir_nodeid = dlm_dir_nodeid(r); in recover_master()
469 r->res_master_nodeid = our_nodeid; in recover_master()
470 r->res_nodeid = 0; in recover_master()
476 set_new_master(r); in recover_master()
479 recover_xa_add(r); in recover_master()
480 error = dlm_send_rcom_lookup(r, dir_nodeid, seq); in recover_master()
502 static int recover_master_static(struct dlm_rsb *r, unsigned int *count) in recover_master_static() argument
504 int dir_nodeid = dlm_dir_nodeid(r); in recover_master_static()
510 dlm_purge_mstcpy_locks(r); in recover_master_static()
511 r->res_master_nodeid = dir_nodeid; in recover_master_static()
512 r->res_nodeid = new_master; in recover_master_static()
513 set_new_master(r); in recover_master_static()
531 struct dlm_rsb *r; in dlm_recover_masters() local
539 list_for_each_entry(r, root_list, res_root_list) { in dlm_recover_masters()
545 lock_rsb(r); in dlm_recover_masters()
547 error = recover_master_static(r, &count); in dlm_recover_masters()
549 error = recover_master(r, &count, seq); in dlm_recover_masters()
550 unlock_rsb(r); in dlm_recover_masters()
569 struct dlm_rsb *r; in dlm_recover_master_reply() local
572 r = recover_xa_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_xa_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()
664 struct dlm_rsb *r; in dlm_recover_locks() local
667 list_for_each_entry(r, root_list, res_root_list) { in dlm_recover_locks()
668 if (r->res_nodeid != -1 && 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()
681 error = recover_locks(r, seq); in dlm_recover_locks()
685 count += r->res_recover_locks_count; in dlm_recover_locks()
697 void dlm_recovered_lock(struct dlm_rsb *r) in dlm_recovered_lock() argument
699 DLM_ASSERT(rsb_flag(r, RSB_NEW_MASTER), dlm_dump_rsb(r);); in dlm_recovered_lock()
701 r->res_recover_locks_count--; in dlm_recovered_lock()
702 if (!r->res_recover_locks_count) { in dlm_recovered_lock()
703 rsb_clear_flag(r, RSB_NEW_MASTER); in dlm_recovered_lock()
704 recover_list_del(r); in dlm_recovered_lock()
707 if (recover_list_empty(r->res_ls)) in dlm_recovered_lock()
708 wake_up(&r->res_ls->ls_wait_general); in dlm_recovered_lock()
731 static void recover_lvb(struct dlm_rsb *r) in recover_lvb() argument
736 int lvblen = r->res_ls->ls_lvblen; in recover_lvb()
738 if (!rsb_flag(r, RSB_NEW_MASTER2) && in recover_lvb()
739 rsb_flag(r, RSB_RECOVER_LVB_INVAL)) { in recover_lvb()
741 rsb_set_flag(r, RSB_VALNOTVALID); in recover_lvb()
745 if (!rsb_flag(r, RSB_NEW_MASTER2)) in recover_lvb()
751 list_for_each_entry(iter, &r->res_grantqueue, lkb_statequeue) { in recover_lvb()
768 list_for_each_entry(iter, &r->res_convertqueue, lkb_statequeue) { in recover_lvb()
791 rsb_set_flag(r, RSB_VALNOTVALID); in recover_lvb()
793 if (!r->res_lvbptr) { in recover_lvb()
794 r->res_lvbptr = dlm_allocate_lvb(r->res_ls); in recover_lvb()
795 if (!r->res_lvbptr) in recover_lvb()
800 r->res_lvbseq = big_lkb->lkb_lvbseq; in recover_lvb()
801 memcpy(r->res_lvbptr, big_lkb->lkb_lvbptr, lvblen); in recover_lvb()
803 r->res_lvbseq = high_lkb->lkb_lvbseq; in recover_lvb()
804 memcpy(r->res_lvbptr, high_lkb->lkb_lvbptr, lvblen); in recover_lvb()
806 r->res_lvbseq = 0; in recover_lvb()
807 memset(r->res_lvbptr, 0, lvblen); in recover_lvb()
816 static void recover_conversion(struct dlm_rsb *r) in recover_conversion() argument
818 struct dlm_ls *ls = r->res_ls; in recover_conversion()
822 list_for_each_entry(lkb, &r->res_grantqueue, lkb_statequeue) { in recover_conversion()
830 list_for_each_entry(lkb, &r->res_convertqueue, lkb_statequeue) { in recover_conversion()
849 static void recover_grant(struct dlm_rsb *r) in recover_grant() argument
851 if (!list_empty(&r->res_waitqueue) || !list_empty(&r->res_convertqueue)) in recover_grant()
852 rsb_set_flag(r, RSB_RECOVER_GRANT); in recover_grant()
857 struct dlm_rsb *r; in dlm_recover_rsbs() local
860 list_for_each_entry(r, root_list, res_root_list) { in dlm_recover_rsbs()
861 lock_rsb(r); in dlm_recover_rsbs()
862 if (r->res_nodeid != -1 && is_master(r)) { in dlm_recover_rsbs()
863 if (rsb_flag(r, RSB_RECOVER_CONVERT)) in dlm_recover_rsbs()
864 recover_conversion(r); in dlm_recover_rsbs()
868 recover_lvb(r); in dlm_recover_rsbs()
870 if (rsb_flag(r, RSB_NEW_MASTER2)) in dlm_recover_rsbs()
871 recover_grant(r); in dlm_recover_rsbs()
874 rsb_clear_flag(r, RSB_VALNOTVALID); in dlm_recover_rsbs()
876 rsb_clear_flag(r, RSB_RECOVER_CONVERT); in dlm_recover_rsbs()
877 rsb_clear_flag(r, RSB_RECOVER_LVB_INVAL); in dlm_recover_rsbs()
878 rsb_clear_flag(r, RSB_NEW_MASTER2); in dlm_recover_rsbs()
879 unlock_rsb(r); in dlm_recover_rsbs()
888 struct dlm_rsb *r, *safe; in dlm_clear_inactive() local
892 list_for_each_entry_safe(r, safe, &ls->ls_slow_inactive, res_slow_list) { in dlm_clear_inactive()
893 list_del(&r->res_slow_list); in dlm_clear_inactive()
894 rhashtable_remove_fast(&ls->ls_rsbtbl, &r->res_node, in dlm_clear_inactive()
897 if (!list_empty(&r->res_scan_list)) in dlm_clear_inactive()
898 list_del_init(&r->res_scan_list); in dlm_clear_inactive()
900 free_inactive_rsb(r); in dlm_clear_inactive()