aboutsummaryrefslogtreecommitdiffstats
path: root/fs/gfs2/lock_dlm.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/gfs2/lock_dlm.c')
-rw-r--r--fs/gfs2/lock_dlm.c39
1 files changed, 20 insertions, 19 deletions
diff --git a/fs/gfs2/lock_dlm.c b/fs/gfs2/lock_dlm.c
index 9802de0f85e6..c8423d6de6c3 100644
--- a/fs/gfs2/lock_dlm.c
+++ b/fs/gfs2/lock_dlm.c
@@ -483,12 +483,8 @@ static void control_lvb_write(struct lm_lockstruct *ls, uint32_t lvb_gen,
483 483
484static int all_jid_bits_clear(char *lvb) 484static int all_jid_bits_clear(char *lvb)
485{ 485{
486 int i; 486 return !memchr_inv(lvb + JID_BITMAP_OFFSET, 0,
487 for (i = JID_BITMAP_OFFSET; i < GDLM_LVB_SIZE; i++) { 487 GDLM_LVB_SIZE - JID_BITMAP_OFFSET);
488 if (lvb[i])
489 return 0;
490 }
491 return 1;
492} 488}
493 489
494static void sync_wait_cb(void *arg) 490static void sync_wait_cb(void *arg)
@@ -580,7 +576,6 @@ static void gfs2_control_func(struct work_struct *work)
580{ 576{
581 struct gfs2_sbd *sdp = container_of(work, struct gfs2_sbd, sd_control_work.work); 577 struct gfs2_sbd *sdp = container_of(work, struct gfs2_sbd, sd_control_work.work);
582 struct lm_lockstruct *ls = &sdp->sd_lockstruct; 578 struct lm_lockstruct *ls = &sdp->sd_lockstruct;
583 char lvb_bits[GDLM_LVB_SIZE];
584 uint32_t block_gen, start_gen, lvb_gen, flags; 579 uint32_t block_gen, start_gen, lvb_gen, flags;
585 int recover_set = 0; 580 int recover_set = 0;
586 int write_lvb = 0; 581 int write_lvb = 0;
@@ -634,7 +629,7 @@ static void gfs2_control_func(struct work_struct *work)
634 return; 629 return;
635 } 630 }
636 631
637 control_lvb_read(ls, &lvb_gen, lvb_bits); 632 control_lvb_read(ls, &lvb_gen, ls->ls_lvb_bits);
638 633
639 spin_lock(&ls->ls_recover_spin); 634 spin_lock(&ls->ls_recover_spin);
640 if (block_gen != ls->ls_recover_block || 635 if (block_gen != ls->ls_recover_block ||
@@ -664,10 +659,10 @@ static void gfs2_control_func(struct work_struct *work)
664 659
665 ls->ls_recover_result[i] = 0; 660 ls->ls_recover_result[i] = 0;
666 661
667 if (!test_bit_le(i, lvb_bits + JID_BITMAP_OFFSET)) 662 if (!test_bit_le(i, ls->ls_lvb_bits + JID_BITMAP_OFFSET))
668 continue; 663 continue;
669 664
670 __clear_bit_le(i, lvb_bits + JID_BITMAP_OFFSET); 665 __clear_bit_le(i, ls->ls_lvb_bits + JID_BITMAP_OFFSET);
671 write_lvb = 1; 666 write_lvb = 1;
672 } 667 }
673 } 668 }
@@ -691,7 +686,7 @@ static void gfs2_control_func(struct work_struct *work)
691 continue; 686 continue;
692 if (ls->ls_recover_submit[i] < start_gen) { 687 if (ls->ls_recover_submit[i] < start_gen) {
693 ls->ls_recover_submit[i] = 0; 688 ls->ls_recover_submit[i] = 0;
694 __set_bit_le(i, lvb_bits + JID_BITMAP_OFFSET); 689 __set_bit_le(i, ls->ls_lvb_bits + JID_BITMAP_OFFSET);
695 } 690 }
696 } 691 }
697 /* even if there are no bits to set, we need to write the 692 /* even if there are no bits to set, we need to write the
@@ -705,7 +700,7 @@ static void gfs2_control_func(struct work_struct *work)
705 spin_unlock(&ls->ls_recover_spin); 700 spin_unlock(&ls->ls_recover_spin);
706 701
707 if (write_lvb) { 702 if (write_lvb) {
708 control_lvb_write(ls, start_gen, lvb_bits); 703 control_lvb_write(ls, start_gen, ls->ls_lvb_bits);
709 flags = DLM_LKF_CONVERT | DLM_LKF_VALBLK; 704 flags = DLM_LKF_CONVERT | DLM_LKF_VALBLK;
710 } else { 705 } else {
711 flags = DLM_LKF_CONVERT; 706 flags = DLM_LKF_CONVERT;
@@ -725,7 +720,7 @@ static void gfs2_control_func(struct work_struct *work)
725 */ 720 */
726 721
727 for (i = 0; i < recover_size; i++) { 722 for (i = 0; i < recover_size; i++) {
728 if (test_bit_le(i, lvb_bits + JID_BITMAP_OFFSET)) { 723 if (test_bit_le(i, ls->ls_lvb_bits + JID_BITMAP_OFFSET)) {
729 fs_info(sdp, "recover generation %u jid %d\n", 724 fs_info(sdp, "recover generation %u jid %d\n",
730 start_gen, i); 725 start_gen, i);
731 gfs2_recover_set(sdp, i); 726 gfs2_recover_set(sdp, i);
@@ -758,7 +753,6 @@ static void gfs2_control_func(struct work_struct *work)
758static int control_mount(struct gfs2_sbd *sdp) 753static int control_mount(struct gfs2_sbd *sdp)
759{ 754{
760 struct lm_lockstruct *ls = &sdp->sd_lockstruct; 755 struct lm_lockstruct *ls = &sdp->sd_lockstruct;
761 char lvb_bits[GDLM_LVB_SIZE];
762 uint32_t start_gen, block_gen, mount_gen, lvb_gen; 756 uint32_t start_gen, block_gen, mount_gen, lvb_gen;
763 int mounted_mode; 757 int mounted_mode;
764 int retries = 0; 758 int retries = 0;
@@ -857,7 +851,7 @@ locks_done:
857 * lvb_gen will be non-zero. 851 * lvb_gen will be non-zero.
858 */ 852 */
859 853
860 control_lvb_read(ls, &lvb_gen, lvb_bits); 854 control_lvb_read(ls, &lvb_gen, ls->ls_lvb_bits);
861 855
862 if (lvb_gen == 0xFFFFFFFF) { 856 if (lvb_gen == 0xFFFFFFFF) {
863 /* special value to force mount attempts to fail */ 857 /* special value to force mount attempts to fail */
@@ -887,7 +881,7 @@ locks_done:
887 * and all lvb bits to be clear (no pending journal recoveries.) 881 * and all lvb bits to be clear (no pending journal recoveries.)
888 */ 882 */
889 883
890 if (!all_jid_bits_clear(lvb_bits)) { 884 if (!all_jid_bits_clear(ls->ls_lvb_bits)) {
891 /* journals need recovery, wait until all are clear */ 885 /* journals need recovery, wait until all are clear */
892 fs_info(sdp, "control_mount wait for journal recovery\n"); 886 fs_info(sdp, "control_mount wait for journal recovery\n");
893 goto restart; 887 goto restart;
@@ -949,7 +943,6 @@ static int dlm_recovery_wait(void *word)
949static int control_first_done(struct gfs2_sbd *sdp) 943static int control_first_done(struct gfs2_sbd *sdp)
950{ 944{
951 struct lm_lockstruct *ls = &sdp->sd_lockstruct; 945 struct lm_lockstruct *ls = &sdp->sd_lockstruct;
952 char lvb_bits[GDLM_LVB_SIZE];
953 uint32_t start_gen, block_gen; 946 uint32_t start_gen, block_gen;
954 int error; 947 int error;
955 948
@@ -991,8 +984,8 @@ restart:
991 memset(ls->ls_recover_result, 0, ls->ls_recover_size*sizeof(uint32_t)); 984 memset(ls->ls_recover_result, 0, ls->ls_recover_size*sizeof(uint32_t));
992 spin_unlock(&ls->ls_recover_spin); 985 spin_unlock(&ls->ls_recover_spin);
993 986
994 memset(lvb_bits, 0, sizeof(lvb_bits)); 987 memset(ls->ls_lvb_bits, 0, GDLM_LVB_SIZE);
995 control_lvb_write(ls, start_gen, lvb_bits); 988 control_lvb_write(ls, start_gen, ls->ls_lvb_bits);
996 989
997 error = mounted_lock(sdp, DLM_LOCK_PR, DLM_LKF_CONVERT); 990 error = mounted_lock(sdp, DLM_LOCK_PR, DLM_LKF_CONVERT);
998 if (error) 991 if (error)
@@ -1022,6 +1015,12 @@ static int set_recover_size(struct gfs2_sbd *sdp, struct dlm_slot *slots,
1022 uint32_t old_size, new_size; 1015 uint32_t old_size, new_size;
1023 int i, max_jid; 1016 int i, max_jid;
1024 1017
1018 if (!ls->ls_lvb_bits) {
1019 ls->ls_lvb_bits = kzalloc(GDLM_LVB_SIZE, GFP_NOFS);
1020 if (!ls->ls_lvb_bits)
1021 return -ENOMEM;
1022 }
1023
1025 max_jid = 0; 1024 max_jid = 0;
1026 for (i = 0; i < num_slots; i++) { 1025 for (i = 0; i < num_slots; i++) {
1027 if (max_jid < slots[i].slot - 1) 1026 if (max_jid < slots[i].slot - 1)
@@ -1057,6 +1056,7 @@ static int set_recover_size(struct gfs2_sbd *sdp, struct dlm_slot *slots,
1057 1056
1058static void free_recover_size(struct lm_lockstruct *ls) 1057static void free_recover_size(struct lm_lockstruct *ls)
1059{ 1058{
1059 kfree(ls->ls_lvb_bits);
1060 kfree(ls->ls_recover_submit); 1060 kfree(ls->ls_recover_submit);
1061 kfree(ls->ls_recover_result); 1061 kfree(ls->ls_recover_result);
1062 ls->ls_recover_submit = NULL; 1062 ls->ls_recover_submit = NULL;
@@ -1205,6 +1205,7 @@ static int gdlm_mount(struct gfs2_sbd *sdp, const char *table)
1205 ls->ls_recover_size = 0; 1205 ls->ls_recover_size = 0;
1206 ls->ls_recover_submit = NULL; 1206 ls->ls_recover_submit = NULL;
1207 ls->ls_recover_result = NULL; 1207 ls->ls_recover_result = NULL;
1208 ls->ls_lvb_bits = NULL;
1208 1209
1209 error = set_recover_size(sdp, NULL, 0); 1210 error = set_recover_size(sdp, NULL, 0);
1210 if (error) 1211 if (error)