patch-2.4.11-dontuse linux/fs/reiserfs/ibalance.c
Next file: linux/fs/reiserfs/inode.c
Previous file: linux/fs/reiserfs/fix_node.c
Back to the patch index
Back to the overall index
- Lines: 392
- Date:
Mon Oct 8 11:52:58 2001
- Orig file:
v2.4.10/linux/fs/reiserfs/ibalance.c
- Orig date:
Sun Sep 23 11:41:00 2001
diff -u --recursive --new-file v2.4.10/linux/fs/reiserfs/ibalance.c linux/fs/reiserfs/ibalance.c
@@ -36,10 +36,8 @@
struct buffer_head ** cf
)
{
-#ifdef CONFIG_REISERFS_CHECK
memset (dest_bi, 0, sizeof (struct buffer_info));
memset (src_bi, 0, sizeof (struct buffer_info));
-#endif
/* define dest, src, dest parent, dest position */
switch (shift_mode) {
case INTERNAL_SHIFT_FROM_S_TO_L: /* used in internal_shift_left */
@@ -144,13 +142,11 @@
nr = le16_to_cpu ((blkh = B_BLK_HEAD(cur))->blk_nr_item);
-#ifdef CONFIG_REISERFS_CHECK
- if (count > 2)
- reiserfs_panic (0, "internal_insert_childs", "too many children (%d) are to be inserted", count);
- if (B_FREE_SPACE (cur) < count * (KEY_SIZE + DC_SIZE))
- reiserfs_panic (0, "internal_insert_childs", "no enough free space (%d), needed %d bytes",
- B_FREE_SPACE (cur), count * (KEY_SIZE + DC_SIZE));
-#endif /* CONFIG_REISERFS_CHECK */
+ RFALSE( count > 2,
+ "too many children (%d) are to be inserted", count);
+ RFALSE( B_FREE_SPACE (cur) < count * (KEY_SIZE + DC_SIZE),
+ "no enough free space (%d), needed %d bytes",
+ B_FREE_SPACE (cur), count * (KEY_SIZE + DC_SIZE));
/* prepare space for count disk_child */
dc = B_N_CHILD(cur,to+1);
@@ -213,43 +209,29 @@
struct key * key;
struct disk_child * dc;
-#ifdef CONFIG_REISERFS_CHECK
- if (cur == NULL)
- reiserfs_panic (0, "internal_delete_pointers_items1: buffer is 0");
-
- if (del_num < 0)
- reiserfs_panic (0, "internal_delete_pointers_items2",
- "negative number of items (%d) can not be deleted", del_num);
-
- if (first_p < 0 || first_p + del_num > B_NR_ITEMS (cur) + 1 || first_i < 0)
- reiserfs_panic (0, "internal_delete_pointers_items3",
- "first pointer order (%d) < 0 or "
- "no so many pointers (%d), only (%d) or "
- "first key order %d < 0", first_p,
- first_p + del_num, B_NR_ITEMS (cur) + 1, first_i);
-#endif /* CONFIG_REISERFS_CHECK */
+ RFALSE( cur == NULL, "buffer is 0");
+ RFALSE( del_num < 0,
+ "negative number of items (%d) can not be deleted", del_num);
+ RFALSE( first_p < 0 || first_p + del_num > B_NR_ITEMS (cur) + 1 || first_i < 0,
+ "first pointer order (%d) < 0 or "
+ "no so many pointers (%d), only (%d) or "
+ "first key order %d < 0", first_p,
+ first_p + del_num, B_NR_ITEMS (cur) + 1, first_i);
if ( del_num == 0 )
return;
nr = le16_to_cpu ((blkh = B_BLK_HEAD(cur))->blk_nr_item);
if ( first_p == 0 && del_num == nr + 1 ) {
-#ifdef CONFIG_REISERFS_CHECK
- if ( first_i != 0 )
- reiserfs_panic (0, "internal_delete_pointers_items5",
- "first deleted key must have order 0, not %d", first_i);
-#endif /* CONFIG_REISERFS_CHECK */
+ RFALSE( first_i != 0, "1st deleted key must have order 0, not %d", first_i);
make_empty_node (cur_bi);
return;
}
-#ifdef CONFIG_REISERFS_CHECK
- if (first_i + del_num > B_NR_ITEMS (cur)) {
- printk("first_i = %d del_num = %d\n",first_i,del_num);
- reiserfs_panic (0, "internal_delete_pointers_items4: :"
- "no so many keys (%d) in the node (%b)(%z)", first_i + del_num, cur, cur);
- }
-#endif /* CONFIG_REISERFS_CHECK */
+ RFALSE( first_i + del_num > B_NR_ITEMS (cur),
+ "first_i = %d del_num = %d "
+ "no so many keys (%d) in the node (%b)(%z)",
+ first_i, del_num, first_i + del_num, cur, cur);
/* deleting */
@@ -315,25 +297,16 @@
nr_src = B_NR_ITEMS (src);
-#ifdef CONFIG_REISERFS_CHECK
- if ( dest == NULL || src == NULL )
- reiserfs_panic (0, "internal_copy_pointers_items", "src (%p) or dest (%p) buffer is 0", src, dest);
-
- if (last_first != FIRST_TO_LAST && last_first != LAST_TO_FIRST)
- reiserfs_panic (0, "internal_copy_pointers_items",
- "invalid last_first parameter (%d)", last_first);
-
- if ( nr_src < cpy_num - 1 )
- reiserfs_panic (0, "internal_copy_pointers_items", "no so many items (%d) in src (%d)", cpy_num, nr_src);
-
- if ( cpy_num < 0 )
- reiserfs_panic (0, "internal_copy_pointers_items", "cpy_num less than 0 (%d)", cpy_num);
-
- if (cpy_num - 1 + B_NR_ITEMS(dest) > (int)MAX_NR_KEY(dest))
- reiserfs_panic (0, "internal_copy_pointers_items",
- "cpy_num (%d) + item number in dest (%d) can not be more than MAX_NR_KEY(%d)",
- cpy_num, B_NR_ITEMS(dest), MAX_NR_KEY(dest));
-#endif
+ RFALSE( dest == NULL || src == NULL,
+ "src (%p) or dest (%p) buffer is 0", src, dest);
+ RFALSE( last_first != FIRST_TO_LAST && last_first != LAST_TO_FIRST,
+ "invalid last_first parameter (%d)", last_first);
+ RFALSE( nr_src < cpy_num - 1,
+ "no so many items (%d) in src (%d)", cpy_num, nr_src);
+ RFALSE( cpy_num < 0, "cpy_num less than 0 (%d)", cpy_num);
+ RFALSE( cpy_num - 1 + B_NR_ITEMS(dest) > (int)MAX_NR_KEY(dest),
+ "cpy_num (%d) + item number in dest (%d) can not be > MAX_NR_KEY(%d)",
+ cpy_num, B_NR_ITEMS(dest), MAX_NR_KEY(dest));
if ( cpy_num == 0 )
return;
@@ -427,23 +400,18 @@
struct block_head * blkh;
struct key * key;
-#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 @@
/* 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 @@
internal_delete_childs (&bi, child_pos, -insert_num);
-#ifdef CONFIG_REISERFS_CHECK
- if ( tb->blknum[h] > 1 )
- reiserfs_panic (tb->tb_sb, "balance_internal_when_delete", "tb->blknum[%d]=%d when insert_size < 0",
- h, tb->blknum[h]);
-#endif /* CONFIG_REISERFS_CHECK */
+ RFALSE( tb->blknum[h] > 1,
+ "tb->blknum[%d]=%d when insert_size < 0", h, tb->blknum[h]);
n = B_NR_ITEMS(tbSh);
@@ -633,14 +597,9 @@
/* node S[h] (root of the tree) is empty now */
struct buffer_head *new_root;
-#ifdef CONFIG_REISERFS_CHECK
- if (n || B_FREE_SPACE (tbSh) != MAX_CHILD_SIZE(tbSh) - DC_SIZE)
- reiserfs_panic (tb->tb_sb, "balance_internal_when_delete", "buffer must have only 0 keys (%d)",
- n);
-
- if (bi.bi_parent)
- reiserfs_panic (tb->tb_sb, "balance_internal_when_delete", "root has parent (%p)", bi.bi_parent);
-#endif /* CONFIG_REISERFS_CHECK */
+ RFALSE( n || B_FREE_SPACE (tbSh) != MAX_CHILD_SIZE(tbSh) - DC_SIZE,
+ "buffer must have only 0 keys (%d)", n);
+ RFALSE( bi.bi_parent, "root has parent (%p)", bi.bi_parent);
/* choose a new root */
if ( ! tb->L[h-1] || ! B_NR_ITEMS(tb->L[h-1]) )
@@ -669,11 +628,9 @@
if ( tb->L[h] && tb->lnum[h] == -B_NR_ITEMS(tb->L[h]) - 1 ) { /* join S[h] with 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 joining S[h] with L[h]",
- h, tb->rnum[h]);
-#endif /* CONFIG_REISERFS_CHECK */
+ RFALSE( tb->rnum[h] != 0,
+ "invalid tb->rnum[%d]==%d when joining S[h] with L[h]",
+ h, tb->rnum[h]);
internal_shift_left (INTERNAL_SHIFT_FROM_S_TO_L, tb, h, n + 1);
reiserfs_invalidate_buffer(tb, tbSh);
@@ -682,11 +639,9 @@
}
if ( tb->R[h] && tb->rnum[h] == -B_NR_ITEMS(tb->R[h]) - 1 ) { /* join S[h] with 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 joining S[h] with R[h]",
- h, tb->lnum[h]);
-#endif /* CONFIG_REISERFS_CHECK */
+ RFALSE( tb->lnum[h] != 0,
+ "invalid tb->lnum[%d]==%d when joining S[h] with R[h]",
+ h, tb->lnum[h]);
internal_shift_right (INTERNAL_SHIFT_FROM_S_TO_R, tb, h, n + 1);
@@ -695,33 +650,25 @@
}
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);
internal_shift_left (INTERNAL_SHIFT_FROM_S_TO_L, tb, h, tb->lnum[h]);/*tb->L[h], tb->CFL[h], tb->lkey[h], tb->S[h], tb->lnum[h]);*/
internal_shift_right (INTERNAL_SHIFT_FROM_S_TO_R, tb, h, tb->rnum[h]);
@@ -742,11 +689,9 @@
struct item_head * key
)
{
-#ifdef CONFIG_REISERFS_CHECK
- if (tb->L[h] == NULL || tb->CFL[h] == NULL)
- reiserfs_panic (tb->tb_sb, "replace_lkey: 12255: "
- "L[h](%p) and CFL[h](%p) must exist in replace_lkey", tb->L[h], tb->CFL[h]);
-#endif
+ RFALSE( tb->L[h] == NULL || tb->CFL[h] == NULL,
+ "L[h](%p) and CFL[h](%p) must exist in replace_lkey",
+ tb->L[h], tb->CFL[h]);
if (B_NR_ITEMS(PATH_H_PBUFFER(tb->tb_path, h)) == 0)
return;
@@ -764,15 +709,12 @@
struct item_head * key
)
{
-#ifdef CONFIG_REISERFS_CHECK
- if (tb->R[h] == NULL || tb->CFR[h] == NULL)
- reiserfs_panic (tb->tb_sb, "replace_rkey: 12260: "
- "R[h](%p) and CFR[h](%p) must exist in replace_rkey", tb->R[h], tb->CFR[h]);
-
- if (B_NR_ITEMS(tb->R[h]) == 0)
- reiserfs_panic (tb->tb_sb, "replace_rkey: 12265: "
- "R[h] can not be empty if it exists (item number=%d)", B_NR_ITEMS(tb->R[h]));
-#endif
+ RFALSE( tb->R[h] == NULL || tb->CFR[h] == NULL,
+ "R[h](%p) and CFR[h](%p) must exist in replace_rkey",
+ tb->R[h], tb->CFR[h]);
+ RFALSE( B_NR_ITEMS(tb->R[h]) == 0,
+ "R[h] can not be empty if it exists (item number=%d)",
+ B_NR_ITEMS(tb->R[h]));
memcpy (B_N_PDELIM_KEY(tb->CFR[h],tb->rkey[h]), key, KEY_SIZE);
@@ -810,10 +752,7 @@
struct buffer_head * new_insert_ptr = NULL;
struct item_head * new_insert_key_addr = insert_key;
-#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;
@@ -822,16 +761,12 @@
insert_num = tb->insert_size[h]/((int)(KEY_SIZE + DC_SIZE));
/* 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 @@
}
/** 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 @@
/* new_insert_ptr = node_pointer to S_new */
new_insert_ptr = S_new;
-#ifdef CONFIG_REISERFS_CHECK
- if ( buffer_locked(S_new) || atomic_read (&(S_new->b_count)) != 1)
- if (buffer_locked(S_new) || atomic_read(&(S_new->b_count)) > 2 ||
- !(buffer_journaled(S_new) || buffer_journal_dirty(S_new))) {
- reiserfs_panic (tb->tb_sb, "cm-00001: balance_internal: bad S_new (%b)", S_new);
- }
-#endif /* CONFIG_REISERFS_CHECK */
+ RFALSE(( buffer_locked(S_new) || atomic_read (&(S_new->b_count)) != 1) &&
+ (buffer_locked(S_new) || atomic_read(&(S_new->b_count)) > 2 ||
+ !(buffer_journaled(S_new) || buffer_journal_dirty(S_new))),
+ "cm-00001: bad S_new (%b)", S_new);
// S_new is released in unfix_nodes
}
FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)