aboutsummaryrefslogtreecommitdiffstats
path: root/fs/reiserfs/fix_node.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/reiserfs/fix_node.c')
-rw-r--r--fs/reiserfs/fix_node.c22
1 files changed, 17 insertions, 5 deletions
diff --git a/fs/reiserfs/fix_node.c b/fs/reiserfs/fix_node.c
index 5e5a4e6fbaf8..1e4250bc3a6f 100644
--- a/fs/reiserfs/fix_node.c
+++ b/fs/reiserfs/fix_node.c
@@ -35,6 +35,7 @@
35 **/ 35 **/
36 36
37#include <linux/time.h> 37#include <linux/time.h>
38#include <linux/slab.h>
38#include <linux/string.h> 39#include <linux/string.h>
39#include <linux/reiserfs_fs.h> 40#include <linux/reiserfs_fs.h>
40#include <linux/buffer_head.h> 41#include <linux/buffer_head.h>
@@ -563,9 +564,6 @@ static int get_num_ver(int mode, struct tree_balance *tb, int h,
563 return needed_nodes; 564 return needed_nodes;
564} 565}
565 566
566#ifdef CONFIG_REISERFS_CHECK
567extern struct tree_balance *cur_tb;
568#endif
569 567
570/* Set parameters for balancing. 568/* Set parameters for balancing.
571 * Performs write of results of analysis of balancing into structure tb, 569 * Performs write of results of analysis of balancing into structure tb,
@@ -834,7 +832,7 @@ static int get_empty_nodes(struct tree_balance *tb, int h)
834 RFALSE(buffer_dirty(new_bh) || 832 RFALSE(buffer_dirty(new_bh) ||
835 buffer_journaled(new_bh) || 833 buffer_journaled(new_bh) ||
836 buffer_journal_dirty(new_bh), 834 buffer_journal_dirty(new_bh),
837 "PAP-8140: journlaled or dirty buffer %b for the new block", 835 "PAP-8140: journaled or dirty buffer %b for the new block",
838 new_bh); 836 new_bh);
839 837
840 /* Put empty buffers into the array. */ 838 /* Put empty buffers into the array. */
@@ -1022,7 +1020,11 @@ static int get_far_parent(struct tree_balance *tb,
1022 /* Check whether the common parent is locked. */ 1020 /* Check whether the common parent is locked. */
1023 1021
1024 if (buffer_locked(*pcom_father)) { 1022 if (buffer_locked(*pcom_father)) {
1023
1024 /* Release the write lock while the buffer is busy */
1025 reiserfs_write_unlock(tb->tb_sb);
1025 __wait_on_buffer(*pcom_father); 1026 __wait_on_buffer(*pcom_father);
1027 reiserfs_write_lock(tb->tb_sb);
1026 if (FILESYSTEM_CHANGED_TB(tb)) { 1028 if (FILESYSTEM_CHANGED_TB(tb)) {
1027 brelse(*pcom_father); 1029 brelse(*pcom_father);
1028 return REPEAT_SEARCH; 1030 return REPEAT_SEARCH;
@@ -1927,7 +1929,9 @@ static int get_direct_parent(struct tree_balance *tb, int h)
1927 return REPEAT_SEARCH; 1929 return REPEAT_SEARCH;
1928 1930
1929 if (buffer_locked(bh)) { 1931 if (buffer_locked(bh)) {
1932 reiserfs_write_unlock(tb->tb_sb);
1930 __wait_on_buffer(bh); 1933 __wait_on_buffer(bh);
1934 reiserfs_write_lock(tb->tb_sb);
1931 if (FILESYSTEM_CHANGED_TB(tb)) 1935 if (FILESYSTEM_CHANGED_TB(tb))
1932 return REPEAT_SEARCH; 1936 return REPEAT_SEARCH;
1933 } 1937 }
@@ -1965,7 +1969,9 @@ static int get_neighbors(struct tree_balance *tb, int h)
1965 tb->FL[h]) ? tb->lkey[h] : B_NR_ITEMS(tb-> 1969 tb->FL[h]) ? tb->lkey[h] : B_NR_ITEMS(tb->
1966 FL[h]); 1970 FL[h]);
1967 son_number = B_N_CHILD_NUM(tb->FL[h], child_position); 1971 son_number = B_N_CHILD_NUM(tb->FL[h], child_position);
1972 reiserfs_write_unlock(sb);
1968 bh = sb_bread(sb, son_number); 1973 bh = sb_bread(sb, son_number);
1974 reiserfs_write_lock(sb);
1969 if (!bh) 1975 if (!bh)
1970 return IO_ERROR; 1976 return IO_ERROR;
1971 if (FILESYSTEM_CHANGED_TB(tb)) { 1977 if (FILESYSTEM_CHANGED_TB(tb)) {
@@ -2003,7 +2009,9 @@ static int get_neighbors(struct tree_balance *tb, int h)
2003 child_position = 2009 child_position =
2004 (bh == tb->FR[h]) ? tb->rkey[h] + 1 : 0; 2010 (bh == tb->FR[h]) ? tb->rkey[h] + 1 : 0;
2005 son_number = B_N_CHILD_NUM(tb->FR[h], child_position); 2011 son_number = B_N_CHILD_NUM(tb->FR[h], child_position);
2012 reiserfs_write_unlock(sb);
2006 bh = sb_bread(sb, son_number); 2013 bh = sb_bread(sb, son_number);
2014 reiserfs_write_lock(sb);
2007 if (!bh) 2015 if (!bh)
2008 return IO_ERROR; 2016 return IO_ERROR;
2009 if (FILESYSTEM_CHANGED_TB(tb)) { 2017 if (FILESYSTEM_CHANGED_TB(tb)) {
@@ -2278,7 +2286,9 @@ static int wait_tb_buffers_until_unlocked(struct tree_balance *tb)
2278 REPEAT_SEARCH : CARRY_ON; 2286 REPEAT_SEARCH : CARRY_ON;
2279 } 2287 }
2280#endif 2288#endif
2289 reiserfs_write_unlock(tb->tb_sb);
2281 __wait_on_buffer(locked); 2290 __wait_on_buffer(locked);
2291 reiserfs_write_lock(tb->tb_sb);
2282 if (FILESYSTEM_CHANGED_TB(tb)) 2292 if (FILESYSTEM_CHANGED_TB(tb))
2283 return REPEAT_SEARCH; 2293 return REPEAT_SEARCH;
2284 } 2294 }
@@ -2349,12 +2359,14 @@ int fix_nodes(int op_mode, struct tree_balance *tb,
2349 2359
2350 /* if it possible in indirect_to_direct conversion */ 2360 /* if it possible in indirect_to_direct conversion */
2351 if (buffer_locked(tbS0)) { 2361 if (buffer_locked(tbS0)) {
2362 reiserfs_write_unlock(tb->tb_sb);
2352 __wait_on_buffer(tbS0); 2363 __wait_on_buffer(tbS0);
2364 reiserfs_write_lock(tb->tb_sb);
2353 if (FILESYSTEM_CHANGED_TB(tb)) 2365 if (FILESYSTEM_CHANGED_TB(tb))
2354 return REPEAT_SEARCH; 2366 return REPEAT_SEARCH;
2355 } 2367 }
2356#ifdef CONFIG_REISERFS_CHECK 2368#ifdef CONFIG_REISERFS_CHECK
2357 if (cur_tb) { 2369 if (REISERFS_SB(tb->tb_sb)->cur_tb) {
2358 print_cur_tb("fix_nodes"); 2370 print_cur_tb("fix_nodes");
2359 reiserfs_panic(tb->tb_sb, "PAP-8305", 2371 reiserfs_panic(tb->tb_sb, "PAP-8305",
2360 "there is pending do_balance"); 2372 "there is pending do_balance");