diff options
author | Jeff Mahoney <jeffm@suse.com> | 2009-03-30 14:02:50 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2009-03-30 15:16:40 -0400 |
commit | ee93961be1faddf9e9a638bc519145c20f0cfeba (patch) | |
tree | 9c62f05dca9ea72c2b419a7f1f9d5874b587e5ab /fs/reiserfs/fix_node.c | |
parent | d68caa9530a8ba54f97002e02bf6a0ad2462b8c0 (diff) |
reiserfs: rename [cn]_* variables
This patch renames n_, c_, etc variables to something more sane. This
is the sixth in a series of patches to rip out some of the awful
variable naming in reiserfs.
Signed-off-by: Jeff Mahoney <jeffm@suse.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'fs/reiserfs/fix_node.c')
-rw-r--r-- | fs/reiserfs/fix_node.c | 474 |
1 files changed, 237 insertions, 237 deletions
diff --git a/fs/reiserfs/fix_node.c b/fs/reiserfs/fix_node.c index d97a55574ba9..5e5a4e6fbaf8 100644 --- a/fs/reiserfs/fix_node.c +++ b/fs/reiserfs/fix_node.c | |||
@@ -751,24 +751,24 @@ else \ | |||
751 | 751 | ||
752 | static void free_buffers_in_tb(struct tree_balance *tb) | 752 | static void free_buffers_in_tb(struct tree_balance *tb) |
753 | { | 753 | { |
754 | int n_counter; | 754 | int i; |
755 | 755 | ||
756 | pathrelse(tb->tb_path); | 756 | pathrelse(tb->tb_path); |
757 | 757 | ||
758 | for (n_counter = 0; n_counter < MAX_HEIGHT; n_counter++) { | 758 | for (i = 0; i < MAX_HEIGHT; i++) { |
759 | brelse(tb->L[n_counter]); | 759 | brelse(tb->L[i]); |
760 | brelse(tb->R[n_counter]); | 760 | brelse(tb->R[i]); |
761 | brelse(tb->FL[n_counter]); | 761 | brelse(tb->FL[i]); |
762 | brelse(tb->FR[n_counter]); | 762 | brelse(tb->FR[i]); |
763 | brelse(tb->CFL[n_counter]); | 763 | brelse(tb->CFL[i]); |
764 | brelse(tb->CFR[n_counter]); | 764 | brelse(tb->CFR[i]); |
765 | 765 | ||
766 | tb->L[n_counter] = NULL; | 766 | tb->L[i] = NULL; |
767 | tb->R[n_counter] = NULL; | 767 | tb->R[i] = NULL; |
768 | tb->FL[n_counter] = NULL; | 768 | tb->FL[i] = NULL; |
769 | tb->FR[n_counter] = NULL; | 769 | tb->FR[i] = NULL; |
770 | tb->CFL[n_counter] = NULL; | 770 | tb->CFL[i] = NULL; |
771 | tb->CFR[n_counter] = NULL; | 771 | tb->CFR[i] = NULL; |
772 | } | 772 | } |
773 | } | 773 | } |
774 | 774 | ||
@@ -778,13 +778,13 @@ static void free_buffers_in_tb(struct tree_balance *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 *tb, int n_h) | 781 | static int get_empty_nodes(struct tree_balance *tb, int h) |
782 | { | 782 | { |
783 | struct buffer_head *new_bh, | 783 | struct buffer_head *new_bh, |
784 | *Sh = PATH_H_PBUFFER(tb->tb_path, n_h); | 784 | *Sh = PATH_H_PBUFFER(tb->tb_path, h); |
785 | b_blocknr_t *blocknr, a_n_blocknrs[MAX_AMOUNT_NEEDED] = { 0, }; | 785 | b_blocknr_t *blocknr, blocknrs[MAX_AMOUNT_NEEDED] = { 0, }; |
786 | int n_counter, n_number_of_freeblk, n_amount_needed, /* number of needed empty blocks */ | 786 | int counter, number_of_freeblk, amount_needed, /* number of needed empty blocks */ |
787 | n_retval = CARRY_ON; | 787 | retval = CARRY_ON; |
788 | struct super_block *sb = 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 |
@@ -793,7 +793,7 @@ static int get_empty_nodes(struct tree_balance *tb, int n_h) | |||
793 | number_of_freeblk = tb->cur_blknum can be non-zero if a schedule occurs | 793 | number_of_freeblk = tb->cur_blknum can be non-zero if a schedule occurs |
794 | after empty blocks are acquired, and the balancing analysis is | 794 | after empty blocks are acquired, and the balancing analysis is |
795 | then restarted, amount_needed is the number needed by this level | 795 | then restarted, amount_needed is the number needed by this level |
796 | (n_h) of the balancing analysis. | 796 | (h) of the balancing analysis. |
797 | 797 | ||
798 | Note that for systems with many processes writing, it would be | 798 | Note that for systems with many processes writing, it would be |
799 | more layout optimal to calculate the total number needed by all | 799 | more layout optimal to calculate the total number needed by all |
@@ -801,31 +801,31 @@ static int get_empty_nodes(struct tree_balance *tb, int n_h) | |||
801 | 801 | ||
802 | /* Initiate number_of_freeblk to the amount acquired prior to the restart of | 802 | /* Initiate number_of_freeblk to the amount acquired prior to the restart of |
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 h. */ |
805 | /* blknum includes S[n_h], so we subtract 1 in this calculation */ | 805 | /* blknum includes S[h], so we subtract 1 in this calculation */ |
806 | for (n_counter = 0, n_number_of_freeblk = tb->cur_blknum; | 806 | for (counter = 0, number_of_freeblk = tb->cur_blknum; |
807 | n_counter < n_h; n_counter++) | 807 | counter < h; counter++) |
808 | n_number_of_freeblk -= | 808 | number_of_freeblk -= |
809 | (tb->blknum[n_counter]) ? (tb->blknum[n_counter] - | 809 | (tb->blknum[counter]) ? (tb->blknum[counter] - |
810 | 1) : 0; | 810 | 1) : 0; |
811 | 811 | ||
812 | /* Allocate missing empty blocks. */ | 812 | /* Allocate missing empty blocks. */ |
813 | /* if Sh == 0 then we are getting a new root */ | 813 | /* if Sh == 0 then we are getting a new root */ |
814 | n_amount_needed = (Sh) ? (tb->blknum[n_h] - 1) : 1; | 814 | amount_needed = (Sh) ? (tb->blknum[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 (amount_needed > number_of_freeblk) |
817 | n_amount_needed -= n_number_of_freeblk; | 817 | amount_needed -= number_of_freeblk; |
818 | else /* If we have enough already then there is nothing to do. */ | 818 | else /* If we have enough already then there is nothing to do. */ |
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(tb, a_n_blocknrs, | 822 | if (reiserfs_new_form_blocknrs(tb, blocknrs, |
823 | n_amount_needed) == NO_DISK_SPACE) | 823 | amount_needed) == NO_DISK_SPACE) |
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 (blocknr = a_n_blocknrs, n_counter = 0; | 827 | for (blocknr = blocknrs, counter = 0; |
828 | n_counter < n_amount_needed; blocknr++, n_counter++) { | 828 | counter < amount_needed; blocknr++, counter++) { |
829 | 829 | ||
830 | RFALSE(!*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"); |
@@ -845,10 +845,10 @@ static int get_empty_nodes(struct tree_balance *tb, int n_h) | |||
845 | tb->FEB[tb->cur_blknum++] = 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 (retval == CARRY_ON && FILESYSTEM_CHANGED_TB(tb)) |
849 | n_retval = REPEAT_SEARCH; | 849 | retval = REPEAT_SEARCH; |
850 | 850 | ||
851 | return n_retval; | 851 | return retval; |
852 | } | 852 | } |
853 | 853 | ||
854 | /* Get free space of the left neighbor, which is stored in the parent | 854 | /* Get free space of the left neighbor, which is stored in the parent |
@@ -896,36 +896,36 @@ 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 *tb, int n_h) | 899 | static int is_left_neighbor_in_cache(struct tree_balance *tb, int h) |
900 | { | 900 | { |
901 | struct buffer_head *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 left_neighbor_blocknr; |
904 | int n_left_neighbor_position; | 904 | int left_neighbor_position; |
905 | 905 | ||
906 | /* Father of the left neighbor does not exist. */ | 906 | /* Father of the left neighbor does not exist. */ |
907 | if (!tb->FL[n_h]) | 907 | if (!tb->FL[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 | father = PATH_H_PBUFFER(tb->tb_path, n_h + 1); | 911 | father = PATH_H_PBUFFER(tb->tb_path, h + 1); |
912 | 912 | ||
913 | RFALSE(!father || | 913 | RFALSE(!father || |
914 | !B_IS_IN_TREE(father) || | 914 | !B_IS_IN_TREE(father) || |
915 | !B_IS_IN_TREE(tb->FL[n_h]) || | 915 | !B_IS_IN_TREE(tb->FL[h]) || |
916 | !buffer_uptodate(father) || | 916 | !buffer_uptodate(father) || |
917 | !buffer_uptodate(tb->FL[n_h]), | 917 | !buffer_uptodate(tb->FL[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 | father, tb->FL[n_h]); | 919 | father, tb->FL[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 = (father == tb->FL[n_h]) ? | 922 | left_neighbor_position = (father == tb->FL[h]) ? |
923 | tb->lkey[n_h] : B_NR_ITEMS(tb->FL[n_h]); | 923 | tb->lkey[h] : B_NR_ITEMS(tb->FL[h]); |
924 | /* Get left neighbor block number. */ | 924 | /* Get left neighbor block number. */ |
925 | n_left_neighbor_blocknr = | 925 | left_neighbor_blocknr = |
926 | B_N_CHILD_NUM(tb->FL[n_h], n_left_neighbor_position); | 926 | B_N_CHILD_NUM(tb->FL[h], left_neighbor_position); |
927 | /* Look for the left neighbor in the cache. */ | 927 | /* Look for the left neighbor in the cache. */ |
928 | if ((left = sb_find_get_block(sb, n_left_neighbor_blocknr))) { | 928 | if ((left = sb_find_get_block(sb, left_neighbor_blocknr))) { |
929 | 929 | ||
930 | RFALSE(buffer_uptodate(left) && !B_IS_IN_TREE(left), | 930 | RFALSE(buffer_uptodate(left) && !B_IS_IN_TREE(left), |
931 | "vs-8170: left neighbor (%b %z) is not in the tree", | 931 | "vs-8170: left neighbor (%b %z) is not in the tree", |
@@ -955,7 +955,7 @@ static void decrement_key(struct cpu_key *key) | |||
955 | * CARRY_ON - schedule didn't occur while the function worked; | 955 | * CARRY_ON - schedule didn't occur while the function worked; |
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 h, |
959 | struct buffer_head **pfather, | 959 | struct buffer_head **pfather, |
960 | struct buffer_head **pcom_father, char c_lr_par) | 960 | struct buffer_head **pcom_father, char c_lr_par) |
961 | { | 961 | { |
@@ -963,38 +963,38 @@ static int get_far_parent(struct tree_balance *tb, | |||
963 | INITIALIZE_PATH(s_path_to_neighbor_father); | 963 | INITIALIZE_PATH(s_path_to_neighbor_father); |
964 | struct treepath *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 counter, |
967 | n_position = INT_MAX, | 967 | position = INT_MAX, |
968 | n_first_last_position = 0, | 968 | first_last_position = 0, |
969 | n_path_offset = PATH_H_PATH_OFFSET(path, n_h); | 969 | path_offset = PATH_H_PATH_OFFSET(path, h); |
970 | 970 | ||
971 | /* Starting from F[n_h] go upwards in the tree, and look for the common | 971 | /* Starting from F[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[h], and its neighbor l/r, that should be obtained. */ |
973 | 973 | ||
974 | n_counter = n_path_offset; | 974 | counter = path_offset; |
975 | 975 | ||
976 | RFALSE(n_counter < FIRST_PATH_ELEMENT_OFFSET, | 976 | RFALSE(counter < FIRST_PATH_ELEMENT_OFFSET, |
977 | "PAP-8180: invalid path length"); | 977 | "PAP-8180: invalid path length"); |
978 | 978 | ||
979 | for (; n_counter > FIRST_PATH_ELEMENT_OFFSET; n_counter--) { | 979 | for (; counter > FIRST_PATH_ELEMENT_OFFSET; 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 | (parent = PATH_OFFSET_PBUFFER(path, n_counter - 1))) | 982 | (parent = PATH_OFFSET_PBUFFER(path, 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 ((position = |
986 | PATH_OFFSET_POSITION(path, | 986 | PATH_OFFSET_POSITION(path, |
987 | n_counter - 1)) > | 987 | counter - 1)) > |
988 | B_NR_ITEMS(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(parent, n_position) != | 991 | if (B_N_CHILD_NUM(parent, position) != |
992 | PATH_OFFSET_PBUFFER(path, n_counter)->b_blocknr) | 992 | PATH_OFFSET_PBUFFER(path, 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(parent); | 996 | first_last_position = B_NR_ITEMS(parent); |
997 | if (n_position != n_first_last_position) { | 997 | if (position != first_last_position) { |
998 | *pcom_father = parent; | 998 | *pcom_father = parent; |
999 | get_bh(*pcom_father); | 999 | get_bh(*pcom_father); |
1000 | /*(*pcom_father = parent)->b_count++; */ | 1000 | /*(*pcom_father = parent)->b_count++; */ |
@@ -1003,7 +1003,7 @@ static int get_far_parent(struct tree_balance *tb, | |||
1003 | } | 1003 | } |
1004 | 1004 | ||
1005 | /* if we are in the root of the tree, then there is no common father */ | 1005 | /* if we are in the root of the tree, then there is no common father */ |
1006 | if (n_counter == FIRST_PATH_ELEMENT_OFFSET) { | 1006 | if (counter == FIRST_PATH_ELEMENT_OFFSET) { |
1007 | /* 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. */ |
1008 | if (PATH_OFFSET_PBUFFER | 1008 | if (PATH_OFFSET_PBUFFER |
1009 | (tb->tb_path, | 1009 | (tb->tb_path, |
@@ -1036,18 +1036,18 @@ static int get_far_parent(struct tree_balance *tb, | |||
1036 | le_key2cpu_key(&s_lr_father_key, | 1036 | le_key2cpu_key(&s_lr_father_key, |
1037 | B_N_PDELIM_KEY(*pcom_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[h - 1] = |
1040 | n_position - | 1040 | position - |
1041 | 1) : (tb->rkey[n_h - | 1041 | 1) : (tb->rkey[h - |
1042 | 1] = | 1042 | 1] = |
1043 | n_position))); | 1043 | position))); |
1044 | 1044 | ||
1045 | if (c_lr_par == LEFT_PARENTS) | 1045 | if (c_lr_par == LEFT_PARENTS) |
1046 | decrement_key(&s_lr_father_key); | 1046 | decrement_key(&s_lr_father_key); |
1047 | 1047 | ||
1048 | if (search_by_key | 1048 | if (search_by_key |
1049 | (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, |
1050 | n_h + 1) == IO_ERROR) | 1050 | h + 1) == IO_ERROR) |
1051 | // path is released | 1051 | // path is released |
1052 | return IO_ERROR; | 1052 | return IO_ERROR; |
1053 | 1053 | ||
@@ -1059,7 +1059,7 @@ static int get_far_parent(struct tree_balance *tb, | |||
1059 | 1059 | ||
1060 | *pfather = PATH_PLAST_BUFFER(&s_path_to_neighbor_father); | 1060 | *pfather = PATH_PLAST_BUFFER(&s_path_to_neighbor_father); |
1061 | 1061 | ||
1062 | RFALSE(B_LEVEL(*pfather) != n_h + 1, | 1062 | RFALSE(B_LEVEL(*pfather) != h + 1, |
1063 | "PAP-8190: (%b %z) level too small", *pfather, *pfather); | 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"); |
@@ -1069,92 +1069,92 @@ static int get_far_parent(struct tree_balance *tb, | |||
1069 | return CARRY_ON; | 1069 | return CARRY_ON; |
1070 | } | 1070 | } |
1071 | 1071 | ||
1072 | /* Get parents of neighbors of node in the path(S[n_path_offset]) and common parents of | 1072 | /* Get parents of neighbors of node in the path(S[path_offset]) and common parents of |
1073 | * S[n_path_offset] and L[n_path_offset]/R[n_path_offset]: F[n_path_offset], FL[n_path_offset], | 1073 | * S[path_offset] and L[path_offset]/R[path_offset]: F[path_offset], FL[path_offset], |
1074 | * FR[n_path_offset], CFL[n_path_offset], CFR[n_path_offset]. | 1074 | * FR[path_offset], CFL[path_offset], CFR[path_offset]. |
1075 | * Calculate numbers of left and right delimiting keys position: lkey[n_path_offset], rkey[n_path_offset]. | 1075 | * Calculate numbers of left and right delimiting keys position: lkey[path_offset], rkey[path_offset]. |
1076 | * Returns: SCHEDULE_OCCURRED - schedule occurred while the function worked; | 1076 | * Returns: SCHEDULE_OCCURRED - schedule occurred while the function worked; |
1077 | * CARRY_ON - schedule didn't occur while the function worked; | 1077 | * CARRY_ON - schedule didn't occur while the function worked; |
1078 | */ | 1078 | */ |
1079 | static int get_parents(struct tree_balance *tb, int n_h) | 1079 | static int get_parents(struct tree_balance *tb, int h) |
1080 | { | 1080 | { |
1081 | struct treepath *path = tb->tb_path; | 1081 | struct treepath *path = tb->tb_path; |
1082 | int n_position, | 1082 | int position, |
1083 | n_ret_value, | 1083 | ret, |
1084 | n_path_offset = PATH_H_PATH_OFFSET(tb->tb_path, n_h); | 1084 | path_offset = PATH_H_PATH_OFFSET(tb->tb_path, h); |
1085 | struct buffer_head *curf, *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 (path_offset <= FIRST_PATH_ELEMENT_OFFSET) { |
1089 | /* The root can not have parents. | 1089 | /* The root can not have parents. |
1090 | 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. */ |
1091 | brelse(tb->FL[n_h]); | 1091 | brelse(tb->FL[h]); |
1092 | brelse(tb->CFL[n_h]); | 1092 | brelse(tb->CFL[h]); |
1093 | brelse(tb->FR[n_h]); | 1093 | brelse(tb->FR[h]); |
1094 | brelse(tb->CFR[n_h]); | 1094 | brelse(tb->CFR[h]); |
1095 | tb->FL[n_h] = NULL; | 1095 | tb->FL[h] = NULL; |
1096 | tb->CFL[n_h] = NULL; | 1096 | tb->CFL[h] = NULL; |
1097 | tb->FR[n_h] = NULL; | 1097 | tb->FR[h] = NULL; |
1098 | tb->CFR[n_h] = NULL; | 1098 | tb->CFR[h] = NULL; |
1099 | return CARRY_ON; | 1099 | return CARRY_ON; |
1100 | } | 1100 | } |
1101 | 1101 | ||
1102 | /* Get parent FL[n_path_offset] of L[n_path_offset]. */ | 1102 | /* Get parent FL[path_offset] of L[path_offset]. */ |
1103 | n_position = PATH_OFFSET_POSITION(path, n_path_offset - 1); | 1103 | position = PATH_OFFSET_POSITION(path, path_offset - 1); |
1104 | if (n_position) { | 1104 | if (position) { |
1105 | /* Current node is not the first child of its parent. */ | 1105 | /* Current node is not the first child of its parent. */ |
1106 | curf = PATH_OFFSET_PBUFFER(path, n_path_offset - 1); | 1106 | curf = PATH_OFFSET_PBUFFER(path, path_offset - 1); |
1107 | curcf = PATH_OFFSET_PBUFFER(path, n_path_offset - 1); | 1107 | curcf = PATH_OFFSET_PBUFFER(path, path_offset - 1); |
1108 | get_bh(curf); | 1108 | get_bh(curf); |
1109 | get_bh(curf); | 1109 | get_bh(curf); |
1110 | tb->lkey[n_h] = n_position - 1; | 1110 | tb->lkey[h] = 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[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[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[path_offset] not equal FL[path_offset] and CFL[path_offset] not equal F[path_offset]. |
1115 | Calculate lkey[n_path_offset]. */ | 1115 | Calculate lkey[path_offset]. */ |
1116 | if ((n_ret_value = get_far_parent(tb, n_h + 1, &curf, | 1116 | if ((ret = get_far_parent(tb, h + 1, &curf, |
1117 | &curcf, | 1117 | &curcf, |
1118 | LEFT_PARENTS)) != CARRY_ON) | 1118 | LEFT_PARENTS)) != CARRY_ON) |
1119 | return n_ret_value; | 1119 | return ret; |
1120 | } | 1120 | } |
1121 | 1121 | ||
1122 | brelse(tb->FL[n_h]); | 1122 | brelse(tb->FL[h]); |
1123 | tb->FL[n_h] = curf; /* New initialization of FL[n_h]. */ | 1123 | tb->FL[h] = curf; /* New initialization of FL[h]. */ |
1124 | brelse(tb->CFL[n_h]); | 1124 | brelse(tb->CFL[h]); |
1125 | tb->CFL[n_h] = curcf; /* New initialization of CFL[n_h]. */ | 1125 | tb->CFL[h] = curcf; /* New initialization of CFL[h]. */ |
1126 | 1126 | ||
1127 | RFALSE((curf && !B_IS_IN_TREE(curf)) || | 1127 | RFALSE((curf && !B_IS_IN_TREE(curf)) || |
1128 | (curcf && !B_IS_IN_TREE(curcf)), | 1128 | (curcf && !B_IS_IN_TREE(curcf)), |
1129 | "PAP-8195: FL (%b) or CFL (%b) is invalid", curf, 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[h] of R[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[h]. FR[h] != F[h]. */ |
1134 | if (n_position == B_NR_ITEMS(PATH_H_PBUFFER(path, n_h + 1))) { | 1134 | if (position == B_NR_ITEMS(PATH_H_PBUFFER(path, 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[h], which is the right neighbor of F[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[h] and current node. Note that CFR[h] |
1137 | not equal FR[n_path_offset] and CFR[n_h] not equal F[n_h]. */ | 1137 | not equal FR[path_offset] and CFR[h] not equal F[h]. */ |
1138 | if ((n_ret_value = | 1138 | if ((ret = |
1139 | get_far_parent(tb, n_h + 1, &curf, &curcf, | 1139 | get_far_parent(tb, h + 1, &curf, &curcf, |
1140 | RIGHT_PARENTS)) != CARRY_ON) | 1140 | RIGHT_PARENTS)) != CARRY_ON) |
1141 | return n_ret_value; | 1141 | return ret; |
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[h]. */ |
1144 | curf = PATH_OFFSET_PBUFFER(path, n_path_offset - 1); | 1144 | curf = PATH_OFFSET_PBUFFER(path, path_offset - 1); |
1145 | curcf = PATH_OFFSET_PBUFFER(path, n_path_offset - 1); | 1145 | curcf = PATH_OFFSET_PBUFFER(path, path_offset - 1); |
1146 | get_bh(curf); | 1146 | get_bh(curf); |
1147 | get_bh(curf); | 1147 | get_bh(curf); |
1148 | tb->rkey[n_h] = n_position; | 1148 | tb->rkey[h] = position; |
1149 | } | 1149 | } |
1150 | 1150 | ||
1151 | brelse(tb->FR[n_h]); | 1151 | brelse(tb->FR[h]); |
1152 | /* New initialization of FR[n_path_offset]. */ | 1152 | /* New initialization of FR[path_offset]. */ |
1153 | tb->FR[n_h] = curf; | 1153 | tb->FR[h] = curf; |
1154 | 1154 | ||
1155 | brelse(tb->CFR[n_h]); | 1155 | brelse(tb->CFR[h]); |
1156 | /* New initialization of CFR[n_path_offset]. */ | 1156 | /* New initialization of CFR[path_offset]. */ |
1157 | tb->CFR[n_h] = curcf; | 1157 | tb->CFR[h] = curcf; |
1158 | 1158 | ||
1159 | RFALSE((curf && !B_IS_IN_TREE(curf)) || | 1159 | RFALSE((curf && !B_IS_IN_TREE(curf)) || |
1160 | (curcf && !B_IS_IN_TREE(curcf)), | 1160 | (curcf && !B_IS_IN_TREE(curcf)), |
@@ -1222,7 +1222,7 @@ static int ip_check_balance(struct tree_balance *tb, int h) | |||
1222 | contains node being balanced. The mnemonic is | 1222 | contains node being balanced. The mnemonic is |
1223 | that the attempted change in node space used level | 1223 | that the attempted change in node space used level |
1224 | is levbytes bytes. */ | 1224 | is levbytes bytes. */ |
1225 | n_ret_value; | 1225 | ret; |
1226 | 1226 | ||
1227 | int lfree, sfree, rfree /* free space in L, S and R */ ; | 1227 | int lfree, sfree, rfree /* free space in L, S and R */ ; |
1228 | 1228 | ||
@@ -1262,22 +1262,22 @@ static int ip_check_balance(struct tree_balance *tb, int h) | |||
1262 | if (!h) | 1262 | if (!h) |
1263 | reiserfs_panic(tb->tb_sb, "vs-8210", | 1263 | reiserfs_panic(tb->tb_sb, "vs-8210", |
1264 | "S[0] can not be 0"); | 1264 | "S[0] can not be 0"); |
1265 | switch (n_ret_value = get_empty_nodes(tb, h)) { | 1265 | switch (ret = get_empty_nodes(tb, h)) { |
1266 | case CARRY_ON: | 1266 | case CARRY_ON: |
1267 | set_parameters(tb, h, 0, 0, 1, NULL, -1, -1); | 1267 | set_parameters(tb, h, 0, 0, 1, NULL, -1, -1); |
1268 | return NO_BALANCING_NEEDED; /* no balancing for higher levels needed */ | 1268 | return NO_BALANCING_NEEDED; /* no balancing for higher levels needed */ |
1269 | 1269 | ||
1270 | case NO_DISK_SPACE: | 1270 | case NO_DISK_SPACE: |
1271 | case REPEAT_SEARCH: | 1271 | case REPEAT_SEARCH: |
1272 | return n_ret_value; | 1272 | return ret; |
1273 | default: | 1273 | default: |
1274 | reiserfs_panic(tb->tb_sb, "vs-8215", "incorrect " | 1274 | reiserfs_panic(tb->tb_sb, "vs-8215", "incorrect " |
1275 | "return value of get_empty_nodes"); | 1275 | "return value of get_empty_nodes"); |
1276 | } | 1276 | } |
1277 | } | 1277 | } |
1278 | 1278 | ||
1279 | if ((n_ret_value = get_parents(tb, h)) != CARRY_ON) /* get parents of S[h] neighbors. */ | 1279 | if ((ret = get_parents(tb, h)) != CARRY_ON) /* get parents of S[h] neighbors. */ |
1280 | return n_ret_value; | 1280 | return ret; |
1281 | 1281 | ||
1282 | sfree = B_FREE_SPACE(Sh); | 1282 | sfree = B_FREE_SPACE(Sh); |
1283 | 1283 | ||
@@ -1564,7 +1564,7 @@ static int dc_check_balance_internal(struct tree_balance *tb, int h) | |||
1564 | /* Sh is the node whose balance is currently being checked, | 1564 | /* Sh is the node whose balance is currently being checked, |
1565 | and Fh is its father. */ | 1565 | and Fh is its father. */ |
1566 | struct buffer_head *Sh, *Fh; | 1566 | struct buffer_head *Sh, *Fh; |
1567 | int maxsize, n_ret_value; | 1567 | int maxsize, ret; |
1568 | int lfree, rfree /* free space in L and R */ ; | 1568 | int lfree, rfree /* free space in L and R */ ; |
1569 | 1569 | ||
1570 | Sh = PATH_H_PBUFFER(tb->tb_path, h); | 1570 | Sh = PATH_H_PBUFFER(tb->tb_path, h); |
@@ -1589,8 +1589,8 @@ static int dc_check_balance_internal(struct tree_balance *tb, int h) | |||
1589 | return CARRY_ON; | 1589 | return CARRY_ON; |
1590 | } | 1590 | } |
1591 | 1591 | ||
1592 | if ((n_ret_value = get_parents(tb, h)) != CARRY_ON) | 1592 | if ((ret = get_parents(tb, h)) != CARRY_ON) |
1593 | return n_ret_value; | 1593 | return ret; |
1594 | 1594 | ||
1595 | /* get free space of neighbors */ | 1595 | /* get free space of neighbors */ |
1596 | rfree = get_rfree(tb, h); | 1596 | rfree = get_rfree(tb, h); |
@@ -1747,7 +1747,7 @@ static int dc_check_balance_leaf(struct tree_balance *tb, int h) | |||
1747 | attempted change in node space used level is levbytes bytes. */ | 1747 | attempted change in node space used level is levbytes bytes. */ |
1748 | int levbytes; | 1748 | int levbytes; |
1749 | /* the maximal item size */ | 1749 | /* the maximal item size */ |
1750 | int maxsize, n_ret_value; | 1750 | int maxsize, ret; |
1751 | /* S0 is the node whose balance is currently being checked, | 1751 | /* S0 is the node whose balance is currently being checked, |
1752 | and F0 is its father. */ | 1752 | and F0 is its father. */ |
1753 | struct buffer_head *S0, *F0; | 1753 | struct buffer_head *S0, *F0; |
@@ -1769,8 +1769,8 @@ static int dc_check_balance_leaf(struct tree_balance *tb, int h) | |||
1769 | return NO_BALANCING_NEEDED; | 1769 | return NO_BALANCING_NEEDED; |
1770 | } | 1770 | } |
1771 | 1771 | ||
1772 | if ((n_ret_value = get_parents(tb, h)) != CARRY_ON) | 1772 | if ((ret = get_parents(tb, h)) != CARRY_ON) |
1773 | return n_ret_value; | 1773 | return ret; |
1774 | 1774 | ||
1775 | /* get free space of neighbors */ | 1775 | /* get free space of neighbors */ |
1776 | rfree = get_rfree(tb, h); | 1776 | rfree = get_rfree(tb, h); |
@@ -1889,40 +1889,40 @@ static int check_balance(int mode, | |||
1889 | } | 1889 | } |
1890 | 1890 | ||
1891 | /* Check whether parent at the path is the really parent of the current node.*/ | 1891 | /* Check whether parent at the path is the really parent of the current node.*/ |
1892 | static int get_direct_parent(struct tree_balance *tb, int n_h) | 1892 | static int get_direct_parent(struct tree_balance *tb, int h) |
1893 | { | 1893 | { |
1894 | struct buffer_head *bh; | 1894 | struct buffer_head *bh; |
1895 | struct treepath *path = tb->tb_path; | 1895 | struct treepath *path = tb->tb_path; |
1896 | int n_position, | 1896 | int position, |
1897 | n_path_offset = PATH_H_PATH_OFFSET(tb->tb_path, n_h); | 1897 | path_offset = PATH_H_PATH_OFFSET(tb->tb_path, h); |
1898 | 1898 | ||
1899 | /* We are in the root or in the new root. */ | 1899 | /* We are in the root or in the new root. */ |
1900 | if (n_path_offset <= FIRST_PATH_ELEMENT_OFFSET) { | 1900 | if (path_offset <= FIRST_PATH_ELEMENT_OFFSET) { |
1901 | 1901 | ||
1902 | RFALSE(n_path_offset < FIRST_PATH_ELEMENT_OFFSET - 1, | 1902 | RFALSE(path_offset < FIRST_PATH_ELEMENT_OFFSET - 1, |
1903 | "PAP-8260: invalid offset in the path"); | 1903 | "PAP-8260: invalid offset in the path"); |
1904 | 1904 | ||
1905 | if (PATH_OFFSET_PBUFFER(path, FIRST_PATH_ELEMENT_OFFSET)-> | 1905 | if (PATH_OFFSET_PBUFFER(path, FIRST_PATH_ELEMENT_OFFSET)-> |
1906 | b_blocknr == SB_ROOT_BLOCK(tb->tb_sb)) { | 1906 | b_blocknr == SB_ROOT_BLOCK(tb->tb_sb)) { |
1907 | /* Root is not changed. */ | 1907 | /* Root is not changed. */ |
1908 | PATH_OFFSET_PBUFFER(path, n_path_offset - 1) = NULL; | 1908 | PATH_OFFSET_PBUFFER(path, path_offset - 1) = NULL; |
1909 | PATH_OFFSET_POSITION(path, n_path_offset - 1) = 0; | 1909 | PATH_OFFSET_POSITION(path, path_offset - 1) = 0; |
1910 | return CARRY_ON; | 1910 | return CARRY_ON; |
1911 | } | 1911 | } |
1912 | 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. */ |
1913 | } | 1913 | } |
1914 | 1914 | ||
1915 | if (!B_IS_IN_TREE | 1915 | if (!B_IS_IN_TREE |
1916 | (bh = PATH_OFFSET_PBUFFER(path, n_path_offset - 1))) | 1916 | (bh = PATH_OFFSET_PBUFFER(path, path_offset - 1))) |
1917 | 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. */ |
1918 | 1918 | ||
1919 | if ((n_position = | 1919 | if ((position = |
1920 | PATH_OFFSET_POSITION(path, | 1920 | PATH_OFFSET_POSITION(path, |
1921 | n_path_offset - 1)) > B_NR_ITEMS(bh)) | 1921 | path_offset - 1)) > B_NR_ITEMS(bh)) |
1922 | return REPEAT_SEARCH; | 1922 | return REPEAT_SEARCH; |
1923 | 1923 | ||
1924 | if (B_N_CHILD_NUM(bh, n_position) != | 1924 | if (B_N_CHILD_NUM(bh, position) != |
1925 | PATH_OFFSET_PBUFFER(path, n_path_offset)->b_blocknr) | 1925 | PATH_OFFSET_PBUFFER(path, path_offset)->b_blocknr) |
1926 | /* 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. */ |
1927 | return REPEAT_SEARCH; | 1927 | return REPEAT_SEARCH; |
1928 | 1928 | ||
@@ -1935,92 +1935,92 @@ static int get_direct_parent(struct tree_balance *tb, int n_h) | |||
1935 | return CARRY_ON; /* Parent in the path is unlocked and really parent of the current node. */ | 1935 | return CARRY_ON; /* Parent in the path is unlocked and really parent of the current node. */ |
1936 | } | 1936 | } |
1937 | 1937 | ||
1938 | /* Using lnum[n_h] and rnum[n_h] we should determine what neighbors | 1938 | /* Using lnum[h] and rnum[h] we should determine what neighbors |
1939 | * of S[n_h] we | 1939 | * of S[h] we |
1940 | * need in order to balance S[n_h], and get them if necessary. | 1940 | * need in order to balance S[h], and get them if necessary. |
1941 | * Returns: SCHEDULE_OCCURRED - schedule occurred while the function worked; | 1941 | * Returns: SCHEDULE_OCCURRED - schedule occurred while the function worked; |
1942 | * CARRY_ON - schedule didn't occur while the function worked; | 1942 | * CARRY_ON - schedule didn't occur while the function worked; |
1943 | */ | 1943 | */ |
1944 | static int get_neighbors(struct tree_balance *tb, int n_h) | 1944 | static int get_neighbors(struct tree_balance *tb, int h) |
1945 | { | 1945 | { |
1946 | int n_child_position, | 1946 | int child_position, |
1947 | n_path_offset = PATH_H_PATH_OFFSET(tb->tb_path, n_h + 1); | 1947 | path_offset = PATH_H_PATH_OFFSET(tb->tb_path, h + 1); |
1948 | unsigned long n_son_number; | 1948 | unsigned long son_number; |
1949 | struct super_block *sb = tb->tb_sb; | 1949 | struct super_block *sb = tb->tb_sb; |
1950 | struct buffer_head *bh; | 1950 | struct buffer_head *bh; |
1951 | 1951 | ||
1952 | PROC_INFO_INC(sb, get_neighbors[n_h]); | 1952 | PROC_INFO_INC(sb, get_neighbors[h]); |
1953 | 1953 | ||
1954 | if (tb->lnum[n_h]) { | 1954 | if (tb->lnum[h]) { |
1955 | /* We need left neighbor to balance S[n_h]. */ | 1955 | /* We need left neighbor to balance S[h]. */ |
1956 | PROC_INFO_INC(sb, need_l_neighbor[n_h]); | 1956 | PROC_INFO_INC(sb, need_l_neighbor[h]); |
1957 | bh = PATH_OFFSET_PBUFFER(tb->tb_path, n_path_offset); | 1957 | bh = PATH_OFFSET_PBUFFER(tb->tb_path, path_offset); |
1958 | 1958 | ||
1959 | RFALSE(bh == tb->FL[n_h] && | 1959 | RFALSE(bh == tb->FL[h] && |
1960 | !PATH_OFFSET_POSITION(tb->tb_path, n_path_offset), | 1960 | !PATH_OFFSET_POSITION(tb->tb_path, path_offset), |
1961 | "PAP-8270: invalid position in the parent"); | 1961 | "PAP-8270: invalid position in the parent"); |
1962 | 1962 | ||
1963 | n_child_position = | 1963 | child_position = |
1964 | (bh == | 1964 | (bh == |
1965 | tb->FL[n_h]) ? tb->lkey[n_h] : B_NR_ITEMS(tb-> | 1965 | tb->FL[h]) ? tb->lkey[h] : B_NR_ITEMS(tb-> |
1966 | FL[n_h]); | 1966 | FL[h]); |
1967 | n_son_number = B_N_CHILD_NUM(tb->FL[n_h], n_child_position); | 1967 | son_number = B_N_CHILD_NUM(tb->FL[h], child_position); |
1968 | bh = sb_bread(sb, n_son_number); | 1968 | bh = sb_bread(sb, son_number); |
1969 | if (!bh) | 1969 | if (!bh) |
1970 | return IO_ERROR; | 1970 | return IO_ERROR; |
1971 | if (FILESYSTEM_CHANGED_TB(tb)) { | 1971 | if (FILESYSTEM_CHANGED_TB(tb)) { |
1972 | brelse(bh); | 1972 | brelse(bh); |
1973 | PROC_INFO_INC(sb, get_neighbors_restart[n_h]); | 1973 | PROC_INFO_INC(sb, get_neighbors_restart[h]); |
1974 | return REPEAT_SEARCH; | 1974 | return REPEAT_SEARCH; |
1975 | } | 1975 | } |
1976 | 1976 | ||
1977 | RFALSE(!B_IS_IN_TREE(tb->FL[n_h]) || | 1977 | RFALSE(!B_IS_IN_TREE(tb->FL[h]) || |
1978 | n_child_position > B_NR_ITEMS(tb->FL[n_h]) || | 1978 | child_position > B_NR_ITEMS(tb->FL[h]) || |
1979 | B_N_CHILD_NUM(tb->FL[n_h], n_child_position) != | 1979 | B_N_CHILD_NUM(tb->FL[h], child_position) != |
1980 | bh->b_blocknr, "PAP-8275: invalid parent"); | 1980 | bh->b_blocknr, "PAP-8275: invalid parent"); |
1981 | RFALSE(!B_IS_IN_TREE(bh), "PAP-8280: invalid child"); | 1981 | RFALSE(!B_IS_IN_TREE(bh), "PAP-8280: invalid child"); |
1982 | RFALSE(!n_h && | 1982 | RFALSE(!h && |
1983 | B_FREE_SPACE(bh) != | 1983 | B_FREE_SPACE(bh) != |
1984 | MAX_CHILD_SIZE(bh) - | 1984 | MAX_CHILD_SIZE(bh) - |
1985 | dc_size(B_N_CHILD(tb->FL[0], n_child_position)), | 1985 | dc_size(B_N_CHILD(tb->FL[0], child_position)), |
1986 | "PAP-8290: invalid child size of left neighbor"); | 1986 | "PAP-8290: invalid child size of left neighbor"); |
1987 | 1987 | ||
1988 | brelse(tb->L[n_h]); | 1988 | brelse(tb->L[h]); |
1989 | tb->L[n_h] = bh; | 1989 | tb->L[h] = bh; |
1990 | } | 1990 | } |
1991 | 1991 | ||
1992 | /* We need right neighbor to balance S[n_path_offset]. */ | 1992 | /* We need right neighbor to balance S[path_offset]. */ |
1993 | if (tb->rnum[n_h]) { | 1993 | if (tb->rnum[h]) { /* We need right neighbor to balance S[path_offset]. */ |
1994 | PROC_INFO_INC(sb, need_r_neighbor[n_h]); | 1994 | PROC_INFO_INC(sb, need_r_neighbor[h]); |
1995 | bh = PATH_OFFSET_PBUFFER(tb->tb_path, n_path_offset); | 1995 | bh = PATH_OFFSET_PBUFFER(tb->tb_path, path_offset); |
1996 | 1996 | ||
1997 | RFALSE(bh == tb->FR[n_h] && | 1997 | RFALSE(bh == tb->FR[h] && |
1998 | PATH_OFFSET_POSITION(tb->tb_path, | 1998 | PATH_OFFSET_POSITION(tb->tb_path, |
1999 | n_path_offset) >= | 1999 | path_offset) >= |
2000 | B_NR_ITEMS(bh), | 2000 | B_NR_ITEMS(bh), |
2001 | "PAP-8295: invalid position in the parent"); | 2001 | "PAP-8295: invalid position in the parent"); |
2002 | 2002 | ||
2003 | n_child_position = | 2003 | child_position = |
2004 | (bh == tb->FR[n_h]) ? tb->rkey[n_h] + 1 : 0; | 2004 | (bh == tb->FR[h]) ? tb->rkey[h] + 1 : 0; |
2005 | n_son_number = B_N_CHILD_NUM(tb->FR[n_h], n_child_position); | 2005 | son_number = B_N_CHILD_NUM(tb->FR[h], child_position); |
2006 | bh = sb_bread(sb, n_son_number); | 2006 | bh = sb_bread(sb, son_number); |
2007 | if (!bh) | 2007 | if (!bh) |
2008 | return IO_ERROR; | 2008 | return IO_ERROR; |
2009 | if (FILESYSTEM_CHANGED_TB(tb)) { | 2009 | if (FILESYSTEM_CHANGED_TB(tb)) { |
2010 | brelse(bh); | 2010 | brelse(bh); |
2011 | PROC_INFO_INC(sb, get_neighbors_restart[n_h]); | 2011 | PROC_INFO_INC(sb, get_neighbors_restart[h]); |
2012 | return REPEAT_SEARCH; | 2012 | return REPEAT_SEARCH; |
2013 | } | 2013 | } |
2014 | brelse(tb->R[n_h]); | 2014 | brelse(tb->R[h]); |
2015 | tb->R[n_h] = bh; | 2015 | tb->R[h] = bh; |
2016 | 2016 | ||
2017 | RFALSE(!n_h | 2017 | RFALSE(!h |
2018 | && B_FREE_SPACE(bh) != | 2018 | && B_FREE_SPACE(bh) != |
2019 | MAX_CHILD_SIZE(bh) - | 2019 | MAX_CHILD_SIZE(bh) - |
2020 | dc_size(B_N_CHILD(tb->FR[0], n_child_position)), | 2020 | dc_size(B_N_CHILD(tb->FR[0], child_position)), |
2021 | "PAP-8300: invalid child size of right neighbor (%d != %d - %d)", | 2021 | "PAP-8300: invalid child size of right neighbor (%d != %d - %d)", |
2022 | B_FREE_SPACE(bh), MAX_CHILD_SIZE(bh), | 2022 | B_FREE_SPACE(bh), MAX_CHILD_SIZE(bh), |
2023 | dc_size(B_N_CHILD(tb->FR[0], n_child_position))); | 2023 | dc_size(B_N_CHILD(tb->FR[0], child_position))); |
2024 | 2024 | ||
2025 | } | 2025 | } |
2026 | return CARRY_ON; | 2026 | return CARRY_ON; |
@@ -2317,11 +2317,11 @@ static int wait_tb_buffers_until_unlocked(struct tree_balance *tb) | |||
2317 | * -1 - if no_disk_space | 2317 | * -1 - if no_disk_space |
2318 | */ | 2318 | */ |
2319 | 2319 | ||
2320 | int fix_nodes(int n_op_mode, struct tree_balance *tb, | 2320 | int fix_nodes(int op_mode, struct tree_balance *tb, |
2321 | struct item_head *ins_ih, const void *data) | 2321 | struct item_head *ins_ih, const void *data) |
2322 | { | 2322 | { |
2323 | int n_ret_value, n_h, n_item_num = PATH_LAST_POSITION(tb->tb_path); | 2323 | int ret, h, item_num = PATH_LAST_POSITION(tb->tb_path); |
2324 | int n_pos_in_item; | 2324 | int pos_in_item; |
2325 | 2325 | ||
2326 | /* we set wait_tb_buffers_run when we have to restore any dirty bits cleared | 2326 | /* we set wait_tb_buffers_run when we have to restore any dirty bits cleared |
2327 | ** during wait_tb_buffers_run | 2327 | ** during wait_tb_buffers_run |
@@ -2331,7 +2331,7 @@ int fix_nodes(int n_op_mode, struct tree_balance *tb, | |||
2331 | 2331 | ||
2332 | ++REISERFS_SB(tb->tb_sb)->s_fix_nodes; | 2332 | ++REISERFS_SB(tb->tb_sb)->s_fix_nodes; |
2333 | 2333 | ||
2334 | n_pos_in_item = tb->tb_path->pos_in_item; | 2334 | pos_in_item = tb->tb_path->pos_in_item; |
2335 | 2335 | ||
2336 | tb->fs_gen = get_generation(tb->tb_sb); | 2336 | tb->fs_gen = get_generation(tb->tb_sb); |
2337 | 2337 | ||
@@ -2364,26 +2364,26 @@ int fix_nodes(int n_op_mode, struct tree_balance *tb, | |||
2364 | reiserfs_panic(tb->tb_sb, "PAP-8320", "S[0] (%b %z) is " | 2364 | reiserfs_panic(tb->tb_sb, "PAP-8320", "S[0] (%b %z) is " |
2365 | "not uptodate at the beginning of fix_nodes " | 2365 | "not uptodate at the beginning of fix_nodes " |
2366 | "or not in tree (mode %c)", | 2366 | "or not in tree (mode %c)", |
2367 | tbS0, tbS0, n_op_mode); | 2367 | tbS0, tbS0, op_mode); |
2368 | 2368 | ||
2369 | /* Check parameters. */ | 2369 | /* Check parameters. */ |
2370 | switch (n_op_mode) { | 2370 | switch (op_mode) { |
2371 | case M_INSERT: | 2371 | case M_INSERT: |
2372 | if (n_item_num <= 0 || n_item_num > B_NR_ITEMS(tbS0)) | 2372 | if (item_num <= 0 || item_num > B_NR_ITEMS(tbS0)) |
2373 | reiserfs_panic(tb->tb_sb, "PAP-8330", "Incorrect " | 2373 | reiserfs_panic(tb->tb_sb, "PAP-8330", "Incorrect " |
2374 | "item number %d (in S0 - %d) in case " | 2374 | "item number %d (in S0 - %d) in case " |
2375 | "of insert", n_item_num, | 2375 | "of insert", item_num, |
2376 | B_NR_ITEMS(tbS0)); | 2376 | B_NR_ITEMS(tbS0)); |
2377 | break; | 2377 | break; |
2378 | case M_PASTE: | 2378 | case M_PASTE: |
2379 | case M_DELETE: | 2379 | case M_DELETE: |
2380 | case M_CUT: | 2380 | case M_CUT: |
2381 | if (n_item_num < 0 || n_item_num >= B_NR_ITEMS(tbS0)) { | 2381 | if (item_num < 0 || item_num >= B_NR_ITEMS(tbS0)) { |
2382 | print_block(tbS0, 0, -1, -1); | 2382 | print_block(tbS0, 0, -1, -1); |
2383 | reiserfs_panic(tb->tb_sb, "PAP-8335", "Incorrect " | 2383 | reiserfs_panic(tb->tb_sb, "PAP-8335", "Incorrect " |
2384 | "item number(%d); mode = %c " | 2384 | "item number(%d); mode = %c " |
2385 | "insert_size = %d", | 2385 | "insert_size = %d", |
2386 | n_item_num, n_op_mode, | 2386 | item_num, op_mode, |
2387 | tb->insert_size[0]); | 2387 | tb->insert_size[0]); |
2388 | } | 2388 | } |
2389 | break; | 2389 | break; |
@@ -2397,73 +2397,73 @@ int fix_nodes(int n_op_mode, struct tree_balance *tb, | |||
2397 | // FIXME: maybe -ENOMEM when tb->vn_buf == 0? Now just repeat | 2397 | // FIXME: maybe -ENOMEM when tb->vn_buf == 0? Now just repeat |
2398 | return REPEAT_SEARCH; | 2398 | return REPEAT_SEARCH; |
2399 | 2399 | ||
2400 | /* Starting from the leaf level; for all levels n_h of the tree. */ | 2400 | /* Starting from the leaf level; for all levels h of the tree. */ |
2401 | for (n_h = 0; n_h < MAX_HEIGHT && tb->insert_size[n_h]; n_h++) { | 2401 | for (h = 0; h < MAX_HEIGHT && tb->insert_size[h]; h++) { |
2402 | n_ret_value = get_direct_parent(tb, n_h); | 2402 | ret = get_direct_parent(tb, h); |
2403 | if (n_ret_value != CARRY_ON) | 2403 | if (ret != CARRY_ON) |
2404 | goto repeat; | 2404 | goto repeat; |
2405 | 2405 | ||
2406 | n_ret_value = check_balance(n_op_mode, tb, n_h, n_item_num, | 2406 | ret = check_balance(op_mode, tb, h, item_num, |
2407 | n_pos_in_item, ins_ih, data); | 2407 | pos_in_item, ins_ih, data); |
2408 | if (n_ret_value != CARRY_ON) { | 2408 | if (ret != CARRY_ON) { |
2409 | if (n_ret_value == NO_BALANCING_NEEDED) { | 2409 | if (ret == NO_BALANCING_NEEDED) { |
2410 | /* No balancing for higher levels needed. */ | 2410 | /* No balancing for higher levels needed. */ |
2411 | n_ret_value = get_neighbors(tb, n_h); | 2411 | ret = get_neighbors(tb, h); |
2412 | if (n_ret_value != CARRY_ON) | 2412 | if (ret != CARRY_ON) |
2413 | goto repeat; | 2413 | goto repeat; |
2414 | if (n_h != MAX_HEIGHT - 1) | 2414 | if (h != MAX_HEIGHT - 1) |
2415 | tb->insert_size[n_h + 1] = 0; | 2415 | tb->insert_size[h + 1] = 0; |
2416 | /* ok, analysis and resource gathering are complete */ | 2416 | /* ok, analysis and resource gathering are complete */ |
2417 | break; | 2417 | break; |
2418 | } | 2418 | } |
2419 | goto repeat; | 2419 | goto repeat; |
2420 | } | 2420 | } |
2421 | 2421 | ||
2422 | n_ret_value = get_neighbors(tb, n_h); | 2422 | ret = get_neighbors(tb, h); |
2423 | if (n_ret_value != CARRY_ON) | 2423 | if (ret != CARRY_ON) |
2424 | goto repeat; | 2424 | goto repeat; |
2425 | 2425 | ||
2426 | /* No disk space, or schedule occurred and analysis may be | 2426 | /* No disk space, or schedule occurred and analysis may be |
2427 | * invalid and needs to be redone. */ | 2427 | * invalid and needs to be redone. */ |
2428 | n_ret_value = get_empty_nodes(tb, n_h); | 2428 | ret = get_empty_nodes(tb, h); |
2429 | if (n_ret_value != CARRY_ON) | 2429 | if (ret != CARRY_ON) |
2430 | goto repeat; | 2430 | goto repeat; |
2431 | 2431 | ||
2432 | if (!PATH_H_PBUFFER(tb->tb_path, n_h)) { | 2432 | if (!PATH_H_PBUFFER(tb->tb_path, h)) { |
2433 | /* We have a positive insert size but no nodes exist on this | 2433 | /* We have a positive insert size but no nodes exist on this |
2434 | level, this means that we are creating a new root. */ | 2434 | level, this means that we are creating a new root. */ |
2435 | 2435 | ||
2436 | RFALSE(tb->blknum[n_h] != 1, | 2436 | RFALSE(tb->blknum[h] != 1, |
2437 | "PAP-8350: creating new empty root"); | 2437 | "PAP-8350: creating new empty root"); |
2438 | 2438 | ||
2439 | if (n_h < MAX_HEIGHT - 1) | 2439 | if (h < MAX_HEIGHT - 1) |
2440 | tb->insert_size[n_h + 1] = 0; | 2440 | tb->insert_size[h + 1] = 0; |
2441 | } else if (!PATH_H_PBUFFER(tb->tb_path, n_h + 1)) { | 2441 | } else if (!PATH_H_PBUFFER(tb->tb_path, h + 1)) { |
2442 | if (tb->blknum[n_h] > 1) { | 2442 | if (tb->blknum[h] > 1) { |
2443 | /* The tree needs to be grown, so this node S[n_h] | 2443 | /* The tree needs to be grown, so this node S[h] |
2444 | which is the root node is split into two nodes, | 2444 | which is the root node is split into two nodes, |
2445 | and a new node (S[n_h+1]) will be created to | 2445 | and a new node (S[h+1]) will be created to |
2446 | become the root node. */ | 2446 | become the root node. */ |
2447 | 2447 | ||
2448 | RFALSE(n_h == MAX_HEIGHT - 1, | 2448 | RFALSE(h == MAX_HEIGHT - 1, |
2449 | "PAP-8355: attempt to create too high of a tree"); | 2449 | "PAP-8355: attempt to create too high of a tree"); |
2450 | 2450 | ||
2451 | tb->insert_size[n_h + 1] = | 2451 | tb->insert_size[h + 1] = |
2452 | (DC_SIZE + | 2452 | (DC_SIZE + |
2453 | KEY_SIZE) * (tb->blknum[n_h] - 1) + | 2453 | KEY_SIZE) * (tb->blknum[h] - 1) + |
2454 | DC_SIZE; | 2454 | DC_SIZE; |
2455 | } else if (n_h < MAX_HEIGHT - 1) | 2455 | } else if (h < MAX_HEIGHT - 1) |
2456 | tb->insert_size[n_h + 1] = 0; | 2456 | tb->insert_size[h + 1] = 0; |
2457 | } else | 2457 | } else |
2458 | tb->insert_size[n_h + 1] = | 2458 | tb->insert_size[h + 1] = |
2459 | (DC_SIZE + KEY_SIZE) * (tb->blknum[n_h] - 1); | 2459 | (DC_SIZE + KEY_SIZE) * (tb->blknum[h] - 1); |
2460 | } | 2460 | } |
2461 | 2461 | ||
2462 | n_ret_value = wait_tb_buffers_until_unlocked(tb); | 2462 | ret = wait_tb_buffers_until_unlocked(tb); |
2463 | if (n_ret_value == CARRY_ON) { | 2463 | if (ret == CARRY_ON) { |
2464 | if (FILESYSTEM_CHANGED_TB(tb)) { | 2464 | if (FILESYSTEM_CHANGED_TB(tb)) { |
2465 | wait_tb_buffers_run = 1; | 2465 | wait_tb_buffers_run = 1; |
2466 | n_ret_value = REPEAT_SEARCH; | 2466 | ret = REPEAT_SEARCH; |
2467 | goto repeat; | 2467 | goto repeat; |
2468 | } else { | 2468 | } else { |
2469 | return CARRY_ON; | 2469 | return CARRY_ON; |
@@ -2529,7 +2529,7 @@ int fix_nodes(int n_op_mode, struct tree_balance *tb, | |||
2529 | (tb->tb_sb, tb->FEB[i]); | 2529 | (tb->tb_sb, tb->FEB[i]); |
2530 | } | 2530 | } |
2531 | } | 2531 | } |
2532 | return n_ret_value; | 2532 | return ret; |
2533 | } | 2533 | } |
2534 | 2534 | ||
2535 | } | 2535 | } |