C-reiserfs-check.patch
Replaces consistency checks inside defined( CONFIG_REISERFS_CHECK )
with RFALSE()---assert-like macro. Makes code more readable and compact.
Doesn't change functionality in any way.
diff -rup linux-2.4.6/fs/reiserfs/bitmap.c linux-2.4.6.cleanup/fs/reiserfs/bitmap.c
--- linux-2.4.6/fs/reiserfs/bitmap.c Sun Jul 15 16:12:02 2001
+++ linux-2.4.6.cleanup/fs/reiserfs/bitmap.c Sun Jul 15 16:12:36 2001
@@ -68,23 +68,6 @@ int is_reusable (struct super_block * s,
#endif /* CONFIG_REISERFS_CHECK */
-#if 0
-/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
-int is_used (struct super_block * s, unsigned long block)
-{
- int i, j;
-
- i = block / (s->s_blocksize << 3);
- j = block % (s->s_blocksize << 3);
- if (reiserfs_test_le_bit(j, SB_AP_BITMAP (s)[i]->b_data))
- return 1;
- return 0;
-
-}
-/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
-#endif
-
-
/* get address of corresponding bit (bitmap block number and offset in it) */
static inline void get_bit_address (struct super_block * s, unsigned long block, int * bmap_nr, int * offset)
{
@@ -109,13 +92,8 @@ void reiserfs_free_block (struct reiserf
struct buffer_head ** apbh;
int nr, offset;
-#ifdef CONFIG_REISERFS_CHECK
- if (!s)
- reiserfs_panic (s, "vs-4060: reiserfs_free_block: trying to free block on nonexistent device");
-
- if (is_reusable (s, block, 1) == 0)
- reiserfs_panic (s, "vs-4070: reiserfs_free_block: can not free such block");
-#endif
+ RFALSE(!s, "vs-4060: trying to free block on nonexistent device");
+ RFALSE(is_reusable (s, block, 1) == 0, "vs-4070: can not free such block");
-#ifdef CONFIG_REISERFS_CHECK
- if (!s)
- reiserfs_panic (s, "vs-4090: reiserfs_new_blocknrs: trying to get new block from nonexistent device");
-
- if (search_start == MAX_B_NUM)
- reiserfs_panic (s, "vs-4100: reiserfs_new_blocknrs: we are optimizing location based on "
- "the bogus location of a temp buffer (%lu).", search_start);
-
- if (amount_needed < 1 || amount_needed > 2)
- reiserfs_panic (s, "vs-4110: reiserfs_new_blocknrs: amount_needed parameter incorrect (%d)", amount_needed);
-#endif /* CONFIG_REISERFS_CHECK */
+ RFALSE( !s, "vs-4090: trying to get new block from nonexistent device");
+ RFALSE( search_start == MAX_B_NUM,
+ "vs-4100: we are optimizing location based on "
+ "the bogus location of a temp buffer (%lu).", search_start);
+ RFALSE( amount_needed < 1 || amount_needed > 2,
+ "vs-4110: amount_needed parameter incorrect (%d)", amount_needed);
/* We continue the while loop if another process snatches our found
* free block from us after we find it but before we successfully
@@ -337,10 +310,8 @@ static int do_reiserfs_new_blocknrs (str
while (amount_needed--) {
/* skip over any blocknrs already gotten last time. */
if (*(free_blocknrs) != 0) {
-#ifdef CONFIG_REISERFS_CHECK
- if (is_reusable (s, *free_blocknrs, 1) == 0)
- reiserfs_panic(s, "vs-4120: reiserfs_new_blocknrs: bad blocknr on free_blocknrs list");
-#endif /* CONFIG_REISERFS_CHECK */
+ RFALSE( is_reusable (s, *free_blocknrs, 1) == 0,
+ "vs-4120: bad blocknr on free_blocknrs list");
free_blocknrs++;
continue;
}
@@ -414,10 +385,9 @@ free_and_return:
-#ifdef CONFIG_REISERFS_CHECK
- if (buffer_locked (SB_AP_BITMAP (s)[i]) || is_reusable (s, search_start, 0) == 0)
- reiserfs_panic (s, "vs-4140: reiserfs_new_blocknrs: bitmap block is locked or bad block number found");
-#endif
+ RFALSE( buffer_locked (SB_AP_BITMAP (s)[i]) ||
+ is_reusable (s, search_start, 0) == 0,
+ "vs-4140: bitmap block is locked or bad block number found");
/* if this bit was already set, we've scheduled, and someone else
** has allocated it. loop around and try again
diff -rup linux-2.4.6/fs/reiserfs/buffer2.c linux-2.4.6.cleanup/fs/reiserfs/buffer2.c
--- linux-2.4.6/fs/reiserfs/buffer2.c Sun Jul 15 16:12:02 2001
+++ linux-2.4.6.cleanup/fs/reiserfs/buffer2.c Sun Jul 15 16:12:36 2001
@@ -109,11 +109,9 @@ static int get_new_buffer_near_blocknr(
*pp_s_new_bh = reiserfs_getblk(p_s_sb->s_dev, n_new_blocknumber, p_s_sb->s_blocksize);
if ( buffer_uptodate(*pp_s_new_bh) ) {
-#ifdef CONFIG_REISERFS_CHECK
- if ( buffer_dirty(*pp_s_new_bh) || (*pp_s_new_bh)->b_dev == NODEV ) {
- reiserfs_panic(p_s_sb, "PAP-14080: get_new_buffer: invalid uptodate buffer %b for the new block", *pp_s_new_bh);
- }
-#endif
+ RFALSE( buffer_dirty(*pp_s_new_bh) || (*pp_s_new_bh)->b_dev == NODEV,
+ "PAP-14080: invalid uptodate buffer %b for the new block",
+ *pp_s_new_bh);
/* Free path buffers to prevent deadlock. */
/* It is possible that this process has the buffer, which this function is getting, already in
@@ -158,12 +156,9 @@ static int get_new_buffer_near_blocknr(
else {
;
-#ifdef CONFIG_REISERFS_CHECK
- if (atomic_read (&((*pp_s_new_bh)->b_count)) != 1) {
- reiserfs_panic(p_s_sb,"PAP-14100: get_new_buffer: not uptodate buffer %b for the new block has b_count more than one",
- *pp_s_new_bh);
- }
-#endif
+ RFALSE( atomic_read (&((*pp_s_new_bh)->b_count)) != 1,
+ "PAP-14100: not uptodate buffer %b for the new block has b_count more than one",
+ *pp_s_new_bh);
-#ifdef CONFIG_REISERFS_CHECK
- if ( atomic_read (&((*pp_s_new_bh)->b_count)) != 1 || buffer_dirty (*pp_s_new_bh)) {
- reiserfs_panic(p_s_sb,"PAP-14100: get_new_buffer: not free or dirty buffer %b for the new block",
- *pp_s_new_bh);
- }
-#endif
+ RFALSE( atomic_read (&((*pp_s_new_bh)->b_count)) != 1 ||
+ buffer_dirty (*pp_s_new_bh),
+ "PAP-14100: not free or dirty buffer %b for the new block",
+ *pp_s_new_bh);
return n_repeat;
}
diff -rup linux-2.4.6/fs/reiserfs/dir.c linux-2.4.6.cleanup/fs/reiserfs/dir.c
--- linux-2.4.6/fs/reiserfs/dir.c Sun Jul 15 16:12:02 2001
+++ linux-2.4.6.cleanup/fs/reiserfs/dir.c Sun Jul 15 16:12:36 2001
@@ -102,24 +102,18 @@ static int reiserfs_readdir (struct file
ih = de.de_ih;
store_ih (&tmp_ih, ih);
-#ifdef CONFIG_REISERFS_CHECK
/* we must have found item, that is item of this directory, */
- if (COMP_SHORT_KEYS (&(ih->ih_key), &pos_key))
- reiserfs_panic (inode->i_sb, "vs-9000: reiserfs_readdir: "
- "found item %h does not match to dir we readdir %k",
- ih, &pos_key);
-
- if (item_num > B_NR_ITEMS (bh) - 1)
- reiserfs_panic (inode->i_sb, "vs-9005: reiserfs_readdir: "
- "item_num == %d, item amount == %d",
- item_num, B_NR_ITEMS (bh));
+ RFALSE( COMP_SHORT_KEYS (&(ih->ih_key), &pos_key),
+ "vs-9000: found item %h does not match to dir we readdir %k",
+ ih, &pos_key);
+ RFALSE( item_num > B_NR_ITEMS (bh) - 1,
+ "vs-9005 item_num == %d, item amount == %d",
+ item_num, B_NR_ITEMS (bh));
/* and entry must be not more than number of entries in the item */
- if (I_ENTRY_COUNT (ih) < entry_num)
- reiserfs_panic (inode->i_sb, "vs-9010: reiserfs_readdir: "
- "entry number is too big %d (%d)",
- entry_num, I_ENTRY_COUNT (ih));
-#endif /* CONFIG_REISERFS_CHECK */
+ RFALSE( I_ENTRY_COUNT (ih) < entry_num,
+ "vs-9010: entry number is too big %d (%d)",
+ entry_num, I_ENTRY_COUNT (ih));
if (search_res == POSITION_FOUND || entry_num < I_ENTRY_COUNT (ih)) {
/* go through all entries in the directory item beginning from the entry, that has been found */
diff -rup linux-2.4.6/fs/reiserfs/do_balan.c linux-2.4.6.cleanup/fs/reiserfs/do_balan.c
--- linux-2.4.6/fs/reiserfs/do_balan.c Sun Jul 15 16:12:09 2001
+++ linux-2.4.6.cleanup/fs/reiserfs/do_balan.c Sun Jul 15 16:13:16 2001
@@ -90,18 +90,12 @@ static int balance_leaf_when_delete (str
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 @@ static int balance_leaf_when_delete (str
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);
-#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 @@ static int balance_leaf_when_delete (str
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 @@ static int balance_leaf_when_delete (str
}
/* 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);
-#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 @@ static int balance_leaf (struct tree_bal
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 @@ static int balance_leaf (struct tree_bal
/* 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 @@ static int balance_leaf (struct tree_bal
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 @@ static int balance_leaf (struct tree_bal
/* 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 @@ static int balance_leaf (struct tree_bal
}
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 @@ static int balance_leaf (struct tree_bal
/* 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 @@ static int balance_leaf (struct tree_bal
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 @@ static int balance_leaf (struct tree_bal
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 @@ static int balance_leaf (struct tree_bal
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 @@ static int balance_leaf (struct tree_bal
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 @@ static int balance_leaf (struct tree_bal
{ /* 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 @@ static int balance_leaf (struct tree_bal
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);
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");
-#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");
-#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 @@ static int balance_leaf (struct tree_bal
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 @@ static int balance_leaf (struct tree_bal
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 @@ static int balance_leaf (struct tree_bal
{ /* 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 @@ static int balance_leaf (struct tree_bal
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 @@ static int balance_leaf (struct tree_bal
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 @@ static int balance_leaf (struct tree_bal
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);
/* prepare space */
bi.tb = tb;
@@ -1479,12 +1356,8 @@ static int balance_leaf (struct tree_bal
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 @@ static int balance_leaf (struct tree_bal
}
} 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 @@ static int balance_leaf (struct tree_bal
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 @@ void make_empty_node (struct buffer_info
{
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");
- 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 @@ static inline void do_balance_starts (st
/* 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
}
Only in linux-2.4.6.cleanup/fs/reiserfs: do_balan.c~
diff -rup linux-2.4.6/fs/reiserfs/fix_node.c linux-2.4.6.cleanup/fs/reiserfs/fix_node.c
--- linux-2.4.6/fs/reiserfs/fix_node.c Sun Jul 15 16:12:09 2001
+++ linux-2.4.6.cleanup/fs/reiserfs/fix_node.c Sun Jul 15 16:12:36 2001
@@ -65,19 +65,14 @@ static inline int old_item_num (int new_
if (mode == M_INSERT) {
-#ifdef CONFIG_REISERFS_CHECK
- if (new_num == 0)
- reiserfs_panic (0,"vs-8005: old_item_num: for INSERT mode and item number of inserted item");
-#endif
+ RFALSE( new_num == 0,
+ "vs-8005: for INSERT mode and item number of inserted item");
return new_num - 1;
}
-#ifdef CONFIG_REISERFS_CHECK
- if (mode != M_DELETE)
- reiserfs_panic (0, "vs-8010: old_item_num: mode must be M_DELETE (mode = \'%c\'", mode);
-#endif
-
+ RFALSE( mode != M_DELETE,
+ "vs-8010: old_item_num: mode must be M_DELETE (mode = \'%c\'", mode);
/* delete mode */
return new_num + 1;
}
@@ -156,37 +151,14 @@ static void create_virtual_node (struct
if (vn->vn_mode == M_INSERT) {
struct virtual_item * vi = vn->vn_vi + vn->vn_affected_item_num;
-#ifdef CONFIG_REISERFS_CHECK
- if (vn->vn_ins_ih == 0)
- reiserfs_panic (0, "vs-8040: create_virtual_node: item header of inserted item is not specified");
-#endif
-
+ RFALSE( vn->vn_ins_ih == 0,
+ "vs-8040: item header of inserted item is not specified");
vi->vi_item_len = tb->insert_size[0];
vi->vi_ih = vn->vn_ins_ih;
vi->vi_item = vn->vn_data;
vi->vi_uarea = vn->vn_free_ptr;
op_create_vi (vn, vi, 0/*not pasted or cut*/, tb->insert_size [0]);
-#if 0
- switch (type/*le_key_k_type (ih_version (vn->vn_ins_ih), &(vn->vn_ins_ih->ih_key))*/) {
- case TYPE_STAT_DATA:
- vn->vn_vi[vn->vn_affected_item_num].vi_type |= VI_TYPE_STAT_DATA;
- break;
- case TYPE_DIRECT:
- vn->vn_vi[vn->vn_affected_item_num].vi_type |= VI_TYPE_DIRECT;
- break;
- case TYPE_INDIRECT:
- vn->vn_vi[vn->vn_affected_item_num].vi_type |= VI_TYPE_INDIRECT;
- break;
- default:
- /* inseted item is directory (it must be item with "." and "..") */
- vn->vn_vi[vn->vn_affected_item_num].vi_type |=
- (VI_TYPE_DIRECTORY | VI_TYPE_FIRST_DIRECTORY_ITEM | VI_TYPE_INSERTED_DIRECTORY_ITEM);
-
- /* this directory item can not be split, so do not set sizes of entries */
- break;
- }
-#endif
}
/* set right merge flag we take right delimiting key and check whether it is a mergeable item */
@@ -227,10 +199,7 @@ static void check_left (struct tree_bala
struct virtual_item * vi;
int d_size, ih_size;
-#ifdef CONFIG_REISERFS_CHECK
- if (!PATH_H_PPARENT (tb->tb_path, 0))
- reiserfs_panic (0, "vs-8055: check_left: parent does not exist or invalid");
-#endif
+ RFALSE( !PATH_H_PPARENT (tb->tb_path, 0),
+ "vs-8055: parent does not exist or invalid");
vi = vn->vn_vi;
if ((unsigned int)cur_free >= (vn->vn_size - ((vi->vi_type & VI_TYPE_LEFT_MERGEABLE) ? IH_SIZE : 0))) {
/* all contents of S[0] fits into L[0] */
-#ifdef CONFIG_REISERFS_CHECK
- if (!PATH_H_PPARENT (tb->tb_path, 0))
- reiserfs_panic (tb->tb_sb, "vs-8075: check_right: parent does not exist or invalid");
-#endif
+ RFALSE( !PATH_H_PPARENT (tb->tb_path, 0),
+ "vs-8075: parent does not exist or invalid");
vi = vn->vn_vi + vn->vn_nr_item - 1;
if ((unsigned int)cur_free >= (vn->vn_size - ((vi->vi_type & VI_TYPE_RIGHT_MERGEABLE) ? IH_SIZE : 0))) {
/* all contents of S[0] fits into R[0] */
-#ifdef CONFIG_REISERFS_CHECK
/* We only create additional nodes if we are in insert or paste mode
or we are in replace mode at the internal level. If h is 0 and
the mode is M_REPLACE then in fix_nodes we change the mode to
paste or insert before we get here in the code. */
- if ( tb->insert_size[h] < 0 || (mode != M_INSERT && mode != M_PASTE))
- reiserfs_panic (0, "vs-8100: get_num_ver: insert_size < 0 in overflow");
-#endif
+ RFALSE( tb->insert_size[h] < 0 || (mode != M_INSERT && mode != M_PASTE),
+ "vs-8100: insert_size < 0 in overflow");
@@ -469,11 +425,7 @@ static int get_num_ver (int mode, struct
struct virtual_item * vi = vn->vn_vi + i;
int skip_from_end = ((i == end_item) ? end_bytes : 0);
-#ifdef CONFIG_REISERFS_CHECK
- if (needed_nodes > 3) {
- reiserfs_panic (tb->tb_sb, "vs-8105: get_num_ver: too many nodes are needed");
- }
-#endif
+ RFALSE( needed_nodes > 3, "vs-8105: too many nodes are needed");
/* get size of current item */
current_item_size = vi->vi_item_len;
@@ -495,12 +447,10 @@ static int get_num_ver (int mode, struct
if (current_item_size > max_node_size) {
/* virtual item length is longer, than max size of item in
a node. It is impossible for direct item */
-#ifdef CONFIG_REISERFS_CHECK
- if (is_direct_le_ih (vi->vi_ih))
- reiserfs_panic (tb->tb_sb, "vs-8110: get_num_ver: "
- "direct item length is %d. It can not be longer than %d",
- current_item_size, max_node_size);
-#endif
+ RFALSE( is_direct_le_ih (vi->vi_ih),
+ "vs-8110: "
+ "direct item length is %d. It can not be longer than %d",
+ current_item_size, max_node_size);
/* we will try to split it */
flow = 1;
}
@@ -691,10 +641,8 @@ static int are_leaves_removable (struct
/* there was only one item and it will be deleted */
struct item_head * ih;
-#ifdef CONFIG_REISERFS_CHECK
- if (B_NR_ITEMS (S0) != 1)
- reiserfs_panic (0, "vs-8125: are_leaves_removable: item number must be 1: it is %d", B_NR_ITEMS(S0));
-#endif
+ RFALSE( B_NR_ITEMS (S0) != 1,
+ "vs-8125: item number must be 1: it is %d", B_NR_ITEMS(S0));
ih = B_N_PITEM_HEAD (S0, 0);
if (tb->CFR[0] && !comp_short_le_keys (&(ih->ih_key), B_N_PDELIM_KEY (tb->CFR[0], tb->rkey[0])))
@@ -708,13 +656,11 @@ static int are_leaves_removable (struct
we can save ih_size */
ih_size = IH_SIZE;
-#ifdef CONFIG_REISERFS_CHECK
/* we might check that left neighbor exists and is of the
same directory */
- if (le_key_k_offset (ih_version (ih), &(ih->ih_key)) == DOT_OFFSET)
- reiserfs_panic (tb->tb_sb, "vs-8130: are_leaves_removable: "
- "first directory item can not be removed until directory is not empty");
-#endif
+ RFALSE( le_key_k_offset
+ (ih_version (ih), &(ih->ih_key)) == DOT_OFFSET,
+ "vs-8130: first directory item can not be removed until directory is not empty");
}
-#ifdef CONFIG_REISERFS_CHECK
- if ( ! *p_n_blocknr )
- reiserfs_panic(p_s_sb, "PAP-8135: get_empty_nodes: reiserfs_new_blocknrs failed when got new blocks");
-#endif
+ RFALSE( ! *p_n_blocknr,
+ "PAP-8135: reiserfs_new_blocknrs failed when got new blocks");
p_s_new_bh = reiserfs_getblk(p_s_sb->s_dev, *p_n_blocknr, p_s_sb->s_blocksize);
if (atomic_read (&(p_s_new_bh->b_count)) > 1) {
@@ -873,15 +817,13 @@ static int get_empty_nodes(
wait_buffer_until_released (p_s_new_bh);
}
}
-#ifdef CONFIG_REISERFS_CHECK
- if (atomic_read (&(p_s_new_bh->b_count)) != 1 || buffer_dirty (p_s_new_bh)) {
- if (atomic_read(&(p_s_new_bh->b_count)) > 2 ||
- !(buffer_journaled(p_s_new_bh) || buffer_journal_dirty(p_s_new_bh))) {
- reiserfs_panic(p_s_sb,"PAP-8140: get_empty_nodes: not free or dirty buffer %b for the new block",
- p_s_new_bh);
- }
- }
-#endif
+ RFALSE( (atomic_read (&(p_s_new_bh->b_count)) != 1 ||
+ buffer_dirty (p_s_new_bh)) &&
+ (atomic_read(&(p_s_new_bh->b_count)) > 2 ||
+ !(buffer_journaled(p_s_new_bh) ||
+ buffer_journal_dirty(p_s_new_bh))),
+ "PAP-8140: not free or dirty buffer %b for the new block",
+ p_s_new_bh);
/* Put empty buffers into the array. */
if (p_s_tb->FEB[p_s_tb->cur_blknum])
@@ -958,13 +900,13 @@ static int is_left_neighbor_in_cache(
/* Calculate father of the node to be balanced. */
p_s_father = PATH_H_PBUFFER(p_s_tb->tb_path, n_h + 1);
/* Get position of the pointer to the left neighbor into the left father. */
@@ -975,12 +917,8 @@ static int is_left_neighbor_in_cache(
/* Look for the left neighbor in the cache. */
if ( (left = get_hash_table(p_s_sb->s_dev, n_left_neighbor_blocknr, p_s_sb->s_blocksize)) ) {
-#ifdef CONFIG_REISERFS_CHECK
- if ( buffer_uptodate (left) && ! B_IS_IN_TREE(left) ) {
- reiserfs_panic(p_s_sb, "vs-8170: is_left_neighbor_in_cache: left neighbor (%b %z) is not in the tree",
- left, left);
- }
-#endif
+ RFALSE( buffer_uptodate (left) && ! B_IS_IN_TREE(left),
+ "vs-8170: left neighbor (%b %z) is not in the tree", left, left);
atomic_dec (&(left->b_count));
return 1;
}
@@ -997,28 +935,6 @@ static void decrement_key (struct cpu_ke
{
// call item specific function for this key
item_ops[cpu_key_k_type (p_s_key)]->decrement_key (p_s_key);
-
-
-#if 0 /* this works wrong when key is key of second part of tail: it
- sets key to be of indirect type. It looks like it makes no
- harm but it is unclear */
-
- unsigned long * p_n_key_field = (unsigned long *)p_s_key + REISERFS_FULL_KEY_LEN - 1;
- int n_counter;
-
- for( n_counter = 0; n_counter < REISERFS_FULL_KEY_LEN; n_counter++, p_n_key_field-- ) {
- if ( *p_n_key_field ) {
- (*p_n_key_field)--;
- break;
- }
- }
-#ifdef CONFIG_REISERFS_CHECK
- if ( n_counter == REISERFS_FULL_KEY_LEN )
- reiserfs_panic(NULL, "PAP-8175: decrement_key: zero key");
-#endif
-
-#endif /*0*/
-
}
@@ -1052,10 +968,8 @@ static int get_far_parent (struct tree_
return CARRY_ON;
}
@@ -1400,15 +1305,14 @@ static int ip_check_balance (struct tree
return CARRY_ON;
}
-#ifdef CONFIG_REISERFS_CHECK
/* this checks balance condition, that any two neighboring nodes can not fit in one node */
- if ( h && ( tb->lnum[h] >= vn->vn_nr_item + 1 || tb->rnum[h] >= vn->vn_nr_item + 1) )
- reiserfs_panic (tb->tb_sb, "vs-8220: ip_check_balance: tree is not balanced on internal level");
-
- if ( ! h && ((tb->lnum[h] >= vn->vn_nr_item && (tb->lbytes == -1)) ||
- (tb->rnum[h] >= vn->vn_nr_item && (tb->rbytes == -1)) ))
- reiserfs_panic(tb->tb_sb, "vs-8225: ip_check_balance: tree is not balanced on leaf level");
-#endif
+ RFALSE( h &&
+ ( tb->lnum[h] >= vn->vn_nr_item + 1 ||
+ tb->rnum[h] >= vn->vn_nr_item + 1),
+ "vs-8220: tree is not balanced on internal level");
+ RFALSE( ! h && ((tb->lnum[h] >= vn->vn_nr_item && (tb->lbytes == -1)) ||
+ (tb->rnum[h] >= vn->vn_nr_item && (tb->rbytes == -1)) ),
+ "vs-8225: tree is not balanced on leaf level");
/* all contents of S[0] can be moved into its neighbors
S[0] will be removed after balancing. */
@@ -1553,10 +1457,11 @@ static int ip_check_balance (struct tree
/* we can win TWO or ONE nodes by shifting in both directions */
if (lrnver < lnver && lrnver < rnver)
{
-#ifdef CONFIG_REISERFS_CHECK
- if (h && (tb->lnum[h] != 1 || tb->rnum[h] != 1 || lrnver != 1 || rnver != 2 || lnver != 2 || h != 1))
- reiserfs_panic (0, "vs-8230: check_balance: bad h");
-#endif
+ RFALSE( h &&
+ (tb->lnum[h] != 1 ||
+ tb->rnum[h] != 1 ||
+ lrnver != 1 || rnver != 2 || lnver != 2 || h != 1),
+ "vs-8230: bad h");
if (lrset == LR_SHIFT_FLOW)
set_parameters (tb, h, tb->lnum[h], tb->rnum[h], lrnver, snum012 + lrset,
tb->lbytes, tb->rbytes);
@@ -1757,10 +1662,7 @@ static int dc_check_balance_internal (st
}
/* For internal nodes try to borrow item from a neighbor */
-#ifdef CONFIG_REISERFS_CHECK
- if (!tb->FL[h] && !tb->FR[h])
- reiserfs_panic (0, "vs-8235: dc_check_balance_internal: trying to borrow for root");
-#endif
+ RFALSE( !tb->FL[h] && !tb->FR[h], "vs-8235: trying to borrow for root");
/* Borrow one or two items from caching neighbor */
if (is_left_neighbor_in_cache (tb,h) || !tb->FR[h])
@@ -1818,10 +1720,8 @@ static int dc_check_balance_leaf (struct
if ( ! F0 )
{ /* S[0] is the root now. */
set_parameters (tb, h, 0, 0, 1, NULL, -1, -1);
return NO_BALANCING_NEEDED;
@@ -1853,10 +1753,7 @@ static int dc_check_balance_leaf (struct
((tb->rnum[0] - ((tb->rbytes == -1) ? 0 : 1)) < vn->vn_nr_item) || /* S can not be merged with R */
!tb->FR[h]) {
-#ifdef CONFIG_REISERFS_CHECK
- if (!tb->FL[h])
- reiserfs_panic (0, "vs-8245: dc_check_balance_leaf: FL[h] must exist");
-#endif
+ RFALSE( !tb->FL[h], "vs-8245: dc_check_balance_leaf: FL[h] must exist");
/* set parameter to merge S[0] with its left neighbor */
set_parameters (tb, h, -1, 0, 0, NULL, -1, -1);
@@ -1896,11 +1793,7 @@ static int dc_check_balance_leaf (struct
*/
static int dc_check_balance (struct tree_balance * tb, int h)
{
-
-#ifdef CONFIG_REISERFS_CHECK
- if ( ! (PATH_H_PBUFFER (tb->tb_path, h)) )
- reiserfs_panic(tb->tb_sb, "vs-8250: dc_check_balance: S is not initialized");
-#endif
+ RFALSE( ! (PATH_H_PBUFFER (tb->tb_path, h)), "vs-8250: S is not initialized");
if ( h )
return dc_check_balance_internal (tb, h);
@@ -1947,10 +1840,8 @@ static int check_balance (int mode,
vn->vn_ins_ih = ins_ih;
vn->vn_data = data;
-#ifdef CONFIG_REISERFS_CHECK
- if (mode == M_INSERT && !vn->vn_ins_ih)
- reiserfs_panic (0, "vs-8255: check_balance: ins_ih can not be 0 in insert mode");
-#endif
+ RFALSE( mode == M_INSERT && !vn->vn_ins_ih,
+ "vs-8255: ins_ih can not be 0 in insert mode");
if ( tb->insert_size[h] > 0 )
/* Calculate balance parameters when size of node is increasing. */
@@ -1975,10 +1866,8 @@ static int get_direct_parent(
/* We are in the root or in the new root. */
if ( n_path_offset <= FIRST_PATH_ELEMENT_OFFSET ) {
-#ifdef CONFIG_REISERFS_CHECK
- if ( n_path_offset < FIRST_PATH_ELEMENT_OFFSET - 1 )
- reiserfs_panic(p_s_tb->tb_sb, "PAP-8260: get_direct_parent: illegal offset in the path");
-#endif
+ RFALSE( n_path_offset < FIRST_PATH_ELEMENT_OFFSET - 1,
+ "PAP-8260: illegal offset in the path");
if ( PATH_OFFSET_PBUFFER(p_s_path, FIRST_PATH_ELEMENT_OFFSET)->b_blocknr ==
SB_ROOT_BLOCK (p_s_tb->tb_sb) ) {
@@ -2031,10 +1920,9 @@ static int get_neighbors(
/* We need left neighbor to balance S[n_h]. */
p_s_bh = PATH_OFFSET_PBUFFER(p_s_tb->tb_path, n_path_offset);
-#ifdef CONFIG_REISERFS_CHECK
- if ( p_s_bh == p_s_tb->FL[n_h] && ! PATH_OFFSET_POSITION(p_s_tb->tb_path, n_path_offset) )
- reiserfs_panic (p_s_tb->tb_sb, "PAP-8270: get_neighbors: invalid position in the parent");
-#endif
+ RFALSE( p_s_bh == p_s_tb->FL[n_h] &&
+ ! PATH_OFFSET_POSITION(p_s_tb->tb_path, n_path_offset),
+ "PAP-8270: invalid position in the parent");
decrement_bcount(p_s_tb->L[n_h]);
p_s_tb->L[n_h] = p_s_bh;
@@ -2065,10 +1951,9 @@ static int get_neighbors(
if ( p_s_tb->rnum[n_h] ) { /* We need right neighbor to balance S[n_path_offset]. */
p_s_bh = PATH_OFFSET_PBUFFER(p_s_tb->tb_path, n_path_offset);
-#ifdef CONFIG_REISERFS_CHECK
- if ( p_s_bh == p_s_tb->FR[n_h] && PATH_OFFSET_POSITION(p_s_tb->tb_path, n_path_offset) >= B_NR_ITEMS(p_s_bh) )
- reiserfs_panic (p_s_tb->tb_sb, "PAP-8295: get_neighbors: invalid position in the parent");
-#endif
+ RFALSE( p_s_bh == p_s_tb->FR[n_h] &&
+ PATH_OFFSET_POSITION(p_s_tb->tb_path, n_path_offset) >= B_NR_ITEMS(p_s_bh),
+ "PAP-8295: invalid position in the parent");
if ( !locked && p_s_tb->CFR[i] ) {
-#ifdef CONFIG_REISERFS_CHECK
tb_buffer_sanity_check (p_s_tb->tb_sb, p_s_tb->CFR[i], "CFR", i);
-#endif
clear_all_dirty_bits(p_s_tb->tb_sb, p_s_tb->CFR[i]) ;
if ( buffer_locked (p_s_tb->CFR[i]) )
locked = p_s_tb->CFR[i];
@@ -2536,10 +2412,8 @@ int fix_nodes (int n_op_mode,
/* We have a positive insert size but no nodes exist on this
level, this means that we are creating a new root. */
if ( n_h < MAX_HEIGHT - 1 )
p_s_tb->insert_size[n_h + 1] = 0;
@@ -2552,10 +2426,8 @@ int fix_nodes (int n_op_mode,
and a new node (S[n_h+1]) will be created to
become the root node. */
-#ifdef CONFIG_REISERFS_CHECK
- if ( n_h == MAX_HEIGHT - 1 )
- reiserfs_panic(p_s_tb->tb_sb, "PAP-8355: fix_nodes: attempt to create too high of a tree");
-#endif /* CONFIG_REISERFS_CHECK */
+ RFALSE( n_h == MAX_HEIGHT - 1,
+ "PAP-8355: attempt to create too high of a tree");
-#ifdef CONFIG_REISERFS_CHECK
- if (dest == NULL || src == NULL)
- reiserfs_panic (0, "internal_insert_key", "sourse(%p) or dest(%p) buffer is 0", src, dest);
-
- if (dest_position_before < 0 || src_position < 0)
- reiserfs_panic (0, "internal_insert_key", "source(%d) or dest(%d) key number less than 0",
- src_position, dest_position_before);
-
- if (dest_position_before > B_NR_ITEMS (dest) || src_position >= B_NR_ITEMS(src))
- reiserfs_panic (0, "internal_insert_key",
- "invalid position in dest (%d (key number %d)) or in src (%d (key number %d))",
- dest_position_before, B_NR_ITEMS (dest), src_position, B_NR_ITEMS(src));
-
- if (B_FREE_SPACE (dest) < KEY_SIZE)
- reiserfs_panic (0, "internal_insert_key",
- "no enough free space (%d) in dest buffer", B_FREE_SPACE (dest));
-#endif
+ RFALSE( dest == NULL || src == NULL,
+ "source(%p) or dest(%p) buffer is 0", src, dest);
+ RFALSE( dest_position_before < 0 || src_position < 0,
+ "source(%d) or dest(%d) key number less than 0",
+ src_position, dest_position_before);
+ RFALSE( dest_position_before > B_NR_ITEMS (dest) ||
+ src_position >= B_NR_ITEMS(src),
+ "invalid position in dest (%d (key number %d)) or in src (%d (key number %d))",
+ dest_position_before, B_NR_ITEMS (dest),
+ src_position, B_NR_ITEMS(src));
+ RFALSE( B_FREE_SPACE (dest) < KEY_SIZE,
+ "no enough free space (%d) in dest buffer", B_FREE_SPACE (dest));
nr = le16_to_cpu ((blkh=B_BLK_HEAD(dest))->blk_nr_item);
@@ -557,11 +525,10 @@ static void internal_shift_right (
/* insert delimiting key from common father of dest and src to dest node into position 0 */
internal_insert_key (&dest_bi, 0, cf, d_key_position);
if (nr == pointer_amount - 1) {
-#ifdef CONFIG_REISERFS_CHECK
- if ( src_bi.bi_bh != PATH_H_PBUFFER (tb->tb_path, h)/*tb->S[h]*/ || dest_bi.bi_bh != tb->R[h])
- reiserfs_panic (tb->tb_sb, "internal_shift_right", "src (%p) must be == tb->S[h](%p) when it disappears",
- src_bi.bi_bh, PATH_H_PBUFFER (tb->tb_path, h));
-#endif
+ RFALSE( src_bi.bi_bh != PATH_H_PBUFFER (tb->tb_path, h)/*tb->S[h]*/ ||
+ dest_bi.bi_bh != tb->R[h],
+ "src (%p) must be == tb->S[h](%p) when it disappears",
+ src_bi.bi_bh, PATH_H_PBUFFER (tb->tb_path, h));
/* when S[h] disappers replace left delemiting key as well */
if (tb->CFL[h])
replace_key (tb, cf, d_key_position, tb->CFL[h], tb->lkey[h]);
@@ -620,11 +587,8 @@ static void balance_internal_when_delete
if ( tb->lnum[h] < 0 ) { /* borrow from left neighbor L[h] */
-#ifdef CONFIG_REISERFS_CHECK
- if ( tb->rnum[h] != 0 )
- reiserfs_panic (tb->tb_sb, "balance_internal_when_delete", "invalid tb->rnum[%d]==%d when borrow from L[h]",
- h, tb->rnum[h]);
-#endif /* CONFIG_REISERFS_CHECK */
+ RFALSE( tb->rnum[h] != 0,
+ "wrong tb->rnum[%d]==%d when borrow from L[h]", h, tb->rnum[h]);
/*internal_shift_right (tb, h, tb->L[h], tb->CFL[h], tb->lkey[h], tb->S[h], -tb->lnum[h]);*/
internal_shift_right (INTERNAL_SHIFT_FROM_L_TO_S, tb, h, -tb->lnum[h]);
return;
}
if ( tb->rnum[h] < 0 ) { /* borrow from right neighbor R[h] */
-#ifdef CONFIG_REISERFS_CHECK
- if ( tb->lnum[h] != 0 )
- reiserfs_panic (tb->tb_sb, "balance_internal_when_delete", "invalid tb->lnum[%d]==%d when borrow from R[h]",
- h, tb->lnum[h]);
-#endif /* CONFIG_REISERFS_CHECK */
+ RFALSE( tb->lnum[h] != 0,
+ "invalid tb->lnum[%d]==%d when borrow from R[h]",
+ h, tb->lnum[h]);
internal_shift_left (INTERNAL_SHIFT_FROM_R_TO_S, tb, h, -tb->rnum[h]);/*tb->S[h], tb->CFR[h], tb->rkey[h], tb->R[h], -tb->rnum[h]);*/
return;
}
if ( tb->lnum[h] > 0 ) { /* split S[h] into two parts and put them into neighbors */
-#ifdef CONFIG_REISERFS_CHECK
- if ( tb->rnum[h] == 0 || tb->lnum[h] + tb->rnum[h] != n + 1 )
- reiserfs_panic (tb->tb_sb, "balance_internal_when_delete",
- "invalid tb->lnum[%d]==%d or tb->rnum[%d]==%d when S[h](item number == %d) is split between them",
- h, tb->lnum[h], h, tb->rnum[h], n);
-#endif /* CONFIG_REISERFS_CHECK */
+ RFALSE( tb->rnum[h] == 0 || tb->lnum[h] + tb->rnum[h] != n + 1,
+ "invalid tb->lnum[%d]==%d or tb->rnum[%d]==%d when S[h](item number == %d) is split between them",
+ h, tb->lnum[h], h, tb->rnum[h], n);
-#ifdef CONFIG_REISERFS_CHECK
- if ( h < 1 )
- reiserfs_panic (tb->tb_sb, "balance_internal", "h (%d) can not be < 1 on internal level", h);
-#endif /* CONFIG_REISERFS_CHECK */
+ RFALSE( h < 1, "h (%d) can not be < 1 on internal level", h);
order = ( tbSh ) ? PATH_H_POSITION (tb->tb_path, h + 1)/*tb->S[h]->b_item_order*/ : 0;
/* Check whether insert_num is proper **/
-#ifdef CONFIG_REISERFS_CHECK
- if ( insert_num < -2 || insert_num > 2 )
- reiserfs_panic (tb->tb_sb, "balance_internal",
- "incorrect number of items inserted to the internal node (%d)", insert_num);
-
- if ( h > 1 && (insert_num > 1 || insert_num < -1) )
- reiserfs_panic (tb->tb_sb, "balance_internal",
- "incorrect number of items (%d) inserted to the internal node on a level (h=%d) higher than last internal level",
- insert_num, h);
-#endif /* CONFIG_REISERFS_CHECK */
+ RFALSE( insert_num < -2 || insert_num > 2,
+ "incorrect number of items inserted to the internal node (%d)",
+ insert_num);
+ RFALSE( h > 1 && (insert_num > 1 || insert_num < -1),
+ "incorrect number of items (%d) inserted to the internal node on a level (h=%d) higher than last internal level",
+ insert_num, h);
/* Make balance in case insert_num < 0 */
if ( insert_num < 0 ) {
@@ -951,19 +886,12 @@ int balance_internal (struct tree_balanc
}
/** Fill new node that appears instead of S[h] **/
-#ifdef CONFIG_REISERFS_CHECK
- if ( tb->blknum[h] > 2 )
- reiserfs_panic(0, "balance_internal", "blknum can not be > 2 for internal level");
- if ( tb->blknum[h] < 0 )
- reiserfs_panic(0, "balance_internal", "blknum can not be < 0");
-#endif /* CONFIG_REISERFS_CHECK */
+ RFALSE( tb->blknum[h] > 2, "blknum can not be > 2 for internal level");
+ RFALSE( tb->blknum[h] < 0, "blknum can not be < 0");
if ( ! tb->blknum[h] )
{ /* node S[h] is empty now */
-#ifdef CONFIG_REISERFS_CHECK
- if ( ! tbSh )
- reiserfs_panic(0,"balance_internal", "S[h] is equal NULL");
-#endif /* CONFIG_REISERFS_CHECK */
+ RFALSE( ! tbSh, "S[h] is equal NULL");
/* do what is needed for buffer thrown from tree */
reiserfs_invalidate_buffer(tb,tbSh);
@@ -1081,13 +1009,10 @@ int balance_internal (struct tree_balanc
/* new_insert_ptr = node_pointer to S_new */
new_insert_ptr = S_new;
if (reiserfs_dont_log(p_s_sb)) {
th->t_super = p_s_sb ; /* others will check this for the don't log flag */
@@ -2633,12 +2629,8 @@ void reiserfs_prepare_for_journal(struct
}
set_bit(BH_JPrepared, &bh->b_state) ;
if (wait) {
-#ifdef CONFIG_REISERFS_CHECK
- if (buffer_locked(bh) && cur_tb != NULL) {
- printk("reiserfs_prepare_for_journal, waiting while do_balance was running\n") ;
- BUG() ;
- }
-#endif
+ RFALSE( buffer_locked(bh) && cur_tb != NULL,
+ "waiting while do_balance was running\n") ;
wait_on_buffer(bh) ;
}
retry_count++ ;
diff -rup linux-2.4.6/fs/reiserfs/lbalance.c linux-2.4.6.cleanup/fs/reiserfs/lbalance.c
--- linux-2.4.6/fs/reiserfs/lbalance.c Sun Jul 15 16:12:09 2001
+++ linux-2.4.6.cleanup/fs/reiserfs/lbalance.c Sun Jul 15 16:12:36 2001
@@ -37,10 +37,7 @@ static void leaf_copy_dir_entries (struc
ih = B_N_PITEM_HEAD (source, item_num);
-#ifdef CONFIG_REISERFS_CHECK
- if (!is_direntry_le_ih (ih))
- reiserfs_panic(0, "vs-10000: leaf_copy_dir_entries: item must be directory item");
-#endif
+ RFALSE( !is_direntry_le_ih (ih), "vs-10000: item must be directory item");
/* length of all record to be copied and first byte of the last of them */
deh = B_I_DEH (source, ih);
@@ -126,10 +123,7 @@ static int leaf_copy_boundary_item (stru
/* there is nothing to merge */
return 0;
-#ifdef CONFIG_REISERFS_CHECK
- if ( ! ih->ih_item_len )
- reiserfs_panic (0, "vs-10010: leaf_copy_boundary_item: item can not have empty dynamic length");
-#endif
+ RFALSE( ! ih->ih_item_len, "vs-10010: item can not have empty length");
if ( is_direntry_le_ih (ih) ) {
if ( bytes_or_entries == -1 )
@@ -162,12 +156,9 @@ static int leaf_copy_boundary_item (stru
);
if (is_indirect_le_ih (dih)) {
-#ifdef CONFIG_REISERFS_CHECK
- if (get_ih_free_space (dih))
- reiserfs_panic (0, "vs-10030: leaf_copy_boundary_item: "
- "merge to left: last unformatted node of non-last indirect item %h must have zerto free space",
- ih);
-#endif
+ RFALSE( get_ih_free_space (dih),
+ "vs-10030: merge to left: last unformatted node of non-last indirect item %h must have zero free space",
+ ih);
if (bytes_or_entries == le16_to_cpu (ih->ih_item_len))
set_ih_free_space (dih, get_ih_free_space (ih));
}
@@ -202,21 +193,17 @@ static int leaf_copy_boundary_item (stru
don't create new item header
*/
-#ifdef CONFIG_REISERFS_CHECK
- if (is_indirect_le_ih(ih) && get_ih_free_space (ih))
- reiserfs_panic (0, "vs-10040: leaf_copy_boundary_item: "
- "merge to right: last unformatted node of non-last indirect item must be filled entirely (%h)",
+ RFALSE( is_indirect_le_ih(ih) && get_ih_free_space (ih),
+ "vs-10040: merge to right: last unformatted node of non-last indirect item must be filled entirely (%h)",
ih);
-#endif
if ( bytes_or_entries == -1 ) {
/* bytes_or_entries = length of last item body of SOURCE */
bytes_or_entries = ih->ih_item_len;
-#ifdef CONFIG_REISERFS_CHECK
- if (le_ih_k_offset (dih) != le_ih_k_offset (ih) + op_bytes_number (ih, src->b_size))
- reiserfs_panic (0, "vs-10050: leaf_copy_boundary_item: items %h and %h do not match", ih, dih);
-#endif
+ RFALSE( le_ih_k_offset (dih) !=
+ le_ih_k_offset (ih) + op_bytes_number (ih, src->b_size),
+ "vs-10050: items %h and %h do not match", ih, dih);
/* change first item key of the DEST */
set_le_ih_k_offset (dih, le_ih_k_offset (ih));
@@ -226,26 +213,20 @@ static int leaf_copy_boundary_item (stru
set_le_ih_k_type (dih, le_ih_k_type (ih));
} else {
/* merge to right only part of item */
-#ifdef CONFIG_REISERFS_CHECK
- if ( le16_to_cpu (ih->ih_item_len) <= bytes_or_entries )
- reiserfs_panic (0, "vs-10060: leaf_copy_boundary_item: no so much bytes %lu (needed %lu)",
- ih->ih_item_len, bytes_or_entries);
-#endif
+ RFALSE( le16_to_cpu (ih->ih_item_len) <= bytes_or_entries,
+ "vs-10060: no so much bytes %lu (needed %lu)",
+ ih->ih_item_len, bytes_or_entries);
-#ifdef CONFIG_REISERFS_CHECK
- if (last_first != LAST_TO_FIRST && last_first != FIRST_TO_LAST)
- reiserfs_panic (0, "vs-10090: leaf_copy_items_entirely: bad last_first parameter %d", last_first);
-
- if (B_NR_ITEMS (src) - first < cpy_num)
- reiserfs_panic (0, "vs-10100: leaf_copy_items_entirely: too few items in source %d, required %d from %d",
- B_NR_ITEMS(src), cpy_num, first);
-
- if (cpy_num < 0)
- reiserfs_panic (0, "vs-10110: leaf_copy_items_entirely: can not copy negative amount of items");
-
- if ( ! dest_bi )
- reiserfs_panic (0, "vs-10120: leaf_copy_items_entirely: can not copy negative amount of items");
-#endif
+ RFALSE( last_first != LAST_TO_FIRST && last_first != FIRST_TO_LAST,
+ "vs-10090: bad last_first parameter %d", last_first);
+ RFALSE( B_NR_ITEMS (src) - first < cpy_num,
+ "vs-10100: too few items in source %d, required %d from %d",
+ B_NR_ITEMS(src), cpy_num, first);
+ RFALSE( cpy_num < 0, "vs-10110: can not copy negative amount of items");
+ RFALSE( ! dest_bi, "vs-10120: can not copy negative amount of items");
dest = dest_bi->bi_bh;
-#ifdef CONFIG_REISERFS_CHECK
- if ( ! dest )
- reiserfs_panic (0, "vs-10130: leaf_copy_items_entirely: can not copy negative amount of items");
-#endif
+ RFALSE( ! dest, "vs-10130: can not copy negative amount of items");
if (cpy_num == 0)
return;
@@ -303,13 +274,9 @@ static void leaf_copy_items_entirely (st
/* location of head of first new item */
ih = B_N_PITEM_HEAD (dest, dest_before);
if (dest_bi->bi_parent) {
-#ifdef CONFIG_REISERFS_CHECK
- if (B_N_CHILD (dest_bi->bi_parent, dest_bi->bi_position)->dc_block_number != dest->b_blocknr) {
- reiserfs_panic (0, "vs-10160: leaf_copy_items_entirely: "
- "block number in bh does not match to field in disk_child structure %lu and %lu",
- dest->b_blocknr, B_N_CHILD (dest_bi->bi_parent, dest_bi->bi_position)->dc_block_number);
- }
-#endif
+ RFALSE( B_N_CHILD (dest_bi->bi_parent, dest_bi->bi_position)->dc_block_number != dest->b_blocknr,
+ "vs-10160: block number in bh does not match to field in disk_child structure %lu and %lu",
+ dest->b_blocknr, B_N_CHILD (dest_bi->bi_parent, dest_bi->bi_position)->dc_block_number);
B_N_CHILD (dest_bi->bi_parent, dest_bi->bi_position)->dc_size +=
j - last_inserted_loc + IH_SIZE * cpy_num;
-#ifdef CONFIG_REISERFS_CHECK
- if ( !bh )
- reiserfs_panic (0, "leaf_delete_items: 10155: bh is not defined");
-
- if ( del_num < 0 )
- reiserfs_panic (0, "leaf_delete_items: 10160: del_num can not be < 0. del_num==%d", del_num);
-
- if ( first < 0 || first + del_num > item_amount )
- reiserfs_panic (0, "leaf_delete_items: 10165: invalid number of first item to be deleted (%d) or "
- "no so much items (%d) to delete (only %d)", first, first + del_num, item_amount);
-#endif
+ RFALSE( !bh, "10155: bh is not defined");
+ RFALSE( del_num < 0, "10160: del_num can not be < 0. del_num==%d", del_num);
+ RFALSE( first < 0 || first + del_num > item_amount,
+ "10165: invalid number of first item to be deleted (%d) or "
+ "no so much items (%d) to delete (only %d)",
+ first, first + del_num, item_amount);
nr = le16_to_cpu ((blkh = B_BLK_HEAD (bh))->blk_nr_item);
-#ifdef CONFIG_REISERFS_CHECK
/* check free space */
- if (le16_to_cpu (blkh->blk_free_space) < le16_to_cpu (inserted_item_ih->ih_item_len) + IH_SIZE)
- reiserfs_panic (0, "leaf_insert_into_buf: 10170: "
- "not enough free space in block %z, new item %h",
- bh, inserted_item_ih);
- if (zeros_number > inserted_item_ih->ih_item_len)
- reiserfs_panic (0, "vs-10172: leaf_insert_into_buf: "
- "zero number == %d, item length == %d", zeros_number, inserted_item_ih->ih_item_len);
-#endif /* CONFIG_REISERFS_CHECK */
+ RFALSE( le16_to_cpu (blkh->blk_free_space) <
+ le16_to_cpu (inserted_item_ih->ih_item_len) + IH_SIZE,
+ "not enough free space in block %z, new item %h",
+ bh, inserted_item_ih);
+ RFALSE( zeros_number > inserted_item_ih->ih_item_len,
+ "vs-10172: zero number == %d, item length == %d",
+ zeros_number, inserted_item_ih->ih_item_len);
/* get item new item must be inserted before */
@@ -886,11 +815,11 @@ void leaf_paste_in_buffer (struct buffer
nr = le16_to_cpu ((blkh = B_BLK_HEAD(bh))->blk_nr_item);
-#ifdef CONFIG_REISERFS_CHECK
/* check free space */
- if (le16_to_cpu (blkh->blk_free_space) < paste_size)
- reiserfs_panic (0, "leaf_paste_in_buffer: 10175: not enough free space: needed %d, available %d",
- paste_size, le16_to_cpu (blkh->blk_free_space));
+ RFALSE( le16_to_cpu (blkh->blk_free_space) < paste_size,
+ "10175: not enough free space: needed %d, available %d",
+ paste_size, le16_to_cpu (blkh->blk_free_space));
+#ifdef CONFIG_REISERFS_CHECK
if (zeros_number > paste_size) {
print_cur_tb ("10177");
reiserfs_panic (0, "vs-10177: leaf_paste_in_buffer: zero number == %d, paste_size == %d",
@@ -965,16 +894,12 @@ static int leaf_cut_entries (
int i;
-#ifdef CONFIG_REISERFS_CHECK
/* make sure, that item is directory and there are enough entries to
remove */
- if (!is_direntry_le_ih (ih))
- reiserfs_panic (0, "leaf_cut_entries: 10180: item is not directory item");
-
- if (I_ENTRY_COUNT(ih) < from + del_count)
- reiserfs_panic (0, "leaf_cut_entries: 10185: item contains not enough entries: entry_cout = %d, from = %d, to delete = %d",
- I_ENTRY_COUNT(ih), from, del_count);
-#endif
+ RFALSE( !is_direntry_le_ih (ih), "10180: item is not directory item");
+ RFALSE( I_ENTRY_COUNT(ih) < from + del_count,
+ "10185: item contains not enough entries: entry_cout = %d, from = %d, to delete = %d",
+ I_ENTRY_COUNT(ih), from, del_count);
if (del_count == 0)
return 0;
@@ -1042,25 +967,19 @@ void leaf_cut_from_buffer (struct buffer
cut_size = leaf_cut_entries (bh, ih, pos_in_item, cut_size);
if (pos_in_item == 0) {
/* change key */
-#ifdef CONFIG_REISERFS_CHECK
- if (cut_item_num)
- reiserfs_panic (0, "leaf_cut_from_buffer: 10190: "
+ RFALSE( cut_item_num,
"when 0-th enrty of item is cut, that item must be first in the node, not %d-th", cut_item_num);
-#endif
/* change item key by key of first entry in the item */
set_le_ih_k_offset (ih, le32_to_cpu (B_I_DEH (bh, ih)->deh_offset));
/*memcpy (&ih->ih_key.k_offset, &(B_I_DEH (bh, ih)->deh_offset), SHORT_KEY_SIZE);*/
}
} else {
/* item is direct or indirect */
-#ifdef CONFIG_REISERFS_CHECK
- if (is_statdata_le_ih (ih))
- reiserfs_panic (0, "leaf_cut_from_buffer: 10195: item is stat data");
-
- if (pos_in_item && pos_in_item + cut_size != le16_to_cpu (ih->ih_item_len) )
- reiserfs_panic (0, "cut_from_buf: 10200: invalid offset (%lu) or trunc_size (%lu) or ih_item_len (%lu)",
+ RFALSE( is_statdata_le_ih (ih), "10195: item is stat data");
+ RFALSE( pos_in_item &&
+ pos_in_item + cut_size != le16_to_cpu (ih->ih_item_len),
+ "invalid offset (%lu) or trunc_size (%lu) or ih_item_len (%lu)",
pos_in_item, cut_size, le16_to_cpu (ih->ih_item_len));
-#endif
/* shift item body to left if cut is from the head of item */
if (pos_in_item == 0) {
@@ -1072,10 +991,9 @@ void leaf_cut_from_buffer (struct buffer
set_le_ih_k_offset (ih, le_ih_k_offset (ih) + cut_size);
else {
set_le_ih_k_offset (ih, le_ih_k_offset (ih) + (cut_size / UNFM_P_SIZE) * bh->b_size);
-#ifdef CONFIG_REISERFS_CHECK
- if ( le16_to_cpu (ih->ih_item_len) == cut_size && get_ih_free_space (ih) )
- reiserfs_panic (0, "leaf_cut_from_buf: 10205: invalid ih_free_space (%h)", ih);
-#endif
+ RFALSE( le16_to_cpu (ih->ih_item_len) == cut_size &&
+ get_ih_free_space (ih),
+ "10205: invalid ih_free_space (%h)", ih);
}
}
}
@@ -1130,23 +1048,16 @@ static void leaf_delete_items_entirely (
struct block_head * blkh;
struct item_head * ih;
-#ifdef CONFIG_REISERFS_CHECK
- if (bh == NULL)
- reiserfs_panic (0, "leaf_delete_items_entirely: 10210: buffer is 0");
-
- if (del_num < 0)
- reiserfs_panic (0, "leaf_delete_items_entirely: 10215: del_num less than 0 (%d)", del_num);
-#endif /* CONFIG_REISERFS_CHECK */
+ RFALSE( bh == NULL, "10210: buffer is 0");
+ RFALSE( del_num < 0, "10215: del_num less than 0 (%d)", del_num);
if (del_num == 0)
return;
nr = le16_to_cpu ((blkh = B_BLK_HEAD(bh))->blk_nr_item);
-#ifdef CONFIG_REISERFS_CHECK
- if (first < 0 || first + del_num > nr)
- reiserfs_panic (0, "leaf_delete_items_entirely: 10220: first=%d, number=%d, there is %d items", first, del_num, nr);
-#endif /* CONFIG_REISERFS_CHECK */
+ RFALSE( first < 0 || first + del_num > nr,
+ "10220: first=%d, number=%d, there is %d items", first, del_num, nr);
if (first == 0 && del_num == nr) {
/* this does not work */
@@ -1213,15 +1124,11 @@ void leaf_paste_entries (
ih = B_N_PITEM_HEAD(bh, item_num);
-#ifdef CONFIG_REISERFS_CHECK
/* make sure, that item is directory, and there are enough records in it */
- if (!is_direntry_le_ih (ih))
- reiserfs_panic (0, "leaf_paste_entries: 10225: item is not directory item");
-
- if (I_ENTRY_COUNT (ih) < before)
- reiserfs_panic (0, "leaf_paste_entries: 10230: there are no entry we paste entries before. entry_count = %d, before = %d",
- I_ENTRY_COUNT (ih), before);
-#endif
+ RFALSE( !is_direntry_le_ih (ih), "10225: item is not directory item");
+ RFALSE( I_ENTRY_COUNT (ih) < before,
+ "10230: there are no entry we paste entries before. entry_count = %d, before = %d",
+ I_ENTRY_COUNT (ih), before);
/* first byte of dest item */
@@ -1268,13 +1175,6 @@ void leaf_paste_entries (
/* change item key if neccessary (when we paste before 0-th entry */
if (!before)
{
-#ifdef CONFIG_REISERFS_CHECK
-/*
- if ( old_entry_num && COMP_SHORT_KEYS ((unsigned long *)&ih->ih_key.k_offset,
- &(new_dehs->deh_offset)) <= 0)
- reiserfs_panic (0, "leaf_paste_entries: 10235: new key must be less, that old key");
-*/
-#endif
set_le_ih_k_offset (ih, le32_to_cpu (new_dehs->deh_offset));
/* memcpy (&ih->ih_key.k_offset,
&new_dehs->deh_offset, SHORT_KEY_SIZE);*/
diff -rup linux-2.4.6/fs/reiserfs/namei.c linux-2.4.6.cleanup/fs/reiserfs/namei.c
--- linux-2.4.6/fs/reiserfs/namei.c Sun Jul 15 16:12:03 2001
+++ linux-2.4.6.cleanup/fs/reiserfs/namei.c Sun Jul 15 16:12:36 2001
@@ -245,10 +245,8 @@ static int linear_search_in_dir_item (st
i --;
}
-#ifdef CONFIG_REISERFS_CHECK
- if (de->de_deh != B_I_DEH (de->de_bh, de->de_ih))
- reiserfs_panic (0, "vs-7010: linear_search_in_dir_item: array of entry headers not found");
-#endif /* CONFIG_REISERFS_CHECK */
+ RFALSE( de->de_deh != B_I_DEH (de->de_bh, de->de_ih),
+ "vs-7010: array of entry headers not found");
deh += i;
@@ -290,11 +288,8 @@ static int linear_search_in_dir_item (st
// so, this is a bug
return NAME_NOT_FOUND;
-#ifdef CONFIG_REISERFS_CHECK
- if (de->de_item_num)
- reiserfs_panic (0, "vs-7015: linear_search_in_dir_item: "
- "two diritems of the same directory in one node?");
-#endif /* CONFIG_REISERFS_CHECK */
+ RFALSE( de->de_item_num,
+ "vs-7015: two diritems of the same directory in one node?");
-#ifdef CONFIG_REISERFS_CHECK
- if ( n_path_offset < FIRST_PATH_ELEMENT_OFFSET )
- reiserfs_panic(p_s_sb,"PAP-5010: get_lkey: illegal offset in the path");
-#endif
+ RFALSE( n_path_offset < FIRST_PATH_ELEMENT_OFFSET,
+ "PAP-5010: illegal offset in the path");
/* While not higher in path than first element. */
while ( n_path_offset-- > FIRST_PATH_ELEMENT_OFFSET ) {
-#ifdef CONFIG_REISERFS_CHECK
- if ( ! buffer_uptodate(PATH_OFFSET_PBUFFER(p_s_chk_path, n_path_offset)) )
- reiserfs_panic(p_s_sb, "PAP-5020: get_lkey: parent is not uptodate");
-#endif
+ RFALSE( ! buffer_uptodate(PATH_OFFSET_PBUFFER(p_s_chk_path, n_path_offset)),
+ "PAP-5020: parent is not uptodate");
/* Parent at the path is not in the tree now. */
if ( ! B_IS_IN_TREE(p_s_parent = PATH_OFFSET_PBUFFER(p_s_chk_path, n_path_offset)) )
@@ -356,17 +347,13 @@ inline struct key * get_rkey (
n_path_offset = p_s_chk_path->path_length;
struct buffer_head * p_s_parent;
-#ifdef CONFIG_REISERFS_CHECK
- if ( n_path_offset < FIRST_PATH_ELEMENT_OFFSET )
- reiserfs_panic(p_s_sb,"PAP-5030: get_rkey: illegal offset in the path");
-#endif
+ RFALSE( n_path_offset < FIRST_PATH_ELEMENT_OFFSET,
+ "PAP-5030: illegal offset in the path");
while ( n_path_offset-- > FIRST_PATH_ELEMENT_OFFSET ) {
-#ifdef CONFIG_REISERFS_CHECK
- if ( ! buffer_uptodate(PATH_OFFSET_PBUFFER(p_s_chk_path, n_path_offset)) )
- reiserfs_panic(p_s_sb, "PAP-5040: get_rkey: parent is not uptodate");
-#endif
+ RFALSE( ! buffer_uptodate(PATH_OFFSET_PBUFFER(p_s_chk_path, n_path_offset)),
+ "PAP-5040: parent is not uptodate");
/* Parent at the path is not in the tree now. */
if ( ! B_IS_IN_TREE(p_s_parent = PATH_OFFSET_PBUFFER(p_s_chk_path, n_path_offset)) )
@@ -401,15 +388,12 @@ static inline int key_in_buffer (
struct super_block * p_s_sb /* Super block pointer. */
) {
-#ifdef CONFIG_REISERFS_CHECK
- if ( ! p_s_key || p_s_chk_path->path_length < FIRST_PATH_ELEMENT_OFFSET ||
- p_s_chk_path->path_length > MAX_HEIGHT )
- reiserfs_panic(p_s_sb, "PAP-5050: key_in_buffer: pointer to the key(%p) is NULL or illegal path length(%d)",
- p_s_key, p_s_chk_path->path_length);
-
- if ( PATH_PLAST_BUFFER(p_s_chk_path)->b_dev == NODEV )
- reiserfs_panic(p_s_sb, "PAP-5060: key_in_buffer: device must not be NODEV");
-#endif
+ RFALSE( ! p_s_key || p_s_chk_path->path_length < FIRST_PATH_ELEMENT_OFFSET ||
+ p_s_chk_path->path_length > MAX_HEIGHT,
+ "PAP-5050: pointer to the key(%p) is NULL or illegal path length(%d)",
+ p_s_key, p_s_chk_path->path_length);
+ RFALSE( PATH_PLAST_BUFFER(p_s_chk_path)->b_dev == NODEV,
+ "PAP-5060: device must not be NODEV");
if ( COMP_KEYS(get_lkey(p_s_chk_path, p_s_sb), p_s_key) == 1 )
/* left delimiting key is bigger, that the key we look for */
@@ -441,11 +425,9 @@ void decrement_counters_in_path (
) {
int n_path_offset = p_s_search_path->path_length;
while ( n_path_offset > ILLEGAL_PATH_ELEMENT_OFFSET )
brelse(PATH_OFFSET_PBUFFER(p_s_search_path, n_path_offset--));
@@ -742,15 +716,13 @@ int search_by_key (struct super_block *
continue;
}
+ RFALSE( ! key_in_buffer(p_s_search_path, p_s_key, p_s_sb),
+ "PAP-5130: key is not in the buffer");
#ifdef CONFIG_REISERFS_CHECK
-
- if ( ! key_in_buffer(p_s_search_path, p_s_key, p_s_sb) )
- reiserfs_panic(p_s_sb, "PAP-5130: search_by_key: key is not in the buffer");
if ( cur_tb ) {
print_cur_tb ("5140");
reiserfs_panic(p_s_sb, "PAP-5140: search_by_key: schedule occurred in do_balance!");
}
-
#endif
// make sure, that the node contents look like a node of
@@ -765,13 +737,9 @@ int search_by_key (struct super_block *
/* ok, we have acquired next formatted node in the tree */
n_node_level = B_LEVEL (p_s_bh);
-#ifdef CONFIG_REISERFS_CHECK
-
- if (n_node_level < n_stop_level)
- reiserfs_panic (p_s_sb, "vs-5152: search_by_key: tree level is less than stop level (%d)",
- n_node_level, n_stop_level);
-
-#endif
+ RFALSE( n_node_level < n_stop_level,
+ "vs-5152: tree level is less than stop level (%d)",
+ n_node_level, n_stop_level);
-#ifdef CONFIG_REISERFS_CHECK
- if ( ! PATH_LAST_POSITION(p_s_search_path) )
- reiserfs_panic(p_s_sb, "PAP-5170: search_for_position_by_key: position equals zero");
-#endif
+ RFALSE( ! PATH_LAST_POSITION(p_s_search_path),
+ "PAP-5170: position equals zero");
/* Item is not found. Set path to the previous item. */
p_le_ih = B_N_PITEM_HEAD(PATH_PLAST_BUFFER(p_s_search_path), --PATH_LAST_POSITION(p_s_search_path));
@@ -863,22 +828,6 @@ int search_for_position_by_key (struct s
return FILE_NOT_FOUND;
}
-#if 0
-/*#ifdef CONFIG_REISERFS_CHECK*/
-
- /* we expect to find stat data or item of the same type */
- if ( ! is_statdata_le_ih(p_le_ih) && ((is_indirect_cpu_key(p_cpu_key) && ! is_indirect_le_ih(p_le_ih)) ||
- (is_direct_cpu_key(p_cpu_key) && ! is_direct_le_ih(p_le_ih))) ) {
- print_block (PATH_PLAST_BUFFER(p_s_search_path), PRINT_LEAF_ITEMS,
- PATH_LAST_POSITION (p_s_search_path) - 2,
- PATH_LAST_POSITION (p_s_search_path) + 2);
- reiserfs_panic(p_s_sb, "PAP-5190: search_for_position_by_key: "
- "found item %h type does not match to the expected one %k",
- p_le_ih, p_cpu_key);
- }
-/*#endif*/
-#endif
-
// FIXME: quite ugly this far
/* Calculate balance mode and position in the item to remove unformatted nodes. */
if ( n_new_file_length == max_reiserfs_offset (inode) ) {/* Case of delete. */
@@ -1122,10 +1064,8 @@ static char prepare_for_delete_or_cut(
/* indirect item must be truncated starting from *p_n_pos_in_item-th position */
pos_in_item (p_s_path) = (n_new_file_length + n_blk_size - le_ih_k_offset (&s_ih) ) >> p_s_sb->s_blocksize_bits;
-#ifdef CONFIG_REISERFS_CHECK
- if ( pos_in_item (p_s_path) > n_unfm_number )
- reiserfs_panic(p_s_sb, "PAP-5250: prepare_for_delete_or_cut: illegal position in the item");
-#endif
+ RFALSE( pos_in_item (p_s_path) > n_unfm_number,
+ "PAP-5250: illegal position in the item");
/* Either convert last unformatted node of indirect item to direct item or increase
its free space. */
@@ -1140,10 +1080,8 @@ static char prepare_for_delete_or_cut(
}
}
-#ifdef CONFIG_REISERFS_CHECK
- if ( n_unfm_number <= pos_in_item (p_s_path) )
- reiserfs_panic(p_s_sb, "PAP-5260: prepare_for_delete_or_cut: illegal position in the indirect item");
-#endif
+ RFALSE( n_unfm_number <= pos_in_item (p_s_path),
+ "PAP-5260: illegal position in the indirect item");
if ( ! *p_n_unfm_pointer ) { /* Hole, nothing to remove. */
if ( ! n_retry )
@@ -1213,13 +1149,12 @@ static char prepare_for_delete_or_cut(
if ( ! n_retry )
(*p_n_removed)++;
-#ifdef CONFIG_REISERFS_CHECK
- if ( p_s_un_bh && (*p_n_unfm_pointer != p_s_un_bh->b_blocknr ))
+ RFALSE( p_s_un_bh &&
+ (*p_n_unfm_pointer != p_s_un_bh->b_blocknr ),
// note: minix_truncate allows that. As truncate is
// protected by down (inode->i_sem), two truncates can not
// co-exist
- reiserfs_panic(p_s_sb, "PAP-5280: prepare_for_delete_or_cut: blocks numbers are different");
-#endif
+ "PAP-5280: blocks numbers are different");
tmp = *p_n_unfm_pointer;
*p_n_unfm_pointer = 0;
@@ -1266,9 +1201,8 @@ static char prepare_for_delete_or_cut(
if ( n_retry ) {
/* There is block in use. Wait, they should release it soon */
/* Calculate number of bytes that need to be cut from the item. */
if (retval2 == -1)
@@ -1883,13 +1798,9 @@ void reiserfs_do_truncate (struct reiser
return;
}