diff options
Diffstat (limited to 'fs')
-rw-r--r-- | fs/reiserfs/fix_node.c | 482 | ||||
-rw-r--r-- | fs/reiserfs/stree.c | 21 |
2 files changed, 253 insertions, 250 deletions
diff --git a/fs/reiserfs/fix_node.c b/fs/reiserfs/fix_node.c index ad42c45af44f..5236a8829e31 100644 --- a/fs/reiserfs/fix_node.c +++ b/fs/reiserfs/fix_node.c | |||
@@ -749,26 +749,26 @@ else \ | |||
749 | -1, -1);\ | 749 | -1, -1);\ |
750 | } | 750 | } |
751 | 751 | ||
752 | static void free_buffers_in_tb(struct tree_balance *p_s_tb) | 752 | static void free_buffers_in_tb(struct tree_balance *tb) |
753 | { | 753 | { |
754 | int n_counter; | 754 | int n_counter; |
755 | 755 | ||
756 | pathrelse(p_s_tb->tb_path); | 756 | pathrelse(tb->tb_path); |
757 | 757 | ||
758 | for (n_counter = 0; n_counter < MAX_HEIGHT; n_counter++) { | 758 | for (n_counter = 0; n_counter < MAX_HEIGHT; n_counter++) { |
759 | brelse(p_s_tb->L[n_counter]); | 759 | brelse(tb->L[n_counter]); |
760 | brelse(p_s_tb->R[n_counter]); | 760 | brelse(tb->R[n_counter]); |
761 | brelse(p_s_tb->FL[n_counter]); | 761 | brelse(tb->FL[n_counter]); |
762 | brelse(p_s_tb->FR[n_counter]); | 762 | brelse(tb->FR[n_counter]); |
763 | brelse(p_s_tb->CFL[n_counter]); | 763 | brelse(tb->CFL[n_counter]); |
764 | brelse(p_s_tb->CFR[n_counter]); | 764 | brelse(tb->CFR[n_counter]); |
765 | 765 | ||
766 | p_s_tb->L[n_counter] = NULL; | 766 | tb->L[n_counter] = NULL; |
767 | p_s_tb->R[n_counter] = NULL; | 767 | tb->R[n_counter] = NULL; |
768 | p_s_tb->FL[n_counter] = NULL; | 768 | tb->FL[n_counter] = NULL; |
769 | p_s_tb->FR[n_counter] = NULL; | 769 | tb->FR[n_counter] = NULL; |
770 | p_s_tb->CFL[n_counter] = NULL; | 770 | tb->CFL[n_counter] = NULL; |
771 | p_s_tb->CFR[n_counter] = NULL; | 771 | tb->CFR[n_counter] = NULL; |
772 | } | 772 | } |
773 | } | 773 | } |
774 | 774 | ||
@@ -778,14 +778,14 @@ static void free_buffers_in_tb(struct tree_balance *p_s_tb) | |||
778 | * NO_DISK_SPACE - no disk space. | 778 | * NO_DISK_SPACE - no disk space. |
779 | */ | 779 | */ |
780 | /* The function is NOT SCHEDULE-SAFE! */ | 780 | /* The function is NOT SCHEDULE-SAFE! */ |
781 | static int get_empty_nodes(struct tree_balance *p_s_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 *p_s_new_bh, |
784 | *p_s_Sh = PATH_H_PBUFFER(p_s_tb->tb_path, n_h); | 784 | *p_s_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 *p_n_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 = p_s_tb->tb_sb; | 788 | struct super_block *sb = tb->tb_sb; |
789 | 789 | ||
790 | /* number_of_freeblk is the number of empty blocks which have been | 790 | /* number_of_freeblk is the number of empty blocks which have been |
791 | acquired for use by the balancing algorithm minus the number of | 791 | acquired for use by the balancing algorithm minus the number of |
@@ -803,15 +803,15 @@ static int get_empty_nodes(struct tree_balance *p_s_tb, int n_h) | |||
803 | the analysis or 0 if not restarted, then subtract the amount needed | 803 | the analysis or 0 if not restarted, then subtract the amount needed |
804 | by all of the levels of the tree below n_h. */ | 804 | by all of the levels of the tree below n_h. */ |
805 | /* blknum includes S[n_h], so we subtract 1 in this calculation */ | 805 | /* blknum includes S[n_h], so we subtract 1 in this calculation */ |
806 | for (n_counter = 0, n_number_of_freeblk = p_s_tb->cur_blknum; | 806 | for (n_counter = 0, n_number_of_freeblk = tb->cur_blknum; |
807 | n_counter < n_h; n_counter++) | 807 | n_counter < n_h; n_counter++) |
808 | n_number_of_freeblk -= | 808 | n_number_of_freeblk -= |
809 | (p_s_tb->blknum[n_counter]) ? (p_s_tb->blknum[n_counter] - | 809 | (tb->blknum[n_counter]) ? (tb->blknum[n_counter] - |
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 p_s_Sh == 0 then we are getting a new root */ |
814 | n_amount_needed = (p_s_Sh) ? (p_s_tb->blknum[n_h] - 1) : 1; | 814 | n_amount_needed = (p_s_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; |
@@ -819,7 +819,7 @@ static int get_empty_nodes(struct tree_balance *p_s_tb, int n_h) | |||
819 | return CARRY_ON; | 819 | return CARRY_ON; |
820 | 820 | ||
821 | /* No need to check quota - is not allocated for blocks used for formatted nodes */ | 821 | /* No need to check quota - is not allocated for blocks used for formatted nodes */ |
822 | if (reiserfs_new_form_blocknrs(p_s_tb, a_n_blocknrs, | 822 | if (reiserfs_new_form_blocknrs(tb, a_n_blocknrs, |
823 | n_amount_needed) == NO_DISK_SPACE) | 823 | n_amount_needed) == NO_DISK_SPACE) |
824 | return NO_DISK_SPACE; | 824 | return NO_DISK_SPACE; |
825 | 825 | ||
@@ -838,14 +838,14 @@ static int get_empty_nodes(struct tree_balance *p_s_tb, int n_h) | |||
838 | p_s_new_bh); | 838 | p_s_new_bh); |
839 | 839 | ||
840 | /* Put empty buffers into the array. */ | 840 | /* Put empty buffers into the array. */ |
841 | RFALSE(p_s_tb->FEB[p_s_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(p_s_new_bh); |
845 | p_s_tb->FEB[p_s_tb->cur_blknum++] = p_s_new_bh; | 845 | tb->FEB[tb->cur_blknum++] = p_s_new_bh; |
846 | } | 846 | } |
847 | 847 | ||
848 | if (n_retval == CARRY_ON && FILESYSTEM_CHANGED_TB(p_s_tb)) | 848 | if (n_retval == CARRY_ON && FILESYSTEM_CHANGED_TB(tb)) |
849 | n_retval = REPEAT_SEARCH; | 849 | n_retval = REPEAT_SEARCH; |
850 | 850 | ||
851 | return n_retval; | 851 | return n_retval; |
@@ -896,33 +896,34 @@ static int get_rfree(struct tree_balance *tb, int h) | |||
896 | } | 896 | } |
897 | 897 | ||
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 *p_s_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 *p_s_father, *left; |
902 | struct super_block *sb = p_s_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; |
905 | 905 | ||
906 | if (!p_s_tb->FL[n_h]) /* Father of the left neighbor does not exist. */ | 906 | /* Father of the left neighbor does not exist. */ |
907 | if (!tb->FL[n_h]) | ||
907 | return 0; | 908 | return 0; |
908 | 909 | ||
909 | /* Calculate father of the node to be balanced. */ | 910 | /* Calculate father of the node to be balanced. */ |
910 | p_s_father = PATH_H_PBUFFER(p_s_tb->tb_path, n_h + 1); | 911 | p_s_father = PATH_H_PBUFFER(tb->tb_path, n_h + 1); |
911 | 912 | ||
912 | RFALSE(!p_s_father || | 913 | RFALSE(!p_s_father || |
913 | !B_IS_IN_TREE(p_s_father) || | 914 | !B_IS_IN_TREE(p_s_father) || |
914 | !B_IS_IN_TREE(p_s_tb->FL[n_h]) || | 915 | !B_IS_IN_TREE(tb->FL[n_h]) || |
915 | !buffer_uptodate(p_s_father) || | 916 | !buffer_uptodate(p_s_father) || |
916 | !buffer_uptodate(p_s_tb->FL[n_h]), | 917 | !buffer_uptodate(tb->FL[n_h]), |
917 | "vs-8165: F[h] (%b) or FL[h] (%b) is invalid", | 918 | "vs-8165: F[h] (%b) or FL[h] (%b) is invalid", |
918 | p_s_father, p_s_tb->FL[n_h]); | 919 | p_s_father, tb->FL[n_h]); |
919 | 920 | ||
920 | /* 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. */ |
921 | n_left_neighbor_position = (p_s_father == p_s_tb->FL[n_h]) ? | 922 | n_left_neighbor_position = (p_s_father == tb->FL[n_h]) ? |
922 | p_s_tb->lkey[n_h] : B_NR_ITEMS(p_s_tb->FL[n_h]); | 923 | tb->lkey[n_h] : B_NR_ITEMS(tb->FL[n_h]); |
923 | /* Get left neighbor block number. */ | 924 | /* Get left neighbor block number. */ |
924 | n_left_neighbor_blocknr = | 925 | n_left_neighbor_blocknr = |
925 | B_N_CHILD_NUM(p_s_tb->FL[n_h], n_left_neighbor_position); | 926 | B_N_CHILD_NUM(tb->FL[n_h], n_left_neighbor_position); |
926 | /* Look for the left neighbor in the cache. */ | 927 | /* Look for the left neighbor in the cache. */ |
927 | if ((left = sb_find_get_block(sb, n_left_neighbor_blocknr))) { | 928 | if ((left = sb_find_get_block(sb, n_left_neighbor_blocknr))) { |
928 | 929 | ||
@@ -953,14 +954,14 @@ static void decrement_key(struct cpu_key *p_s_key) | |||
953 | SCHEDULE_OCCURRED - schedule occurred while the function worked; | 954 | SCHEDULE_OCCURRED - schedule occurred while the function worked; |
954 | * CARRY_ON - schedule didn't occur while the function worked; | 955 | * CARRY_ON - schedule didn't occur while the function worked; |
955 | */ | 956 | */ |
956 | static int get_far_parent(struct tree_balance *p_s_tb, | 957 | static int get_far_parent(struct tree_balance *tb, |
957 | int n_h, | 958 | int n_h, |
958 | struct buffer_head **pp_s_father, | 959 | struct buffer_head **pp_s_father, |
959 | struct buffer_head **pp_s_com_father, char c_lr_par) | 960 | struct buffer_head **pp_s_com_father, char c_lr_par) |
960 | { | 961 | { |
961 | struct buffer_head *p_s_parent; | 962 | struct buffer_head *p_s_parent; |
962 | INITIALIZE_PATH(s_path_to_neighbor_father); | 963 | INITIALIZE_PATH(s_path_to_neighbor_father); |
963 | struct treepath *p_s_path = p_s_tb->tb_path; | 964 | struct treepath *p_s_path = tb->tb_path; |
964 | struct cpu_key s_lr_father_key; | 965 | struct cpu_key s_lr_father_key; |
965 | int n_counter, | 966 | int n_counter, |
966 | n_position = INT_MAX, | 967 | n_position = INT_MAX, |
@@ -1005,9 +1006,9 @@ static int get_far_parent(struct tree_balance *p_s_tb, | |||
1005 | if (n_counter == FIRST_PATH_ELEMENT_OFFSET) { | 1006 | if (n_counter == FIRST_PATH_ELEMENT_OFFSET) { |
1006 | /* Check whether first buffer in the path is the root of the tree. */ | 1007 | /* Check whether first buffer in the path is the root of the tree. */ |
1007 | if (PATH_OFFSET_PBUFFER | 1008 | if (PATH_OFFSET_PBUFFER |
1008 | (p_s_tb->tb_path, | 1009 | (tb->tb_path, |
1009 | FIRST_PATH_ELEMENT_OFFSET)->b_blocknr == | 1010 | FIRST_PATH_ELEMENT_OFFSET)->b_blocknr == |
1010 | SB_ROOT_BLOCK(p_s_tb->tb_sb)) { | 1011 | SB_ROOT_BLOCK(tb->tb_sb)) { |
1011 | *pp_s_father = *pp_s_com_father = NULL; | 1012 | *pp_s_father = *pp_s_com_father = NULL; |
1012 | return CARRY_ON; | 1013 | return CARRY_ON; |
1013 | } | 1014 | } |
@@ -1022,7 +1023,7 @@ static int get_far_parent(struct tree_balance *p_s_tb, | |||
1022 | 1023 | ||
1023 | if (buffer_locked(*pp_s_com_father)) { | 1024 | if (buffer_locked(*pp_s_com_father)) { |
1024 | __wait_on_buffer(*pp_s_com_father); | 1025 | __wait_on_buffer(*pp_s_com_father); |
1025 | if (FILESYSTEM_CHANGED_TB(p_s_tb)) { | 1026 | if (FILESYSTEM_CHANGED_TB(tb)) { |
1026 | brelse(*pp_s_com_father); | 1027 | brelse(*pp_s_com_father); |
1027 | return REPEAT_SEARCH; | 1028 | return REPEAT_SEARCH; |
1028 | } | 1029 | } |
@@ -1035,9 +1036,9 @@ static int get_far_parent(struct tree_balance *p_s_tb, | |||
1035 | le_key2cpu_key(&s_lr_father_key, | 1036 | le_key2cpu_key(&s_lr_father_key, |
1036 | B_N_PDELIM_KEY(*pp_s_com_father, | 1037 | B_N_PDELIM_KEY(*pp_s_com_father, |
1037 | (c_lr_par == | 1038 | (c_lr_par == |
1038 | LEFT_PARENTS) ? (p_s_tb->lkey[n_h - 1] = | 1039 | LEFT_PARENTS) ? (tb->lkey[n_h - 1] = |
1039 | n_position - | 1040 | n_position - |
1040 | 1) : (p_s_tb->rkey[n_h - | 1041 | 1) : (tb->rkey[n_h - |
1041 | 1] = | 1042 | 1] = |
1042 | n_position))); | 1043 | n_position))); |
1043 | 1044 | ||
@@ -1045,12 +1046,12 @@ static int get_far_parent(struct tree_balance *p_s_tb, | |||
1045 | decrement_key(&s_lr_father_key); | 1046 | decrement_key(&s_lr_father_key); |
1046 | 1047 | ||
1047 | if (search_by_key | 1048 | if (search_by_key |
1048 | (p_s_tb->tb_sb, &s_lr_father_key, &s_path_to_neighbor_father, | 1049 | (tb->tb_sb, &s_lr_father_key, &s_path_to_neighbor_father, |
1049 | n_h + 1) == IO_ERROR) | 1050 | n_h + 1) == IO_ERROR) |
1050 | // path is released | 1051 | // path is released |
1051 | return IO_ERROR; | 1052 | return IO_ERROR; |
1052 | 1053 | ||
1053 | if (FILESYSTEM_CHANGED_TB(p_s_tb)) { | 1054 | if (FILESYSTEM_CHANGED_TB(tb)) { |
1054 | pathrelse(&s_path_to_neighbor_father); | 1055 | pathrelse(&s_path_to_neighbor_father); |
1055 | brelse(*pp_s_com_father); | 1056 | brelse(*pp_s_com_father); |
1056 | return REPEAT_SEARCH; | 1057 | return REPEAT_SEARCH; |
@@ -1075,24 +1076,26 @@ static int get_far_parent(struct tree_balance *p_s_tb, | |||
1075 | * Returns: SCHEDULE_OCCURRED - schedule occurred while the function worked; | 1076 | * Returns: SCHEDULE_OCCURRED - schedule occurred while the function worked; |
1076 | * CARRY_ON - schedule didn't occur while the function worked; | 1077 | * CARRY_ON - schedule didn't occur while the function worked; |
1077 | */ | 1078 | */ |
1078 | static int get_parents(struct tree_balance *p_s_tb, int n_h) | 1079 | static int get_parents(struct tree_balance *tb, int n_h) |
1079 | { | 1080 | { |
1080 | struct treepath *p_s_path = p_s_tb->tb_path; | 1081 | struct treepath *p_s_path = tb->tb_path; |
1081 | int n_position, | 1082 | int n_position, |
1082 | n_ret_value, | 1083 | n_ret_value, |
1083 | n_path_offset = PATH_H_PATH_OFFSET(p_s_tb->tb_path, n_h); | 1084 | n_path_offset = PATH_H_PATH_OFFSET(tb->tb_path, n_h); |
1084 | struct buffer_head *p_s_curf, *p_s_curcf; | 1085 | struct buffer_head *p_s_curf, *p_s_curcf; |
1085 | 1086 | ||
1086 | /* 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 */ |
1087 | if (n_path_offset <= FIRST_PATH_ELEMENT_OFFSET) { | 1088 | if (n_path_offset <= FIRST_PATH_ELEMENT_OFFSET) { |
1088 | /* The root can not have parents. | 1089 | /* The root can not have parents. |
1089 | Release nodes which previously were obtained as parents of the current node neighbors. */ | 1090 | Release nodes which previously were obtained as parents of the current node neighbors. */ |
1090 | brelse(p_s_tb->FL[n_h]); | 1091 | brelse(tb->FL[n_h]); |
1091 | brelse(p_s_tb->CFL[n_h]); | 1092 | brelse(tb->CFL[n_h]); |
1092 | brelse(p_s_tb->FR[n_h]); | 1093 | brelse(tb->FR[n_h]); |
1093 | brelse(p_s_tb->CFR[n_h]); | 1094 | brelse(tb->CFR[n_h]); |
1094 | p_s_tb->FL[n_h] = p_s_tb->CFL[n_h] = p_s_tb->FR[n_h] = | 1095 | tb->FL[n_h] = NULL; |
1095 | p_s_tb->CFR[n_h] = NULL; | 1096 | tb->CFL[n_h] = NULL; |
1097 | tb->FR[n_h] = NULL; | ||
1098 | tb->CFR[n_h] = NULL; | ||
1096 | return CARRY_ON; | 1099 | return CARRY_ON; |
1097 | } | 1100 | } |
1098 | 1101 | ||
@@ -1104,22 +1107,22 @@ static int get_parents(struct tree_balance *p_s_tb, int n_h) | |||
1104 | PATH_OFFSET_PBUFFER(p_s_path, n_path_offset - 1); | 1107 | PATH_OFFSET_PBUFFER(p_s_path, n_path_offset - 1); |
1105 | get_bh(p_s_curf); | 1108 | get_bh(p_s_curf); |
1106 | get_bh(p_s_curf); | 1109 | get_bh(p_s_curf); |
1107 | p_s_tb->lkey[n_h] = n_position - 1; | 1110 | tb->lkey[n_h] = n_position - 1; |
1108 | } else { | 1111 | } else { |
1109 | /* 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. |
1110 | 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 |
1111 | 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]. |
1112 | Calculate lkey[n_path_offset]. */ | 1115 | Calculate lkey[n_path_offset]. */ |
1113 | if ((n_ret_value = get_far_parent(p_s_tb, n_h + 1, &p_s_curf, | 1116 | if ((n_ret_value = get_far_parent(tb, n_h + 1, &p_s_curf, |
1114 | &p_s_curcf, | 1117 | &p_s_curcf, |
1115 | LEFT_PARENTS)) != CARRY_ON) | 1118 | LEFT_PARENTS)) != CARRY_ON) |
1116 | return n_ret_value; | 1119 | return n_ret_value; |
1117 | } | 1120 | } |
1118 | 1121 | ||
1119 | brelse(p_s_tb->FL[n_h]); | 1122 | brelse(tb->FL[n_h]); |
1120 | p_s_tb->FL[n_h] = p_s_curf; /* New initialization of FL[n_h]. */ | 1123 | tb->FL[n_h] = p_s_curf; /* New initialization of FL[n_h]. */ |
1121 | brelse(p_s_tb->CFL[n_h]); | 1124 | brelse(tb->CFL[n_h]); |
1122 | p_s_tb->CFL[n_h] = p_s_curcf; /* New initialization of CFL[n_h]. */ | 1125 | tb->CFL[n_h] = p_s_curcf; /* New initialization of CFL[n_h]. */ |
1123 | 1126 | ||
1124 | RFALSE((p_s_curf && !B_IS_IN_TREE(p_s_curf)) || | 1127 | RFALSE((p_s_curf && !B_IS_IN_TREE(p_s_curf)) || |
1125 | (p_s_curcf && !B_IS_IN_TREE(p_s_curcf)), | 1128 | (p_s_curcf && !B_IS_IN_TREE(p_s_curcf)), |
@@ -1133,7 +1136,7 @@ static int get_parents(struct tree_balance *p_s_tb, int n_h) | |||
1133 | 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] |
1134 | 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]. */ |
1135 | if ((n_ret_value = | 1138 | if ((n_ret_value = |
1136 | get_far_parent(p_s_tb, n_h + 1, &p_s_curf, &p_s_curcf, | 1139 | get_far_parent(tb, n_h + 1, &p_s_curf, &p_s_curcf, |
1137 | RIGHT_PARENTS)) != CARRY_ON) | 1140 | RIGHT_PARENTS)) != CARRY_ON) |
1138 | return n_ret_value; | 1141 | return n_ret_value; |
1139 | } else { | 1142 | } else { |
@@ -1143,14 +1146,16 @@ static int get_parents(struct tree_balance *p_s_tb, int n_h) | |||
1143 | PATH_OFFSET_PBUFFER(p_s_path, n_path_offset - 1); | 1146 | PATH_OFFSET_PBUFFER(p_s_path, n_path_offset - 1); |
1144 | get_bh(p_s_curf); | 1147 | get_bh(p_s_curf); |
1145 | get_bh(p_s_curf); | 1148 | get_bh(p_s_curf); |
1146 | p_s_tb->rkey[n_h] = n_position; | 1149 | tb->rkey[n_h] = n_position; |
1147 | } | 1150 | } |
1148 | 1151 | ||
1149 | brelse(p_s_tb->FR[n_h]); | 1152 | brelse(tb->FR[n_h]); |
1150 | p_s_tb->FR[n_h] = p_s_curf; /* New initialization of FR[n_path_offset]. */ | 1153 | /* New initialization of FR[n_path_offset]. */ |
1154 | tb->FR[n_h] = p_s_curf; | ||
1151 | 1155 | ||
1152 | brelse(p_s_tb->CFR[n_h]); | 1156 | brelse(tb->CFR[n_h]); |
1153 | p_s_tb->CFR[n_h] = p_s_curcf; /* New initialization of CFR[n_path_offset]. */ | 1157 | /* New initialization of CFR[n_path_offset]. */ |
1158 | tb->CFR[n_h] = p_s_curcf; | ||
1154 | 1159 | ||
1155 | RFALSE((p_s_curf && !B_IS_IN_TREE(p_s_curf)) || | 1160 | RFALSE((p_s_curf && !B_IS_IN_TREE(p_s_curf)) || |
1156 | (p_s_curcf && !B_IS_IN_TREE(p_s_curcf)), | 1161 | (p_s_curcf && !B_IS_IN_TREE(p_s_curcf)), |
@@ -1885,12 +1890,12 @@ static int check_balance(int mode, | |||
1885 | } | 1890 | } |
1886 | 1891 | ||
1887 | /* Check whether parent at the path is the really parent of the current node.*/ | 1892 | /* Check whether parent at the path is the really parent of the current node.*/ |
1888 | static int get_direct_parent(struct tree_balance *p_s_tb, int n_h) | 1893 | static int get_direct_parent(struct tree_balance *tb, int n_h) |
1889 | { | 1894 | { |
1890 | struct buffer_head *bh; | 1895 | struct buffer_head *bh; |
1891 | struct treepath *p_s_path = p_s_tb->tb_path; | 1896 | struct treepath *p_s_path = tb->tb_path; |
1892 | int n_position, | 1897 | int n_position, |
1893 | n_path_offset = PATH_H_PATH_OFFSET(p_s_tb->tb_path, n_h); | 1898 | n_path_offset = PATH_H_PATH_OFFSET(tb->tb_path, n_h); |
1894 | 1899 | ||
1895 | /* We are in the root or in the new root. */ | 1900 | /* We are in the root or in the new root. */ |
1896 | if (n_path_offset <= FIRST_PATH_ELEMENT_OFFSET) { | 1901 | if (n_path_offset <= FIRST_PATH_ELEMENT_OFFSET) { |
@@ -1899,7 +1904,7 @@ static int get_direct_parent(struct tree_balance *p_s_tb, int n_h) | |||
1899 | "PAP-8260: invalid offset in the path"); | 1904 | "PAP-8260: invalid offset in the path"); |
1900 | 1905 | ||
1901 | if (PATH_OFFSET_PBUFFER(p_s_path, FIRST_PATH_ELEMENT_OFFSET)-> | 1906 | if (PATH_OFFSET_PBUFFER(p_s_path, FIRST_PATH_ELEMENT_OFFSET)-> |
1902 | b_blocknr == SB_ROOT_BLOCK(p_s_tb->tb_sb)) { | 1907 | b_blocknr == SB_ROOT_BLOCK(tb->tb_sb)) { |
1903 | /* Root is not changed. */ | 1908 | /* Root is not changed. */ |
1904 | PATH_OFFSET_PBUFFER(p_s_path, n_path_offset - 1) = NULL; | 1909 | PATH_OFFSET_PBUFFER(p_s_path, n_path_offset - 1) = NULL; |
1905 | PATH_OFFSET_POSITION(p_s_path, n_path_offset - 1) = 0; | 1910 | PATH_OFFSET_POSITION(p_s_path, n_path_offset - 1) = 0; |
@@ -1924,7 +1929,7 @@ static int get_direct_parent(struct tree_balance *p_s_tb, int n_h) | |||
1924 | 1929 | ||
1925 | if (buffer_locked(bh)) { | 1930 | if (buffer_locked(bh)) { |
1926 | __wait_on_buffer(bh); | 1931 | __wait_on_buffer(bh); |
1927 | if (FILESYSTEM_CHANGED_TB(p_s_tb)) | 1932 | if (FILESYSTEM_CHANGED_TB(tb)) |
1928 | return REPEAT_SEARCH; | 1933 | return REPEAT_SEARCH; |
1929 | } | 1934 | } |
1930 | 1935 | ||
@@ -1937,85 +1942,86 @@ static int get_direct_parent(struct tree_balance *p_s_tb, int n_h) | |||
1937 | * Returns: SCHEDULE_OCCURRED - schedule occurred while the function worked; | 1942 | * Returns: SCHEDULE_OCCURRED - schedule occurred while the function worked; |
1938 | * CARRY_ON - schedule didn't occur while the function worked; | 1943 | * CARRY_ON - schedule didn't occur while the function worked; |
1939 | */ | 1944 | */ |
1940 | static int get_neighbors(struct tree_balance *p_s_tb, int n_h) | 1945 | static int get_neighbors(struct tree_balance *tb, int n_h) |
1941 | { | 1946 | { |
1942 | int n_child_position, | 1947 | int n_child_position, |
1943 | n_path_offset = PATH_H_PATH_OFFSET(p_s_tb->tb_path, n_h + 1); | 1948 | n_path_offset = PATH_H_PATH_OFFSET(tb->tb_path, n_h + 1); |
1944 | unsigned long n_son_number; | 1949 | unsigned long n_son_number; |
1945 | struct super_block *sb = p_s_tb->tb_sb; | 1950 | struct super_block *sb = tb->tb_sb; |
1946 | struct buffer_head *bh; | 1951 | struct buffer_head *bh; |
1947 | 1952 | ||
1948 | PROC_INFO_INC(sb, get_neighbors[n_h]); | 1953 | PROC_INFO_INC(sb, get_neighbors[n_h]); |
1949 | 1954 | ||
1950 | if (p_s_tb->lnum[n_h]) { | 1955 | if (tb->lnum[n_h]) { |
1951 | /* We need left neighbor to balance S[n_h]. */ | 1956 | /* We need left neighbor to balance S[n_h]. */ |
1952 | PROC_INFO_INC(sb, need_l_neighbor[n_h]); | 1957 | PROC_INFO_INC(sb, need_l_neighbor[n_h]); |
1953 | bh = PATH_OFFSET_PBUFFER(p_s_tb->tb_path, n_path_offset); | 1958 | bh = PATH_OFFSET_PBUFFER(tb->tb_path, n_path_offset); |
1954 | 1959 | ||
1955 | RFALSE(bh == p_s_tb->FL[n_h] && | 1960 | RFALSE(bh == tb->FL[n_h] && |
1956 | !PATH_OFFSET_POSITION(p_s_tb->tb_path, n_path_offset), | 1961 | !PATH_OFFSET_POSITION(tb->tb_path, n_path_offset), |
1957 | "PAP-8270: invalid position in the parent"); | 1962 | "PAP-8270: invalid position in the parent"); |
1958 | 1963 | ||
1959 | n_child_position = | 1964 | n_child_position = |
1960 | (bh == | 1965 | (bh == |
1961 | p_s_tb->FL[n_h]) ? p_s_tb->lkey[n_h] : B_NR_ITEMS(p_s_tb-> | 1966 | tb->FL[n_h]) ? tb->lkey[n_h] : B_NR_ITEMS(tb-> |
1962 | FL[n_h]); | 1967 | FL[n_h]); |
1963 | n_son_number = B_N_CHILD_NUM(p_s_tb->FL[n_h], n_child_position); | 1968 | n_son_number = B_N_CHILD_NUM(tb->FL[n_h], n_child_position); |
1964 | bh = sb_bread(sb, n_son_number); | 1969 | bh = sb_bread(sb, n_son_number); |
1965 | if (!bh) | 1970 | if (!bh) |
1966 | return IO_ERROR; | 1971 | return IO_ERROR; |
1967 | if (FILESYSTEM_CHANGED_TB(p_s_tb)) { | 1972 | if (FILESYSTEM_CHANGED_TB(tb)) { |
1968 | brelse(bh); | 1973 | brelse(bh); |
1969 | PROC_INFO_INC(sb, get_neighbors_restart[n_h]); | 1974 | PROC_INFO_INC(sb, get_neighbors_restart[n_h]); |
1970 | return REPEAT_SEARCH; | 1975 | return REPEAT_SEARCH; |
1971 | } | 1976 | } |
1972 | 1977 | ||
1973 | RFALSE(!B_IS_IN_TREE(p_s_tb->FL[n_h]) || | 1978 | RFALSE(!B_IS_IN_TREE(tb->FL[n_h]) || |
1974 | n_child_position > B_NR_ITEMS(p_s_tb->FL[n_h]) || | 1979 | n_child_position > B_NR_ITEMS(tb->FL[n_h]) || |
1975 | B_N_CHILD_NUM(p_s_tb->FL[n_h], n_child_position) != | 1980 | B_N_CHILD_NUM(tb->FL[n_h], n_child_position) != |
1976 | bh->b_blocknr, "PAP-8275: invalid parent"); | 1981 | bh->b_blocknr, "PAP-8275: invalid parent"); |
1977 | RFALSE(!B_IS_IN_TREE(bh), "PAP-8280: invalid child"); | 1982 | RFALSE(!B_IS_IN_TREE(bh), "PAP-8280: invalid child"); |
1978 | RFALSE(!n_h && | 1983 | RFALSE(!n_h && |
1979 | B_FREE_SPACE(bh) != | 1984 | B_FREE_SPACE(bh) != |
1980 | MAX_CHILD_SIZE(bh) - | 1985 | MAX_CHILD_SIZE(bh) - |
1981 | dc_size(B_N_CHILD(p_s_tb->FL[0], n_child_position)), | 1986 | dc_size(B_N_CHILD(tb->FL[0], n_child_position)), |
1982 | "PAP-8290: invalid child size of left neighbor"); | 1987 | "PAP-8290: invalid child size of left neighbor"); |
1983 | 1988 | ||
1984 | brelse(p_s_tb->L[n_h]); | 1989 | brelse(tb->L[n_h]); |
1985 | p_s_tb->L[n_h] = bh; | 1990 | tb->L[n_h] = bh; |
1986 | } | 1991 | } |
1987 | 1992 | ||
1988 | if (p_s_tb->rnum[n_h]) { /* We need right neighbor to balance S[n_path_offset]. */ | 1993 | /* We need right neighbor to balance S[n_path_offset]. */ |
1994 | if (tb->rnum[n_h]) { | ||
1989 | PROC_INFO_INC(sb, need_r_neighbor[n_h]); | 1995 | PROC_INFO_INC(sb, need_r_neighbor[n_h]); |
1990 | bh = PATH_OFFSET_PBUFFER(p_s_tb->tb_path, n_path_offset); | 1996 | bh = PATH_OFFSET_PBUFFER(tb->tb_path, n_path_offset); |
1991 | 1997 | ||
1992 | RFALSE(bh == p_s_tb->FR[n_h] && | 1998 | RFALSE(bh == tb->FR[n_h] && |
1993 | PATH_OFFSET_POSITION(p_s_tb->tb_path, | 1999 | PATH_OFFSET_POSITION(tb->tb_path, |
1994 | n_path_offset) >= | 2000 | n_path_offset) >= |
1995 | B_NR_ITEMS(bh), | 2001 | B_NR_ITEMS(bh), |
1996 | "PAP-8295: invalid position in the parent"); | 2002 | "PAP-8295: invalid position in the parent"); |
1997 | 2003 | ||
1998 | n_child_position = | 2004 | n_child_position = |
1999 | (bh == p_s_tb->FR[n_h]) ? p_s_tb->rkey[n_h] + 1 : 0; | 2005 | (bh == tb->FR[n_h]) ? tb->rkey[n_h] + 1 : 0; |
2000 | n_son_number = B_N_CHILD_NUM(p_s_tb->FR[n_h], n_child_position); | 2006 | n_son_number = B_N_CHILD_NUM(tb->FR[n_h], n_child_position); |
2001 | bh = sb_bread(sb, n_son_number); | 2007 | bh = sb_bread(sb, n_son_number); |
2002 | if (!bh) | 2008 | if (!bh) |
2003 | return IO_ERROR; | 2009 | return IO_ERROR; |
2004 | if (FILESYSTEM_CHANGED_TB(p_s_tb)) { | 2010 | if (FILESYSTEM_CHANGED_TB(tb)) { |
2005 | brelse(bh); | 2011 | brelse(bh); |
2006 | PROC_INFO_INC(sb, get_neighbors_restart[n_h]); | 2012 | PROC_INFO_INC(sb, get_neighbors_restart[n_h]); |
2007 | return REPEAT_SEARCH; | 2013 | return REPEAT_SEARCH; |
2008 | } | 2014 | } |
2009 | brelse(p_s_tb->R[n_h]); | 2015 | brelse(tb->R[n_h]); |
2010 | p_s_tb->R[n_h] = bh; | 2016 | tb->R[n_h] = bh; |
2011 | 2017 | ||
2012 | RFALSE(!n_h | 2018 | RFALSE(!n_h |
2013 | && B_FREE_SPACE(bh) != | 2019 | && B_FREE_SPACE(bh) != |
2014 | MAX_CHILD_SIZE(bh) - | 2020 | MAX_CHILD_SIZE(bh) - |
2015 | dc_size(B_N_CHILD(p_s_tb->FR[0], n_child_position)), | 2021 | dc_size(B_N_CHILD(tb->FR[0], n_child_position)), |
2016 | "PAP-8300: invalid child size of right neighbor (%d != %d - %d)", | 2022 | "PAP-8300: invalid child size of right neighbor (%d != %d - %d)", |
2017 | B_FREE_SPACE(bh), MAX_CHILD_SIZE(bh), | 2023 | B_FREE_SPACE(bh), MAX_CHILD_SIZE(bh), |
2018 | dc_size(B_N_CHILD(p_s_tb->FR[0], n_child_position))); | 2024 | dc_size(B_N_CHILD(tb->FR[0], n_child_position))); |
2019 | 2025 | ||
2020 | } | 2026 | } |
2021 | return CARRY_ON; | 2027 | return CARRY_ON; |
@@ -2139,7 +2145,7 @@ static int clear_all_dirty_bits(struct super_block *s, struct buffer_head *bh) | |||
2139 | return reiserfs_prepare_for_journal(s, bh, 0); | 2145 | return reiserfs_prepare_for_journal(s, bh, 0); |
2140 | } | 2146 | } |
2141 | 2147 | ||
2142 | static int wait_tb_buffers_until_unlocked(struct tree_balance *p_s_tb) | 2148 | static int wait_tb_buffers_until_unlocked(struct tree_balance *tb) |
2143 | { | 2149 | { |
2144 | struct buffer_head *locked; | 2150 | struct buffer_head *locked; |
2145 | #ifdef CONFIG_REISERFS_CHECK | 2151 | #ifdef CONFIG_REISERFS_CHECK |
@@ -2151,95 +2157,94 @@ static int wait_tb_buffers_until_unlocked(struct tree_balance *p_s_tb) | |||
2151 | 2157 | ||
2152 | locked = NULL; | 2158 | locked = NULL; |
2153 | 2159 | ||
2154 | for (i = p_s_tb->tb_path->path_length; | 2160 | for (i = tb->tb_path->path_length; |
2155 | !locked && i > ILLEGAL_PATH_ELEMENT_OFFSET; i--) { | 2161 | !locked && i > ILLEGAL_PATH_ELEMENT_OFFSET; i--) { |
2156 | if (PATH_OFFSET_PBUFFER(p_s_tb->tb_path, i)) { | 2162 | if (PATH_OFFSET_PBUFFER(tb->tb_path, i)) { |
2157 | /* if I understand correctly, we can only be sure the last buffer | 2163 | /* if I understand correctly, we can only be sure the last buffer |
2158 | ** in the path is in the tree --clm | 2164 | ** in the path is in the tree --clm |
2159 | */ | 2165 | */ |
2160 | #ifdef CONFIG_REISERFS_CHECK | 2166 | #ifdef CONFIG_REISERFS_CHECK |
2161 | if (PATH_PLAST_BUFFER(p_s_tb->tb_path) == | 2167 | if (PATH_PLAST_BUFFER(tb->tb_path) == |
2162 | PATH_OFFSET_PBUFFER(p_s_tb->tb_path, i)) { | 2168 | PATH_OFFSET_PBUFFER(tb->tb_path, i)) |
2163 | tb_buffer_sanity_check(p_s_tb->tb_sb, | 2169 | tb_buffer_sanity_check(tb->tb_sb, |
2164 | PATH_OFFSET_PBUFFER | 2170 | PATH_OFFSET_PBUFFER |
2165 | (p_s_tb->tb_path, | 2171 | (tb->tb_path, |
2166 | i), "S", | 2172 | i), "S", |
2167 | p_s_tb->tb_path-> | 2173 | tb->tb_path-> |
2168 | path_length - i); | 2174 | path_length - i); |
2169 | } | ||
2170 | #endif | 2175 | #endif |
2171 | if (!clear_all_dirty_bits(p_s_tb->tb_sb, | 2176 | if (!clear_all_dirty_bits(tb->tb_sb, |
2172 | PATH_OFFSET_PBUFFER | 2177 | PATH_OFFSET_PBUFFER |
2173 | (p_s_tb->tb_path, | 2178 | (tb->tb_path, |
2174 | i))) { | 2179 | i))) { |
2175 | locked = | 2180 | locked = |
2176 | PATH_OFFSET_PBUFFER(p_s_tb->tb_path, | 2181 | PATH_OFFSET_PBUFFER(tb->tb_path, |
2177 | i); | 2182 | i); |
2178 | } | 2183 | } |
2179 | } | 2184 | } |
2180 | } | 2185 | } |
2181 | 2186 | ||
2182 | for (i = 0; !locked && i < MAX_HEIGHT && p_s_tb->insert_size[i]; | 2187 | for (i = 0; !locked && i < MAX_HEIGHT && tb->insert_size[i]; |
2183 | i++) { | 2188 | i++) { |
2184 | 2189 | ||
2185 | if (p_s_tb->lnum[i]) { | 2190 | if (tb->lnum[i]) { |
2186 | 2191 | ||
2187 | if (p_s_tb->L[i]) { | 2192 | if (tb->L[i]) { |
2188 | tb_buffer_sanity_check(p_s_tb->tb_sb, | 2193 | tb_buffer_sanity_check(tb->tb_sb, |
2189 | p_s_tb->L[i], | 2194 | tb->L[i], |
2190 | "L", i); | 2195 | "L", i); |
2191 | if (!clear_all_dirty_bits | 2196 | if (!clear_all_dirty_bits |
2192 | (p_s_tb->tb_sb, p_s_tb->L[i])) | 2197 | (tb->tb_sb, tb->L[i])) |
2193 | locked = p_s_tb->L[i]; | 2198 | locked = tb->L[i]; |
2194 | } | 2199 | } |
2195 | 2200 | ||
2196 | if (!locked && p_s_tb->FL[i]) { | 2201 | if (!locked && tb->FL[i]) { |
2197 | tb_buffer_sanity_check(p_s_tb->tb_sb, | 2202 | tb_buffer_sanity_check(tb->tb_sb, |
2198 | p_s_tb->FL[i], | 2203 | tb->FL[i], |
2199 | "FL", i); | 2204 | "FL", i); |
2200 | if (!clear_all_dirty_bits | 2205 | if (!clear_all_dirty_bits |
2201 | (p_s_tb->tb_sb, p_s_tb->FL[i])) | 2206 | (tb->tb_sb, tb->FL[i])) |
2202 | locked = p_s_tb->FL[i]; | 2207 | locked = tb->FL[i]; |
2203 | } | 2208 | } |
2204 | 2209 | ||
2205 | if (!locked && p_s_tb->CFL[i]) { | 2210 | if (!locked && tb->CFL[i]) { |
2206 | tb_buffer_sanity_check(p_s_tb->tb_sb, | 2211 | tb_buffer_sanity_check(tb->tb_sb, |
2207 | p_s_tb->CFL[i], | 2212 | tb->CFL[i], |
2208 | "CFL", i); | 2213 | "CFL", i); |
2209 | if (!clear_all_dirty_bits | 2214 | if (!clear_all_dirty_bits |
2210 | (p_s_tb->tb_sb, p_s_tb->CFL[i])) | 2215 | (tb->tb_sb, tb->CFL[i])) |
2211 | locked = p_s_tb->CFL[i]; | 2216 | locked = tb->CFL[i]; |
2212 | } | 2217 | } |
2213 | 2218 | ||
2214 | } | 2219 | } |
2215 | 2220 | ||
2216 | if (!locked && (p_s_tb->rnum[i])) { | 2221 | if (!locked && (tb->rnum[i])) { |
2217 | 2222 | ||
2218 | if (p_s_tb->R[i]) { | 2223 | if (tb->R[i]) { |
2219 | tb_buffer_sanity_check(p_s_tb->tb_sb, | 2224 | tb_buffer_sanity_check(tb->tb_sb, |
2220 | p_s_tb->R[i], | 2225 | tb->R[i], |
2221 | "R", i); | 2226 | "R", i); |
2222 | if (!clear_all_dirty_bits | 2227 | if (!clear_all_dirty_bits |
2223 | (p_s_tb->tb_sb, p_s_tb->R[i])) | 2228 | (tb->tb_sb, tb->R[i])) |
2224 | locked = p_s_tb->R[i]; | 2229 | locked = tb->R[i]; |
2225 | } | 2230 | } |
2226 | 2231 | ||
2227 | if (!locked && p_s_tb->FR[i]) { | 2232 | if (!locked && tb->FR[i]) { |
2228 | tb_buffer_sanity_check(p_s_tb->tb_sb, | 2233 | tb_buffer_sanity_check(tb->tb_sb, |
2229 | p_s_tb->FR[i], | 2234 | tb->FR[i], |
2230 | "FR", i); | 2235 | "FR", i); |
2231 | if (!clear_all_dirty_bits | 2236 | if (!clear_all_dirty_bits |
2232 | (p_s_tb->tb_sb, p_s_tb->FR[i])) | 2237 | (tb->tb_sb, tb->FR[i])) |
2233 | locked = p_s_tb->FR[i]; | 2238 | locked = tb->FR[i]; |
2234 | } | 2239 | } |
2235 | 2240 | ||
2236 | if (!locked && p_s_tb->CFR[i]) { | 2241 | if (!locked && tb->CFR[i]) { |
2237 | tb_buffer_sanity_check(p_s_tb->tb_sb, | 2242 | tb_buffer_sanity_check(tb->tb_sb, |
2238 | p_s_tb->CFR[i], | 2243 | tb->CFR[i], |
2239 | "CFR", i); | 2244 | "CFR", i); |
2240 | if (!clear_all_dirty_bits | 2245 | if (!clear_all_dirty_bits |
2241 | (p_s_tb->tb_sb, p_s_tb->CFR[i])) | 2246 | (tb->tb_sb, tb->CFR[i])) |
2242 | locked = p_s_tb->CFR[i]; | 2247 | locked = tb->CFR[i]; |
2243 | } | 2248 | } |
2244 | } | 2249 | } |
2245 | } | 2250 | } |
@@ -2252,10 +2257,10 @@ static int wait_tb_buffers_until_unlocked(struct tree_balance *p_s_tb) | |||
2252 | ** --clm | 2257 | ** --clm |
2253 | */ | 2258 | */ |
2254 | for (i = 0; !locked && i < MAX_FEB_SIZE; i++) { | 2259 | for (i = 0; !locked && i < MAX_FEB_SIZE; i++) { |
2255 | if (p_s_tb->FEB[i]) { | 2260 | if (tb->FEB[i]) { |
2256 | if (!clear_all_dirty_bits | 2261 | if (!clear_all_dirty_bits |
2257 | (p_s_tb->tb_sb, p_s_tb->FEB[i])) | 2262 | (tb->tb_sb, tb->FEB[i])) |
2258 | locked = p_s_tb->FEB[i]; | 2263 | locked = tb->FEB[i]; |
2259 | } | 2264 | } |
2260 | } | 2265 | } |
2261 | 2266 | ||
@@ -2263,21 +2268,20 @@ static int wait_tb_buffers_until_unlocked(struct tree_balance *p_s_tb) | |||
2263 | #ifdef CONFIG_REISERFS_CHECK | 2268 | #ifdef CONFIG_REISERFS_CHECK |
2264 | repeat_counter++; | 2269 | repeat_counter++; |
2265 | if ((repeat_counter % 10000) == 0) { | 2270 | if ((repeat_counter % 10000) == 0) { |
2266 | reiserfs_warning(p_s_tb->tb_sb, "reiserfs-8200", | 2271 | reiserfs_warning(tb->tb_sb, "reiserfs-8200", |
2267 | "too many iterations waiting " | 2272 | "too many iterations waiting " |
2268 | "for buffer to unlock " | 2273 | "for buffer to unlock " |
2269 | "(%b)", locked); | 2274 | "(%b)", locked); |
2270 | 2275 | ||
2271 | /* Don't loop forever. Try to recover from possible error. */ | 2276 | /* Don't loop forever. Try to recover from possible error. */ |
2272 | 2277 | ||
2273 | return (FILESYSTEM_CHANGED_TB(p_s_tb)) ? | 2278 | return (FILESYSTEM_CHANGED_TB(tb)) ? |
2274 | REPEAT_SEARCH : CARRY_ON; | 2279 | REPEAT_SEARCH : CARRY_ON; |
2275 | } | 2280 | } |
2276 | #endif | 2281 | #endif |
2277 | __wait_on_buffer(locked); | 2282 | __wait_on_buffer(locked); |
2278 | if (FILESYSTEM_CHANGED_TB(p_s_tb)) { | 2283 | if (FILESYSTEM_CHANGED_TB(tb)) |
2279 | return REPEAT_SEARCH; | 2284 | return REPEAT_SEARCH; |
2280 | } | ||
2281 | } | 2285 | } |
2282 | 2286 | ||
2283 | } while (locked); | 2287 | } while (locked); |
@@ -2307,138 +2311,136 @@ static int wait_tb_buffers_until_unlocked(struct tree_balance *p_s_tb) | |||
2307 | * tb tree_balance structure; | 2311 | * tb tree_balance structure; |
2308 | * inum item number in S[h]; | 2312 | * inum item number in S[h]; |
2309 | * pos_in_item - comment this if you can | 2313 | * pos_in_item - comment this if you can |
2310 | * ins_ih & ins_sd are used when inserting | 2314 | * ins_ih item head of item being inserted |
2315 | * data inserted item or data to be pasted | ||
2311 | * Returns: 1 - schedule occurred while the function worked; | 2316 | * Returns: 1 - schedule occurred while the function worked; |
2312 | * 0 - schedule didn't occur while the function worked; | 2317 | * 0 - schedule didn't occur while the function worked; |
2313 | * -1 - if no_disk_space | 2318 | * -1 - if no_disk_space |
2314 | */ | 2319 | */ |
2315 | 2320 | ||
2316 | int fix_nodes(int n_op_mode, struct tree_balance *p_s_tb, struct item_head *p_s_ins_ih, // item head of item being inserted | 2321 | int fix_nodes(int n_op_mode, struct tree_balance *tb, |
2317 | const void *data // inserted item or data to be pasted | 2322 | struct item_head *p_s_ins_ih, const void *data) |
2318 | ) | ||
2319 | { | 2323 | { |
2320 | int n_ret_value, n_h, n_item_num = PATH_LAST_POSITION(p_s_tb->tb_path); | 2324 | int n_ret_value, n_h, n_item_num = PATH_LAST_POSITION(tb->tb_path); |
2321 | int n_pos_in_item; | 2325 | int n_pos_in_item; |
2322 | 2326 | ||
2323 | /* we set wait_tb_buffers_run when we have to restore any dirty bits cleared | 2327 | /* we set wait_tb_buffers_run when we have to restore any dirty bits cleared |
2324 | ** during wait_tb_buffers_run | 2328 | ** during wait_tb_buffers_run |
2325 | */ | 2329 | */ |
2326 | int wait_tb_buffers_run = 0; | 2330 | int wait_tb_buffers_run = 0; |
2327 | struct buffer_head *p_s_tbS0 = PATH_PLAST_BUFFER(p_s_tb->tb_path); | 2331 | struct buffer_head *tbS0 = PATH_PLAST_BUFFER(tb->tb_path); |
2328 | 2332 | ||
2329 | ++REISERFS_SB(p_s_tb->tb_sb)->s_fix_nodes; | 2333 | ++REISERFS_SB(tb->tb_sb)->s_fix_nodes; |
2330 | 2334 | ||
2331 | n_pos_in_item = p_s_tb->tb_path->pos_in_item; | 2335 | n_pos_in_item = tb->tb_path->pos_in_item; |
2332 | 2336 | ||
2333 | p_s_tb->fs_gen = get_generation(p_s_tb->tb_sb); | 2337 | tb->fs_gen = get_generation(tb->tb_sb); |
2334 | 2338 | ||
2335 | /* we prepare and log the super here so it will already be in the | 2339 | /* we prepare and log the super here so it will already be in the |
2336 | ** transaction when do_balance needs to change it. | 2340 | ** transaction when do_balance needs to change it. |
2337 | ** This way do_balance won't have to schedule when trying to prepare | 2341 | ** This way do_balance won't have to schedule when trying to prepare |
2338 | ** the super for logging | 2342 | ** the super for logging |
2339 | */ | 2343 | */ |
2340 | reiserfs_prepare_for_journal(p_s_tb->tb_sb, | 2344 | reiserfs_prepare_for_journal(tb->tb_sb, |
2341 | SB_BUFFER_WITH_SB(p_s_tb->tb_sb), 1); | 2345 | SB_BUFFER_WITH_SB(tb->tb_sb), 1); |
2342 | journal_mark_dirty(p_s_tb->transaction_handle, p_s_tb->tb_sb, | 2346 | journal_mark_dirty(tb->transaction_handle, tb->tb_sb, |
2343 | SB_BUFFER_WITH_SB(p_s_tb->tb_sb)); | 2347 | SB_BUFFER_WITH_SB(tb->tb_sb)); |
2344 | if (FILESYSTEM_CHANGED_TB(p_s_tb)) | 2348 | if (FILESYSTEM_CHANGED_TB(tb)) |
2345 | return REPEAT_SEARCH; | 2349 | return REPEAT_SEARCH; |
2346 | 2350 | ||
2347 | /* if it possible in indirect_to_direct conversion */ | 2351 | /* if it possible in indirect_to_direct conversion */ |
2348 | if (buffer_locked(p_s_tbS0)) { | 2352 | if (buffer_locked(tbS0)) { |
2349 | __wait_on_buffer(p_s_tbS0); | 2353 | __wait_on_buffer(tbS0); |
2350 | if (FILESYSTEM_CHANGED_TB(p_s_tb)) | 2354 | if (FILESYSTEM_CHANGED_TB(tb)) |
2351 | return REPEAT_SEARCH; | 2355 | return REPEAT_SEARCH; |
2352 | } | 2356 | } |
2353 | #ifdef CONFIG_REISERFS_CHECK | 2357 | #ifdef CONFIG_REISERFS_CHECK |
2354 | if (cur_tb) { | 2358 | if (cur_tb) { |
2355 | print_cur_tb("fix_nodes"); | 2359 | print_cur_tb("fix_nodes"); |
2356 | reiserfs_panic(p_s_tb->tb_sb, "PAP-8305", | 2360 | reiserfs_panic(tb->tb_sb, "PAP-8305", |
2357 | "there is pending do_balance"); | 2361 | "there is pending do_balance"); |
2358 | } | 2362 | } |
2359 | 2363 | ||
2360 | if (!buffer_uptodate(p_s_tbS0) || !B_IS_IN_TREE(p_s_tbS0)) { | 2364 | if (!buffer_uptodate(tbS0) || !B_IS_IN_TREE(tbS0)) |
2361 | reiserfs_panic(p_s_tb->tb_sb, "PAP-8320", "S[0] (%b %z) is " | 2365 | reiserfs_panic(tb->tb_sb, "PAP-8320", "S[0] (%b %z) is " |
2362 | "not uptodate at the beginning of fix_nodes " | 2366 | "not uptodate at the beginning of fix_nodes " |
2363 | "or not in tree (mode %c)", | 2367 | "or not in tree (mode %c)", |
2364 | p_s_tbS0, p_s_tbS0, n_op_mode); | 2368 | tbS0, tbS0, n_op_mode); |
2365 | } | ||
2366 | 2369 | ||
2367 | /* Check parameters. */ | 2370 | /* Check parameters. */ |
2368 | switch (n_op_mode) { | 2371 | switch (n_op_mode) { |
2369 | case M_INSERT: | 2372 | case M_INSERT: |
2370 | if (n_item_num <= 0 || n_item_num > B_NR_ITEMS(p_s_tbS0)) | 2373 | if (n_item_num <= 0 || n_item_num > B_NR_ITEMS(tbS0)) |
2371 | reiserfs_panic(p_s_tb->tb_sb, "PAP-8330", "Incorrect " | 2374 | reiserfs_panic(tb->tb_sb, "PAP-8330", "Incorrect " |
2372 | "item number %d (in S0 - %d) in case " | 2375 | "item number %d (in S0 - %d) in case " |
2373 | "of insert", n_item_num, | 2376 | "of insert", n_item_num, |
2374 | B_NR_ITEMS(p_s_tbS0)); | 2377 | B_NR_ITEMS(tbS0)); |
2375 | break; | 2378 | break; |
2376 | case M_PASTE: | 2379 | case M_PASTE: |
2377 | case M_DELETE: | 2380 | case M_DELETE: |
2378 | case M_CUT: | 2381 | case M_CUT: |
2379 | if (n_item_num < 0 || n_item_num >= B_NR_ITEMS(p_s_tbS0)) { | 2382 | if (n_item_num < 0 || n_item_num >= B_NR_ITEMS(tbS0)) { |
2380 | print_block(p_s_tbS0, 0, -1, -1); | 2383 | print_block(tbS0, 0, -1, -1); |
2381 | reiserfs_panic(p_s_tb->tb_sb, "PAP-8335", "Incorrect " | 2384 | reiserfs_panic(tb->tb_sb, "PAP-8335", "Incorrect " |
2382 | "item number(%d); mode = %c " | 2385 | "item number(%d); mode = %c " |
2383 | "insert_size = %d", | 2386 | "insert_size = %d", |
2384 | n_item_num, n_op_mode, | 2387 | n_item_num, n_op_mode, |
2385 | p_s_tb->insert_size[0]); | 2388 | tb->insert_size[0]); |
2386 | } | 2389 | } |
2387 | break; | 2390 | break; |
2388 | default: | 2391 | default: |
2389 | reiserfs_panic(p_s_tb->tb_sb, "PAP-8340", "Incorrect mode " | 2392 | reiserfs_panic(tb->tb_sb, "PAP-8340", "Incorrect mode " |
2390 | "of operation"); | 2393 | "of operation"); |
2391 | } | 2394 | } |
2392 | #endif | 2395 | #endif |
2393 | 2396 | ||
2394 | if (get_mem_for_virtual_node(p_s_tb) == REPEAT_SEARCH) | 2397 | if (get_mem_for_virtual_node(tb) == REPEAT_SEARCH) |
2395 | // FIXME: maybe -ENOMEM when tb->vn_buf == 0? Now just repeat | 2398 | // FIXME: maybe -ENOMEM when tb->vn_buf == 0? Now just repeat |
2396 | return REPEAT_SEARCH; | 2399 | return REPEAT_SEARCH; |
2397 | 2400 | ||
2398 | /* Starting from the leaf level; for all levels n_h of the tree. */ | 2401 | /* Starting from the leaf level; for all levels n_h of the tree. */ |
2399 | for (n_h = 0; n_h < MAX_HEIGHT && p_s_tb->insert_size[n_h]; n_h++) { | 2402 | for (n_h = 0; n_h < MAX_HEIGHT && tb->insert_size[n_h]; n_h++) { |
2400 | if ((n_ret_value = get_direct_parent(p_s_tb, n_h)) != CARRY_ON) { | 2403 | n_ret_value = get_direct_parent(tb, n_h); |
2404 | if (n_ret_value != CARRY_ON) | ||
2401 | goto repeat; | 2405 | goto repeat; |
2402 | } | ||
2403 | 2406 | ||
2404 | if ((n_ret_value = | 2407 | n_ret_value = check_balance(n_op_mode, tb, n_h, n_item_num, |
2405 | check_balance(n_op_mode, p_s_tb, n_h, n_item_num, | 2408 | n_pos_in_item, p_s_ins_ih, data); |
2406 | n_pos_in_item, p_s_ins_ih, | 2409 | if (n_ret_value != CARRY_ON) { |
2407 | data)) != CARRY_ON) { | ||
2408 | if (n_ret_value == NO_BALANCING_NEEDED) { | 2410 | if (n_ret_value == NO_BALANCING_NEEDED) { |
2409 | /* No balancing for higher levels needed. */ | 2411 | /* No balancing for higher levels needed. */ |
2410 | if ((n_ret_value = | 2412 | n_ret_value = get_neighbors(tb, n_h); |
2411 | get_neighbors(p_s_tb, n_h)) != CARRY_ON) { | 2413 | if (n_ret_value != CARRY_ON) |
2412 | goto repeat; | 2414 | goto repeat; |
2413 | } | ||
2414 | if (n_h != MAX_HEIGHT - 1) | 2415 | if (n_h != MAX_HEIGHT - 1) |
2415 | p_s_tb->insert_size[n_h + 1] = 0; | 2416 | tb->insert_size[n_h + 1] = 0; |
2416 | /* ok, analysis and resource gathering are complete */ | 2417 | /* ok, analysis and resource gathering are complete */ |
2417 | break; | 2418 | break; |
2418 | } | 2419 | } |
2419 | goto repeat; | 2420 | goto repeat; |
2420 | } | 2421 | } |
2421 | 2422 | ||
2422 | if ((n_ret_value = get_neighbors(p_s_tb, n_h)) != CARRY_ON) { | 2423 | n_ret_value = get_neighbors(tb, n_h); |
2424 | if (n_ret_value != CARRY_ON) | ||
2423 | goto repeat; | 2425 | goto repeat; |
2424 | } | ||
2425 | 2426 | ||
2426 | if ((n_ret_value = get_empty_nodes(p_s_tb, n_h)) != CARRY_ON) { | 2427 | /* No disk space, or schedule occurred and analysis may be |
2427 | goto repeat; /* No disk space, or schedule occurred and | 2428 | * invalid and needs to be redone. */ |
2428 | analysis may be invalid and needs to be redone. */ | 2429 | n_ret_value = get_empty_nodes(tb, n_h); |
2429 | } | 2430 | if (n_ret_value != CARRY_ON) |
2431 | goto repeat; | ||
2430 | 2432 | ||
2431 | if (!PATH_H_PBUFFER(p_s_tb->tb_path, n_h)) { | 2433 | if (!PATH_H_PBUFFER(tb->tb_path, n_h)) { |
2432 | /* We have a positive insert size but no nodes exist on this | 2434 | /* We have a positive insert size but no nodes exist on this |
2433 | level, this means that we are creating a new root. */ | 2435 | level, this means that we are creating a new root. */ |
2434 | 2436 | ||
2435 | RFALSE(p_s_tb->blknum[n_h] != 1, | 2437 | RFALSE(tb->blknum[n_h] != 1, |
2436 | "PAP-8350: creating new empty root"); | 2438 | "PAP-8350: creating new empty root"); |
2437 | 2439 | ||
2438 | if (n_h < MAX_HEIGHT - 1) | 2440 | if (n_h < MAX_HEIGHT - 1) |
2439 | p_s_tb->insert_size[n_h + 1] = 0; | 2441 | tb->insert_size[n_h + 1] = 0; |
2440 | } else if (!PATH_H_PBUFFER(p_s_tb->tb_path, n_h + 1)) { | 2442 | } else if (!PATH_H_PBUFFER(tb->tb_path, n_h + 1)) { |
2441 | if (p_s_tb->blknum[n_h] > 1) { | 2443 | if (tb->blknum[n_h] > 1) { |
2442 | /* The tree needs to be grown, so this node S[n_h] | 2444 | /* The tree needs to be grown, so this node S[n_h] |
2443 | which is the root node is split into two nodes, | 2445 | which is the root node is split into two nodes, |
2444 | and a new node (S[n_h+1]) will be created to | 2446 | and a new node (S[n_h+1]) will be created to |
@@ -2447,19 +2449,20 @@ int fix_nodes(int n_op_mode, struct tree_balance *p_s_tb, struct item_head *p_s_ | |||
2447 | RFALSE(n_h == MAX_HEIGHT - 1, | 2449 | RFALSE(n_h == MAX_HEIGHT - 1, |
2448 | "PAP-8355: attempt to create too high of a tree"); | 2450 | "PAP-8355: attempt to create too high of a tree"); |
2449 | 2451 | ||
2450 | p_s_tb->insert_size[n_h + 1] = | 2452 | tb->insert_size[n_h + 1] = |
2451 | (DC_SIZE + | 2453 | (DC_SIZE + |
2452 | KEY_SIZE) * (p_s_tb->blknum[n_h] - 1) + | 2454 | KEY_SIZE) * (tb->blknum[n_h] - 1) + |
2453 | DC_SIZE; | 2455 | DC_SIZE; |
2454 | } else if (n_h < MAX_HEIGHT - 1) | 2456 | } else if (n_h < MAX_HEIGHT - 1) |
2455 | p_s_tb->insert_size[n_h + 1] = 0; | 2457 | tb->insert_size[n_h + 1] = 0; |
2456 | } else | 2458 | } else |
2457 | p_s_tb->insert_size[n_h + 1] = | 2459 | tb->insert_size[n_h + 1] = |
2458 | (DC_SIZE + KEY_SIZE) * (p_s_tb->blknum[n_h] - 1); | 2460 | (DC_SIZE + KEY_SIZE) * (tb->blknum[n_h] - 1); |
2459 | } | 2461 | } |
2460 | 2462 | ||
2461 | if ((n_ret_value = wait_tb_buffers_until_unlocked(p_s_tb)) == CARRY_ON) { | 2463 | n_ret_value = wait_tb_buffers_until_unlocked(tb); |
2462 | if (FILESYSTEM_CHANGED_TB(p_s_tb)) { | 2464 | if (n_ret_value == CARRY_ON) { |
2465 | if (FILESYSTEM_CHANGED_TB(tb)) { | ||
2463 | wait_tb_buffers_run = 1; | 2466 | wait_tb_buffers_run = 1; |
2464 | n_ret_value = REPEAT_SEARCH; | 2467 | n_ret_value = REPEAT_SEARCH; |
2465 | goto repeat; | 2468 | goto repeat; |
@@ -2482,50 +2485,49 @@ int fix_nodes(int n_op_mode, struct tree_balance *p_s_tb, struct item_head *p_s_ | |||
2482 | 2485 | ||
2483 | /* Release path buffers. */ | 2486 | /* Release path buffers. */ |
2484 | if (wait_tb_buffers_run) { | 2487 | if (wait_tb_buffers_run) { |
2485 | pathrelse_and_restore(p_s_tb->tb_sb, p_s_tb->tb_path); | 2488 | pathrelse_and_restore(tb->tb_sb, tb->tb_path); |
2486 | } else { | 2489 | } else { |
2487 | pathrelse(p_s_tb->tb_path); | 2490 | pathrelse(tb->tb_path); |
2488 | } | 2491 | } |
2489 | /* brelse all resources collected for balancing */ | 2492 | /* brelse all resources collected for balancing */ |
2490 | for (i = 0; i < MAX_HEIGHT; i++) { | 2493 | for (i = 0; i < MAX_HEIGHT; i++) { |
2491 | if (wait_tb_buffers_run) { | 2494 | if (wait_tb_buffers_run) { |
2492 | reiserfs_restore_prepared_buffer(p_s_tb->tb_sb, | 2495 | reiserfs_restore_prepared_buffer(tb->tb_sb, |
2493 | p_s_tb->L[i]); | 2496 | tb->L[i]); |
2494 | reiserfs_restore_prepared_buffer(p_s_tb->tb_sb, | 2497 | reiserfs_restore_prepared_buffer(tb->tb_sb, |
2495 | p_s_tb->R[i]); | 2498 | tb->R[i]); |
2496 | reiserfs_restore_prepared_buffer(p_s_tb->tb_sb, | 2499 | reiserfs_restore_prepared_buffer(tb->tb_sb, |
2497 | p_s_tb->FL[i]); | 2500 | tb->FL[i]); |
2498 | reiserfs_restore_prepared_buffer(p_s_tb->tb_sb, | 2501 | reiserfs_restore_prepared_buffer(tb->tb_sb, |
2499 | p_s_tb->FR[i]); | 2502 | tb->FR[i]); |
2500 | reiserfs_restore_prepared_buffer(p_s_tb->tb_sb, | 2503 | reiserfs_restore_prepared_buffer(tb->tb_sb, |
2501 | p_s_tb-> | 2504 | tb-> |
2502 | CFL[i]); | 2505 | CFL[i]); |
2503 | reiserfs_restore_prepared_buffer(p_s_tb->tb_sb, | 2506 | reiserfs_restore_prepared_buffer(tb->tb_sb, |
2504 | p_s_tb-> | 2507 | tb-> |
2505 | CFR[i]); | 2508 | CFR[i]); |
2506 | } | 2509 | } |
2507 | 2510 | ||
2508 | brelse(p_s_tb->L[i]); | 2511 | brelse(tb->L[i]); |
2509 | brelse(p_s_tb->R[i]); | 2512 | brelse(tb->R[i]); |
2510 | brelse(p_s_tb->FL[i]); | 2513 | brelse(tb->FL[i]); |
2511 | brelse(p_s_tb->FR[i]); | 2514 | brelse(tb->FR[i]); |
2512 | brelse(p_s_tb->CFL[i]); | 2515 | brelse(tb->CFL[i]); |
2513 | brelse(p_s_tb->CFR[i]); | 2516 | brelse(tb->CFR[i]); |
2514 | 2517 | ||
2515 | p_s_tb->L[i] = NULL; | 2518 | tb->L[i] = NULL; |
2516 | p_s_tb->R[i] = NULL; | 2519 | tb->R[i] = NULL; |
2517 | p_s_tb->FL[i] = NULL; | 2520 | tb->FL[i] = NULL; |
2518 | p_s_tb->FR[i] = NULL; | 2521 | tb->FR[i] = NULL; |
2519 | p_s_tb->CFL[i] = NULL; | 2522 | tb->CFL[i] = NULL; |
2520 | p_s_tb->CFR[i] = NULL; | 2523 | tb->CFR[i] = NULL; |
2521 | } | 2524 | } |
2522 | 2525 | ||
2523 | if (wait_tb_buffers_run) { | 2526 | if (wait_tb_buffers_run) { |
2524 | for (i = 0; i < MAX_FEB_SIZE; i++) { | 2527 | for (i = 0; i < MAX_FEB_SIZE; i++) { |
2525 | if (p_s_tb->FEB[i]) { | 2528 | if (tb->FEB[i]) |
2526 | reiserfs_restore_prepared_buffer | 2529 | reiserfs_restore_prepared_buffer |
2527 | (p_s_tb->tb_sb, p_s_tb->FEB[i]); | 2530 | (tb->tb_sb, tb->FEB[i]); |
2528 | } | ||
2529 | } | 2531 | } |
2530 | } | 2532 | } |
2531 | return n_ret_value; | 2533 | return n_ret_value; |
@@ -2533,7 +2535,7 @@ int fix_nodes(int n_op_mode, struct tree_balance *p_s_tb, struct item_head *p_s_ | |||
2533 | 2535 | ||
2534 | } | 2536 | } |
2535 | 2537 | ||
2536 | /* Anatoly will probably forgive me renaming p_s_tb to tb. I just | 2538 | /* Anatoly will probably forgive me renaming tb to tb. I just |
2537 | wanted to make lines shorter */ | 2539 | wanted to make lines shorter */ |
2538 | void unfix_nodes(struct tree_balance *tb) | 2540 | void unfix_nodes(struct tree_balance *tb) |
2539 | { | 2541 | { |
diff --git a/fs/reiserfs/stree.c b/fs/reiserfs/stree.c index 8f220fb777d7..5e867be559ea 100644 --- a/fs/reiserfs/stree.c +++ b/fs/reiserfs/stree.c | |||
@@ -1063,17 +1063,17 @@ static char prepare_for_delete_or_cut(struct reiserfs_transaction_handle *th, st | |||
1063 | } | 1063 | } |
1064 | 1064 | ||
1065 | /* Calculate number of bytes which will be deleted or cut during balance */ | 1065 | /* Calculate number of bytes which will be deleted or cut during balance */ |
1066 | static int calc_deleted_bytes_number(struct tree_balance *p_s_tb, char c_mode) | 1066 | static int calc_deleted_bytes_number(struct tree_balance *tb, char c_mode) |
1067 | { | 1067 | { |
1068 | int n_del_size; | 1068 | int n_del_size; |
1069 | struct item_head *p_le_ih = PATH_PITEM_HEAD(p_s_tb->tb_path); | 1069 | struct item_head *p_le_ih = PATH_PITEM_HEAD(tb->tb_path); |
1070 | 1070 | ||
1071 | if (is_statdata_le_ih(p_le_ih)) | 1071 | if (is_statdata_le_ih(p_le_ih)) |
1072 | return 0; | 1072 | return 0; |
1073 | 1073 | ||
1074 | n_del_size = | 1074 | n_del_size = |
1075 | (c_mode == | 1075 | (c_mode == |
1076 | M_DELETE) ? ih_item_len(p_le_ih) : -p_s_tb->insert_size[0]; | 1076 | M_DELETE) ? ih_item_len(p_le_ih) : -tb->insert_size[0]; |
1077 | if (is_direntry_le_ih(p_le_ih)) { | 1077 | if (is_direntry_le_ih(p_le_ih)) { |
1078 | // return EMPTY_DIR_SIZE; /* We delete emty directoris only. */ | 1078 | // return EMPTY_DIR_SIZE; /* We delete emty directoris only. */ |
1079 | // we can't use EMPTY_DIR_SIZE, as old format dirs have a different | 1079 | // we can't use EMPTY_DIR_SIZE, as old format dirs have a different |
@@ -1083,25 +1083,26 @@ static int calc_deleted_bytes_number(struct tree_balance *p_s_tb, char c_mode) | |||
1083 | } | 1083 | } |
1084 | 1084 | ||
1085 | if (is_indirect_le_ih(p_le_ih)) | 1085 | if (is_indirect_le_ih(p_le_ih)) |
1086 | n_del_size = (n_del_size / UNFM_P_SIZE) * (PATH_PLAST_BUFFER(p_s_tb->tb_path)->b_size); // - get_ih_free_space (p_le_ih); | 1086 | n_del_size = (n_del_size / UNFM_P_SIZE) * |
1087 | (PATH_PLAST_BUFFER(tb->tb_path)->b_size); | ||
1087 | return n_del_size; | 1088 | return n_del_size; |
1088 | } | 1089 | } |
1089 | 1090 | ||
1090 | static void init_tb_struct(struct reiserfs_transaction_handle *th, | 1091 | static void init_tb_struct(struct reiserfs_transaction_handle *th, |
1091 | struct tree_balance *p_s_tb, | 1092 | struct tree_balance *tb, |
1092 | struct super_block *sb, | 1093 | struct super_block *sb, |
1093 | struct treepath *p_s_path, int n_size) | 1094 | struct treepath *p_s_path, int n_size) |
1094 | { | 1095 | { |
1095 | 1096 | ||
1096 | BUG_ON(!th->t_trans_id); | 1097 | BUG_ON(!th->t_trans_id); |
1097 | 1098 | ||
1098 | memset(p_s_tb, '\0', sizeof(struct tree_balance)); | 1099 | memset(tb, '\0', sizeof(struct tree_balance)); |
1099 | p_s_tb->transaction_handle = th; | 1100 | tb->transaction_handle = th; |
1100 | p_s_tb->tb_sb = sb; | 1101 | tb->tb_sb = sb; |
1101 | p_s_tb->tb_path = p_s_path; | 1102 | tb->tb_path = p_s_path; |
1102 | PATH_OFFSET_PBUFFER(p_s_path, ILLEGAL_PATH_ELEMENT_OFFSET) = NULL; | 1103 | PATH_OFFSET_PBUFFER(p_s_path, ILLEGAL_PATH_ELEMENT_OFFSET) = NULL; |
1103 | PATH_OFFSET_POSITION(p_s_path, ILLEGAL_PATH_ELEMENT_OFFSET) = 0; | 1104 | PATH_OFFSET_POSITION(p_s_path, ILLEGAL_PATH_ELEMENT_OFFSET) = 0; |
1104 | p_s_tb->insert_size[0] = n_size; | 1105 | tb->insert_size[0] = n_size; |
1105 | } | 1106 | } |
1106 | 1107 | ||
1107 | void padd_item(char *item, int total_length, int length) | 1108 | void padd_item(char *item, int total_length, int length) |