Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

dlm: change list and timer names

The old terminology of "toss" and "keep" is no longer an
accurate description of the rsb states and lists, so change
the names to "inactive" and "active". The old names had
also been copied into the scanning code, which is changed
back to use the "scan" name.

- "active" rsb structs have lkb's attached, and are ref counted.
- "inactive" rsb structs have no lkb's attached, are not ref counted.
- "scan" list is for rsb's that can be freed after a timeout period.
- "slow" lists are for infrequent iterations through active or
inactive rsb structs.
- inactive rsb structs that are directory records will not be put
on the scan list, since they are not freed based on timeouts.
- inactive rsb structs that are not directory records will be
put on the scan list to be freed, since they are not longer needed.

Signed-off-by: David Teigland <teigland@redhat.com>

+181 -218
+5 -5
fs/dlm/debug_fs.c
··· 380 380 381 381 static int table_seq_show(struct seq_file *seq, void *iter_ptr) 382 382 { 383 - struct dlm_rsb *rsb = list_entry(iter_ptr, struct dlm_rsb, res_rsbs_list); 383 + struct dlm_rsb *rsb = list_entry(iter_ptr, struct dlm_rsb, res_slow_list); 384 384 385 385 if (seq->op == &format1_seq_ops) 386 386 print_format1(rsb, seq); ··· 409 409 } 410 410 411 411 if (seq->op == &format4_seq_ops) 412 - list = &ls->ls_toss; 412 + list = &ls->ls_slow_inactive; 413 413 else 414 - list = &ls->ls_keep; 414 + list = &ls->ls_slow_active; 415 415 416 416 read_lock_bh(&ls->ls_rsbtbl_lock); 417 417 return seq_list_start(list, *pos); ··· 423 423 struct list_head *list; 424 424 425 425 if (seq->op == &format4_seq_ops) 426 - list = &ls->ls_toss; 426 + list = &ls->ls_slow_inactive; 427 427 else 428 - list = &ls->ls_keep; 428 + list = &ls->ls_slow_active; 429 429 430 430 return seq_list_next(iter_ptr, list, pos); 431 431 }
+11 -15
fs/dlm/dlm_internal.h
··· 327 327 struct list_head res_convertqueue; 328 328 struct list_head res_waitqueue; 329 329 330 - struct list_head res_rsbs_list; 330 + struct list_head res_slow_list; /* ls_slow_* */ 331 + struct list_head res_scan_list; 331 332 struct list_head res_root_list; /* used for recovery */ 332 333 struct list_head res_masters_list; /* used for recovery */ 333 334 struct list_head res_recover_list; /* used for recovery */ 334 - struct list_head res_toss_q_list; 335 335 int res_recover_locks_count; 336 336 337 337 char *res_lvbptr; ··· 365 365 RSB_RECOVER_CONVERT, 366 366 RSB_RECOVER_GRANT, 367 367 RSB_RECOVER_LVB_INVAL, 368 - RSB_TOSS, 368 + RSB_INACTIVE, 369 369 }; 370 370 371 371 static inline void rsb_set_flag(struct dlm_rsb *r, enum rsb_flags flag) ··· 572 572 struct xarray ls_lkbxa; 573 573 rwlock_t ls_lkbxa_lock; 574 574 575 + /* an rsb is on rsbtl for primary locking functions, 576 + and on a slow list for recovery/dump iteration */ 575 577 struct rhashtable ls_rsbtbl; 576 - rwlock_t ls_rsbtbl_lock; 578 + rwlock_t ls_rsbtbl_lock; /* for ls_rsbtbl and ls_slow */ 579 + struct list_head ls_slow_inactive; /* to iterate rsbtbl */ 580 + struct list_head ls_slow_active; /* to iterate rsbtbl */ 577 581 578 - struct list_head ls_toss; 579 - struct list_head ls_keep; 580 - 581 - struct timer_list ls_timer; 582 - /* this queue is ordered according the 583 - * absolute res_toss_time jiffies time 584 - * to mod_timer() with the first element 585 - * if necessary. 586 - */ 587 - struct list_head ls_toss_q; 588 - spinlock_t ls_toss_q_lock; 582 + struct timer_list ls_scan_timer; /* based on first scan_list rsb toss_time */ 583 + struct list_head ls_scan_list; /* rsbs ordered by res_toss_time */ 584 + spinlock_t ls_scan_lock; 589 585 590 586 spinlock_t ls_waiters_lock; 591 587 struct list_head ls_waiters; /* lkbs needing a reply */
+140 -168
fs/dlm/lock.c
··· 89 89 const struct dlm_message *ms, bool local); 90 90 static int receive_extralen(const struct dlm_message *ms); 91 91 static void do_purge(struct dlm_ls *ls, int nodeid, int pid); 92 - static void toss_rsb(struct kref *kref); 92 + static void deactivate_rsb(struct kref *kref); 93 93 94 94 /* 95 95 * Lock compatibilty matrix - thanks Steve ··· 330 330 331 331 static inline void hold_rsb(struct dlm_rsb *r) 332 332 { 333 - /* rsbs in toss state never get referenced */ 334 - WARN_ON(rsb_flag(r, RSB_TOSS)); 333 + /* inactive rsbs are not ref counted */ 334 + WARN_ON(rsb_flag(r, RSB_INACTIVE)); 335 335 kref_get(&r->res_ref); 336 336 } 337 337 ··· 370 370 return 0; 371 371 } 372 372 373 - /* When all references to the rsb are gone it's transferred to 374 - the tossed list for later disposal. */ 375 - 376 373 static void put_rsb(struct dlm_rsb *r) 377 374 { 378 375 struct dlm_ls *ls = r->res_ls; 379 376 int rv; 380 377 381 - rv = dlm_kref_put_write_lock_bh(&r->res_ref, toss_rsb, 378 + rv = dlm_kref_put_write_lock_bh(&r->res_ref, deactivate_rsb, 382 379 &ls->ls_rsbtbl_lock); 383 380 if (rv) 384 381 write_unlock_bh(&ls->ls_rsbtbl_lock); ··· 388 391 389 392 /* connected with timer_delete_sync() in dlm_ls_stop() to stop 390 393 * new timers when recovery is triggered and don't run them 391 - * again until a dlm_timer_resume() tries it again. 394 + * again until a resume_scan_timer() tries it again. 392 395 */ 393 - static void __rsb_mod_timer(struct dlm_ls *ls, unsigned long jiffies) 396 + static void enable_scan_timer(struct dlm_ls *ls, unsigned long jiffies) 394 397 { 395 398 if (!dlm_locking_stopped(ls)) 396 - mod_timer(&ls->ls_timer, jiffies); 399 + mod_timer(&ls->ls_scan_timer, jiffies); 397 400 } 398 401 399 402 /* This function tries to resume the timer callback if a rsb 400 - * is on the toss list and no timer is pending. It might that 403 + * is on the scan list and no timer is pending. It might that 401 404 * the first entry is on currently executed as timer callback 402 405 * but we don't care if a timer queued up again and does 403 406 * nothing. Should be a rare case. 404 407 */ 405 - void dlm_timer_resume(struct dlm_ls *ls) 408 + void resume_scan_timer(struct dlm_ls *ls) 406 409 { 407 410 struct dlm_rsb *r; 408 411 409 - spin_lock_bh(&ls->ls_toss_q_lock); 410 - r = list_first_entry_or_null(&ls->ls_toss_q, struct dlm_rsb, 411 - res_toss_q_list); 412 - if (r && !timer_pending(&ls->ls_timer)) 413 - __rsb_mod_timer(ls, r->res_toss_time); 414 - spin_unlock_bh(&ls->ls_toss_q_lock); 412 + spin_lock_bh(&ls->ls_scan_lock); 413 + r = list_first_entry_or_null(&ls->ls_scan_list, struct dlm_rsb, 414 + res_scan_list); 415 + if (r && !timer_pending(&ls->ls_scan_timer)) 416 + enable_scan_timer(ls, r->res_toss_time); 417 + spin_unlock_bh(&ls->ls_scan_lock); 415 418 } 416 419 417 - /* ls_rsbtbl_lock must be held and being sure the rsb is in toss state */ 418 - static void rsb_delete_toss_timer(struct dlm_ls *ls, struct dlm_rsb *r) 420 + /* ls_rsbtbl_lock must be held */ 421 + 422 + static void del_scan(struct dlm_ls *ls, struct dlm_rsb *r) 419 423 { 420 424 struct dlm_rsb *first; 421 425 422 - spin_lock_bh(&ls->ls_toss_q_lock); 426 + spin_lock_bh(&ls->ls_scan_lock); 423 427 r->res_toss_time = 0; 424 428 425 429 /* if the rsb is not queued do nothing */ 426 - if (list_empty(&r->res_toss_q_list)) 430 + if (list_empty(&r->res_scan_list)) 427 431 goto out; 428 432 429 433 /* get the first element before delete */ 430 - first = list_first_entry(&ls->ls_toss_q, struct dlm_rsb, 431 - res_toss_q_list); 432 - list_del_init(&r->res_toss_q_list); 434 + first = list_first_entry(&ls->ls_scan_list, struct dlm_rsb, 435 + res_scan_list); 436 + list_del_init(&r->res_scan_list); 433 437 /* check if the first element was the rsb we deleted */ 434 438 if (first == r) { 435 439 /* try to get the new first element, if the list ··· 440 442 * if the list isn't empty and a new first element got 441 443 * in place, set the new timer expire time. 442 444 */ 443 - first = list_first_entry_or_null(&ls->ls_toss_q, struct dlm_rsb, 444 - res_toss_q_list); 445 + first = list_first_entry_or_null(&ls->ls_scan_list, struct dlm_rsb, 446 + res_scan_list); 445 447 if (!first) 446 - timer_delete(&ls->ls_timer); 448 + timer_delete(&ls->ls_scan_timer); 447 449 else 448 - __rsb_mod_timer(ls, first->res_toss_time); 450 + enable_scan_timer(ls, first->res_toss_time); 449 451 } 450 452 451 453 out: 452 - spin_unlock_bh(&ls->ls_toss_q_lock); 454 + spin_unlock_bh(&ls->ls_scan_lock); 453 455 } 454 456 455 - /* Caller must held ls_rsbtbl_lock and need to be called every time 456 - * when either the rsb enters toss state or the toss state changes 457 - * the dir/master nodeid. 458 - */ 459 - static void rsb_mod_timer(struct dlm_ls *ls, struct dlm_rsb *r) 457 + static void add_scan(struct dlm_ls *ls, struct dlm_rsb *r) 460 458 { 461 459 int our_nodeid = dlm_our_nodeid(); 462 460 struct dlm_rsb *first; ··· 465 471 if (!dlm_no_directory(ls) && 466 472 (r->res_master_nodeid != our_nodeid) && 467 473 (dlm_dir_nodeid(r) == our_nodeid)) { 468 - rsb_delete_toss_timer(ls, r); 474 + del_scan(ls, r); 469 475 return; 470 476 } 471 477 472 - spin_lock_bh(&ls->ls_toss_q_lock); 478 + spin_lock_bh(&ls->ls_scan_lock); 473 479 /* set the new rsb absolute expire time in the rsb */ 474 480 r->res_toss_time = rsb_toss_jiffies(); 475 - if (list_empty(&ls->ls_toss_q)) { 481 + if (list_empty(&ls->ls_scan_list)) { 476 482 /* if the queue is empty add the element and it's 477 483 * our new expire time 478 484 */ 479 - list_add_tail(&r->res_toss_q_list, &ls->ls_toss_q); 480 - __rsb_mod_timer(ls, r->res_toss_time); 485 + list_add_tail(&r->res_scan_list, &ls->ls_scan_list); 486 + enable_scan_timer(ls, r->res_toss_time); 481 487 } else { 482 488 /* check if the rsb was already queued, if so delete 483 489 * it from the toss queue 484 490 */ 485 - if (!list_empty(&r->res_toss_q_list)) 486 - list_del(&r->res_toss_q_list); 491 + if (!list_empty(&r->res_scan_list)) 492 + list_del(&r->res_scan_list); 487 493 488 494 /* try to get the maybe new first element and then add 489 495 * to this rsb with the oldest expire time to the end ··· 491 497 * rsb expire time is our next expiration if it wasn't 492 498 * the now new first elemet is our new expiration time 493 499 */ 494 - first = list_first_entry_or_null(&ls->ls_toss_q, struct dlm_rsb, 495 - res_toss_q_list); 496 - list_add_tail(&r->res_toss_q_list, &ls->ls_toss_q); 500 + first = list_first_entry_or_null(&ls->ls_scan_list, struct dlm_rsb, 501 + res_scan_list); 502 + list_add_tail(&r->res_scan_list, &ls->ls_scan_list); 497 503 if (!first) 498 - __rsb_mod_timer(ls, r->res_toss_time); 504 + enable_scan_timer(ls, r->res_toss_time); 499 505 else 500 - __rsb_mod_timer(ls, first->res_toss_time); 506 + enable_scan_timer(ls, first->res_toss_time); 501 507 } 502 - spin_unlock_bh(&ls->ls_toss_q_lock); 508 + spin_unlock_bh(&ls->ls_scan_lock); 503 509 } 504 510 505 511 /* if we hit contention we do in 250 ms a retry to trylock. ··· 509 515 */ 510 516 #define DLM_TOSS_TIMER_RETRY (jiffies + msecs_to_jiffies(250)) 511 517 512 - void dlm_rsb_toss_timer(struct timer_list *timer) 518 + /* Called by lockspace scan_timer to free unused rsb's. */ 519 + 520 + void dlm_rsb_scan(struct timer_list *timer) 513 521 { 514 - struct dlm_ls *ls = from_timer(ls, timer, ls_timer); 522 + struct dlm_ls *ls = from_timer(ls, timer, ls_scan_timer); 515 523 int our_nodeid = dlm_our_nodeid(); 516 524 struct dlm_rsb *r; 517 525 int rv; ··· 521 525 while (1) { 522 526 /* interrupting point to leave iteration when 523 527 * recovery waits for timer_delete_sync(), recovery 524 - * will take care to delete everything in toss queue. 528 + * will take care to delete everything in scan list. 525 529 */ 526 530 if (dlm_locking_stopped(ls)) 527 531 break; 528 532 529 - rv = spin_trylock(&ls->ls_toss_q_lock); 533 + rv = spin_trylock(&ls->ls_scan_lock); 530 534 if (!rv) { 531 535 /* rearm again try timer */ 532 - __rsb_mod_timer(ls, DLM_TOSS_TIMER_RETRY); 536 + enable_scan_timer(ls, DLM_TOSS_TIMER_RETRY); 533 537 break; 534 538 } 535 539 536 - r = list_first_entry_or_null(&ls->ls_toss_q, struct dlm_rsb, 537 - res_toss_q_list); 540 + r = list_first_entry_or_null(&ls->ls_scan_list, struct dlm_rsb, 541 + res_scan_list); 538 542 if (!r) { 539 - /* nothing to do anymore next rsb queue will 540 - * set next mod_timer() expire. 541 - */ 542 - spin_unlock(&ls->ls_toss_q_lock); 543 + /* the next add_scan will enable the timer again */ 544 + spin_unlock(&ls->ls_scan_lock); 543 545 break; 544 546 } 545 547 546 - /* test if the first rsb isn't expired yet, if 547 - * so we stop freeing rsb from toss queue as 548 - * the order in queue is ascending to the 549 - * absolute res_toss_time jiffies 548 + /* 549 + * If the first rsb is not yet expired, then stop because the 550 + * list is sorted with nearest expiration first. 550 551 */ 551 552 if (time_before(jiffies, r->res_toss_time)) { 552 553 /* rearm with the next rsb to expire in the future */ 553 - __rsb_mod_timer(ls, r->res_toss_time); 554 - spin_unlock(&ls->ls_toss_q_lock); 554 + enable_scan_timer(ls, r->res_toss_time); 555 + spin_unlock(&ls->ls_scan_lock); 555 556 break; 556 557 } 557 558 558 559 /* in find_rsb_dir/nodir there is a reverse order of this 559 560 * lock, however this is only a trylock if we hit some 560 561 * possible contention we try it again. 561 - * 562 - * This lock synchronized while holding ls_toss_q_lock 563 - * synchronize everything that rsb_delete_toss_timer() 564 - * or rsb_mod_timer() can't run after this timer callback 565 - * deletes the rsb from the ls_toss_q. Whereas the other 566 - * holders have always a priority to run as this is only 567 - * a caching handling and the other holders might to put 568 - * this rsb out of the toss state. 569 562 */ 570 563 rv = write_trylock(&ls->ls_rsbtbl_lock); 571 564 if (!rv) { 572 - spin_unlock(&ls->ls_toss_q_lock); 565 + spin_unlock(&ls->ls_scan_lock); 573 566 /* rearm again try timer */ 574 - __rsb_mod_timer(ls, DLM_TOSS_TIMER_RETRY); 567 + enable_scan_timer(ls, DLM_TOSS_TIMER_RETRY); 575 568 break; 576 569 } 577 570 578 - list_del(&r->res_rsbs_list); 571 + list_del(&r->res_slow_list); 579 572 rhashtable_remove_fast(&ls->ls_rsbtbl, &r->res_node, 580 573 dlm_rhash_rsb_params); 581 574 582 - /* not necessary to held the ls_rsbtbl_lock when 583 - * calling send_remove() 584 - */ 575 + /* ls_rsbtbl_lock is not needed when calling send_remove() */ 585 576 write_unlock(&ls->ls_rsbtbl_lock); 586 577 587 - /* remove the rsb out of the toss queue its gone 588 - * drom DLM now 589 - */ 590 - list_del_init(&r->res_toss_q_list); 591 - spin_unlock(&ls->ls_toss_q_lock); 578 + list_del_init(&r->res_scan_list); 579 + spin_unlock(&ls->ls_scan_lock); 592 580 593 - /* no rsb in this state should ever run a timer */ 581 + /* An rsb that is a dir record for a remote master rsb 582 + * cannot be removed, and should not have a timer enabled. 583 + */ 594 584 WARN_ON(!dlm_no_directory(ls) && 595 585 (r->res_master_nodeid != our_nodeid) && 596 586 (dlm_dir_nodeid(r) == our_nodeid)); ··· 590 608 (dlm_dir_nodeid(r) != our_nodeid)) 591 609 send_remove(r); 592 610 593 - free_toss_rsb(r); 611 + free_inactive_rsb(r); 594 612 } 595 613 } 596 614 ··· 617 635 INIT_LIST_HEAD(&r->res_convertqueue); 618 636 INIT_LIST_HEAD(&r->res_waitqueue); 619 637 INIT_LIST_HEAD(&r->res_root_list); 620 - INIT_LIST_HEAD(&r->res_toss_q_list); 638 + INIT_LIST_HEAD(&r->res_scan_list); 621 639 INIT_LIST_HEAD(&r->res_recover_list); 622 640 INIT_LIST_HEAD(&r->res_masters_list); 623 641 ··· 671 689 * So, if the given rsb is on the toss list, it is moved to the keep list 672 690 * before being returned. 673 691 * 674 - * toss_rsb() happens when all local usage of the rsb is done, i.e. no 692 + * deactivate_rsb() happens when all local usage of the rsb is done, i.e. no 675 693 * more refcounts exist, so the rsb is moved from the keep list to the 676 694 * toss list. 677 695 * ··· 719 737 * 720 738 * If someone sends us a request, we are the dir node, and we do 721 739 * not find the rsb anywhere, then recreate it. This happens if 722 - * someone sends us a request after we have removed/freed an rsb 723 - * from our toss list. (They sent a request instead of lookup 724 - * because they are using an rsb from their toss list.) 740 + * someone sends us a request after we have removed/freed an rsb. 741 + * (They sent a request instead of lookup because they are using 742 + * an rsb taken from their scan list.) 725 743 */ 726 744 727 745 if (from_local || from_dir || ··· 731 749 732 750 retry: 733 751 734 - /* check if the rsb is in keep state under read lock - likely path */ 752 + /* check if the rsb is active under read lock - likely path */ 735 753 read_lock_bh(&ls->ls_rsbtbl_lock); 736 754 error = dlm_search_rsb_tree(&ls->ls_rsbtbl, name, len, &r); 737 755 if (error) { ··· 743 761 * rsb is active, so we can't check master_nodeid without lock_rsb. 744 762 */ 745 763 746 - if (rsb_flag(r, RSB_TOSS)) { 764 + if (rsb_flag(r, RSB_INACTIVE)) { 747 765 read_unlock_bh(&ls->ls_rsbtbl_lock); 748 - goto do_toss; 766 + goto do_inactive; 749 767 } 750 768 751 769 kref_get(&r->res_ref); ··· 753 771 goto out; 754 772 755 773 756 - do_toss: 774 + do_inactive: 757 775 write_lock_bh(&ls->ls_rsbtbl_lock); 758 776 759 - /* retry lookup under write lock to see if its still in toss state 760 - * if not it's in keep state and we relookup - unlikely path. 777 + /* retry lookup under write lock to see if its still in inactive state 778 + * if not it's in active state and we relookup - unlikely path. 761 779 */ 762 780 error = dlm_search_rsb_tree(&ls->ls_rsbtbl, name, len, &r); 763 781 if (!error) { 764 - if (!rsb_flag(r, RSB_TOSS)) { 782 + if (!rsb_flag(r, RSB_INACTIVE)) { 765 783 write_unlock_bh(&ls->ls_rsbtbl_lock); 766 784 goto retry; 767 785 } ··· 773 791 /* 774 792 * rsb found inactive (master_nodeid may be out of date unless 775 793 * we are the dir_nodeid or were the master) No other thread 776 - * is using this rsb because it's on the toss list, so we can 794 + * is using this rsb because it's inactive, so we can 777 795 * look at or update res_master_nodeid without lock_rsb. 778 796 */ 779 797 780 798 if ((r->res_master_nodeid != our_nodeid) && from_other) { 781 799 /* our rsb was not master, and another node (not the dir node) 782 800 has sent us a request */ 783 - log_debug(ls, "find_rsb toss from_other %d master %d dir %d %s", 801 + log_debug(ls, "find_rsb inactive from_other %d master %d dir %d %s", 784 802 from_nodeid, r->res_master_nodeid, dir_nodeid, 785 803 r->res_name); 786 804 write_unlock_bh(&ls->ls_rsbtbl_lock); ··· 790 808 791 809 if ((r->res_master_nodeid != our_nodeid) && from_dir) { 792 810 /* don't think this should ever happen */ 793 - log_error(ls, "find_rsb toss from_dir %d master %d", 811 + log_error(ls, "find_rsb inactive from_dir %d master %d", 794 812 from_nodeid, r->res_master_nodeid); 795 813 dlm_print_rsb(r); 796 814 /* fix it and go on */ ··· 807 825 r->res_first_lkid = 0; 808 826 } 809 827 810 - list_move(&r->res_rsbs_list, &ls->ls_keep); 811 - rsb_clear_flag(r, RSB_TOSS); 812 - /* rsb got out of toss state, it becomes alive again 813 - * and we reinit the reference counter that is only 814 - * valid for keep state rsbs 815 - */ 828 + list_move(&r->res_slow_list, &ls->ls_slow_active); 829 + rsb_clear_flag(r, RSB_INACTIVE); 816 830 kref_init(&r->res_ref); 817 - rsb_delete_toss_timer(ls, r); 831 + del_scan(ls, r); 818 832 write_unlock_bh(&ls->ls_rsbtbl_lock); 819 833 820 834 goto out; ··· 879 901 dlm_free_rsb(r); 880 902 goto retry; 881 903 } else if (!error) { 882 - list_add(&r->res_rsbs_list, &ls->ls_keep); 904 + list_add(&r->res_slow_list, &ls->ls_slow_active); 883 905 } 884 906 write_unlock_bh(&ls->ls_rsbtbl_lock); 885 907 out: ··· 902 924 903 925 retry: 904 926 905 - /* check if the rsb is in keep state under read lock - likely path */ 927 + /* check if the rsb is in active state under read lock - likely path */ 906 928 read_lock_bh(&ls->ls_rsbtbl_lock); 907 929 error = dlm_search_rsb_tree(&ls->ls_rsbtbl, name, len, &r); 908 930 if (error) { ··· 910 932 goto do_new; 911 933 } 912 934 913 - if (rsb_flag(r, RSB_TOSS)) { 935 + if (rsb_flag(r, RSB_INACTIVE)) { 914 936 read_unlock_bh(&ls->ls_rsbtbl_lock); 915 - goto do_toss; 937 + goto do_inactive; 916 938 } 917 939 918 940 /* ··· 925 947 goto out; 926 948 927 949 928 - do_toss: 950 + do_inactive: 929 951 write_lock_bh(&ls->ls_rsbtbl_lock); 930 952 931 - /* retry lookup under write lock to see if its still in toss state 932 - * if not it's in keep state and we relookup - unlikely path. 953 + /* retry lookup under write lock to see if its still inactive. 954 + * if it's active, repeat lookup - unlikely path. 933 955 */ 934 956 error = dlm_search_rsb_tree(&ls->ls_rsbtbl, name, len, &r); 935 957 if (!error) { 936 - if (!rsb_flag(r, RSB_TOSS)) { 958 + if (!rsb_flag(r, RSB_INACTIVE)) { 937 959 write_unlock_bh(&ls->ls_rsbtbl_lock); 938 960 goto retry; 939 961 } ··· 945 967 946 968 /* 947 969 * rsb found inactive. No other thread is using this rsb because 948 - * it's on the toss list, so we can look at or update 949 - * res_master_nodeid without lock_rsb. 970 + * it's inactive, so we can look at or update res_master_nodeid 971 + * without lock_rsb. 950 972 */ 951 973 952 974 if (!recover && (r->res_master_nodeid != our_nodeid) && from_nodeid) { 953 975 /* our rsb is not master, and another node has sent us a 954 976 request; this should never happen */ 955 - log_error(ls, "find_rsb toss from_nodeid %d master %d dir %d", 977 + log_error(ls, "find_rsb inactive from_nodeid %d master %d dir %d", 956 978 from_nodeid, r->res_master_nodeid, dir_nodeid); 957 979 dlm_print_rsb(r); 958 980 write_unlock_bh(&ls->ls_rsbtbl_lock); ··· 964 986 (dir_nodeid == our_nodeid)) { 965 987 /* our rsb is not master, and we are dir; may as well fix it; 966 988 this should never happen */ 967 - log_error(ls, "find_rsb toss our %d master %d dir %d", 989 + log_error(ls, "find_rsb inactive our %d master %d dir %d", 968 990 our_nodeid, r->res_master_nodeid, dir_nodeid); 969 991 dlm_print_rsb(r); 970 992 r->res_master_nodeid = our_nodeid; 971 993 r->res_nodeid = 0; 972 994 } 973 995 974 - list_move(&r->res_rsbs_list, &ls->ls_keep); 975 - rsb_clear_flag(r, RSB_TOSS); 976 - /* rsb got out of toss state, it becomes alive again 977 - * and we reinit the reference counter that is only 978 - * valid for keep state rsbs 979 - */ 996 + list_move(&r->res_slow_list, &ls->ls_slow_active); 997 + rsb_clear_flag(r, RSB_INACTIVE); 980 998 kref_init(&r->res_ref); 981 - rsb_delete_toss_timer(ls, r); 999 + del_scan(ls, r); 982 1000 write_unlock_bh(&ls->ls_rsbtbl_lock); 983 1001 984 1002 goto out; ··· 1005 1031 dlm_free_rsb(r); 1006 1032 goto retry; 1007 1033 } else if (!error) { 1008 - list_add(&r->res_rsbs_list, &ls->ls_keep); 1034 + list_add(&r->res_slow_list, &ls->ls_slow_active); 1009 1035 } 1010 1036 write_unlock_bh(&ls->ls_rsbtbl_lock); 1011 1037 ··· 1079 1105 } 1080 1106 1081 1107 static void __dlm_master_lookup(struct dlm_ls *ls, struct dlm_rsb *r, int our_nodeid, 1082 - int from_nodeid, bool toss_list, unsigned int flags, 1108 + int from_nodeid, bool is_inactive, unsigned int flags, 1083 1109 int *r_nodeid, int *result) 1084 1110 { 1085 1111 int fix_master = (flags & DLM_LU_RECOVER_MASTER); ··· 1103 1129 r->res_nodeid = from_nodeid; 1104 1130 rsb_set_flag(r, RSB_NEW_MASTER); 1105 1131 1106 - if (toss_list) { 1107 - /* I don't think we should ever find it on toss list. */ 1108 - log_error(ls, "%s fix_master on toss", __func__); 1132 + if (is_inactive) { 1133 + /* I don't think we should ever find it inactive. */ 1134 + log_error(ls, "%s fix_master inactive", __func__); 1109 1135 dlm_dump_rsb(r); 1110 1136 } 1111 1137 } ··· 1145 1171 if (!from_master && !fix_master && 1146 1172 (r->res_master_nodeid == from_nodeid)) { 1147 1173 /* this can happen when the master sends remove, the dir node 1148 - * finds the rsb on the keep list and ignores the remove, 1174 + * finds the rsb on the active list and ignores the remove, 1149 1175 * and the former master sends a lookup 1150 1176 */ 1151 1177 ··· 1218 1244 1219 1245 retry: 1220 1246 1221 - /* check if the rsb is in keep state under read lock - likely path */ 1247 + /* check if the rsb is active under read lock - likely path */ 1222 1248 read_lock_bh(&ls->ls_rsbtbl_lock); 1223 1249 error = dlm_search_rsb_tree(&ls->ls_rsbtbl, name, len, &r); 1224 1250 if (!error) { 1225 - if (rsb_flag(r, RSB_TOSS)) { 1251 + if (rsb_flag(r, RSB_INACTIVE)) { 1226 1252 read_unlock_bh(&ls->ls_rsbtbl_lock); 1227 - goto do_toss; 1253 + goto do_inactive; 1228 1254 } 1229 1255 1230 1256 /* because the rsb is active, we need to lock_rsb before ··· 1248 1274 goto not_found; 1249 1275 } 1250 1276 1251 - do_toss: 1277 + do_inactive: 1252 1278 /* unlikely path - relookup under write */ 1253 1279 write_lock_bh(&ls->ls_rsbtbl_lock); 1254 1280 1255 - /* rsb_mod_timer() requires to held ls_rsbtbl_lock in write lock 1256 - * check if the rsb is still in toss state, if not relookup 1257 - */ 1258 1281 error = dlm_search_rsb_tree(&ls->ls_rsbtbl, name, len, &r); 1259 1282 if (!error) { 1260 - if (!rsb_flag(r, RSB_TOSS)) { 1283 + if (!rsb_flag(r, RSB_INACTIVE)) { 1261 1284 write_unlock_bh(&ls->ls_rsbtbl_lock); 1262 1285 /* something as changed, very unlikely but 1263 1286 * try again ··· 1266 1295 goto not_found; 1267 1296 } 1268 1297 1269 - /* because the rsb is inactive (on toss list), it's not refcounted 1270 - * and lock_rsb is not used, but is protected by the rsbtbl lock 1271 - */ 1298 + /* because the rsb is inactive, it's not refcounted and lock_rsb 1299 + is not used, but is protected by the rsbtbl lock */ 1272 1300 1273 1301 __dlm_master_lookup(ls, r, our_nodeid, from_nodeid, true, flags, 1274 1302 r_nodeid, result); 1275 1303 1276 - rsb_mod_timer(ls, r); 1277 - /* the rsb was inactive (on toss list) */ 1304 + add_scan(ls, r); 1278 1305 write_unlock_bh(&ls->ls_rsbtbl_lock); 1279 1306 1280 1307 return 0; ··· 1286 1317 r->res_dir_nodeid = our_nodeid; 1287 1318 r->res_master_nodeid = from_nodeid; 1288 1319 r->res_nodeid = from_nodeid; 1289 - rsb_set_flag(r, RSB_TOSS); 1320 + rsb_set_flag(r, RSB_INACTIVE); 1290 1321 1291 1322 write_lock_bh(&ls->ls_rsbtbl_lock); 1292 1323 error = rsb_insert(r, &ls->ls_rsbtbl); ··· 1304 1335 goto retry; 1305 1336 } 1306 1337 1307 - list_add(&r->res_rsbs_list, &ls->ls_toss); 1308 - rsb_mod_timer(ls, r); 1338 + list_add(&r->res_slow_list, &ls->ls_slow_inactive); 1339 + add_scan(ls, r); 1309 1340 write_unlock_bh(&ls->ls_rsbtbl_lock); 1310 1341 1311 1342 if (result) ··· 1320 1351 struct dlm_rsb *r; 1321 1352 1322 1353 read_lock_bh(&ls->ls_rsbtbl_lock); 1323 - list_for_each_entry(r, &ls->ls_keep, res_rsbs_list) { 1354 + list_for_each_entry(r, &ls->ls_slow_active, res_slow_list) { 1324 1355 if (r->res_hash == hash) 1325 1356 dlm_dump_rsb(r); 1326 1357 } ··· 1342 1373 read_unlock_bh(&ls->ls_rsbtbl_lock); 1343 1374 } 1344 1375 1345 - static void toss_rsb(struct kref *kref) 1376 + static void deactivate_rsb(struct kref *kref) 1346 1377 { 1347 1378 struct dlm_rsb *r = container_of(kref, struct dlm_rsb, res_ref); 1348 1379 struct dlm_ls *ls = r->res_ls; 1349 1380 1350 1381 DLM_ASSERT(list_empty(&r->res_root_list), dlm_print_rsb(r);); 1351 - rsb_set_flag(r, RSB_TOSS); 1352 - list_move(&r->res_rsbs_list, &ls->ls_toss); 1353 - rsb_mod_timer(ls, r); 1382 + rsb_set_flag(r, RSB_INACTIVE); 1383 + list_move(&r->res_slow_list, &ls->ls_slow_inactive); 1384 + add_scan(ls, r); 1354 1385 1355 1386 if (r->res_lvbptr) { 1356 1387 dlm_free_lvb(r->res_lvbptr); ··· 1364 1395 { 1365 1396 int rv; 1366 1397 1367 - /* rsbs in toss state never get referenced */ 1368 - WARN_ON(rsb_flag(r, RSB_TOSS)); 1369 - rv = kref_put(&r->res_ref, toss_rsb); 1398 + /* inactive rsbs are not ref counted */ 1399 + WARN_ON(rsb_flag(r, RSB_INACTIVE)); 1400 + rv = kref_put(&r->res_ref, deactivate_rsb); 1370 1401 DLM_ASSERT(!rv, dlm_dump_rsb(r);); 1371 1402 } 1372 1403 1373 - void free_toss_rsb(struct dlm_rsb *r) 1404 + void free_inactive_rsb(struct dlm_rsb *r) 1374 1405 { 1375 - WARN_ON_ONCE(!rsb_flag(r, RSB_TOSS)); 1406 + WARN_ON_ONCE(!rsb_flag(r, RSB_INACTIVE)); 1376 1407 1377 1408 DLM_ASSERT(list_empty(&r->res_lookup), dlm_dump_rsb(r);); 1378 1409 DLM_ASSERT(list_empty(&r->res_grantqueue), dlm_dump_rsb(r);); 1379 1410 DLM_ASSERT(list_empty(&r->res_convertqueue), dlm_dump_rsb(r);); 1380 1411 DLM_ASSERT(list_empty(&r->res_waitqueue), dlm_dump_rsb(r);); 1381 1412 DLM_ASSERT(list_empty(&r->res_root_list), dlm_dump_rsb(r);); 1382 - DLM_ASSERT(list_empty(&r->res_toss_q_list), dlm_dump_rsb(r);); 1413 + DLM_ASSERT(list_empty(&r->res_scan_list), dlm_dump_rsb(r);); 1383 1414 DLM_ASSERT(list_empty(&r->res_recover_list), dlm_dump_rsb(r);); 1384 1415 DLM_ASSERT(list_empty(&r->res_masters_list), dlm_dump_rsb(r);); 1385 1416 ··· 4225 4256 return; 4226 4257 } 4227 4258 4228 - /* Look for name in rsb toss state, if it's there, kill it. 4229 - * If it's in non toss state, it's being used, and we should ignore this 4259 + /* 4260 + * Look for inactive rsb, if it's there, free it. 4261 + * If the rsb is active, it's being used, and we should ignore this 4230 4262 * message. This is an expected race between the dir node sending a 4231 4263 * request to the master node at the same time as the master node sends 4232 4264 * a remove to the dir node. The resolution to that race is for the ··· 4250 4280 return; 4251 4281 } 4252 4282 4253 - if (!rsb_flag(r, RSB_TOSS)) { 4283 + if (!rsb_flag(r, RSB_INACTIVE)) { 4254 4284 if (r->res_master_nodeid != from_nodeid) { 4255 4285 /* should not happen */ 4256 - log_error(ls, "receive_remove keep from %d master %d", 4286 + log_error(ls, "receive_remove on active rsb from %d master %d", 4257 4287 from_nodeid, r->res_master_nodeid); 4258 4288 dlm_print_rsb(r); 4259 4289 write_unlock_bh(&ls->ls_rsbtbl_lock); 4260 4290 return; 4261 4291 } 4292 + 4293 + /* Ignore the remove message, see race comment above. */ 4262 4294 4263 4295 log_debug(ls, "receive_remove from %d master %d first %x %s", 4264 4296 from_nodeid, r->res_master_nodeid, r->res_first_lkid, ··· 4270 4298 } 4271 4299 4272 4300 if (r->res_master_nodeid != from_nodeid) { 4273 - log_error(ls, "receive_remove toss from %d master %d", 4301 + log_error(ls, "receive_remove inactive from %d master %d", 4274 4302 from_nodeid, r->res_master_nodeid); 4275 4303 dlm_print_rsb(r); 4276 4304 write_unlock_bh(&ls->ls_rsbtbl_lock); 4277 4305 return; 4278 4306 } 4279 4307 4280 - list_del(&r->res_rsbs_list); 4308 + list_del(&r->res_slow_list); 4281 4309 rhashtable_remove_fast(&ls->ls_rsbtbl, &r->res_node, 4282 4310 dlm_rhash_rsb_params); 4283 4311 write_unlock_bh(&ls->ls_rsbtbl_lock); 4284 4312 4285 - free_toss_rsb(r); 4313 + free_inactive_rsb(r); 4286 4314 } 4287 4315 4288 4316 static void receive_purge(struct dlm_ls *ls, const struct dlm_message *ms) ··· 5349 5377 struct dlm_rsb *r; 5350 5378 5351 5379 read_lock_bh(&ls->ls_rsbtbl_lock); 5352 - list_for_each_entry(r, &ls->ls_keep, res_rsbs_list) { 5380 + list_for_each_entry(r, &ls->ls_slow_active, res_slow_list) { 5353 5381 if (!rsb_flag(r, RSB_RECOVER_GRANT)) 5354 5382 continue; 5355 5383 if (!is_master(r)) {
+3 -4
fs/dlm/lock.h
··· 11 11 #ifndef __LOCK_DOT_H__ 12 12 #define __LOCK_DOT_H__ 13 13 14 - void dlm_rsb_toss_timer(struct timer_list *timer); 15 14 void dlm_dump_rsb(struct dlm_rsb *r); 16 15 void dlm_dump_rsb_name(struct dlm_ls *ls, const char *name, int len); 17 16 void dlm_print_lkb(struct dlm_lkb *lkb); ··· 18 19 uint32_t saved_seq); 19 20 void dlm_receive_buffer(const union dlm_packet *p, int nodeid); 20 21 int dlm_modes_compat(int mode1, int mode2); 21 - void free_toss_rsb(struct dlm_rsb *r); 22 + void free_inactive_rsb(struct dlm_rsb *r); 22 23 void dlm_put_rsb(struct dlm_rsb *r); 23 24 void dlm_hold_rsb(struct dlm_rsb *r); 24 25 int dlm_put_lkb(struct dlm_lkb *lkb); 25 - void dlm_scan_rsbs(struct dlm_ls *ls); 26 26 int dlm_lock_recovery_try(struct dlm_ls *ls); 27 27 void dlm_lock_recovery(struct dlm_ls *ls); 28 28 void dlm_unlock_recovery(struct dlm_ls *ls); 29 - void dlm_timer_resume(struct dlm_ls *ls); 29 + void dlm_rsb_scan(struct timer_list *timer); 30 + void resume_scan_timer(struct dlm_ls *ls); 30 31 31 32 int dlm_master_lookup(struct dlm_ls *ls, int from_nodeid, const char *name, 32 33 int len, unsigned int flags, int *r_nodeid, int *result);
+6 -7
fs/dlm/lockspace.c
··· 412 412 */ 413 413 ls->ls_exflags = (flags & ~(DLM_LSFL_FS | DLM_LSFL_NEWEXCL)); 414 414 415 - INIT_LIST_HEAD(&ls->ls_toss); 416 - INIT_LIST_HEAD(&ls->ls_keep); 415 + INIT_LIST_HEAD(&ls->ls_slow_inactive); 416 + INIT_LIST_HEAD(&ls->ls_slow_active); 417 417 rwlock_init(&ls->ls_rsbtbl_lock); 418 418 419 419 error = rhashtable_init(&ls->ls_rsbtbl, &dlm_rhash_rsb_params); ··· 490 490 INIT_LIST_HEAD(&ls->ls_dir_dump_list); 491 491 rwlock_init(&ls->ls_dir_dump_lock); 492 492 493 - INIT_LIST_HEAD(&ls->ls_toss_q); 494 - spin_lock_init(&ls->ls_toss_q_lock); 495 - timer_setup(&ls->ls_timer, dlm_rsb_toss_timer, 496 - TIMER_DEFERRABLE); 493 + INIT_LIST_HEAD(&ls->ls_scan_list); 494 + spin_lock_init(&ls->ls_scan_lock); 495 + timer_setup(&ls->ls_scan_timer, dlm_rsb_scan, TIMER_DEFERRABLE); 497 496 498 497 spin_lock_bh(&lslist_lock); 499 498 ls->ls_create_count = 1; ··· 722 723 * time_shutdown_sync(), we don't care anymore 723 724 */ 724 725 clear_bit(LSFL_RUNNING, &ls->ls_flags); 725 - timer_shutdown_sync(&ls->ls_timer); 726 + timer_shutdown_sync(&ls->ls_scan_timer); 726 727 727 728 if (ls_count == 1) { 728 729 dlm_clear_members(ls);
+1 -1
fs/dlm/member.c
··· 642 642 set_bit(LSFL_RECOVER_STOP, &ls->ls_flags); 643 643 new = test_and_clear_bit(LSFL_RUNNING, &ls->ls_flags); 644 644 if (new) 645 - timer_delete_sync(&ls->ls_timer); 645 + timer_delete_sync(&ls->ls_scan_timer); 646 646 ls->ls_recover_seq++; 647 647 648 648 /* activate requestqueue and stop processing */
+7 -10
fs/dlm/recover.c
··· 882 882 log_rinfo(ls, "dlm_recover_rsbs %d done", count); 883 883 } 884 884 885 - /* Create a single list of all root rsb's to be used during recovery */ 886 - 887 - void dlm_clear_toss(struct dlm_ls *ls) 885 + void dlm_clear_inactive(struct dlm_ls *ls) 888 886 { 889 887 struct dlm_rsb *r, *safe; 890 888 unsigned int count = 0; 891 889 892 890 write_lock_bh(&ls->ls_rsbtbl_lock); 893 - list_for_each_entry_safe(r, safe, &ls->ls_toss, res_rsbs_list) { 894 - list_del(&r->res_rsbs_list); 891 + list_for_each_entry_safe(r, safe, &ls->ls_slow_inactive, res_slow_list) { 892 + list_del(&r->res_slow_list); 895 893 rhashtable_remove_fast(&ls->ls_rsbtbl, &r->res_node, 896 894 dlm_rhash_rsb_params); 897 895 898 - /* remove it from the toss queue if its part of it */ 899 - if (!list_empty(&r->res_toss_q_list)) 900 - list_del_init(&r->res_toss_q_list); 896 + if (!list_empty(&r->res_scan_list)) 897 + list_del_init(&r->res_scan_list); 901 898 902 - free_toss_rsb(r); 899 + free_inactive_rsb(r); 903 900 count++; 904 901 } 905 902 write_unlock_bh(&ls->ls_rsbtbl_lock); 906 903 907 904 if (count) 908 - log_rinfo(ls, "dlm_clear_toss %u done", count); 905 + log_rinfo(ls, "dlm_clear_inactive %u done", count); 909 906 } 910 907
+1 -1
fs/dlm/recover.h
··· 25 25 int dlm_recover_locks(struct dlm_ls *ls, uint64_t seq, 26 26 const struct list_head *root_list); 27 27 void dlm_recovered_lock(struct dlm_rsb *r); 28 - void dlm_clear_toss(struct dlm_ls *ls); 28 + void dlm_clear_inactive(struct dlm_ls *ls); 29 29 void dlm_recover_rsbs(struct dlm_ls *ls, const struct list_head *root_list); 30 30 31 31 #endif /* __RECOVER_DOT_H__ */
+7 -7
fs/dlm/recoverd.c
··· 33 33 } 34 34 35 35 read_lock_bh(&ls->ls_rsbtbl_lock); 36 - list_for_each_entry(r, &ls->ls_keep, res_rsbs_list) { 36 + list_for_each_entry(r, &ls->ls_slow_active, res_slow_list) { 37 37 if (r->res_nodeid) 38 38 continue; 39 39 ··· 63 63 struct dlm_rsb *r; 64 64 65 65 read_lock_bh(&ls->ls_rsbtbl_lock); 66 - list_for_each_entry(r, &ls->ls_keep, res_rsbs_list) { 66 + list_for_each_entry(r, &ls->ls_slow_active, res_slow_list) { 67 67 list_add(&r->res_root_list, root_list); 68 68 dlm_hold_rsb(r); 69 69 } 70 70 71 - WARN_ON_ONCE(!list_empty(&ls->ls_toss)); 71 + WARN_ON_ONCE(!list_empty(&ls->ls_slow_inactive)); 72 72 read_unlock_bh(&ls->ls_rsbtbl_lock); 73 73 } 74 74 ··· 98 98 spin_lock_bh(&ls->ls_recover_lock); 99 99 if (ls->ls_recover_seq == seq) { 100 100 set_bit(LSFL_RUNNING, &ls->ls_flags); 101 - /* Schedule next timer if recovery put something on toss. 101 + /* Schedule next timer if recovery put something on inactive. 102 102 * 103 103 * The rsbs that was queued while recovery on toss hasn't 104 104 * started yet because LSFL_RUNNING was set everything 105 105 * else recovery hasn't started as well because ls_in_recovery 106 106 * is still hold. So we should not run into the case that 107 - * dlm_timer_resume() queues a timer that can occur in 107 + * resume_scan_timer() queues a timer that can occur in 108 108 * a no op. 109 109 */ 110 - dlm_timer_resume(ls); 110 + resume_scan_timer(ls); 111 111 /* unblocks processes waiting to enter the dlm */ 112 112 up_write(&ls->ls_in_recovery); 113 113 clear_bit(LSFL_RECOVER_LOCK, &ls->ls_flags); ··· 131 131 132 132 dlm_callback_suspend(ls); 133 133 134 - dlm_clear_toss(ls); 134 + dlm_clear_inactive(ls); 135 135 136 136 /* 137 137 * This list of root rsb's will be the basis of most of the recovery