patch-2.4.11-dontuse linux/fs/reiserfs/stree.c
Next file: linux/fs/reiserfs/tail_conversion.c
Previous file: linux/fs/reiserfs/objectid.c
Back to the patch index
Back to the overall index
- Lines: 453
- Date:
Mon Oct 8 11:52:58 2001
- Orig file:
v2.4.10/linux/fs/reiserfs/stree.c
- Orig date:
Sun Sep 23 11:41:00 2001
diff -u --recursive --new-file v2.4.10/linux/fs/reiserfs/stree.c linux/fs/reiserfs/stree.c
@@ -65,13 +65,8 @@
inline int B_IS_IN_TREE (struct buffer_head * p_s_bh)
{
-#ifdef CONFIG_REISERFS_CHECK
-
- if ( B_LEVEL (p_s_bh) > MAX_HEIGHT ) {
- reiserfs_panic(0, "PAP-1010: B_IS_IN_TREE: block (%b) has too big level (%z)",
- p_s_bh, p_s_bh);
- }
-#endif
+ RFALSE( B_LEVEL (p_s_bh) > MAX_HEIGHT,
+ "PAP-1010: block (%b) has too big level (%z)", p_s_bh, p_s_bh);
return ( B_LEVEL (p_s_bh) != FREE_LEVEL );
}
@@ -312,18 +307,14 @@
int n_position, 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-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 @@
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 @@
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 @@
) {
int n_path_offset = p_s_search_path->path_length;
-#ifdef CONFIG_REISERFS_CHECK
- if ( n_path_offset < ILLEGAL_PATH_ELEMENT_OFFSET ||
- n_path_offset > EXTENDED_MAX_HEIGHT - 1 )
- reiserfs_panic(NULL, "PAP-5080: decrement_counters_in_path: illegal path offset of %d", n_path_offset);
-#endif
+ RFALSE( n_path_offset < ILLEGAL_PATH_ELEMENT_OFFSET ||
+ n_path_offset > EXTENDED_MAX_HEIGHT - 1,
+ "PAP-5080: illegal path offset of %d", n_path_offset);
while ( n_path_offset > ILLEGAL_PATH_ELEMENT_OFFSET ) {
struct buffer_head * bh;
@@ -458,12 +440,8 @@
int reiserfs_check_path(struct path *p) {
-#ifdef CONFIG_REISERFS_CHECK
- if (p->path_length != ILLEGAL_PATH_ELEMENT_OFFSET) {
- reiserfs_warning("check_path, path not properly relsed\n") ;
- BUG() ;
- }
-#endif
+ RFALSE( p->path_length != ILLEGAL_PATH_ELEMENT_OFFSET,
+ "path not properly relsed") ;
return 0 ;
}
@@ -479,10 +457,8 @@
) {
int n_path_offset = p_s_search_path->path_length;
-#ifdef CONFIG_REISERFS_CHECK
- if ( n_path_offset < ILLEGAL_PATH_ELEMENT_OFFSET )
- reiserfs_panic(NULL, "clm-4000: pathrelse: illegal path offset");
-#endif
+ RFALSE( n_path_offset < ILLEGAL_PATH_ELEMENT_OFFSET,
+ "clm-4000: illegal path offset");
while ( n_path_offset > ILLEGAL_PATH_ELEMENT_OFFSET ) {
reiserfs_restore_prepared_buffer(s, PATH_OFFSET_PBUFFER(p_s_search_path,
@@ -498,10 +474,8 @@
) {
int n_path_offset = p_s_search_path->path_length;
-#ifdef CONFIG_REISERFS_CHECK
- if ( n_path_offset < ILLEGAL_PATH_ELEMENT_OFFSET )
- reiserfs_panic(NULL, "PAP-5090: pathrelse: illegal path offset");
-#endif
+ RFALSE( n_path_offset < ILLEGAL_PATH_ELEMENT_OFFSET,
+ "PAP-5090: illegal path offset");
while ( n_path_offset > ILLEGAL_PATH_ELEMENT_OFFSET )
brelse(PATH_OFFSET_PBUFFER(p_s_search_path, n_path_offset--));
@@ -742,15 +716,13 @@
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 @@
/* 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);
n_retval = bin_search (p_s_key, B_N_PITEM_HEAD(p_s_bh, 0), B_NR_ITEMS(p_s_bh),
( n_node_level == DISK_LEAF_NODE_LEVEL ) ? IH_SIZE : KEY_SIZE, &(p_s_last_element->pe_position));
@@ -840,20 +808,17 @@
return retval;
if ( retval == ITEM_FOUND ) {
-#ifdef CONFIG_REISERFS_CHECK
- if ( ! B_N_PITEM_HEAD(PATH_PLAST_BUFFER(p_s_search_path),
- PATH_LAST_POSITION(p_s_search_path))->ih_item_len )
- reiserfs_panic(p_s_sb, "PAP-5165: search_for_position_by_key: item length equals zero");
-#endif
+ RFALSE( ! B_N_PITEM_HEAD
+ (PATH_PLAST_BUFFER(p_s_search_path),
+ PATH_LAST_POSITION(p_s_search_path))->ih_item_len,
+ "PAP-5165: item length equals zero");
pos_in_item(p_s_search_path) = 0;
return POSITION_FOUND;
}
-#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 @@
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
item_offset = le_ih_k_offset (p_le_ih);
@@ -1006,11 +955,8 @@
{
if (le_ih_k_offset (le_ih) == DOT_OFFSET &&
new_file_length == max_reiserfs_offset (inode)) {
-#ifdef CONFIG_REISERFS_CHECK
- if (ih_entry_count (le_ih) != 2)
- reiserfs_panic(inode->i_sb,"PAP-5220: prepare_for_delete_or_cut: "
- "incorrect empty directory item (%h)", le_ih);
-#endif
+ RFALSE( ih_entry_count (le_ih) != 2,
+ "PAP-5220: incorrect empty directory item (%h)", le_ih);
*cut_size = -(IH_SIZE + le16_to_cpu (le_ih->ih_item_len));
return M_DELETE; /* Delete the directory item containing "." and ".." entry. */
}
@@ -1054,10 +1000,8 @@
/* Stat_data item. */
if ( is_statdata_le_ih (p_le_ih) ) {
-#ifdef CONFIG_REISERFS_CHECK
- if ( n_new_file_length != max_reiserfs_offset (inode) )
- reiserfs_panic(p_s_sb, "PAP-5210: prepare_for_delete_or_cut: mode must be M_DELETE");
-#endif
+ RFALSE( n_new_file_length != max_reiserfs_offset (inode),
+ "PAP-5210: mode must be M_DELETE");
*p_n_cut_size = -(IH_SIZE + le16_to_cpu (p_le_ih->ih_item_len));
return M_DELETE;
@@ -1098,13 +1042,11 @@
/* Calculate number of unformatted nodes in this item. */
n_unfm_number = I_UNFM_NUM(&s_ih);
-#ifdef CONFIG_REISERFS_CHECK
- if ( ! is_indirect_le_ih(&s_ih) || ! n_unfm_number ||
- pos_in_item (p_s_path) + 1 != n_unfm_number ) {
- printk("n_unfm_number = %d *p_n_pos_in_item = %d\n",n_unfm_number, pos_in_item (p_s_path));
- reiserfs_panic(p_s_sb, "PAP-5240: prepare_for_delete_or_cut: illegal item %h", &s_ih);
- }
-#endif
+ RFALSE( ! is_indirect_le_ih(&s_ih) || ! n_unfm_number ||
+ pos_in_item (p_s_path) + 1 != n_unfm_number,
+ "PAP-5240: illegal item %h "
+ "n_unfm_number = %d *p_n_pos_in_item = %d",
+ &s_ih, n_unfm_number, pos_in_item (p_s_path));
/* 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 @@
/* 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 @@
}
}
-#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");
/* pointers to be cut */
n_unfm_number -= pos_in_item (p_s_path);
@@ -1169,11 +1107,9 @@
need_research = 1 ;
break;
}
-#ifdef CONFIG_REISERFS_CHECK
- if (p_n_unfm_pointer < (__u32 *)B_I_PITEM(p_s_bh, &s_ih) ||
- p_n_unfm_pointer > (__u32 *)B_I_PITEM(p_s_bh, &s_ih) + I_UNFM_NUM(&s_ih) - 1)
- reiserfs_panic (p_s_sb, "vs-5265: prepare_for_delete_or_cut: pointer out of range");
-#endif
+ RFALSE( p_n_unfm_pointer < (__u32 *)B_I_PITEM(p_s_bh, &s_ih) ||
+ p_n_unfm_pointer > (__u32 *)B_I_PITEM(p_s_bh, &s_ih) + I_UNFM_NUM(&s_ih) - 1,
+ "vs-5265: pointer out of range");
if ( ! *p_n_unfm_pointer ) { /* Hole, nothing to remove. */
if ( ! n_retry )
@@ -1221,13 +1157,12 @@
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;
@@ -1251,9 +1186,8 @@
if ( n_retry ) {
/* There is block in use. Wait, they should release it soon */
+ RFALSE( *p_n_removed >= n_unfm_number, "PAP-5290: illegal case");
#ifdef CONFIG_REISERFS_CHECK
- if ( *p_n_removed >= n_unfm_number )
- reiserfs_panic(p_s_sb, "PAP-5290: prepare_for_delete_or_cut: illegal case");
if ( !(++n_repeat_counter % 500000) ) {
reiserfs_warning("PAP-5300: prepare_for_delete_or_cut: (pid %u): "
"could not delete item %k in (%d) iterations. New file length %Lu. (inode %Ld), Still trying\n",
@@ -1275,15 +1209,10 @@
} while ( (*p_n_removed < n_unfm_number || need_research) &&
search_for_position_by_key(p_s_sb, p_s_item_key, p_s_path) == POSITION_FOUND );
-#ifdef CONFIG_REISERFS_CHECK
- if ( *p_n_removed < n_unfm_number )
- reiserfs_panic(p_s_sb, "PAP-5310: prepare_for_delete_or_cut: indirect item is not found");
-
- if (item_moved (&s_ih, p_s_path) ) {
- printk("prepare_for_delete_or_cut: after while, comp failed, retry\n") ;
- BUG ();
- }
-#endif
+ RFALSE( *p_n_removed < n_unfm_number,
+ "PAP-5310: indirect item is not found");
+ RFALSE( item_moved (&s_ih, p_s_path),
+ "after while, comp failed, retry") ;
if (c_mode == M_CUT)
pos_in_item (p_s_path) *= UNFM_P_SIZE;
@@ -1375,10 +1304,7 @@
#endif
prepare_for_delete_or_cut(th, p_s_inode, p_s_path, p_s_item_key, &n_removed, &n_del_size, max_reiserfs_offset (p_s_inode));
-#ifdef CONFIG_REISERFS_CHECK
- if ( c_mode != M_DELETE )
- reiserfs_panic(p_s_sb, "PAP-5320: reiserfs_delete_item: mode must be M_DELETE");
-#endif
+ RFALSE( c_mode != M_DELETE, "PAP-5320: mode must be M_DELETE");
copy_item_head(&s_ih, PATH_PITEM_HEAD(p_s_path));
s_del_balance.insert_size[0] = n_del_size;
@@ -1597,19 +1523,14 @@
/* look for the last byte of the tail */
if (search_for_position_by_key (inode->i_sb, &tail_key, path) == POSITION_NOT_FOUND)
reiserfs_panic (inode->i_sb, "vs-5615: indirect_to_direct_roll_back: found invalid item");
-#ifdef CONFIG_REISERFS_CHECK
- if (path->pos_in_item != PATH_PITEM_HEAD (path)->ih_item_len - 1)
- reiserfs_panic (inode->i_sb, "vs-5616: indirect_to_direct_roll_back: appended bytes found");
-#endif
+ RFALSE( path->pos_in_item != PATH_PITEM_HEAD (path)->ih_item_len - 1,
+ "vs-5616: appended bytes found");
PATH_LAST_POSITION (path) --;
removed = reiserfs_delete_item (th, path, &tail_key, inode, 0/*unbh not needed*/);
-#ifdef CONFIG_REISERFS_CHECK
- if (removed <= 0 || removed > tail_len)
- reiserfs_panic (inode->i_sb, "vs-5617: indirect_to_direct_roll_back: "
- "there was tail %d bytes, removed item length %d bytes",
- tail_len, removed);
-#endif
+ RFALSE( removed <= 0 || removed > tail_len,
+ "vs-5617: there was tail %d bytes, removed item length %d bytes",
+ tail_len, removed);
tail_len -= removed;
set_cpu_key_k_offset (&tail_key, cpu_key_k_offset (&tail_key) - removed);
}
@@ -1657,10 +1578,7 @@
if ( c_mode == M_CONVERT ) {
/* convert last unformatted node to direct item or leave
tail in the unformatted node */
-#ifdef CONFIG_REISERFS_CHECK
- if ( n_ret_value != CARRY_ON )
- reiserfs_panic (p_s_sb, "PAP-5570: reiserfs_cut_from_item: can not convert twice");
-#endif
+ RFALSE( n_ret_value != CARRY_ON, "PAP-5570: can not convert twice");
n_ret_value = maybe_indirect_to_direct (th, p_s_inode, page, p_s_path, p_s_item_key,
n_new_file_size, &c_mode);
@@ -1724,10 +1642,7 @@
/* go ahead and perform balancing */
-#ifdef CONFIG_REISERFS_CHECK
- if ( c_mode == M_PASTE || c_mode == M_INSERT )
- reiserfs_panic (p_s_sb, "PAP-5640: reiserfs_cut_from_item: illegal mode");
-#endif
+ RFALSE( c_mode == M_PASTE || c_mode == M_INSERT, "illegal mode");
/* Calculate number of bytes that need to be cut from the item. */
if (retval2 == -1)
@@ -1880,13 +1795,9 @@
return;
}
-#ifdef CONFIG_REISERFS_CHECK
- if ( n_deleted > n_file_size ){
- reiserfs_panic (p_s_inode->i_sb, "PAP-5670: reiserfs_truncate_file: "
- "reiserfs_truncate_file returns too big number: deleted %d, file_size %lu, item_key %k",
- n_deleted, n_file_size, &s_item_key);
- }
-#endif
+ RFALSE( n_deleted > n_file_size,
+ "PAP-5670: reiserfs_truncate_file returns too big number: deleted %d, file_size %lu, item_key %k",
+ n_deleted, n_file_size, &s_item_key);
/* Change key to search the last file item. */
n_file_size -= n_deleted;
@@ -1918,12 +1829,9 @@
} while ( n_file_size > ROUND_UP (n_new_file_size) &&
search_for_position_by_key(p_s_inode->i_sb, &s_item_key, &s_search_path) == POSITION_FOUND ) ;
-#ifdef CONFIG_REISERFS_CHECK
- if ( n_file_size > ROUND_UP (n_new_file_size) )
- reiserfs_panic (p_s_inode->i_sb, "PAP-5680: reiserfs_truncate_file: "
- "truncate did not finish: new_file_size %Ld, current %Ld, oid %d\n",
- n_new_file_size, n_file_size, s_item_key.on_disk_key.k_objectid);
-#endif
+ RFALSE( n_file_size > ROUND_UP (n_new_file_size),
+ "PAP-5680: truncate did not finish: new_file_size %Ld, current %Ld, oid %d\n",
+ n_new_file_size, n_file_size, s_item_key.on_disk_key.k_objectid);
if (update_timestamps) {
// this is truncate, not file closing
FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)