aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
Diffstat (limited to 'fs')
-rw-r--r--fs/reiserfs/fix_node.c58
-rw-r--r--fs/reiserfs/stree.c59
2 files changed, 43 insertions, 74 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
diff --git a/fs/reiserfs/stree.c b/fs/reiserfs/stree.c
index ec837a250a4f..b2eaa0c6b7b7 100644
--- a/fs/reiserfs/stree.c
+++ b/fs/reiserfs/stree.c
@@ -23,7 +23,6 @@
23 * get_rkey 23 * get_rkey
24 * key_in_buffer 24 * key_in_buffer
25 * decrement_bcount 25 * decrement_bcount
26 * decrement_counters_in_path
27 * reiserfs_check_path 26 * reiserfs_check_path
28 * pathrelse_and_restore 27 * pathrelse_and_restore
29 * pathrelse 28 * pathrelse
@@ -359,36 +358,6 @@ static inline int key_in_buffer(struct treepath *p_s_chk_path, /* Path which sho
359 return 1; 358 return 1;
360} 359}
361 360
362inline void decrement_bcount(struct buffer_head *p_s_bh)
363{
364 if (p_s_bh) {
365 if (atomic_read(&(p_s_bh->b_count))) {
366 put_bh(p_s_bh);
367 return;
368 }
369 reiserfs_panic(NULL, "PAP-5070",
370 "trying to free free buffer %b", p_s_bh);
371 }
372}
373
374/* Decrement b_count field of the all buffers in the path. */
375void decrement_counters_in_path(struct treepath *p_s_search_path)
376{
377 int n_path_offset = p_s_search_path->path_length;
378
379 RFALSE(n_path_offset < ILLEGAL_PATH_ELEMENT_OFFSET ||
380 n_path_offset > EXTENDED_MAX_HEIGHT - 1,
381 "PAP-5080: invalid path offset of %d", n_path_offset);
382
383 while (n_path_offset > ILLEGAL_PATH_ELEMENT_OFFSET) {
384 struct buffer_head *bh;
385
386 bh = PATH_OFFSET_PBUFFER(p_s_search_path, n_path_offset--);
387 decrement_bcount(bh);
388 }
389 p_s_search_path->path_length = ILLEGAL_PATH_ELEMENT_OFFSET;
390}
391
392int reiserfs_check_path(struct treepath *p) 361int reiserfs_check_path(struct treepath *p)
393{ 362{
394 RFALSE(p->path_length != ILLEGAL_PATH_ELEMENT_OFFSET, 363 RFALSE(p->path_length != ILLEGAL_PATH_ELEMENT_OFFSET,
@@ -396,12 +365,11 @@ int reiserfs_check_path(struct treepath *p)
396 return 0; 365 return 0;
397} 366}
398 367
399/* Release all buffers in the path. Restore dirty bits clean 368/* Drop the reference to each buffer in a path and restore
400** when preparing the buffer for the log 369 * dirty bits clean when preparing the buffer for the log.
401** 370 * This version should only be called from fix_nodes() */
402** only called from fix_nodes() 371void pathrelse_and_restore(struct super_block *sb,
403*/ 372 struct treepath *p_s_search_path)
404void pathrelse_and_restore(struct super_block *s, struct treepath *p_s_search_path)
405{ 373{
406 int n_path_offset = p_s_search_path->path_length; 374 int n_path_offset = p_s_search_path->path_length;
407 375
@@ -409,16 +377,15 @@ void pathrelse_and_restore(struct super_block *s, struct treepath *p_s_search_pa
409 "clm-4000: invalid path offset"); 377 "clm-4000: invalid path offset");
410 378
411 while (n_path_offset > ILLEGAL_PATH_ELEMENT_OFFSET) { 379 while (n_path_offset > ILLEGAL_PATH_ELEMENT_OFFSET) {
412 reiserfs_restore_prepared_buffer(s, 380 struct buffer_head *bh;
413 PATH_OFFSET_PBUFFER 381 bh = PATH_OFFSET_PBUFFER(p_s_search_path, n_path_offset--);
414 (p_s_search_path, 382 reiserfs_restore_prepared_buffer(sb, bh);
415 n_path_offset)); 383 brelse(bh);
416 brelse(PATH_OFFSET_PBUFFER(p_s_search_path, n_path_offset--));
417 } 384 }
418 p_s_search_path->path_length = ILLEGAL_PATH_ELEMENT_OFFSET; 385 p_s_search_path->path_length = ILLEGAL_PATH_ELEMENT_OFFSET;
419} 386}
420 387
421/* Release all buffers in the path. */ 388/* Drop the reference to each buffer in a path */
422void pathrelse(struct treepath *p_s_search_path) 389void pathrelse(struct treepath *p_s_search_path)
423{ 390{
424 int n_path_offset = p_s_search_path->path_length; 391 int n_path_offset = p_s_search_path->path_length;
@@ -631,7 +598,7 @@ int search_by_key(struct super_block *p_s_sb, const struct cpu_key *p_s_key, /*
631 we must be careful to release all nodes in a path before we either 598 we must be careful to release all nodes in a path before we either
632 discard the path struct or re-use the path struct, as we do here. */ 599 discard the path struct or re-use the path struct, as we do here. */
633 600
634 decrement_counters_in_path(p_s_search_path); 601 pathrelse(p_s_search_path);
635 602
636 right_neighbor_of_leaf_node = 0; 603 right_neighbor_of_leaf_node = 0;
637 604
@@ -691,7 +658,7 @@ int search_by_key(struct super_block *p_s_sb, const struct cpu_key *p_s_key, /*
691 PROC_INFO_INC(p_s_sb, search_by_key_restarted); 658 PROC_INFO_INC(p_s_sb, search_by_key_restarted);
692 PROC_INFO_INC(p_s_sb, 659 PROC_INFO_INC(p_s_sb,
693 sbk_restarted[expected_level - 1]); 660 sbk_restarted[expected_level - 1]);
694 decrement_counters_in_path(p_s_search_path); 661 pathrelse(p_s_search_path);
695 662
696 /* Get the root block number so that we can repeat the search 663 /* Get the root block number so that we can repeat the search
697 starting from the root. */ 664 starting from the root. */
@@ -1868,7 +1835,7 @@ int reiserfs_do_truncate(struct reiserfs_transaction_handle *th, struct inode *p
1868 if (journal_transaction_should_end(th, 0) || 1835 if (journal_transaction_should_end(th, 0) ||
1869 reiserfs_transaction_free_space(th) <= JOURNAL_FOR_FREE_BLOCK_AND_UPDATE_SD) { 1836 reiserfs_transaction_free_space(th) <= JOURNAL_FOR_FREE_BLOCK_AND_UPDATE_SD) {
1870 int orig_len_alloc = th->t_blocks_allocated; 1837 int orig_len_alloc = th->t_blocks_allocated;
1871 decrement_counters_in_path(&s_search_path); 1838 pathrelse(&s_search_path);
1872 1839
1873 if (update_timestamps) { 1840 if (update_timestamps) {
1874 p_s_inode->i_mtime = p_s_inode->i_ctime = 1841 p_s_inode->i_mtime = p_s_inode->i_ctime =