B-fsck.patch
Removes code pertaining to reiserfsck conditioned by
defined( REISERFS_FSCK ).
Doesn't change functionality in any way.
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 Tue Jul 10 20:26:53 2001
+++ linux-2.4.6.cleanup/fs/reiserfs/do_balan.c Tue Jul 10 20:34:34 2001
@@ -653,11 +653,7 @@ static int balance_leaf (struct tree_bal
{
struct item_head * pasted;
-#ifdef REISERFS_FSCK
- if ( ! item_pos && is_left_mergeable (tb->tb_sb, tb->tb_path) == 1 )
-#else
if ( ! item_pos && op_is_left_mergeable (B_N_PKEY (tbS0, 0), tbS0->b_size) )
-#endif
{ /* if we paste into first item of S[0] and it is left mergable */
/* then increment pos_in_item by the size of the last item in L[0] */
pasted = B_N_PITEM_HEAD(tb->L[0],n-1);
@@ -1597,10 +1593,6 @@ struct buffer_head * get_FEB (struct tre
tb->FEB[i] = 0;
tb->used[i] = first_b;
/* Replace n_dest'th key in buffer dest by n_src'th key of buffer src.*/
@@ -1987,26 +1965,6 @@ void do_balance (struct tree_balance * t
atomic_inc (&(fs_generation (tb->tb_sb)));
do_balance_starts (tb);
-#ifdef REISERFS_FSCK
- if (flag == M_INTERNAL) {
- insert_ptr[0] = (struct buffer_head *)body;
- /* we must prepare insert_key */
-
- if (PATH_H_B_ITEM_ORDER (tb->tb_path, 0)/*LAST_POSITION (tb->tb_path)*//*item_pos*/ == -1) {
- /* get delimiting key from buffer in tree */
- copy_key (&insert_key[0].ih_key, B_N_PKEY (PATH_PLAST_BUFFER (tb->tb_path), 0));
- /*insert_ptr[0]->b_item_order = 0;*/
- } else {
- /* get delimiting key from new buffer */
- copy_key (&insert_key[0].ih_key, B_N_PKEY((struct buffer_head *)body,0));
- /*insert_ptr[0]->b_item_order = item_pos;*/
- }
-
- /* and insert_ptr instead of balance_leaf */
- child_pos = PATH_H_B_ITEM_ORDER (tb->tb_path, 0)/*item_pos*/;
- } else
-#endif
-
/* balance leaf returns 0 except if combining L R and S into
one node. see balance_internal() for explanation of this
line of code.*/
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 Tue Jul 10 20:26:53 2001
+++ linux-2.4.6.cleanup/fs/reiserfs/fix_node.c Tue Jul 10 20:34:34 2001
@@ -113,11 +113,7 @@ static void create_virtual_node (struct
ih = B_N_PITEM_HEAD (Sh, 0);
/* define the mergeability for 0-th item (if it is not being deleted) */
-#ifdef REISERFS_FSCK
- if (is_left_mergeable (tb->tb_sb, tb->tb_path) == 1 && (vn->vn_mode != M_DELETE || vn->vn_affected_item_num))
-#else
if (op_is_left_mergeable (&(ih->ih_key), Sh->b_size) && (vn->vn_mode != M_DELETE || vn->vn_affected_item_num))
-#endif
vn->vn_vi[0].vi_type |= VI_TYPE_LEFT_MERGEABLE;
/* go through all items those remain in the virtual node (except for the new (inserted) one) */
@@ -198,13 +194,8 @@ static void create_virtual_node (struct
struct key * key;
#ifdef CONFIG_REISERFS_CHECK
@@ -708,8 +699,6 @@ static int are_leaves_removable (struct
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])))
if (is_direntry_le_ih (ih)) {
-#ifndef REISERFS_FSCK
-
/* Directory must be in correct state here: that is
somewhere at the left side should exist first directory
item. But the item being deleted can not be that first
@@ -726,30 +715,6 @@ static int are_leaves_removable (struct
reiserfs_panic (tb->tb_sb, "vs-8130: are_leaves_removable: "
"first directory item can not be removed until directory is not empty");
#endif
-
-
-#else /* REISERFS_FSCK */
-
- /* we can delete any directory item in fsck (if it is unreachable) */
- if (ih->ih_key.k_offset != DOT_OFFSET) {
- /* must get left neighbor here to make sure, that left
- neighbor is of the same directory */
- struct buffer_head * left;
-
- left = get_left_neighbor (tb->tb_sb, tb->tb_path);
- if (left) {
- struct item_head * last;
-
- if (B_NR_ITEMS (left) == 0)
- reiserfs_panic (tb->tb_sb, "vs-8135: are_leaves_removable: "
- "empty node in the tree");
- last = B_N_PITEM_HEAD (left, B_NR_ITEMS (left) - 1);
- if (!comp_short_keys (&last->ih_key, &ih->ih_key))
- ih_size = IH_SIZE;
- brelse (left);
- }
- }
-#endif
}
-#ifdef REISERFS_FSCK
- if (n_h == 0 && p_s_tb->insert_size[n_h] == 0x7fff)
- return CARRY_ON;
-#endif
-
/* number_of_freeblk is the number of empty blocks which have been
acquired for use by the balancing algorithm minus the number of
empty blocks used in the previous levels of the analysis,
@@ -1302,13 +1262,8 @@ static inline int can_node_be_removed (i
if (
lfree + rfree + sfree < MAX_CHILD_SIZE(Sh) + levbytes
/* shifting may merge items which might save space */
-#ifdef REISERFS_FSCK
- - (( ! h && is_left_mergeable (tb->tb_sb, tb->tb_path) == 1 ) ? IH_SIZE : 0)
- - (( ! h && r_ih && is_right_mergeable (tb->tb_sb, tb->tb_path) == 1 ) ? IH_SIZE : 0)
-#else
- (( ! h && op_is_left_mergeable (&(ih->ih_key), Sh->b_size) ) ? IH_SIZE : 0)
- (( ! h && r_key && op_is_left_mergeable (r_key, Sh->b_size) ) ? IH_SIZE : 0)
-#endif
+ (( h ) ? KEY_SIZE : 0))
{
/* node can not be removed */
@@ -1378,15 +1333,6 @@ static int ip_check_balance (struct tree
/* Sh is the node whose balance is currently being checked */
struct buffer_head * Sh;
-#ifdef REISERFS_FSCK
- /* special mode for insert pointer to the most low internal node */
- if (h == 0 && vn->vn_mode == M_INTERNAL) {
- /* blk_num == 2 is to get pointer inserted to the next level */
- set_parameters (tb, h, 0, 0, 2, NULL, -1, -1);
- return 0;
- }
-#endif
-
Sh = PATH_H_PBUFFER (tb->tb_path, h);
levbytes = tb->insert_size[h];
@@ -2527,19 +2473,10 @@ int fix_nodes (int n_op_mode,
/* Check parameters. */
switch (n_op_mode) {
-#ifdef REISERFS_FSCK
- case M_INTERNAL:
- break;
- case M_INSERT:
- if ( n_item_num < 0 || n_item_num > B_NR_ITEMS(p_s_tbS0) )
- reiserfs_panic(p_s_tb->tb_sb,"PAP-8325: fix_nodes: Incorrect item number %d (in S0 - %d) in case of insert",
- n_item_num, B_NR_ITEMS(p_s_tbS0));
-#else
case M_INSERT:
if ( n_item_num <= 0 || n_item_num > B_NR_ITEMS(p_s_tbS0) )
reiserfs_panic(p_s_tb->tb_sb,"PAP-8330: fix_nodes: Incorrect item number %d (in S0 - %d) in case of insert",
n_item_num, B_NR_ITEMS(p_s_tbS0));
-#endif
break;
case M_PASTE:
case M_DELETE:
@@ -2735,151 +2672,10 @@ void unfix_nodes (struct tree_balance *
brelse (tb->used[i]);
}
}
-
-#if 0 /* shouldn't this be in CONFIG_REISERFS_CHECK??? */
- /* make sure, that all we have released got really freed */
- for (i = 0; i < sizeof (tb->thrown) / sizeof (tb->thrown[0]); i ++)
- if (tb->thrown[i]) {
- if (atomic_read (&(tb->thrown[i]->b_count))) {
- /* the log will have the count at one and the buffers marked */
- if (atomic_read(&(tb->thrown[i]->b_count)) > 1 ||
- !(buffer_journaled(tb->thrown[i]) ||
- buffer_journal_dirty(tb->thrown[i]))) {
- foo_print (tb->thrown[i], tb->tb_sb);
- printk ("unfix_nodes: Waiting...(block %lu, count %d)\n",
- tb->thrown[i]->b_blocknr,
- atomic_read (&(tb->thrown[i]->b_count)));
- wait_buffer_until_released (tb->thrown[i]);
- printk ("unfix_nodes: Done (block %lu, count %d)\n",
- tb->thrown[i]->b_blocknr,
- atomic_read (&(tb->thrown[i]->b_count)));
- }
- }
- }
-#endif /* 0 */
if (tb->vn_buf)
reiserfs_kfree (tb->vn_buf, tb->vn_buf_size, tb->tb_sb);
n = B_NR_ITEMS (tbSh); /*number of items in S[h] */
-#ifdef REISERFS_FSCK
- if ( -1 <= child_pos && child_pos <= n && insert_num > 0 ) {
-#else
if ( 0 <= child_pos && child_pos <= n && insert_num > 0 ) {
-#endif
bi.tb = tb;
bi.bi_bh = tbSh;
bi.bi_parent = PATH_H_PPARENT (tb->tb_path, h);
bi.bi_position = PATH_H_POSITION (tb->tb_path, h + 1);
-#ifdef REISERFS_FSCK
- if (child_pos == -1) {
- /* this is a little different from original do_balance:
- here we insert the minimal keys in the tree, that has never happened when file system works */
- if (tb->CFL[h-1] || insert_num != 1 || h != 1)
- die ("balance_internal: invalid child_pos");
-/* insert_child (tb->S[h], tb->S[h-1], child_pos, insert_num, B_N_ITEM_HEAD(tb->S[0],0), insert_ptr);*/
- internal_insert_childs (&bi, child_pos, insert_num, B_N_PITEM_HEAD (PATH_PLAST_BUFFER (tb->tb_path), 0), insert_ptr);
- } else
-#endif
internal_insert_childs (
&bi,/*tbSh,*/
/* ( tb->S[h-1]->b_parent == tb->S[h] ) ? tb->S[h-1]->b_next : tb->S[h]->b_child->b_next,*/
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 Tue Jul 10 20:26:53 2001
+++ linux-2.4.6.cleanup/fs/reiserfs/lbalance.c Tue Jul 10 20:34:34 2001
@@ -58,13 +58,8 @@ static void leaf_copy_dir_entries (struc
/* if there are no items in dest or the first/last item in dest is not item of the same directory */
if ( (item_num_in_dest == - 1) ||
-#ifdef REISERFS_FSCK
- (last_first == FIRST_TO_LAST && are_items_mergeable (B_N_PITEM_HEAD (dest, item_num_in_dest), ih, dest->b_size) == 0) ||
- (last_first == LAST_TO_FIRST && are_items_mergeable (ih, B_N_PITEM_HEAD (dest, item_num_in_dest), dest->b_size) == 0)) {
-#else
(last_first == FIRST_TO_LAST && le_key_k_offset (ih_version (ih), &(ih->ih_key)) == DOT_OFFSET) ||
(last_first == LAST_TO_FIRST && comp_short_le_keys/*COMP_SHORT_KEYS*/ (&ih->ih_key, B_N_PKEY (dest, item_num_in_dest)))) {
-#endif
/* create new item in dest */
struct item_head new_ih;
@@ -127,11 +122,7 @@ static int leaf_copy_boundary_item (stru
that we copy, so we return */
ih = B_N_PITEM_HEAD (src, 0);
dih = B_N_PITEM_HEAD (dest, dest_nr_item - 1);
-#ifdef REISERFS_FSCK
- if (!dest_nr_item || (are_items_mergeable (dih, ih, src->b_size) == 0))
-#else
if (!dest_nr_item || (!op_is_left_mergeable (&(ih->ih_key), src->b_size)))
-#endif
/* there is nothing to merge */
return 0;
@@ -194,11 +185,7 @@ static int leaf_copy_boundary_item (stru
ih = B_N_PITEM_HEAD (src, src_nr_item - 1);
dih = B_N_PITEM_HEAD (dest, 0);