patch-2.4.11-dontuse linux/fs/reiserfs/do_balan.c

Next file: linux/fs/reiserfs/fix_node.c
Previous file: linux/fs/reiserfs/dir.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.4.10/linux/fs/reiserfs/do_balan.c linux/fs/reiserfs/do_balan.c
@@ -90,18 +90,12 @@
     int n;
     struct item_head * ih;
 
-#ifdef CONFIG_REISERFS_CHECK
-    if ( tb->FR[0] && B_LEVEL (tb->FR[0]) != DISK_LEAF_NODE_LEVEL + 1)
-	reiserfs_panic (tb->tb_sb,
-			"vs- 12000: balance_leaf_when_delete:level: wrong FR %z\n", tb->FR[0]);
-    if ( tb->blknum[0] > 1 )
-	reiserfs_panic (tb->tb_sb,
-			"PAP-12005: balance_leaf_when_delete: "
-			"tb->blknum == %d, can not be > 1", tb->blknum[0]);
-	
-    if ( ! tb->blknum[0] && ! PATH_H_PPARENT(tb->tb_path, 0))
-	reiserfs_panic (tb->tb_sb, "PAP-12010: balance_leaf_when_delete: tree can not be empty");
-#endif
+    RFALSE( tb->FR[0] && B_LEVEL (tb->FR[0]) != DISK_LEAF_NODE_LEVEL + 1,
+	    "vs- 12000: level: wrong FR %z\n", tb->FR[0]);
+    RFALSE( tb->blknum[0] > 1,
+	    "PAP-12005: tb->blknum == %d, can not be > 1", tb->blknum[0]);
+    RFALSE( ! tb->blknum[0] && ! PATH_H_PPARENT(tb->tb_path, 0),
+	    "PAP-12010: tree can not be empty");
 
     ih = B_N_PITEM_HEAD (tbS0, item_pos);
 
@@ -110,10 +104,9 @@
     switch (flag) {
     case M_DELETE:   /* delete item in S[0] */
 
-#ifdef CONFIG_REISERFS_CHECK
-	if (le16_to_cpu (ih->ih_item_len) + IH_SIZE != -tb->insert_size [0])
-	    reiserfs_panic (tb->tb_sb, "vs-12013: balance_leaf_when_delete: "
-			    "mode Delete, insert size %d, ih to be deleted %h", ih);
+	 RFALSE( le16_to_cpu (ih->ih_item_len) + IH_SIZE != -tb->insert_size [0],
+		 "vs-12013: mode Delete, insert size %d, ih to be deleted %h", 
+		 ih);
 
 #if 0 /* rigth delim key not supported */
 	if ( ! item_pos && (! tb->L[0] || COMP_KEYS(B_PRIGHT_DELIM_KEY(tb->L[0]), B_N_PKEY(tbS0, 0))) ) {
@@ -126,8 +119,6 @@
 	}
 #endif
 
-#endif
-
 	bi.tb = tb;
 	bi.bi_bh = tbS0;
 	bi.bi_parent = PATH_H_PPARENT (tb->tb_path, 0);
@@ -152,13 +143,8 @@
 	    }
 	} 
 
-#ifdef CONFIG_REISERFS_CHECK
-#if 0
-	if (! item_pos && (!tb->CFL[0] || !tb->L[0]))
-#endif
-	    if (! item_pos && !tb->CFL[0])
-		reiserfs_panic (tb->tb_sb, "PAP-12020: balance_leaf_when_delete: tb->CFL[0]==%p, tb->L[0]==%p", tb->CFL[0], tb->L[0]);
-#endif
+	RFALSE( ! item_pos && !tb->CFL[0],
+		"PAP-12020: tb->CFL[0]==%p, tb->L[0]==%p", tb->CFL[0], tb->L[0]);
     
 	break;
 
@@ -182,10 +168,9 @@
 	    tb->insert_size[0] = -1;
 	    leaf_cut_from_buffer (&bi, item_pos, pos_in_item, -tb->insert_size[0]);
 
-#ifdef CONFIG_REISERFS_CHECK
-	    if (! item_pos && ! pos_in_item && ! tb->CFL[0])
-		reiserfs_panic (tb->tb_sb, "PAP-12030: balance_leaf_when_delete: can not change delimiting key. CFL[0]=%p", tb->CFL[0]);
-#endif /* CONFIG_REISERFS_CHECK */
+	    RFALSE( ! item_pos && ! pos_in_item && ! tb->CFL[0],
+		    "PAP-12030: can not change delimiting key. CFL[0]=%p", 
+		    tb->CFL[0]);
 
 	    if ( ! item_pos && ! pos_in_item && tb->CFL[0] ) {
 		replace_key(tb, tb->CFL[0],tb->lkey[0],tbS0,0);
@@ -197,10 +182,8 @@
 	} else {
 	    leaf_cut_from_buffer (&bi, item_pos, pos_in_item, -tb->insert_size[0]);
 
-#ifdef CONFIG_REISERFS_CHECK
-	    if (! ih->ih_item_len)
-		reiserfs_panic (tb->tb_sb, "PAP-12035: balance_leaf_when_delete: cut must leave non-zero dynamic length of item");
-#endif /* CONFIG_REISERFS_CHECK */
+	    RFALSE( ! ih->ih_item_len,
+		    "PAP-12035: cut must leave non-zero dynamic length of item");
 	}
 	break;
     }
@@ -259,12 +242,8 @@
 		return -1;
 	    }
 
-#ifdef CONFIG_REISERFS_CHECK
-	    if ( tb->rnum[0] != 0 )
-		reiserfs_panic (tb->tb_sb, "PAP-12045: balance_leaf_when_delete: "
-				"rnum must be 0 (%d)", tb->rnum[0]);
-#endif /* CONFIG_REISERFS_CHECK */
-
+	    RFALSE( tb->rnum[0] != 0, 
+		    "PAP-12045: rnum must be 0 (%d)", tb->rnum[0]);
 	    /* all contents of L[0] and S[0] will be in L[0] */
 	    leaf_shift_left(tb, n, -1);
 
@@ -277,21 +256,18 @@
 	}
 	/* a part of contents of S[0] will be in L[0] and the rest part of S[0] will be in R[0] */
 
-#ifdef CONFIG_REISERFS_CHECK
-	if (( tb->lnum[0] + tb->rnum[0] < n ) || ( tb->lnum[0] + tb->rnum[0] > n+1 ))
-	    reiserfs_panic (tb->tb_sb, "PAP-12050: balance_leaf_when_delete: "
-			    "rnum(%d) and lnum(%d) and item number in S[0] are not consistent",
-			    tb->rnum[0], tb->lnum[0], n);
-
-	if (( tb->lnum[0] + tb->rnum[0] == n ) && (tb->lbytes != -1 || tb->rbytes != -1))
-	    reiserfs_panic (tb->tb_sb, "PAP-12055: balance_leaf_when_delete: "
-			    "bad rbytes (%d)/lbytes (%d) parameters when items are not split", 
-			    tb->rbytes, tb->lbytes);
-	if (( tb->lnum[0] + tb->rnum[0] == n + 1 ) && (tb->lbytes < 1 || tb->rbytes != -1))
-	    reiserfs_panic (tb->tb_sb, "PAP-12060: balance_leaf_when_delete: "
-			    "bad rbytes (%d)/lbytes (%d) parameters when items are split", 
-			    tb->rbytes, tb->lbytes);
-#endif
+	RFALSE( ( tb->lnum[0] + tb->rnum[0] < n ) || 
+		( tb->lnum[0] + tb->rnum[0] > n+1 ),
+		"PAP-12050: rnum(%d) and lnum(%d) and item number(%d) in S[0] are not consistent",
+		tb->rnum[0], tb->lnum[0], n);
+	RFALSE( ( tb->lnum[0] + tb->rnum[0] == n ) && 
+		(tb->lbytes != -1 || tb->rbytes != -1),
+		"PAP-12055: bad rbytes (%d)/lbytes (%d) parameters when items are not split", 
+		tb->rbytes, tb->lbytes);
+	RFALSE( ( tb->lnum[0] + tb->rnum[0] == n + 1 ) && 
+		(tb->lbytes < 1 || tb->rbytes != -1),
+		"PAP-12060: bad rbytes (%d)/lbytes (%d) parameters when items are split", 
+		tb->rbytes, tb->lbytes);
 
 	leaf_shift_left (tb, tb->lnum[0], tb->lbytes);
 	leaf_shift_right(tb, tb->rnum[0], tb->rbytes);
@@ -315,12 +291,8 @@
 	return 0;
     }
 
-#ifdef CONFIG_REISERFS_CHECK
-    if ( tb->rnum[0] )
-	reiserfs_panic (tb->tb_sb, "PAP-12065: balance_leaf_when_delete: "
-			"bad rnum parameter must be 0 (%d)", tb->rnum[0]);
-#endif
-
+    RFALSE( tb->rnum[0], 
+	    "PAP-12065: bad rnum parameter must be 0 (%d)", tb->rnum[0]);
     return 0;
 }
 
@@ -394,11 +366,8 @@
 		    int new_item_len;
 		    int version;
 
-#ifdef CONFIG_REISERFS_CHECK
-		    if (!is_direct_le_ih (ih))
-			reiserfs_panic (tb->tb_sb, "PAP-12075: balance_leaf: " 
-					"only direct inserted item can be broken. %h", ih);
-#endif
+		    RFALSE( !is_direct_le_ih (ih),
+			    "PAP-12075: only direct inserted item can be broken. %h", ih);
 		    ret_val = leaf_shift_left (tb, tb->lnum[0]-1, -1);
 		    /* when reading the if conditions preceding the subsequent preserve_shifted
 		       lines understand that their goal is to determine if all that we are
@@ -415,12 +384,9 @@
 		    /* Calculate and check item length to insert to L[0] */
 		    ih->ih_item_len -= new_item_len;
 
-#ifdef CONFIG_REISERFS_CHECK
-		    if ( (int)(ih->ih_item_len) <= 0 )
-			reiserfs_panic(tb->tb_sb, "PAP-12080: balance_leaf: "
-				       "there is nothing to insert into L[0]: ih_item_len=%d",
-				       (int)ih->ih_item_len);
-#endif
+		    RFALSE( (int)(ih->ih_item_len) <= 0,
+			    "PAP-12080: there is nothing to insert into L[0]: ih_item_len=%d",
+			    (int)ih->ih_item_len);
 
 		    /* Insert new item into L[0] */
 		    bi.tb = tb;
@@ -443,12 +409,9 @@
 		    else
 			zeros_num -= tb->lbytes;
 
-#ifdef CONFIG_REISERFS_CHECK
-		    if ( (int)(ih->ih_item_len) <= 0 )
-			reiserfs_panic(tb->tb_sb, "PAP-12085: balance_leaf: "
-				       "there is nothing to insert into S[0]: ih_item_len=%d",
-				       (int)ih->ih_item_len);
-#endif
+		    RFALSE( (int)(ih->ih_item_len) <= 0,
+			    "PAP-12085: there is nothing to insert into S[0]: ih_item_len=%d",
+			    (int)ih->ih_item_len);
 		} else {
 		    /* new item in whole falls into L[0] */
 		    /* Shift lnum[0]-1 items to L[0] */
@@ -481,11 +444,8 @@
 		    /* we must shift the part of the appended item */
 		    if ( is_direntry_le_ih (B_N_PITEM_HEAD (tbS0, item_pos))) {
 
-#ifdef CONFIG_REISERFS_CHECK
-			if ( zeros_num )
-			    reiserfs_panic(tb->tb_sb, "PAP-12090: balance_leaf: illegal parameter in case of a directory");
-#endif
-            
+			RFALSE( zeros_num,
+				"PAP-12090: illegal parameter in case of a directory");
 			/* directory item */
 			if ( tb->lbytes > pos_in_item ) {
 			    /* new directory entry falls into L[0] */
@@ -535,18 +495,12 @@
 		    }
 		    else {
 			/* regular object */
-
-#ifdef CONFIG_REISERFS_CHECK
-			if ( tb->lbytes  <= 0 )
-			    reiserfs_panic(tb->tb_sb, "PAP-12095: balance_leaf: " 
-					   "there is nothing to shift to L[0]. lbytes=%d",
-					   tb->lbytes);
-			if ( pos_in_item != B_N_PITEM_HEAD(tbS0, item_pos)->ih_item_len )
-			    reiserfs_panic(tb->tb_sb, "PAP-12100: balance_leaf: " 
-					   "incorrect position to paste: item_len=%d, pos_in_item=%d",
-					   B_N_PITEM_HEAD(tbS0,item_pos)->ih_item_len, pos_in_item);
-#endif
-
+			RFALSE( tb->lbytes <= 0,
+				"PAP-12095: there is nothing to shift to L[0]. lbytes=%d",
+				tb->lbytes);
+			RFALSE( pos_in_item != B_N_PITEM_HEAD(tbS0, item_pos)->ih_item_len,
+				"PAP-12100: incorrect position to paste: item_len=%d, pos_in_item=%d",
+				B_N_PITEM_HEAD(tbS0,item_pos)->ih_item_len, pos_in_item);
 			if ( tb->lbytes >= pos_in_item ) {
 			    /* appended item will be in L[0] in whole */
 			    int l_n;
@@ -557,13 +511,9 @@
 			    /* Calculate new insert_size[0] */
 			    tb->insert_size[0] -= l_n;
 
-#ifdef CONFIG_REISERFS_CHECK
-			    if ( tb->insert_size[0] <= 0 )
-				reiserfs_panic(tb->tb_sb, "PAP-12105: balance_leaf: " 
-					       "there is nothing to paste into L[0]. insert_size=%d",
-					       tb->insert_size[0]);
-#endif
-
+			    RFALSE( tb->insert_size[0] <= 0,
+				    "PAP-12105: there is nothing to paste into L[0]. insert_size=%d",
+				    tb->insert_size[0]);
 			    ret_val =  leaf_shift_left(tb,tb->lnum[0], 
 						       B_N_PITEM_HEAD(tbS0,item_pos)->ih_item_len);
 #if 0/*preserve list*/
@@ -581,12 +531,11 @@
 				l_n,body, zeros_num > l_n ? l_n : zeros_num
 				);
 
-#ifdef CONFIG_REISERFS_CHECK
-			    if (l_n && is_indirect_le_ih(B_N_PITEM_HEAD(tb->L[0],
-									n + item_pos - ret_val)))
-				reiserfs_panic(tb->tb_sb, "PAP-12110: balance_leaf: "
-					       "pasting more than 1 unformatted node pointer into indirect item");
-#endif
+			    RFALSE( l_n && 
+				    is_indirect_le_ih(B_N_PITEM_HEAD
+						      (tb->L[0],
+						       n + item_pos - ret_val)),
+				    "PAP-12110: pasting more than 1 unformatted node pointer into indirect item");
 
 			    /* 0-th item in S0 can be only of DIRECT type when l_n != 0*/
 			    {
@@ -598,18 +547,10 @@
 			      set_le_key_k_offset (version, B_N_PDELIM_KEY(tb->CFL[0],tb->lkey[0]),
 						   le_key_k_offset (version, B_N_PDELIM_KEY(tb->CFL[0],tb->lkey[0])) + l_n);
 			    }
-#if 0
-			    set_le_key_k_offset (B_PRIGHT_DELIM_KEY(tb->L[0]), le_key_k_offset (B_PRIGHT_DELIM_KEY(tb->L[0])) + l_n);
-#endif
 			    /*    k_offset (B_N_PKEY (tbS0, 0)) += l_n;
 				  k_offset (B_N_PDELIM_KEY(tb->CFL[0],tb->lkey[0])) += l_n;
 				  k_offset (B_PRIGHT_DELIM_KEY(tb->L[0])) += l_n;*/
 
-#ifdef NO_CONFIG_REISERFS_CHECK /* journal victim */
-			    if (!buffer_dirty (tbS0) || !buffer_dirty (tb->CFL[0]) || !buffer_dirty (tb->L[0]))
-				reiserfs_panic(tb->tb_sb, "PAP-12115: balance_leaf: L, CLF and S must be dirty already");
-#endif
-
 			    /* Calculate new body, position in item and insert_size[0] */
 			    if ( l_n > zeros_num ) {
 				body += (l_n - zeros_num);
@@ -619,26 +560,24 @@
 				zeros_num -= l_n;
 			    pos_in_item = 0;	
 
-#ifdef CONFIG_REISERFS_CHECK	
-			    if (comp_short_le_keys (B_N_PKEY(tbS0,0),
-						    B_N_PKEY(tb->L[0],B_NR_ITEMS(tb->L[0])-1)) ||
-				!op_is_left_mergeable (B_N_PKEY (tbS0, 0), tbS0->b_size) ||
-				!op_is_left_mergeable(B_N_PDELIM_KEY(tb->CFL[0],tb->lkey[0]), tbS0->b_size))
-				reiserfs_panic (tb->tb_sb, "PAP-12120: balance_leaf: "
-						"item must be merge-able with left neighboring item");
-#endif
-
+			    RFALSE( comp_short_le_keys 
+				    (B_N_PKEY(tbS0,0),
+				     B_N_PKEY(tb->L[0],B_NR_ITEMS(tb->L[0])-1)) ||
+				
+				    !op_is_left_mergeable 
+				    (B_N_PKEY (tbS0, 0), tbS0->b_size) ||
+				    !op_is_left_mergeable
+				    (B_N_PDELIM_KEY(tb->CFL[0],tb->lkey[0]), 
+				     tbS0->b_size),
+				    "PAP-12120: item must be merge-able with left neighboring item");
 			}
 			else /* only part of the appended item will be in L[0] */
 			{
 			    /* Calculate position in item for append in S[0] */
 			    pos_in_item -= tb->lbytes;
 
-#ifdef CONFIG_REISERFS_CHECK
-			    if ( pos_in_item <= 0 )
-				reiserfs_panic(tb->tb_sb, "PAP-12125: balance_leaf: "
-					       "no place for paste. pos_in_item=%d", pos_in_item);
-#endif
+			    RFALSE( pos_in_item <= 0,
+				    "PAP-12125: no place for paste. pos_in_item=%d", pos_in_item);
 
 			    /* Shift lnum[0] - 1 items in whole. Shift lbytes - 1 byte from item number lnum[0] */
 			    leaf_shift_left(tb,tb->lnum[0],tb->lbytes);
@@ -723,11 +662,9 @@
 		    int version;
 		    loff_t offset;
 
-#ifdef CONFIG_REISERFS_CHECK
-		    if ( !is_direct_le_ih (ih) )
-			reiserfs_panic(tb->tb_sb, "PAP-12135: balance_leaf: "
-				       "only direct item can be split. (%h)", ih);
-#endif
+		    RFALSE( !is_direct_le_ih (ih),
+			    "PAP-12135: only direct item can be split. (%h)", 
+			    ih);
 
 		    leaf_shift_right(tb,tb->rnum[0]-1,-1);
 #if 0/*preserve list*/
@@ -828,24 +765,18 @@
 		    { /* we append to directory item */
 			int entry_count;
 
-#ifdef CONFIG_REISERFS_CHECK
-			if ( zeros_num )
-			    reiserfs_panic(tb->tb_sb, "PAP-12145: balance_leaf: illegal parametr in case of a directory");
-#endif
-
+			RFALSE( zeros_num,
+				"PAP-12145: illegal parametr in case of a directory");
 			entry_count = I_ENTRY_COUNT(B_N_PITEM_HEAD(tbS0, item_pos));
 			if ( entry_count - tb->rbytes < pos_in_item )
 			    /* new directory entry falls into R[0] */
 			{
 			    int paste_entry_position;
 
-#ifdef CONFIG_REISERFS_CHECK
-			    if ( tb->rbytes - 1 >= entry_count || ! tb->insert_size[0] )
-				reiserfs_panic(tb->tb_sb, "PAP-12150: balance_leaf: "
-					       "no enough of entries to shift to R[0]: rbytes=%d, entry_count=%d",
-					       tb->rbytes, entry_count);
-#endif
-
+			    RFALSE( tb->rbytes - 1 >= entry_count || 
+				    ! tb->insert_size[0],
+				    "PAP-12150: no enough of entries to shift to R[0]: rbytes=%d, entry_count=%d",
+				    tb->rbytes, entry_count);
 			    /* Shift rnum[0]-1 items in whole. Shift rbytes-1 directory entries from directory item number rnum[0] */
 			    leaf_shift_right(tb,tb->rnum[0],tb->rbytes - 1);
 #if 0/*preserve list*/
@@ -899,11 +830,9 @@
 			if ( (n_shift = tb->rbytes - tb->insert_size[0]) < 0 )
 			    n_shift = 0;
 
-#ifdef CONFIG_REISERFS_CHECK
-			if (pos_in_item != B_N_PITEM_HEAD (tbS0, item_pos)->ih_item_len)
-			    reiserfs_panic(tb->tb_sb,"PAP-12155: balance_leaf: invalid position to paste. ih_item_len=%d, pos_in_item=%d",
-					   pos_in_item, B_N_PITEM_HEAD(tbS0,item_pos)->ih_item_len);
-#endif
+			RFALSE( pos_in_item != B_N_PITEM_HEAD (tbS0, item_pos)->ih_item_len,
+				"PAP-12155: invalid position to paste. ih_item_len=%d, pos_in_item=%d",
+				pos_in_item, B_N_PITEM_HEAD(tbS0,item_pos)->ih_item_len);
 
 			leaf_shift_right(tb,tb->rnum[0],n_shift);
 #if 0/*preserve list*/
@@ -954,10 +883,8 @@
 
 			if (is_indirect_le_ih (B_N_PITEM_HEAD(tb->R[0],0))) {
 
-#ifdef CONFIG_REISERFS_CHECK
-			    if (n_rem)
-				reiserfs_panic(tb->tb_sb, "PAP-12160: balance_leaf: paste more than one unformatted node pointer");
-#endif
+			    RFALSE( n_rem,
+				    "PAP-12160: paste more than one unformatted node pointer");
 
 			    set_ih_free_space (B_N_PITEM_HEAD(tb->R[0],0), ((struct unfm_nodeinfo*)body)->unfm_freespace);
 			}
@@ -995,11 +922,8 @@
 			    );
 			if ( ! pos_in_item ) {
 
-#ifdef CONFIG_REISERFS_CHECK
-			    if ( item_pos - n + tb->rnum[0] )
-				reiserfs_panic (tb->tb_sb, "PAP-12165: balance_leaf: " 
-						"directory item must be first item of node when pasting is in 0th position");
-#endif
+			    RFALSE( item_pos - n + tb->rnum[0],
+				    "PAP-12165: directory item must be first item of node when pasting is in 0th position");
 
 			    /* update delimiting keys */
 			    replace_key(tb, tb->CFR[0],tb->rkey[0],tb->R[0],0);
@@ -1032,43 +956,18 @@
     }	/* tb->rnum[0] > 0 */
 
 
-#ifdef CONFIG_REISERFS_CHECK
-    if ( tb->blknum[0] > 3 )  
-	reiserfs_panic (tb->tb_sb, "PAP-12180: balance_leaf: blknum can not be %d. It must be <= 3",  tb->blknum[0]);
-
-    if ( tb->blknum[0] < 0 )  
-	reiserfs_panic (tb->tb_sb, "PAP-12185: balance_leaf: blknum can not be %d. It must be >= 0",  tb->blknum[0]);
-#endif
+    RFALSE( tb->blknum[0] > 3,
+	    "PAP-12180: blknum can not be %d. It must be <= 3",  tb->blknum[0]);
+    RFALSE( tb->blknum[0] < 0,
+	    "PAP-12185: blknum can not be %d. It must be >= 0",  tb->blknum[0]);
 
     /* if while adding to a node we discover that it is possible to split
        it in two, and merge the left part into the left neighbor and the
        right part into the right neighbor, eliminating the node */
     if ( tb->blknum[0] == 0 ) { /* node S[0] is empty now */
 
-#ifdef CONFIG_REISERFS_CHECK
-	if ( ! tb->lnum[0] || ! tb->rnum[0] )
-	    reiserfs_panic(tb->tb_sb, "PAP-12190: balance_leaf: lnum and rnum must not be zero");
-#if 0
-	if (COMP_KEYS (B_N_PKEY(tb->R[0], 0), B_PRIGHT_DELIM_KEY(tbS0)))
-	    reiserfs_panic (tb->tb_sb, "vs-12192: balance_leaf: S[0] is being removed from the tree, it has incorrect right delimiting key");
-#endif
-#endif
-
-#if 0
-	/* if insertion was done before 0-th position in R[0], right
-	   delimiting key of the tb->L[0]'s and left delimiting key are
-	   not set correctly */
-	if (tb->L[0]) {
-	    copy_key(B_PRIGHT_DELIM_KEY(tb->L[0]), B_PRIGHT_DELIM_KEY(tbS0));
-	    reiserfs_mark_buffer_dirty (tb->L[0], 0);
-	}
-
-	if (tb->CFL[0]) {
-	    copy_key (B_N_PDELIM_KEY (tb->CFL[0], tb->lkey[0]), B_PRIGHT_DELIM_KEY(tbS0));
-	    reiserfs_mark_buffer_dirty (tb->CFL[0], 0);
-	}
-#endif
-    
+	RFALSE( ! tb->lnum[0] || ! tb->rnum[0],
+		"PAP-12190: lnum and rnum must not be zero");
 	/* if insertion was done before 0-th position in R[0], right
 	   delimiting key of the tb->L[0]'s and left delimiting key are
 	   not set correctly */
@@ -1094,10 +993,7 @@
     sbytes[1] = tb->s2bytes;
     for( i = tb->blknum[0] - 2; i >= 0; i-- ) {
 
-#ifdef CONFIG_REISERFS_CHECK
-	if (!snum[i])
-	    reiserfs_panic(tb->tb_sb,"PAP-12200: balance_leaf: snum[%d] == %d. Must be > 0", i, snum[i]);
-#endif /* CONFIG_REISERFS_CHECK */
+	RFALSE( !snum[i], "PAP-12200: snum[%d] == %d. Must be > 0", i, snum[i]);
 
 	/* here we shift from S to S_new nodes */
 
@@ -1120,14 +1016,11 @@
 		    const char * r_body;
 		    int version;
 
-#ifdef CONFIG_REISERFS_CHECK
-		    if ( !is_direct_le_ih(ih) )
+		    RFALSE( !is_direct_le_ih(ih),
 			/* The items which can be inserted are:
 			   Stat_data item, direct item, indirect item and directory item which consist of only two entries "." and "..".
 			   These items must not be broken except for a direct one. */
-			reiserfs_panic(tb->tb_sb, "PAP-12205: balance_leaf: "
-				       "non-direct item can not be broken when inserting");
-#endif
+			    "PAP-12205: non-direct item can not be broken when inserting");
 
 		    /* Move snum[i]-1 items from S[0] to S_new[i] */
 		    leaf_move_items (LEAF_FROM_S_TO_SNEW, tb, snum[i] - 1, -1, S_new[i]);
@@ -1210,10 +1103,7 @@
 		{ /* we must shift part of the appended item */
 		    struct item_head * aux_ih;
 
-#ifdef CONFIG_REISERFS_CHECK
-		    if ( ih )
-			reiserfs_panic (tb->tb_sb, "PAP-12210: balance_leaf: ih must be 0");
-#endif /* CONFIG_REISERFS_CHECK */
+		    RFALSE( ih, "PAP-12210: ih must be 0");
 
 		    if ( is_direntry_le_ih (aux_ih = B_N_PITEM_HEAD(tbS0,item_pos))) {
 			/* we append to directory item */
@@ -1225,14 +1115,11 @@
 			if ( entry_count - sbytes[i] < pos_in_item  && pos_in_item <= entry_count ) {
 			    /* new directory entry falls into S_new[i] */
 		  
-#ifdef CONFIG_REISERFS_CHECK
-			    if ( ! tb->insert_size[0] )
-				reiserfs_panic (tb->tb_sb, "PAP-12215: balance_leaif: insert_size is already 0");
-			    if ( sbytes[i] - 1 >= entry_count )
-				reiserfs_panic (tb->tb_sb, "PAP-12220: balance_leaf: "
-						"there are no so much entries (%d), only %d",
-						sbytes[i] - 1, entry_count);
-#endif
+			    RFALSE( ! tb->insert_size[0],
+				    "PAP-12215: insert_size is already 0");
+			    RFALSE( sbytes[i] - 1 >= entry_count,
+				    "PAP-12220: there are no so much entries (%d), only %d",
+				    sbytes[i] - 1, entry_count);
 
 			    /* Shift snum[i]-1 items in whole. Shift sbytes[i] directory entries from directory item number snum[i] */
 			    leaf_move_items (LEAF_FROM_S_TO_SNEW, tb, snum[i], sbytes[i]-1, S_new[i]);
@@ -1268,11 +1155,9 @@
 			int n_shift, n_rem, r_zeros_number;
 			const char * r_body;
 
-#ifdef CONFIG_REISERFS_CHECK
-			if ( pos_in_item != B_N_PITEM_HEAD(tbS0,item_pos)->ih_item_len ||
-			     tb->insert_size[0] <= 0 )
-			    reiserfs_panic (tb->tb_sb, "PAP-12225: balance_leaf: item too short or insert_size <= 0");
-#endif
+			RFALSE( pos_in_item != B_N_PITEM_HEAD(tbS0,item_pos)->ih_item_len ||
+				tb->insert_size[0] <= 0,
+				"PAP-12225: item too short or insert_size <= 0");
 
 			/* Calculate number of bytes which must be shifted from appended item */
 			n_shift = sbytes[i] - tb->insert_size[0];
@@ -1340,12 +1225,9 @@
 		    tbS0 = PATH_PLAST_BUFFER (tb->tb_path);
 #endif
 
-#ifdef CONFIG_REISERFS_CHECK
-		    if ( ret_val )
-			reiserfs_panic (tb->tb_sb, "PAP-12240: balance_leaf: "
-					"unexpected value returned by leaf_move_items (%d)",
-					ret_val);
-#endif /* CONFIG_REISERFS_CHECK */
+		    RFALSE( ret_val,
+			    "PAP-12240: unexpected value returned by leaf_move_items (%d)",
+			    ret_val);
 
 		    /* paste into item */
 		    bi.tb = tb;
@@ -1387,14 +1269,11 @@
 	memcpy (insert_key + i,B_N_PKEY(S_new[i],0),KEY_SIZE);
 	insert_ptr[i] = S_new[i];
 
-#ifdef CONFIG_REISERFS_CHECK
-	if (atomic_read (&(S_new[i]->b_count)) != 1) {
-	    if (atomic_read(&(S_new[i]->b_count)) != 2 ||
-	      !(buffer_journaled(S_new[i]) || buffer_journal_dirty(S_new[i]))) {
-	      reiserfs_panic (tb->tb_sb, "PAP-12247: balance_leaf: S_new[%d] : (%b)\n", i, S_new[i]);
-	    }
-	}
-#endif
+	RFALSE( (atomic_read (&(S_new[i]->b_count)) != 1) &&
+		(atomic_read(&(S_new[i]->b_count)) != 2 ||
+		 !(buffer_journaled(S_new[i]) || 
+		   buffer_journal_dirty(S_new[i]))), 
+		"PAP-12247: S_new[%d] : (%b)\n", i, S_new[i]);
 
 #if 0
 	/* update right_delimiting_key fields */
@@ -1452,10 +1331,8 @@
 	    if (is_direntry_le_ih (pasted)) {
 		if ( pos_in_item >= 0 && pos_in_item <= le16_to_cpu (pasted->u.ih_entry_count) ) {
 
-#ifdef CONFIG_REISERFS_CHECK
-		    if ( ! tb->insert_size[0] )
-			reiserfs_panic (tb->tb_sb, "PAP-12260: balance_leaf: insert_size is 0 already");
-#endif /* CONFIG_REISERFS_CHECK */
+		    RFALSE( ! tb->insert_size[0], 
+			    "PAP-12260: insert_size is 0 already");
 
 		    /* prepare space */
 		    bi.tb = tb;
@@ -1479,12 +1356,8 @@
 			body + DEH_SIZE, tb->insert_size[0]
 			);
 		    if ( ! item_pos && ! pos_in_item ) {
-
-#ifdef CONFIG_REISERFS_CHECK
-			if (!tb->CFL[0] || !tb->L[0])
-			    reiserfs_panic (tb->tb_sb, "PAP-12270: balance_leaf: CFL[0]/L[0] must be specified");
-#endif /* CONFIG_REISERFS_CHECK */
-
+			RFALSE( !tb->CFL[0] || !tb->L[0], 
+				"PAP-12270: CFL[0]/L[0] must be specified");
 			if (tb->CFL[0]) {
 			    replace_key(tb, tb->CFL[0], tb->lkey[0],tbS0,0);
 
@@ -1500,12 +1373,9 @@
 		}
 	    } else { /* regular object */
 		if ( pos_in_item == pasted->ih_item_len ) {
-
-#ifdef CONFIG_REISERFS_CHECK
-		    if ( tb->insert_size[0] <= 0 )
-			reiserfs_panic (tb->tb_sb,
-					"PAP-12275: balance_leaf: insert size must not be %d", tb->insert_size[0]);
-#endif /* CONFIG_REISERFS_CHECK */
+		    RFALSE( tb->insert_size[0] <= 0,
+			    "PAP-12275: insert size must not be %d", 
+			    tb->insert_size[0]);
 		    bi.tb = tb;
 		    bi.bi_bh = tbS0;
 		    bi.bi_parent = PATH_H_PPARENT (tb->tb_path, 0);
@@ -1514,13 +1384,9 @@
 
 		    if (is_indirect_le_ih (pasted)) {
 
-#ifdef CONFIG_REISERFS_CHECK
-			if ( tb->insert_size[0] != UNFM_P_SIZE )
-			    reiserfs_panic (tb->tb_sb,
-					    "PAP-12280: balance_leaf: insert_size for indirect item must be %d, not %d",
-					    UNFM_P_SIZE, tb->insert_size[0]);
-#endif /* CONFIG_REISERFS_CHECK */
-
+			RFALSE( tb->insert_size[0] != UNFM_P_SIZE,
+				"PAP-12280: insert_size for indirect item must be %d, not %d",
+				UNFM_P_SIZE, tb->insert_size[0]);
 			set_ih_free_space (pasted, ((struct unfm_nodeinfo*)body)->unfm_freespace);
 		    }
 		    tb->insert_size[0] = 0;
@@ -1557,10 +1423,7 @@
 {
     struct block_head * blkh;
 
-#ifdef CONFIG_REISERFS_CHECK
-    if (bi->bi_bh == NULL)
-	reiserfs_panic (0, "PAP-12295: make_empty_node: pointer to the buffer is NULL");
-#endif
+    RFALSE( bi->bi_bh == NULL, "PAP-12295: pointer to the buffer is NULL");
 
     (blkh = B_BLK_HEAD(bi->bi_bh))->blk_nr_item = cpu_to_le16 (0);
     blkh->blk_free_space = cpu_to_le16 (MAX_CHILD_SIZE(bi->bi_bh));
@@ -1646,21 +1509,17 @@
 		  struct buffer_head * src, int n_src)
 {
 
-#ifdef CONFIG_REISERFS_CHECK
-    if (dest == NULL || src == NULL)
-	reiserfs_panic (0, "vs-12305: replace_key: sourse or destination buffer is 0 (src=%p, dest=%p)", src, dest);
-
-    if ( ! B_IS_KEYS_LEVEL (dest) )
-	reiserfs_panic (0, "vs-12310: replace_key: invalid level (%z) for destination buffer. dest must be leaf",
-			dest);
-
-    if (n_dest < 0 || n_src < 0)
-	reiserfs_panic (0, "vs-12315: replace_key: src(%d) or dest(%d) key number less than 0", n_src, n_dest);
-
-    if (n_dest >= B_NR_ITEMS(dest) || n_src >= B_NR_ITEMS(src))
-	reiserfs_panic (0, "vs-12320: replace_key: src(%d(%d)) or dest(%d(%d)) key number is too big",
-			n_src, B_NR_ITEMS(src), n_dest, B_NR_ITEMS(dest));
-#endif	/* CONFIG_REISERFS_CHECK */
+    RFALSE( dest == NULL || src == NULL,
+	    "vs-12305: source or destination buffer is 0 (src=%p, dest=%p)",
+	    src, dest);
+    RFALSE( ! B_IS_KEYS_LEVEL (dest),
+	    "vs-12310: invalid level (%z) for destination buffer. dest must be leaf",
+	    dest);
+    RFALSE( n_dest < 0 || n_src < 0,
+	    "vs-12315: src(%d) or dest(%d) key number < 0", n_src, n_dest);
+    RFALSE( n_dest >= B_NR_ITEMS(dest) || n_src >= B_NR_ITEMS(src),
+	    "vs-12320: src(%d(%d)) or dest(%d(%d)) key number is too big",
+	    n_src, B_NR_ITEMS(src), n_dest, B_NR_ITEMS(dest));
    
     if (B_IS_ITEMS_LEVEL (src))
 	/* source buffer contains leaf node */
@@ -1679,11 +1538,9 @@
 {
   int Sh_position = PATH_H_POSITION (tb->tb_path, h + 1);
 
-#ifdef CONFIG_REISERFS_CHECK
-  if (PATH_H_PPARENT (tb->tb_path, h) == 0 || tb->FL[h] == 0)
-    reiserfs_panic (tb->tb_sb, "vs-12325: get_left_neighbor_position: FL[%d](%p) or F[%d](%p) does not exist", 
-		    h, tb->FL[h], h, PATH_H_PPARENT (tb->tb_path, h));
-#endif
+  RFALSE( PATH_H_PPARENT (tb->tb_path, h) == 0 || tb->FL[h] == 0,
+	  "vs-12325: FL[%d](%p) or F[%d](%p) does not exist", 
+	  h, tb->FL[h], h, PATH_H_PPARENT (tb->tb_path, h));
 
   if (Sh_position == 0)
     return B_NR_ITEMS (tb->FL[h]);
@@ -1696,11 +1553,9 @@
 {
   int Sh_position = PATH_H_POSITION (tb->tb_path, h + 1);
 
-#ifdef CONFIG_REISERFS_CHECK
-  if (PATH_H_PPARENT (tb->tb_path, h) == 0 || tb->FR[h] == 0)
-    reiserfs_panic (tb->tb_sb, "vs-12330: get_right_neighbor_position: F[%d](%p) or FR[%d](%p) does not exist", 
-		    h, PATH_H_PPARENT (tb->tb_path, h), h, tb->FR[h]);
-#endif
+  RFALSE( PATH_H_PPARENT (tb->tb_path, h) == 0 || tb->FR[h] == 0,
+	  "vs-12330: F[%d](%p) or FR[%d](%p) does not exist", 
+	  h, PATH_H_PPARENT (tb->tb_path, h), h, tb->FR[h]);
 
   if (Sh_position == B_NR_ITEMS (PATH_H_PPARENT (tb->tb_path, h)))
     return 0;
@@ -1717,17 +1572,14 @@
   struct disk_child * dc;
   int i;
 
-  if (!bh)
-    reiserfs_panic (s, "PAP-12336: check_internal_node: bh == 0");
+  RFALSE( !bh, "PAP-12336: bh == 0");
 
   if (!bh || !B_IS_IN_TREE (bh))
     return;
  
-  if (!buffer_dirty (bh) && 
-      !(buffer_journaled(bh) || buffer_journal_dirty(bh))) {
-    reiserfs_panic (s, "PAP-12337: check_internal_node: buffer (%b) must be dirty", bh);
-  }
-
+  RFALSE( !buffer_dirty (bh) && 
+	  !(buffer_journaled(bh) || buffer_journal_dirty(bh)),
+	  "PAP-12337: buffer (%b) must be dirty", bh);
   dc = B_N_CHILD (bh, 0);
 
   for (i = 0; i <= B_NR_ITEMS (bh); i ++, dc ++) {
@@ -1875,18 +1727,13 @@
 
     /* store_print_tb (tb); */
 
-#ifdef CONFIG_REISERFS_CHECK
-
     /* do not delete, just comment it out */
 /*    print_tb(flag, PATH_LAST_POSITION(tb->tb_path), tb->tb_path->pos_in_item, tb, 
 	     "check");*/
-
-    if (check_before_balancing (tb))
-	reiserfs_panic (tb->tb_sb, "PAP-12340: do_balance: locked buffers in TB");
-
+    RFALSE( check_before_balancing (tb), "PAP-12340: locked buffers in TB");
+#ifdef CONFIG_REISERFS_CHECK
     cur_tb = tb;
-    
-#endif /* CONFIG_REISERFS_CHECK */
+#endif
 }
 
 

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)