diff options
Diffstat (limited to 'fs/reiserfs/fix_node.c')
-rw-r--r-- | fs/reiserfs/fix_node.c | 169 |
1 files changed, 84 insertions, 85 deletions
diff --git a/fs/reiserfs/fix_node.c b/fs/reiserfs/fix_node.c index 5236a8829e31..d97a55574ba9 100644 --- a/fs/reiserfs/fix_node.c +++ b/fs/reiserfs/fix_node.c | |||
@@ -780,9 +780,9 @@ static void free_buffers_in_tb(struct tree_balance *tb) | |||
780 | /* The function is NOT SCHEDULE-SAFE! */ | 780 | /* The function is NOT SCHEDULE-SAFE! */ |
781 | static int get_empty_nodes(struct tree_balance *tb, int n_h) | 781 | static int get_empty_nodes(struct tree_balance *tb, int n_h) |
782 | { | 782 | { |
783 | struct buffer_head *p_s_new_bh, | 783 | struct buffer_head *new_bh, |
784 | *p_s_Sh = PATH_H_PBUFFER(tb->tb_path, n_h); | 784 | *Sh = PATH_H_PBUFFER(tb->tb_path, n_h); |
785 | b_blocknr_t *p_n_blocknr, a_n_blocknrs[MAX_AMOUNT_NEEDED] = { 0, }; | 785 | b_blocknr_t *blocknr, a_n_blocknrs[MAX_AMOUNT_NEEDED] = { 0, }; |
786 | int n_counter, n_number_of_freeblk, n_amount_needed, /* number of needed empty blocks */ | 786 | int n_counter, n_number_of_freeblk, n_amount_needed, /* number of needed empty blocks */ |
787 | n_retval = CARRY_ON; | 787 | n_retval = CARRY_ON; |
788 | struct super_block *sb = tb->tb_sb; | 788 | struct super_block *sb = tb->tb_sb; |
@@ -810,8 +810,8 @@ static int get_empty_nodes(struct tree_balance *tb, int n_h) | |||
810 | 1) : 0; | 810 | 1) : 0; |
811 | 811 | ||
812 | /* Allocate missing empty blocks. */ | 812 | /* Allocate missing empty blocks. */ |
813 | /* if p_s_Sh == 0 then we are getting a new root */ | 813 | /* if Sh == 0 then we are getting a new root */ |
814 | n_amount_needed = (p_s_Sh) ? (tb->blknum[n_h] - 1) : 1; | 814 | n_amount_needed = (Sh) ? (tb->blknum[n_h] - 1) : 1; |
815 | /* Amount_needed = the amount that we need more than the amount that we have. */ | 815 | /* Amount_needed = the amount that we need more than the amount that we have. */ |
816 | if (n_amount_needed > n_number_of_freeblk) | 816 | if (n_amount_needed > n_number_of_freeblk) |
817 | n_amount_needed -= n_number_of_freeblk; | 817 | n_amount_needed -= n_number_of_freeblk; |
@@ -824,25 +824,25 @@ static int get_empty_nodes(struct tree_balance *tb, int n_h) | |||
824 | return NO_DISK_SPACE; | 824 | return NO_DISK_SPACE; |
825 | 825 | ||
826 | /* for each blocknumber we just got, get a buffer and stick it on FEB */ | 826 | /* for each blocknumber we just got, get a buffer and stick it on FEB */ |
827 | for (p_n_blocknr = a_n_blocknrs, n_counter = 0; | 827 | for (blocknr = a_n_blocknrs, n_counter = 0; |
828 | n_counter < n_amount_needed; p_n_blocknr++, n_counter++) { | 828 | n_counter < n_amount_needed; blocknr++, n_counter++) { |
829 | 829 | ||
830 | RFALSE(!*p_n_blocknr, | 830 | RFALSE(!*blocknr, |
831 | "PAP-8135: reiserfs_new_blocknrs failed when got new blocks"); | 831 | "PAP-8135: reiserfs_new_blocknrs failed when got new blocks"); |
832 | 832 | ||
833 | p_s_new_bh = sb_getblk(sb, *p_n_blocknr); | 833 | new_bh = sb_getblk(sb, *blocknr); |
834 | RFALSE(buffer_dirty(p_s_new_bh) || | 834 | RFALSE(buffer_dirty(new_bh) || |
835 | buffer_journaled(p_s_new_bh) || | 835 | buffer_journaled(new_bh) || |
836 | buffer_journal_dirty(p_s_new_bh), | 836 | buffer_journal_dirty(new_bh), |
837 | "PAP-8140: journlaled or dirty buffer %b for the new block", | 837 | "PAP-8140: journlaled or dirty buffer %b for the new block", |
838 | p_s_new_bh); | 838 | new_bh); |
839 | 839 | ||
840 | /* Put empty buffers into the array. */ | 840 | /* Put empty buffers into the array. */ |
841 | RFALSE(tb->FEB[tb->cur_blknum], | 841 | RFALSE(tb->FEB[tb->cur_blknum], |
842 | "PAP-8141: busy slot for new buffer"); | 842 | "PAP-8141: busy slot for new buffer"); |
843 | 843 | ||
844 | set_buffer_journal_new(p_s_new_bh); | 844 | set_buffer_journal_new(new_bh); |
845 | tb->FEB[tb->cur_blknum++] = p_s_new_bh; | 845 | tb->FEB[tb->cur_blknum++] = new_bh; |
846 | } | 846 | } |
847 | 847 | ||
848 | if (n_retval == CARRY_ON && FILESYSTEM_CHANGED_TB(tb)) | 848 | if (n_retval == CARRY_ON && FILESYSTEM_CHANGED_TB(tb)) |
@@ -898,7 +898,7 @@ static int get_rfree(struct tree_balance *tb, int h) | |||
898 | /* Check whether left neighbor is in memory. */ | 898 | /* Check whether left neighbor is in memory. */ |
899 | static int is_left_neighbor_in_cache(struct tree_balance *tb, int n_h) | 899 | static int is_left_neighbor_in_cache(struct tree_balance *tb, int n_h) |
900 | { | 900 | { |
901 | struct buffer_head *p_s_father, *left; | 901 | struct buffer_head *father, *left; |
902 | struct super_block *sb = tb->tb_sb; | 902 | struct super_block *sb = tb->tb_sb; |
903 | b_blocknr_t n_left_neighbor_blocknr; | 903 | b_blocknr_t n_left_neighbor_blocknr; |
904 | int n_left_neighbor_position; | 904 | int n_left_neighbor_position; |
@@ -908,18 +908,18 @@ static int is_left_neighbor_in_cache(struct tree_balance *tb, int n_h) | |||
908 | return 0; | 908 | return 0; |
909 | 909 | ||
910 | /* Calculate father of the node to be balanced. */ | 910 | /* Calculate father of the node to be balanced. */ |
911 | p_s_father = PATH_H_PBUFFER(tb->tb_path, n_h + 1); | 911 | father = PATH_H_PBUFFER(tb->tb_path, n_h + 1); |
912 | 912 | ||
913 | RFALSE(!p_s_father || | 913 | RFALSE(!father || |
914 | !B_IS_IN_TREE(p_s_father) || | 914 | !B_IS_IN_TREE(father) || |
915 | !B_IS_IN_TREE(tb->FL[n_h]) || | 915 | !B_IS_IN_TREE(tb->FL[n_h]) || |
916 | !buffer_uptodate(p_s_father) || | 916 | !buffer_uptodate(father) || |
917 | !buffer_uptodate(tb->FL[n_h]), | 917 | !buffer_uptodate(tb->FL[n_h]), |
918 | "vs-8165: F[h] (%b) or FL[h] (%b) is invalid", | 918 | "vs-8165: F[h] (%b) or FL[h] (%b) is invalid", |
919 | p_s_father, tb->FL[n_h]); | 919 | father, tb->FL[n_h]); |
920 | 920 | ||
921 | /* Get position of the pointer to the left neighbor into the left father. */ | 921 | /* Get position of the pointer to the left neighbor into the left father. */ |
922 | n_left_neighbor_position = (p_s_father == tb->FL[n_h]) ? | 922 | n_left_neighbor_position = (father == tb->FL[n_h]) ? |
923 | tb->lkey[n_h] : B_NR_ITEMS(tb->FL[n_h]); | 923 | tb->lkey[n_h] : B_NR_ITEMS(tb->FL[n_h]); |
924 | /* Get left neighbor block number. */ | 924 | /* Get left neighbor block number. */ |
925 | n_left_neighbor_blocknr = | 925 | n_left_neighbor_blocknr = |
@@ -940,10 +940,10 @@ static int is_left_neighbor_in_cache(struct tree_balance *tb, int n_h) | |||
940 | #define LEFT_PARENTS 'l' | 940 | #define LEFT_PARENTS 'l' |
941 | #define RIGHT_PARENTS 'r' | 941 | #define RIGHT_PARENTS 'r' |
942 | 942 | ||
943 | static void decrement_key(struct cpu_key *p_s_key) | 943 | static void decrement_key(struct cpu_key *key) |
944 | { | 944 | { |
945 | // call item specific function for this key | 945 | // call item specific function for this key |
946 | item_ops[cpu_key_k_type(p_s_key)]->decrement_key(p_s_key); | 946 | item_ops[cpu_key_k_type(key)]->decrement_key(key); |
947 | } | 947 | } |
948 | 948 | ||
949 | /* Calculate far left/right parent of the left/right neighbor of the current node, that | 949 | /* Calculate far left/right parent of the left/right neighbor of the current node, that |
@@ -956,17 +956,17 @@ static void decrement_key(struct cpu_key *p_s_key) | |||
956 | */ | 956 | */ |
957 | static int get_far_parent(struct tree_balance *tb, | 957 | static int get_far_parent(struct tree_balance *tb, |
958 | int n_h, | 958 | int n_h, |
959 | struct buffer_head **pp_s_father, | 959 | struct buffer_head **pfather, |
960 | struct buffer_head **pp_s_com_father, char c_lr_par) | 960 | struct buffer_head **pcom_father, char c_lr_par) |
961 | { | 961 | { |
962 | struct buffer_head *p_s_parent; | 962 | struct buffer_head *parent; |
963 | INITIALIZE_PATH(s_path_to_neighbor_father); | 963 | INITIALIZE_PATH(s_path_to_neighbor_father); |
964 | struct treepath *p_s_path = tb->tb_path; | 964 | struct treepath *path = tb->tb_path; |
965 | struct cpu_key s_lr_father_key; | 965 | struct cpu_key s_lr_father_key; |
966 | int n_counter, | 966 | int n_counter, |
967 | n_position = INT_MAX, | 967 | n_position = INT_MAX, |
968 | n_first_last_position = 0, | 968 | n_first_last_position = 0, |
969 | n_path_offset = PATH_H_PATH_OFFSET(p_s_path, n_h); | 969 | n_path_offset = PATH_H_PATH_OFFSET(path, n_h); |
970 | 970 | ||
971 | /* Starting from F[n_h] go upwards in the tree, and look for the common | 971 | /* Starting from F[n_h] go upwards in the tree, and look for the common |
972 | ancestor of F[n_h], and its neighbor l/r, that should be obtained. */ | 972 | ancestor of F[n_h], and its neighbor l/r, that should be obtained. */ |
@@ -979,25 +979,25 @@ static int get_far_parent(struct tree_balance *tb, | |||
979 | for (; n_counter > FIRST_PATH_ELEMENT_OFFSET; n_counter--) { | 979 | for (; n_counter > FIRST_PATH_ELEMENT_OFFSET; n_counter--) { |
980 | /* Check whether parent of the current buffer in the path is really parent in the tree. */ | 980 | /* Check whether parent of the current buffer in the path is really parent in the tree. */ |
981 | if (!B_IS_IN_TREE | 981 | if (!B_IS_IN_TREE |
982 | (p_s_parent = PATH_OFFSET_PBUFFER(p_s_path, n_counter - 1))) | 982 | (parent = PATH_OFFSET_PBUFFER(path, n_counter - 1))) |
983 | return REPEAT_SEARCH; | 983 | return REPEAT_SEARCH; |
984 | /* Check whether position in the parent is correct. */ | 984 | /* Check whether position in the parent is correct. */ |
985 | if ((n_position = | 985 | if ((n_position = |
986 | PATH_OFFSET_POSITION(p_s_path, | 986 | PATH_OFFSET_POSITION(path, |
987 | n_counter - 1)) > | 987 | n_counter - 1)) > |
988 | B_NR_ITEMS(p_s_parent)) | 988 | B_NR_ITEMS(parent)) |
989 | return REPEAT_SEARCH; | 989 | return REPEAT_SEARCH; |
990 | /* Check whether parent at the path really points to the child. */ | 990 | /* Check whether parent at the path really points to the child. */ |
991 | if (B_N_CHILD_NUM(p_s_parent, n_position) != | 991 | if (B_N_CHILD_NUM(parent, n_position) != |
992 | PATH_OFFSET_PBUFFER(p_s_path, n_counter)->b_blocknr) | 992 | PATH_OFFSET_PBUFFER(path, n_counter)->b_blocknr) |
993 | return REPEAT_SEARCH; | 993 | return REPEAT_SEARCH; |
994 | /* Return delimiting key if position in the parent is not equal to first/last one. */ | 994 | /* Return delimiting key if position in the parent is not equal to first/last one. */ |
995 | if (c_lr_par == RIGHT_PARENTS) | 995 | if (c_lr_par == RIGHT_PARENTS) |
996 | n_first_last_position = B_NR_ITEMS(p_s_parent); | 996 | n_first_last_position = B_NR_ITEMS(parent); |
997 | if (n_position != n_first_last_position) { | 997 | if (n_position != n_first_last_position) { |
998 | *pp_s_com_father = p_s_parent; | 998 | *pcom_father = parent; |
999 | get_bh(*pp_s_com_father); | 999 | get_bh(*pcom_father); |
1000 | /*(*pp_s_com_father = p_s_parent)->b_count++; */ | 1000 | /*(*pcom_father = parent)->b_count++; */ |
1001 | break; | 1001 | break; |
1002 | } | 1002 | } |
1003 | } | 1003 | } |
@@ -1009,22 +1009,22 @@ static int get_far_parent(struct tree_balance *tb, | |||
1009 | (tb->tb_path, | 1009 | (tb->tb_path, |
1010 | FIRST_PATH_ELEMENT_OFFSET)->b_blocknr == | 1010 | FIRST_PATH_ELEMENT_OFFSET)->b_blocknr == |
1011 | SB_ROOT_BLOCK(tb->tb_sb)) { | 1011 | SB_ROOT_BLOCK(tb->tb_sb)) { |
1012 | *pp_s_father = *pp_s_com_father = NULL; | 1012 | *pfather = *pcom_father = NULL; |
1013 | return CARRY_ON; | 1013 | return CARRY_ON; |
1014 | } | 1014 | } |
1015 | return REPEAT_SEARCH; | 1015 | return REPEAT_SEARCH; |
1016 | } | 1016 | } |
1017 | 1017 | ||
1018 | RFALSE(B_LEVEL(*pp_s_com_father) <= DISK_LEAF_NODE_LEVEL, | 1018 | RFALSE(B_LEVEL(*pcom_father) <= DISK_LEAF_NODE_LEVEL, |
1019 | "PAP-8185: (%b %z) level too small", | 1019 | "PAP-8185: (%b %z) level too small", |
1020 | *pp_s_com_father, *pp_s_com_father); | 1020 | *pcom_father, *pcom_father); |
1021 | 1021 | ||
1022 | /* Check whether the common parent is locked. */ | 1022 | /* Check whether the common parent is locked. */ |
1023 | 1023 | ||
1024 | if (buffer_locked(*pp_s_com_father)) { | 1024 | if (buffer_locked(*pcom_father)) { |
1025 | __wait_on_buffer(*pp_s_com_father); | 1025 | __wait_on_buffer(*pcom_father); |
1026 | if (FILESYSTEM_CHANGED_TB(tb)) { | 1026 | if (FILESYSTEM_CHANGED_TB(tb)) { |
1027 | brelse(*pp_s_com_father); | 1027 | brelse(*pcom_father); |
1028 | return REPEAT_SEARCH; | 1028 | return REPEAT_SEARCH; |
1029 | } | 1029 | } |
1030 | } | 1030 | } |
@@ -1034,7 +1034,7 @@ static int get_far_parent(struct tree_balance *tb, | |||
1034 | 1034 | ||
1035 | /* Form key to get parent of the left/right neighbor. */ | 1035 | /* Form key to get parent of the left/right neighbor. */ |
1036 | le_key2cpu_key(&s_lr_father_key, | 1036 | le_key2cpu_key(&s_lr_father_key, |
1037 | B_N_PDELIM_KEY(*pp_s_com_father, | 1037 | B_N_PDELIM_KEY(*pcom_father, |
1038 | (c_lr_par == | 1038 | (c_lr_par == |
1039 | LEFT_PARENTS) ? (tb->lkey[n_h - 1] = | 1039 | LEFT_PARENTS) ? (tb->lkey[n_h - 1] = |
1040 | n_position - | 1040 | n_position - |
@@ -1053,14 +1053,14 @@ static int get_far_parent(struct tree_balance *tb, | |||
1053 | 1053 | ||
1054 | if (FILESYSTEM_CHANGED_TB(tb)) { | 1054 | if (FILESYSTEM_CHANGED_TB(tb)) { |
1055 | pathrelse(&s_path_to_neighbor_father); | 1055 | pathrelse(&s_path_to_neighbor_father); |
1056 | brelse(*pp_s_com_father); | 1056 | brelse(*pcom_father); |
1057 | return REPEAT_SEARCH; | 1057 | return REPEAT_SEARCH; |
1058 | } | 1058 | } |
1059 | 1059 | ||
1060 | *pp_s_father = PATH_PLAST_BUFFER(&s_path_to_neighbor_father); | 1060 | *pfather = PATH_PLAST_BUFFER(&s_path_to_neighbor_father); |
1061 | 1061 | ||
1062 | RFALSE(B_LEVEL(*pp_s_father) != n_h + 1, | 1062 | RFALSE(B_LEVEL(*pfather) != n_h + 1, |
1063 | "PAP-8190: (%b %z) level too small", *pp_s_father, *pp_s_father); | 1063 | "PAP-8190: (%b %z) level too small", *pfather, *pfather); |
1064 | RFALSE(s_path_to_neighbor_father.path_length < | 1064 | RFALSE(s_path_to_neighbor_father.path_length < |
1065 | FIRST_PATH_ELEMENT_OFFSET, "PAP-8192: path length is too small"); | 1065 | FIRST_PATH_ELEMENT_OFFSET, "PAP-8192: path length is too small"); |
1066 | 1066 | ||
@@ -1078,11 +1078,11 @@ static int get_far_parent(struct tree_balance *tb, | |||
1078 | */ | 1078 | */ |
1079 | static int get_parents(struct tree_balance *tb, int n_h) | 1079 | static int get_parents(struct tree_balance *tb, int n_h) |
1080 | { | 1080 | { |
1081 | struct treepath *p_s_path = tb->tb_path; | 1081 | struct treepath *path = tb->tb_path; |
1082 | int n_position, | 1082 | int n_position, |
1083 | n_ret_value, | 1083 | n_ret_value, |
1084 | n_path_offset = PATH_H_PATH_OFFSET(tb->tb_path, n_h); | 1084 | n_path_offset = PATH_H_PATH_OFFSET(tb->tb_path, n_h); |
1085 | struct buffer_head *p_s_curf, *p_s_curcf; | 1085 | struct buffer_head *curf, *curcf; |
1086 | 1086 | ||
1087 | /* Current node is the root of the tree or will be root of the tree */ | 1087 | /* Current node is the root of the tree or will be root of the tree */ |
1088 | if (n_path_offset <= FIRST_PATH_ELEMENT_OFFSET) { | 1088 | if (n_path_offset <= FIRST_PATH_ELEMENT_OFFSET) { |
@@ -1100,66 +1100,65 @@ static int get_parents(struct tree_balance *tb, int n_h) | |||
1100 | } | 1100 | } |
1101 | 1101 | ||
1102 | /* Get parent FL[n_path_offset] of L[n_path_offset]. */ | 1102 | /* Get parent FL[n_path_offset] of L[n_path_offset]. */ |
1103 | if ((n_position = PATH_OFFSET_POSITION(p_s_path, n_path_offset - 1))) { | 1103 | n_position = PATH_OFFSET_POSITION(path, n_path_offset - 1); |
1104 | if (n_position) { | ||
1104 | /* Current node is not the first child of its parent. */ | 1105 | /* Current node is not the first child of its parent. */ |
1105 | /*(p_s_curf = p_s_curcf = PATH_OFFSET_PBUFFER(p_s_path, n_path_offset - 1))->b_count += 2; */ | 1106 | curf = PATH_OFFSET_PBUFFER(path, n_path_offset - 1); |
1106 | p_s_curf = p_s_curcf = | 1107 | curcf = PATH_OFFSET_PBUFFER(path, n_path_offset - 1); |
1107 | PATH_OFFSET_PBUFFER(p_s_path, n_path_offset - 1); | 1108 | get_bh(curf); |
1108 | get_bh(p_s_curf); | 1109 | get_bh(curf); |
1109 | get_bh(p_s_curf); | ||
1110 | tb->lkey[n_h] = n_position - 1; | 1110 | tb->lkey[n_h] = n_position - 1; |
1111 | } else { | 1111 | } else { |
1112 | /* Calculate current parent of L[n_path_offset], which is the left neighbor of the current node. | 1112 | /* Calculate current parent of L[n_path_offset], which is the left neighbor of the current node. |
1113 | Calculate current common parent of L[n_path_offset] and the current node. Note that | 1113 | Calculate current common parent of L[n_path_offset] and the current node. Note that |
1114 | CFL[n_path_offset] not equal FL[n_path_offset] and CFL[n_path_offset] not equal F[n_path_offset]. | 1114 | CFL[n_path_offset] not equal FL[n_path_offset] and CFL[n_path_offset] not equal F[n_path_offset]. |
1115 | Calculate lkey[n_path_offset]. */ | 1115 | Calculate lkey[n_path_offset]. */ |
1116 | if ((n_ret_value = get_far_parent(tb, n_h + 1, &p_s_curf, | 1116 | if ((n_ret_value = get_far_parent(tb, n_h + 1, &curf, |
1117 | &p_s_curcf, | 1117 | &curcf, |
1118 | LEFT_PARENTS)) != CARRY_ON) | 1118 | LEFT_PARENTS)) != CARRY_ON) |
1119 | return n_ret_value; | 1119 | return n_ret_value; |
1120 | } | 1120 | } |
1121 | 1121 | ||
1122 | brelse(tb->FL[n_h]); | 1122 | brelse(tb->FL[n_h]); |
1123 | tb->FL[n_h] = p_s_curf; /* New initialization of FL[n_h]. */ | 1123 | tb->FL[n_h] = curf; /* New initialization of FL[n_h]. */ |
1124 | brelse(tb->CFL[n_h]); | 1124 | brelse(tb->CFL[n_h]); |
1125 | tb->CFL[n_h] = p_s_curcf; /* New initialization of CFL[n_h]. */ | 1125 | tb->CFL[n_h] = curcf; /* New initialization of CFL[n_h]. */ |
1126 | 1126 | ||
1127 | RFALSE((p_s_curf && !B_IS_IN_TREE(p_s_curf)) || | 1127 | RFALSE((curf && !B_IS_IN_TREE(curf)) || |
1128 | (p_s_curcf && !B_IS_IN_TREE(p_s_curcf)), | 1128 | (curcf && !B_IS_IN_TREE(curcf)), |
1129 | "PAP-8195: FL (%b) or CFL (%b) is invalid", p_s_curf, p_s_curcf); | 1129 | "PAP-8195: FL (%b) or CFL (%b) is invalid", curf, curcf); |
1130 | 1130 | ||
1131 | /* Get parent FR[n_h] of R[n_h]. */ | 1131 | /* Get parent FR[n_h] of R[n_h]. */ |
1132 | 1132 | ||
1133 | /* Current node is the last child of F[n_h]. FR[n_h] != F[n_h]. */ | 1133 | /* Current node is the last child of F[n_h]. FR[n_h] != F[n_h]. */ |
1134 | if (n_position == B_NR_ITEMS(PATH_H_PBUFFER(p_s_path, n_h + 1))) { | 1134 | if (n_position == B_NR_ITEMS(PATH_H_PBUFFER(path, n_h + 1))) { |
1135 | /* Calculate current parent of R[n_h], which is the right neighbor of F[n_h]. | 1135 | /* Calculate current parent of R[n_h], which is the right neighbor of F[n_h]. |
1136 | Calculate current common parent of R[n_h] and current node. Note that CFR[n_h] | 1136 | Calculate current common parent of R[n_h] and current node. Note that CFR[n_h] |
1137 | not equal FR[n_path_offset] and CFR[n_h] not equal F[n_h]. */ | 1137 | not equal FR[n_path_offset] and CFR[n_h] not equal F[n_h]. */ |
1138 | if ((n_ret_value = | 1138 | if ((n_ret_value = |
1139 | get_far_parent(tb, n_h + 1, &p_s_curf, &p_s_curcf, | 1139 | get_far_parent(tb, n_h + 1, &curf, &curcf, |
1140 | RIGHT_PARENTS)) != CARRY_ON) | 1140 | RIGHT_PARENTS)) != CARRY_ON) |
1141 | return n_ret_value; | 1141 | return n_ret_value; |
1142 | } else { | 1142 | } else { |
1143 | /* Current node is not the last child of its parent F[n_h]. */ | 1143 | /* Current node is not the last child of its parent F[n_h]. */ |
1144 | /*(p_s_curf = p_s_curcf = PATH_OFFSET_PBUFFER(p_s_path, n_path_offset - 1))->b_count += 2; */ | 1144 | curf = PATH_OFFSET_PBUFFER(path, n_path_offset - 1); |
1145 | p_s_curf = p_s_curcf = | 1145 | curcf = PATH_OFFSET_PBUFFER(path, n_path_offset - 1); |
1146 | PATH_OFFSET_PBUFFER(p_s_path, n_path_offset - 1); | 1146 | get_bh(curf); |
1147 | get_bh(p_s_curf); | 1147 | get_bh(curf); |
1148 | get_bh(p_s_curf); | ||
1149 | tb->rkey[n_h] = n_position; | 1148 | tb->rkey[n_h] = n_position; |
1150 | } | 1149 | } |
1151 | 1150 | ||
1152 | brelse(tb->FR[n_h]); | 1151 | brelse(tb->FR[n_h]); |
1153 | /* New initialization of FR[n_path_offset]. */ | 1152 | /* New initialization of FR[n_path_offset]. */ |
1154 | tb->FR[n_h] = p_s_curf; | 1153 | tb->FR[n_h] = curf; |
1155 | 1154 | ||
1156 | brelse(tb->CFR[n_h]); | 1155 | brelse(tb->CFR[n_h]); |
1157 | /* New initialization of CFR[n_path_offset]. */ | 1156 | /* New initialization of CFR[n_path_offset]. */ |
1158 | tb->CFR[n_h] = p_s_curcf; | 1157 | tb->CFR[n_h] = curcf; |
1159 | 1158 | ||
1160 | RFALSE((p_s_curf && !B_IS_IN_TREE(p_s_curf)) || | 1159 | RFALSE((curf && !B_IS_IN_TREE(curf)) || |
1161 | (p_s_curcf && !B_IS_IN_TREE(p_s_curcf)), | 1160 | (curcf && !B_IS_IN_TREE(curcf)), |
1162 | "PAP-8205: FR (%b) or CFR (%b) is invalid", p_s_curf, p_s_curcf); | 1161 | "PAP-8205: FR (%b) or CFR (%b) is invalid", curf, curcf); |
1163 | 1162 | ||
1164 | return CARRY_ON; | 1163 | return CARRY_ON; |
1165 | } | 1164 | } |
@@ -1893,7 +1892,7 @@ static int check_balance(int mode, | |||
1893 | static int get_direct_parent(struct tree_balance *tb, int n_h) | 1892 | static int get_direct_parent(struct tree_balance *tb, int n_h) |
1894 | { | 1893 | { |
1895 | struct buffer_head *bh; | 1894 | struct buffer_head *bh; |
1896 | struct treepath *p_s_path = tb->tb_path; | 1895 | struct treepath *path = tb->tb_path; |
1897 | int n_position, | 1896 | int n_position, |
1898 | n_path_offset = PATH_H_PATH_OFFSET(tb->tb_path, n_h); | 1897 | n_path_offset = PATH_H_PATH_OFFSET(tb->tb_path, n_h); |
1899 | 1898 | ||
@@ -1903,27 +1902,27 @@ static int get_direct_parent(struct tree_balance *tb, int n_h) | |||
1903 | RFALSE(n_path_offset < FIRST_PATH_ELEMENT_OFFSET - 1, | 1902 | RFALSE(n_path_offset < FIRST_PATH_ELEMENT_OFFSET - 1, |
1904 | "PAP-8260: invalid offset in the path"); | 1903 | "PAP-8260: invalid offset in the path"); |
1905 | 1904 | ||
1906 | if (PATH_OFFSET_PBUFFER(p_s_path, FIRST_PATH_ELEMENT_OFFSET)-> | 1905 | if (PATH_OFFSET_PBUFFER(path, FIRST_PATH_ELEMENT_OFFSET)-> |
1907 | b_blocknr == SB_ROOT_BLOCK(tb->tb_sb)) { | 1906 | b_blocknr == SB_ROOT_BLOCK(tb->tb_sb)) { |
1908 | /* Root is not changed. */ | 1907 | /* Root is not changed. */ |
1909 | PATH_OFFSET_PBUFFER(p_s_path, n_path_offset - 1) = NULL; | 1908 | PATH_OFFSET_PBUFFER(path, n_path_offset - 1) = NULL; |
1910 | PATH_OFFSET_POSITION(p_s_path, n_path_offset - 1) = 0; | 1909 | PATH_OFFSET_POSITION(path, n_path_offset - 1) = 0; |
1911 | return CARRY_ON; | 1910 | return CARRY_ON; |
1912 | } | 1911 | } |
1913 | return REPEAT_SEARCH; /* Root is changed and we must recalculate the path. */ | 1912 | return REPEAT_SEARCH; /* Root is changed and we must recalculate the path. */ |
1914 | } | 1913 | } |
1915 | 1914 | ||
1916 | if (!B_IS_IN_TREE | 1915 | if (!B_IS_IN_TREE |
1917 | (bh = PATH_OFFSET_PBUFFER(p_s_path, n_path_offset - 1))) | 1916 | (bh = PATH_OFFSET_PBUFFER(path, n_path_offset - 1))) |
1918 | return REPEAT_SEARCH; /* Parent in the path is not in the tree. */ | 1917 | return REPEAT_SEARCH; /* Parent in the path is not in the tree. */ |
1919 | 1918 | ||
1920 | if ((n_position = | 1919 | if ((n_position = |
1921 | PATH_OFFSET_POSITION(p_s_path, | 1920 | PATH_OFFSET_POSITION(path, |
1922 | n_path_offset - 1)) > B_NR_ITEMS(bh)) | 1921 | n_path_offset - 1)) > B_NR_ITEMS(bh)) |
1923 | return REPEAT_SEARCH; | 1922 | return REPEAT_SEARCH; |
1924 | 1923 | ||
1925 | if (B_N_CHILD_NUM(bh, n_position) != | 1924 | if (B_N_CHILD_NUM(bh, n_position) != |
1926 | PATH_OFFSET_PBUFFER(p_s_path, n_path_offset)->b_blocknr) | 1925 | PATH_OFFSET_PBUFFER(path, n_path_offset)->b_blocknr) |
1927 | /* Parent in the path is not parent of the current node in the tree. */ | 1926 | /* Parent in the path is not parent of the current node in the tree. */ |
1928 | return REPEAT_SEARCH; | 1927 | return REPEAT_SEARCH; |
1929 | 1928 | ||
@@ -2319,7 +2318,7 @@ static int wait_tb_buffers_until_unlocked(struct tree_balance *tb) | |||
2319 | */ | 2318 | */ |
2320 | 2319 | ||
2321 | int fix_nodes(int n_op_mode, struct tree_balance *tb, | 2320 | int fix_nodes(int n_op_mode, struct tree_balance *tb, |
2322 | struct item_head *p_s_ins_ih, const void *data) | 2321 | struct item_head *ins_ih, const void *data) |
2323 | { | 2322 | { |
2324 | int n_ret_value, n_h, n_item_num = PATH_LAST_POSITION(tb->tb_path); | 2323 | int n_ret_value, n_h, n_item_num = PATH_LAST_POSITION(tb->tb_path); |
2325 | int n_pos_in_item; | 2324 | int n_pos_in_item; |
@@ -2405,7 +2404,7 @@ int fix_nodes(int n_op_mode, struct tree_balance *tb, | |||
2405 | goto repeat; | 2404 | goto repeat; |
2406 | 2405 | ||
2407 | n_ret_value = check_balance(n_op_mode, tb, n_h, n_item_num, | 2406 | n_ret_value = check_balance(n_op_mode, tb, n_h, n_item_num, |
2408 | n_pos_in_item, p_s_ins_ih, data); | 2407 | n_pos_in_item, ins_ih, data); |
2409 | if (n_ret_value != CARRY_ON) { | 2408 | if (n_ret_value != CARRY_ON) { |
2410 | if (n_ret_value == NO_BALANCING_NEEDED) { | 2409 | if (n_ret_value == NO_BALANCING_NEEDED) { |
2411 | /* No balancing for higher levels needed. */ | 2410 | /* No balancing for higher levels needed. */ |