diff options
author | David Teigland <teigland@redhat.com> | 2009-01-07 17:50:41 -0500 |
---|---|---|
committer | David Teigland <teigland@redhat.com> | 2009-01-08 16:12:39 -0500 |
commit | c7be761a8163d2f1ac0b606c21e4316b7abc5af7 (patch) | |
tree | 1687373b56379c1c310f43b1c05ac486c67dec48 /fs | |
parent | 892c4467e335e9050c95e0d8409c136c4dadaca2 (diff) |
dlm: change rsbtbl rwlock to spinlock
The rwlock is almost always used in write mode, so there's no reason
to not use a spinlock instead.
Signed-off-by: David Teigland <teigland@redhat.com>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/dlm/debug_fs.c | 24 | ||||
-rw-r--r-- | fs/dlm/dlm_internal.h | 2 | ||||
-rw-r--r-- | fs/dlm/lock.c | 26 | ||||
-rw-r--r-- | fs/dlm/lockspace.c | 2 | ||||
-rw-r--r-- | fs/dlm/recover.c | 10 |
5 files changed, 32 insertions, 32 deletions
diff --git a/fs/dlm/debug_fs.c b/fs/dlm/debug_fs.c index bc4af3ef65a3..1d1d27442235 100644 --- a/fs/dlm/debug_fs.c +++ b/fs/dlm/debug_fs.c | |||
@@ -416,7 +416,7 @@ static void *table_seq_start(struct seq_file *seq, loff_t *pos) | |||
416 | if (seq->op == &format3_seq_ops) | 416 | if (seq->op == &format3_seq_ops) |
417 | ri->format = 3; | 417 | ri->format = 3; |
418 | 418 | ||
419 | read_lock(&ls->ls_rsbtbl[bucket].lock); | 419 | spin_lock(&ls->ls_rsbtbl[bucket].lock); |
420 | if (!list_empty(&ls->ls_rsbtbl[bucket].list)) { | 420 | if (!list_empty(&ls->ls_rsbtbl[bucket].list)) { |
421 | list_for_each_entry(r, &ls->ls_rsbtbl[bucket].list, | 421 | list_for_each_entry(r, &ls->ls_rsbtbl[bucket].list, |
422 | res_hashchain) { | 422 | res_hashchain) { |
@@ -424,12 +424,12 @@ static void *table_seq_start(struct seq_file *seq, loff_t *pos) | |||
424 | dlm_hold_rsb(r); | 424 | dlm_hold_rsb(r); |
425 | ri->rsb = r; | 425 | ri->rsb = r; |
426 | ri->bucket = bucket; | 426 | ri->bucket = bucket; |
427 | read_unlock(&ls->ls_rsbtbl[bucket].lock); | 427 | spin_unlock(&ls->ls_rsbtbl[bucket].lock); |
428 | return ri; | 428 | return ri; |
429 | } | 429 | } |
430 | } | 430 | } |
431 | } | 431 | } |
432 | read_unlock(&ls->ls_rsbtbl[bucket].lock); | 432 | spin_unlock(&ls->ls_rsbtbl[bucket].lock); |
433 | 433 | ||
434 | /* | 434 | /* |
435 | * move to the first rsb in the next non-empty bucket | 435 | * move to the first rsb in the next non-empty bucket |
@@ -447,18 +447,18 @@ static void *table_seq_start(struct seq_file *seq, loff_t *pos) | |||
447 | return NULL; | 447 | return NULL; |
448 | } | 448 | } |
449 | 449 | ||
450 | read_lock(&ls->ls_rsbtbl[bucket].lock); | 450 | spin_lock(&ls->ls_rsbtbl[bucket].lock); |
451 | if (!list_empty(&ls->ls_rsbtbl[bucket].list)) { | 451 | if (!list_empty(&ls->ls_rsbtbl[bucket].list)) { |
452 | r = list_first_entry(&ls->ls_rsbtbl[bucket].list, | 452 | r = list_first_entry(&ls->ls_rsbtbl[bucket].list, |
453 | struct dlm_rsb, res_hashchain); | 453 | struct dlm_rsb, res_hashchain); |
454 | dlm_hold_rsb(r); | 454 | dlm_hold_rsb(r); |
455 | ri->rsb = r; | 455 | ri->rsb = r; |
456 | ri->bucket = bucket; | 456 | ri->bucket = bucket; |
457 | read_unlock(&ls->ls_rsbtbl[bucket].lock); | 457 | spin_unlock(&ls->ls_rsbtbl[bucket].lock); |
458 | *pos = n; | 458 | *pos = n; |
459 | return ri; | 459 | return ri; |
460 | } | 460 | } |
461 | read_unlock(&ls->ls_rsbtbl[bucket].lock); | 461 | spin_unlock(&ls->ls_rsbtbl[bucket].lock); |
462 | } | 462 | } |
463 | } | 463 | } |
464 | 464 | ||
@@ -477,7 +477,7 @@ static void *table_seq_next(struct seq_file *seq, void *iter_ptr, loff_t *pos) | |||
477 | * move to the next rsb in the same bucket | 477 | * move to the next rsb in the same bucket |
478 | */ | 478 | */ |
479 | 479 | ||
480 | read_lock(&ls->ls_rsbtbl[bucket].lock); | 480 | spin_lock(&ls->ls_rsbtbl[bucket].lock); |
481 | rp = ri->rsb; | 481 | rp = ri->rsb; |
482 | next = rp->res_hashchain.next; | 482 | next = rp->res_hashchain.next; |
483 | 483 | ||
@@ -485,12 +485,12 @@ static void *table_seq_next(struct seq_file *seq, void *iter_ptr, loff_t *pos) | |||
485 | r = list_entry(next, struct dlm_rsb, res_hashchain); | 485 | r = list_entry(next, struct dlm_rsb, res_hashchain); |
486 | dlm_hold_rsb(r); | 486 | dlm_hold_rsb(r); |
487 | ri->rsb = r; | 487 | ri->rsb = r; |
488 | read_unlock(&ls->ls_rsbtbl[bucket].lock); | 488 | spin_unlock(&ls->ls_rsbtbl[bucket].lock); |
489 | dlm_put_rsb(rp); | 489 | dlm_put_rsb(rp); |
490 | ++*pos; | 490 | ++*pos; |
491 | return ri; | 491 | return ri; |
492 | } | 492 | } |
493 | read_unlock(&ls->ls_rsbtbl[bucket].lock); | 493 | spin_unlock(&ls->ls_rsbtbl[bucket].lock); |
494 | dlm_put_rsb(rp); | 494 | dlm_put_rsb(rp); |
495 | 495 | ||
496 | /* | 496 | /* |
@@ -509,18 +509,18 @@ static void *table_seq_next(struct seq_file *seq, void *iter_ptr, loff_t *pos) | |||
509 | return NULL; | 509 | return NULL; |
510 | } | 510 | } |
511 | 511 | ||
512 | read_lock(&ls->ls_rsbtbl[bucket].lock); | 512 | spin_lock(&ls->ls_rsbtbl[bucket].lock); |
513 | if (!list_empty(&ls->ls_rsbtbl[bucket].list)) { | 513 | if (!list_empty(&ls->ls_rsbtbl[bucket].list)) { |
514 | r = list_first_entry(&ls->ls_rsbtbl[bucket].list, | 514 | r = list_first_entry(&ls->ls_rsbtbl[bucket].list, |
515 | struct dlm_rsb, res_hashchain); | 515 | struct dlm_rsb, res_hashchain); |
516 | dlm_hold_rsb(r); | 516 | dlm_hold_rsb(r); |
517 | ri->rsb = r; | 517 | ri->rsb = r; |
518 | ri->bucket = bucket; | 518 | ri->bucket = bucket; |
519 | read_unlock(&ls->ls_rsbtbl[bucket].lock); | 519 | spin_unlock(&ls->ls_rsbtbl[bucket].lock); |
520 | *pos = n; | 520 | *pos = n; |
521 | return ri; | 521 | return ri; |
522 | } | 522 | } |
523 | read_unlock(&ls->ls_rsbtbl[bucket].lock); | 523 | spin_unlock(&ls->ls_rsbtbl[bucket].lock); |
524 | } | 524 | } |
525 | } | 525 | } |
526 | 526 | ||
diff --git a/fs/dlm/dlm_internal.h b/fs/dlm/dlm_internal.h index ef2f1e353966..076e86f38bc8 100644 --- a/fs/dlm/dlm_internal.h +++ b/fs/dlm/dlm_internal.h | |||
@@ -105,7 +105,7 @@ struct dlm_dirtable { | |||
105 | struct dlm_rsbtable { | 105 | struct dlm_rsbtable { |
106 | struct list_head list; | 106 | struct list_head list; |
107 | struct list_head toss; | 107 | struct list_head toss; |
108 | rwlock_t lock; | 108 | spinlock_t lock; |
109 | }; | 109 | }; |
110 | 110 | ||
111 | struct dlm_lkbtable { | 111 | struct dlm_lkbtable { |
diff --git a/fs/dlm/lock.c b/fs/dlm/lock.c index 6cfe65bbf4a2..01e7d39c5fba 100644 --- a/fs/dlm/lock.c +++ b/fs/dlm/lock.c | |||
@@ -412,9 +412,9 @@ static int search_rsb(struct dlm_ls *ls, char *name, int len, int b, | |||
412 | unsigned int flags, struct dlm_rsb **r_ret) | 412 | unsigned int flags, struct dlm_rsb **r_ret) |
413 | { | 413 | { |
414 | int error; | 414 | int error; |
415 | write_lock(&ls->ls_rsbtbl[b].lock); | 415 | spin_lock(&ls->ls_rsbtbl[b].lock); |
416 | error = _search_rsb(ls, name, len, b, flags, r_ret); | 416 | error = _search_rsb(ls, name, len, b, flags, r_ret); |
417 | write_unlock(&ls->ls_rsbtbl[b].lock); | 417 | spin_unlock(&ls->ls_rsbtbl[b].lock); |
418 | return error; | 418 | return error; |
419 | } | 419 | } |
420 | 420 | ||
@@ -478,16 +478,16 @@ static int find_rsb(struct dlm_ls *ls, char *name, int namelen, | |||
478 | r->res_nodeid = nodeid; | 478 | r->res_nodeid = nodeid; |
479 | } | 479 | } |
480 | 480 | ||
481 | write_lock(&ls->ls_rsbtbl[bucket].lock); | 481 | spin_lock(&ls->ls_rsbtbl[bucket].lock); |
482 | error = _search_rsb(ls, name, namelen, bucket, 0, &tmp); | 482 | error = _search_rsb(ls, name, namelen, bucket, 0, &tmp); |
483 | if (!error) { | 483 | if (!error) { |
484 | write_unlock(&ls->ls_rsbtbl[bucket].lock); | 484 | spin_unlock(&ls->ls_rsbtbl[bucket].lock); |
485 | dlm_free_rsb(r); | 485 | dlm_free_rsb(r); |
486 | r = tmp; | 486 | r = tmp; |
487 | goto out; | 487 | goto out; |
488 | } | 488 | } |
489 | list_add(&r->res_hashchain, &ls->ls_rsbtbl[bucket].list); | 489 | list_add(&r->res_hashchain, &ls->ls_rsbtbl[bucket].list); |
490 | write_unlock(&ls->ls_rsbtbl[bucket].lock); | 490 | spin_unlock(&ls->ls_rsbtbl[bucket].lock); |
491 | error = 0; | 491 | error = 0; |
492 | out: | 492 | out: |
493 | *r_ret = r; | 493 | *r_ret = r; |
@@ -530,9 +530,9 @@ static void put_rsb(struct dlm_rsb *r) | |||
530 | struct dlm_ls *ls = r->res_ls; | 530 | struct dlm_ls *ls = r->res_ls; |
531 | uint32_t bucket = r->res_bucket; | 531 | uint32_t bucket = r->res_bucket; |
532 | 532 | ||
533 | write_lock(&ls->ls_rsbtbl[bucket].lock); | 533 | spin_lock(&ls->ls_rsbtbl[bucket].lock); |
534 | kref_put(&r->res_ref, toss_rsb); | 534 | kref_put(&r->res_ref, toss_rsb); |
535 | write_unlock(&ls->ls_rsbtbl[bucket].lock); | 535 | spin_unlock(&ls->ls_rsbtbl[bucket].lock); |
536 | } | 536 | } |
537 | 537 | ||
538 | void dlm_put_rsb(struct dlm_rsb *r) | 538 | void dlm_put_rsb(struct dlm_rsb *r) |
@@ -967,7 +967,7 @@ static int shrink_bucket(struct dlm_ls *ls, int b) | |||
967 | 967 | ||
968 | for (;;) { | 968 | for (;;) { |
969 | found = 0; | 969 | found = 0; |
970 | write_lock(&ls->ls_rsbtbl[b].lock); | 970 | spin_lock(&ls->ls_rsbtbl[b].lock); |
971 | list_for_each_entry_reverse(r, &ls->ls_rsbtbl[b].toss, | 971 | list_for_each_entry_reverse(r, &ls->ls_rsbtbl[b].toss, |
972 | res_hashchain) { | 972 | res_hashchain) { |
973 | if (!time_after_eq(jiffies, r->res_toss_time + | 973 | if (!time_after_eq(jiffies, r->res_toss_time + |
@@ -978,20 +978,20 @@ static int shrink_bucket(struct dlm_ls *ls, int b) | |||
978 | } | 978 | } |
979 | 979 | ||
980 | if (!found) { | 980 | if (!found) { |
981 | write_unlock(&ls->ls_rsbtbl[b].lock); | 981 | spin_unlock(&ls->ls_rsbtbl[b].lock); |
982 | break; | 982 | break; |
983 | } | 983 | } |
984 | 984 | ||
985 | if (kref_put(&r->res_ref, kill_rsb)) { | 985 | if (kref_put(&r->res_ref, kill_rsb)) { |
986 | list_del(&r->res_hashchain); | 986 | list_del(&r->res_hashchain); |
987 | write_unlock(&ls->ls_rsbtbl[b].lock); | 987 | spin_unlock(&ls->ls_rsbtbl[b].lock); |
988 | 988 | ||
989 | if (is_master(r)) | 989 | if (is_master(r)) |
990 | dir_remove(r); | 990 | dir_remove(r); |
991 | dlm_free_rsb(r); | 991 | dlm_free_rsb(r); |
992 | count++; | 992 | count++; |
993 | } else { | 993 | } else { |
994 | write_unlock(&ls->ls_rsbtbl[b].lock); | 994 | spin_unlock(&ls->ls_rsbtbl[b].lock); |
995 | log_error(ls, "tossed rsb in use %s", r->res_name); | 995 | log_error(ls, "tossed rsb in use %s", r->res_name); |
996 | } | 996 | } |
997 | } | 997 | } |
@@ -4224,7 +4224,7 @@ static struct dlm_rsb *find_purged_rsb(struct dlm_ls *ls, int bucket) | |||
4224 | { | 4224 | { |
4225 | struct dlm_rsb *r, *r_ret = NULL; | 4225 | struct dlm_rsb *r, *r_ret = NULL; |
4226 | 4226 | ||
4227 | read_lock(&ls->ls_rsbtbl[bucket].lock); | 4227 | spin_lock(&ls->ls_rsbtbl[bucket].lock); |
4228 | list_for_each_entry(r, &ls->ls_rsbtbl[bucket].list, res_hashchain) { | 4228 | list_for_each_entry(r, &ls->ls_rsbtbl[bucket].list, res_hashchain) { |
4229 | if (!rsb_flag(r, RSB_LOCKS_PURGED)) | 4229 | if (!rsb_flag(r, RSB_LOCKS_PURGED)) |
4230 | continue; | 4230 | continue; |
@@ -4233,7 +4233,7 @@ static struct dlm_rsb *find_purged_rsb(struct dlm_ls *ls, int bucket) | |||
4233 | r_ret = r; | 4233 | r_ret = r; |
4234 | break; | 4234 | break; |
4235 | } | 4235 | } |
4236 | read_unlock(&ls->ls_rsbtbl[bucket].lock); | 4236 | spin_unlock(&ls->ls_rsbtbl[bucket].lock); |
4237 | return r_ret; | 4237 | return r_ret; |
4238 | } | 4238 | } |
4239 | 4239 | ||
diff --git a/fs/dlm/lockspace.c b/fs/dlm/lockspace.c index 8d86b7960f0d..aa32e5f02493 100644 --- a/fs/dlm/lockspace.c +++ b/fs/dlm/lockspace.c | |||
@@ -464,7 +464,7 @@ static int new_lockspace(char *name, int namelen, void **lockspace, | |||
464 | for (i = 0; i < size; i++) { | 464 | for (i = 0; i < size; i++) { |
465 | INIT_LIST_HEAD(&ls->ls_rsbtbl[i].list); | 465 | INIT_LIST_HEAD(&ls->ls_rsbtbl[i].list); |
466 | INIT_LIST_HEAD(&ls->ls_rsbtbl[i].toss); | 466 | INIT_LIST_HEAD(&ls->ls_rsbtbl[i].toss); |
467 | rwlock_init(&ls->ls_rsbtbl[i].lock); | 467 | spin_lock_init(&ls->ls_rsbtbl[i].lock); |
468 | } | 468 | } |
469 | 469 | ||
470 | size = dlm_config.ci_lkbtbl_size; | 470 | size = dlm_config.ci_lkbtbl_size; |
diff --git a/fs/dlm/recover.c b/fs/dlm/recover.c index 80aba5bdd4a4..eda43f362616 100644 --- a/fs/dlm/recover.c +++ b/fs/dlm/recover.c | |||
@@ -726,7 +726,7 @@ int dlm_create_root_list(struct dlm_ls *ls) | |||
726 | } | 726 | } |
727 | 727 | ||
728 | for (i = 0; i < ls->ls_rsbtbl_size; i++) { | 728 | for (i = 0; i < ls->ls_rsbtbl_size; i++) { |
729 | read_lock(&ls->ls_rsbtbl[i].lock); | 729 | spin_lock(&ls->ls_rsbtbl[i].lock); |
730 | list_for_each_entry(r, &ls->ls_rsbtbl[i].list, res_hashchain) { | 730 | list_for_each_entry(r, &ls->ls_rsbtbl[i].list, res_hashchain) { |
731 | list_add(&r->res_root_list, &ls->ls_root_list); | 731 | list_add(&r->res_root_list, &ls->ls_root_list); |
732 | dlm_hold_rsb(r); | 732 | dlm_hold_rsb(r); |
@@ -737,7 +737,7 @@ int dlm_create_root_list(struct dlm_ls *ls) | |||
737 | but no other recovery steps should do anything with them. */ | 737 | but no other recovery steps should do anything with them. */ |
738 | 738 | ||
739 | if (dlm_no_directory(ls)) { | 739 | if (dlm_no_directory(ls)) { |
740 | read_unlock(&ls->ls_rsbtbl[i].lock); | 740 | spin_unlock(&ls->ls_rsbtbl[i].lock); |
741 | continue; | 741 | continue; |
742 | } | 742 | } |
743 | 743 | ||
@@ -745,7 +745,7 @@ int dlm_create_root_list(struct dlm_ls *ls) | |||
745 | list_add(&r->res_root_list, &ls->ls_root_list); | 745 | list_add(&r->res_root_list, &ls->ls_root_list); |
746 | dlm_hold_rsb(r); | 746 | dlm_hold_rsb(r); |
747 | } | 747 | } |
748 | read_unlock(&ls->ls_rsbtbl[i].lock); | 748 | spin_unlock(&ls->ls_rsbtbl[i].lock); |
749 | } | 749 | } |
750 | out: | 750 | out: |
751 | up_write(&ls->ls_root_sem); | 751 | up_write(&ls->ls_root_sem); |
@@ -775,7 +775,7 @@ void dlm_clear_toss_list(struct dlm_ls *ls) | |||
775 | int i; | 775 | int i; |
776 | 776 | ||
777 | for (i = 0; i < ls->ls_rsbtbl_size; i++) { | 777 | for (i = 0; i < ls->ls_rsbtbl_size; i++) { |
778 | write_lock(&ls->ls_rsbtbl[i].lock); | 778 | spin_lock(&ls->ls_rsbtbl[i].lock); |
779 | list_for_each_entry_safe(r, safe, &ls->ls_rsbtbl[i].toss, | 779 | list_for_each_entry_safe(r, safe, &ls->ls_rsbtbl[i].toss, |
780 | res_hashchain) { | 780 | res_hashchain) { |
781 | if (dlm_no_directory(ls) || !is_master(r)) { | 781 | if (dlm_no_directory(ls) || !is_master(r)) { |
@@ -783,7 +783,7 @@ void dlm_clear_toss_list(struct dlm_ls *ls) | |||
783 | dlm_free_rsb(r); | 783 | dlm_free_rsb(r); |
784 | } | 784 | } |
785 | } | 785 | } |
786 | write_unlock(&ls->ls_rsbtbl[i].lock); | 786 | spin_unlock(&ls->ls_rsbtbl[i].lock); |
787 | } | 787 | } |
788 | } | 788 | } |
789 | 789 | ||