diff options
author | Jeff Mahoney <jeffm@suse.com> | 2009-03-30 14:02:43 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2009-03-30 15:16:39 -0400 |
commit | 3cd6dbe6feb9b32347e6c6f25a27f0cde9d50418 (patch) | |
tree | 613a4aaa00bc830b69a97ff2cb3558dc163f957d /fs/reiserfs/fix_node.c | |
parent | fba4ebb5f0f84a6f9989e9591741ddff946de320 (diff) |
reiserfs: cleanup path functions
This patch cleans up some redundancies in the reiserfs tree path code.
decrement_bcount() is essentially the same function as brelse(), so we use
that instead.
decrement_counters_in_path() is exactly the same function as pathrelse(), so
we kill that and use pathrelse() instead.
There's also a bit of cleanup that makes the code a bit more readable.
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 | 58 |
1 files changed, 30 insertions, 28 deletions
diff --git a/fs/reiserfs/fix_node.c b/fs/reiserfs/fix_node.c index bbb37b0589af..aee50c97988d 100644 --- a/fs/reiserfs/fix_node.c +++ b/fs/reiserfs/fix_node.c | |||
@@ -753,20 +753,21 @@ static void free_buffers_in_tb(struct tree_balance *p_s_tb) | |||
753 | { | 753 | { |
754 | int n_counter; | 754 | int n_counter; |
755 | 755 | ||
756 | decrement_counters_in_path(p_s_tb->tb_path); | 756 | pathrelse(p_s_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 | decrement_bcount(p_s_tb->L[n_counter]); | 759 | brelse(p_s_tb->L[n_counter]); |
760 | brelse(p_s_tb->R[n_counter]); | ||
761 | brelse(p_s_tb->FL[n_counter]); | ||
762 | brelse(p_s_tb->FR[n_counter]); | ||
763 | brelse(p_s_tb->CFL[n_counter]); | ||
764 | brelse(p_s_tb->CFR[n_counter]); | ||
765 | |||
760 | p_s_tb->L[n_counter] = NULL; | 766 | p_s_tb->L[n_counter] = NULL; |
761 | decrement_bcount(p_s_tb->R[n_counter]); | ||
762 | p_s_tb->R[n_counter] = NULL; | 767 | p_s_tb->R[n_counter] = NULL; |
763 | decrement_bcount(p_s_tb->FL[n_counter]); | ||
764 | p_s_tb->FL[n_counter] = NULL; | 768 | p_s_tb->FL[n_counter] = NULL; |
765 | decrement_bcount(p_s_tb->FR[n_counter]); | ||
766 | p_s_tb->FR[n_counter] = NULL; | 769 | p_s_tb->FR[n_counter] = NULL; |
767 | decrement_bcount(p_s_tb->CFL[n_counter]); | ||
768 | p_s_tb->CFL[n_counter] = NULL; | 770 | p_s_tb->CFL[n_counter] = NULL; |
769 | decrement_bcount(p_s_tb->CFR[n_counter]); | ||
770 | p_s_tb->CFR[n_counter] = NULL; | 771 | p_s_tb->CFR[n_counter] = NULL; |
771 | } | 772 | } |
772 | } | 773 | } |
@@ -1022,7 +1023,7 @@ static int get_far_parent(struct tree_balance *p_s_tb, | |||
1022 | if (buffer_locked(*pp_s_com_father)) { | 1023 | if (buffer_locked(*pp_s_com_father)) { |
1023 | __wait_on_buffer(*pp_s_com_father); | 1024 | __wait_on_buffer(*pp_s_com_father); |
1024 | if (FILESYSTEM_CHANGED_TB(p_s_tb)) { | 1025 | if (FILESYSTEM_CHANGED_TB(p_s_tb)) { |
1025 | decrement_bcount(*pp_s_com_father); | 1026 | brelse(*pp_s_com_father); |
1026 | return REPEAT_SEARCH; | 1027 | return REPEAT_SEARCH; |
1027 | } | 1028 | } |
1028 | } | 1029 | } |
@@ -1050,8 +1051,8 @@ static int get_far_parent(struct tree_balance *p_s_tb, | |||
1050 | return IO_ERROR; | 1051 | return IO_ERROR; |
1051 | 1052 | ||
1052 | if (FILESYSTEM_CHANGED_TB(p_s_tb)) { | 1053 | if (FILESYSTEM_CHANGED_TB(p_s_tb)) { |
1053 | decrement_counters_in_path(&s_path_to_neighbor_father); | 1054 | pathrelse(&s_path_to_neighbor_father); |
1054 | decrement_bcount(*pp_s_com_father); | 1055 | brelse(*pp_s_com_father); |
1055 | return REPEAT_SEARCH; | 1056 | return REPEAT_SEARCH; |
1056 | } | 1057 | } |
1057 | 1058 | ||
@@ -1063,7 +1064,7 @@ static int get_far_parent(struct tree_balance *p_s_tb, | |||
1063 | FIRST_PATH_ELEMENT_OFFSET, "PAP-8192: path length is too small"); | 1064 | FIRST_PATH_ELEMENT_OFFSET, "PAP-8192: path length is too small"); |
1064 | 1065 | ||
1065 | s_path_to_neighbor_father.path_length--; | 1066 | s_path_to_neighbor_father.path_length--; |
1066 | decrement_counters_in_path(&s_path_to_neighbor_father); | 1067 | pathrelse(&s_path_to_neighbor_father); |
1067 | return CARRY_ON; | 1068 | return CARRY_ON; |
1068 | } | 1069 | } |
1069 | 1070 | ||
@@ -1086,10 +1087,10 @@ static int get_parents(struct tree_balance *p_s_tb, int n_h) | |||
1086 | if (n_path_offset <= FIRST_PATH_ELEMENT_OFFSET) { | 1087 | if (n_path_offset <= FIRST_PATH_ELEMENT_OFFSET) { |
1087 | /* The root can not have parents. | 1088 | /* The root can not have parents. |
1088 | Release nodes which previously were obtained as parents of the current node neighbors. */ | 1089 | Release nodes which previously were obtained as parents of the current node neighbors. */ |
1089 | decrement_bcount(p_s_tb->FL[n_h]); | 1090 | brelse(p_s_tb->FL[n_h]); |
1090 | decrement_bcount(p_s_tb->CFL[n_h]); | 1091 | brelse(p_s_tb->CFL[n_h]); |
1091 | decrement_bcount(p_s_tb->FR[n_h]); | 1092 | brelse(p_s_tb->FR[n_h]); |
1092 | decrement_bcount(p_s_tb->CFR[n_h]); | 1093 | brelse(p_s_tb->CFR[n_h]); |
1093 | p_s_tb->FL[n_h] = p_s_tb->CFL[n_h] = p_s_tb->FR[n_h] = | 1094 | p_s_tb->FL[n_h] = p_s_tb->CFL[n_h] = p_s_tb->FR[n_h] = |
1094 | p_s_tb->CFR[n_h] = NULL; | 1095 | p_s_tb->CFR[n_h] = NULL; |
1095 | return CARRY_ON; | 1096 | return CARRY_ON; |
@@ -1115,9 +1116,9 @@ static int get_parents(struct tree_balance *p_s_tb, int n_h) | |||
1115 | return n_ret_value; | 1116 | return n_ret_value; |
1116 | } | 1117 | } |
1117 | 1118 | ||
1118 | decrement_bcount(p_s_tb->FL[n_h]); | 1119 | brelse(p_s_tb->FL[n_h]); |
1119 | p_s_tb->FL[n_h] = p_s_curf; /* New initialization of FL[n_h]. */ | 1120 | p_s_tb->FL[n_h] = p_s_curf; /* New initialization of FL[n_h]. */ |
1120 | decrement_bcount(p_s_tb->CFL[n_h]); | 1121 | brelse(p_s_tb->CFL[n_h]); |
1121 | p_s_tb->CFL[n_h] = p_s_curcf; /* New initialization of CFL[n_h]. */ | 1122 | p_s_tb->CFL[n_h] = p_s_curcf; /* New initialization of CFL[n_h]. */ |
1122 | 1123 | ||
1123 | RFALSE((p_s_curf && !B_IS_IN_TREE(p_s_curf)) || | 1124 | RFALSE((p_s_curf && !B_IS_IN_TREE(p_s_curf)) || |
@@ -1145,10 +1146,10 @@ static int get_parents(struct tree_balance *p_s_tb, int n_h) | |||
1145 | p_s_tb->rkey[n_h] = n_position; | 1146 | p_s_tb->rkey[n_h] = n_position; |
1146 | } | 1147 | } |
1147 | 1148 | ||
1148 | decrement_bcount(p_s_tb->FR[n_h]); | 1149 | brelse(p_s_tb->FR[n_h]); |
1149 | p_s_tb->FR[n_h] = p_s_curf; /* New initialization of FR[n_path_offset]. */ | 1150 | p_s_tb->FR[n_h] = p_s_curf; /* New initialization of FR[n_path_offset]. */ |
1150 | 1151 | ||
1151 | decrement_bcount(p_s_tb->CFR[n_h]); | 1152 | brelse(p_s_tb->CFR[n_h]); |
1152 | p_s_tb->CFR[n_h] = p_s_curcf; /* New initialization of CFR[n_path_offset]. */ | 1153 | p_s_tb->CFR[n_h] = p_s_curcf; /* New initialization of CFR[n_path_offset]. */ |
1153 | 1154 | ||
1154 | RFALSE((p_s_curf && !B_IS_IN_TREE(p_s_curf)) || | 1155 | RFALSE((p_s_curf && !B_IS_IN_TREE(p_s_curf)) || |
@@ -1964,7 +1965,7 @@ static int get_neighbors(struct tree_balance *p_s_tb, int n_h) | |||
1964 | if (!p_s_bh) | 1965 | if (!p_s_bh) |
1965 | return IO_ERROR; | 1966 | return IO_ERROR; |
1966 | if (FILESYSTEM_CHANGED_TB(p_s_tb)) { | 1967 | if (FILESYSTEM_CHANGED_TB(p_s_tb)) { |
1967 | decrement_bcount(p_s_bh); | 1968 | brelse(p_s_bh); |
1968 | PROC_INFO_INC(p_s_sb, get_neighbors_restart[n_h]); | 1969 | PROC_INFO_INC(p_s_sb, get_neighbors_restart[n_h]); |
1969 | return REPEAT_SEARCH; | 1970 | return REPEAT_SEARCH; |
1970 | } | 1971 | } |
@@ -1980,7 +1981,7 @@ static int get_neighbors(struct tree_balance *p_s_tb, int n_h) | |||
1980 | dc_size(B_N_CHILD(p_s_tb->FL[0], n_child_position)), | 1981 | dc_size(B_N_CHILD(p_s_tb->FL[0], n_child_position)), |
1981 | "PAP-8290: invalid child size of left neighbor"); | 1982 | "PAP-8290: invalid child size of left neighbor"); |
1982 | 1983 | ||
1983 | decrement_bcount(p_s_tb->L[n_h]); | 1984 | brelse(p_s_tb->L[n_h]); |
1984 | p_s_tb->L[n_h] = p_s_bh; | 1985 | p_s_tb->L[n_h] = p_s_bh; |
1985 | } | 1986 | } |
1986 | 1987 | ||
@@ -2001,11 +2002,11 @@ static int get_neighbors(struct tree_balance *p_s_tb, int n_h) | |||
2001 | if (!p_s_bh) | 2002 | if (!p_s_bh) |
2002 | return IO_ERROR; | 2003 | return IO_ERROR; |
2003 | if (FILESYSTEM_CHANGED_TB(p_s_tb)) { | 2004 | if (FILESYSTEM_CHANGED_TB(p_s_tb)) { |
2004 | decrement_bcount(p_s_bh); | 2005 | brelse(p_s_bh); |
2005 | PROC_INFO_INC(p_s_sb, get_neighbors_restart[n_h]); | 2006 | PROC_INFO_INC(p_s_sb, get_neighbors_restart[n_h]); |
2006 | return REPEAT_SEARCH; | 2007 | return REPEAT_SEARCH; |
2007 | } | 2008 | } |
2008 | decrement_bcount(p_s_tb->R[n_h]); | 2009 | brelse(p_s_tb->R[n_h]); |
2009 | p_s_tb->R[n_h] = p_s_bh; | 2010 | p_s_tb->R[n_h] = p_s_bh; |
2010 | 2011 | ||
2011 | RFALSE(!n_h | 2012 | RFALSE(!n_h |
@@ -2511,16 +2512,17 @@ int fix_nodes(int n_op_mode, struct tree_balance *p_s_tb, struct item_head *p_s_ | |||
2511 | } | 2512 | } |
2512 | 2513 | ||
2513 | brelse(p_s_tb->L[i]); | 2514 | brelse(p_s_tb->L[i]); |
2514 | p_s_tb->L[i] = NULL; | ||
2515 | brelse(p_s_tb->R[i]); | 2515 | brelse(p_s_tb->R[i]); |
2516 | p_s_tb->R[i] = NULL; | ||
2517 | brelse(p_s_tb->FL[i]); | 2516 | brelse(p_s_tb->FL[i]); |
2518 | p_s_tb->FL[i] = NULL; | ||
2519 | brelse(p_s_tb->FR[i]); | 2517 | brelse(p_s_tb->FR[i]); |
2520 | p_s_tb->FR[i] = NULL; | ||
2521 | brelse(p_s_tb->CFL[i]); | 2518 | brelse(p_s_tb->CFL[i]); |
2522 | p_s_tb->CFL[i] = NULL; | ||
2523 | brelse(p_s_tb->CFR[i]); | 2519 | brelse(p_s_tb->CFR[i]); |
2520 | |||
2521 | p_s_tb->L[i] = NULL; | ||
2522 | p_s_tb->R[i] = NULL; | ||
2523 | p_s_tb->FL[i] = NULL; | ||
2524 | p_s_tb->FR[i] = NULL; | ||
2525 | p_s_tb->CFL[i] = NULL; | ||
2524 | p_s_tb->CFR[i] = NULL; | 2526 | p_s_tb->CFR[i] = NULL; |
2525 | } | 2527 | } |
2526 | 2528 | ||