corruption bugs in 2.6 v3
PATCH 1/1 corruption bugs in 2.6 v3
Hello everyone,
These two patches fix corruption problems I've been hitting on 2.6. Both bugs are present in the vanilla and suse kernels.
reiserfs-search-restart:
This was originally from [email protected], I recently made a small addition to make sure the expected height was checked after reading in blocks in search_by_key (this depends on reiserfs-lock-lat from my data logging directory).
reiserfs-write-sched-bug:
Fixes two schedule related bugs during reiserfs_file_write. One place in the code assumes that after a schedule, path.pos_in_item will still be valid even if the item has moved. Since items can split during a schedule this is incorrect.
The second bug took a little longer to figure out, reiserfs_prepare_file_region_for_write needs to make sure a stale item pointer isn't used if search_for_position_by_key doesn't return POSITION_FOUND.
The most common symptoms of the two bugs is attempts to read beyond the end of the device, file data corruption and errors like this:
is_tree_node: node level X does not match to the expected one Y
Where X and Y are both valid tree heights (between 1 and 5) and usually one away from each other.
These reproduced reliably for me by running dbench 20 in a loop for about 20 minutes on an amd64 box.
Hans, I'd like to submit these along with the other fixes I ported from 2.4 and sent to reiserfs-dev. Any objections?
-chris
fix a bug in reiserfs search_by_key call, where it might not properly detect a change in tree height during a schedule. Originally from [email protected]
fs/reiserfs/stree.c +10 -6
@@ -678,7 +678,7 @@current node, and calculate the next current node(next path element) for the next iteration of this loop.. */ n_block_number =SB_ROOT_BLOCK (p_s_sb); - expected_level =SB_TREE_HEIGHT (p_s_sb); + expected_level =-1 ;while (1 ) {#ifdef CONFIG_REISERFS_CHECK
@@ -692,7 +692,6 @@/* prep path to have another element added to it. */ p_s_last_element =PATH_OFFSET_PELEMENT (p_s_search_path, ++p_s_search_path->path_length); fs_gen =get_generation (p_s_sb); - expected_level --;#ifdef SEARCH_BY_KEY_READA /* schedule read of right neighbor */
@@ -707,21 +706,26 @@pathrelse (p_s_search_path);return IO_ERROR ; } +if (expected_level ==-1 ) + expected_level =SB_TREE_HEIGHT (p_s_sb); + expected_level --;/* It is possible that schedule occurred. We must check whether the key to search is still in the tree rooted from the current buffer. If not then repeat search from the root. */ if (fs_changed (fs_gen, p_s_sb) && - (!B_IS_IN_TREE (p_s_bh) || !key_in_buffer (p_s_search_path, p_s_key, p_s_sb)) ) { + (!B_IS_IN_TREE (p_s_bh) || +B_LEVEL (p_s_bh) != expected_level || + !key_in_buffer (p_s_search_path, p_s_key, p_s_sb))) {PROC_INFO_INC ( p_s_sb, search_by_key_fs_changed ); -PROC_INFO_INC ( p_s_sb, search_by_key_restarted ); +PROC_INFO_INC ( p_s_sb, search_by_key_restarted );PROC_INFO_INC ( p_s_sb, sbk_restarted[ expected_level -1 ] );decrement_counters_in_path (p_s_search_path);/* Get the root block number so that we can repeat the search -starting from the root. */ +starting from the root. */ n_block_number =SB_ROOT_BLOCK (p_s_sb); - expected_level =SB_TREE_HEIGHT (p_s_sb); + expected_level =-1 ; right_neighbor_of_leaf_node =0 ;/* repeat search from the root */
fs/reiserfs/file.c +8 -4
@@ -365,7 +365,7 @@// it means there are no existing in-tree representation for file area // we are going to overwrite, so there is nothing to scan through for holes. for ( curr_block =0 , itempos = path.pos_in_item ; curr_block < blocks_to_allocate && res ==POSITION_FOUND ; ) { - +retry:if ( itempos >=ih_item_len (ih)/UNFM_P_SIZE ) {/* We run out of data in this indirect item, let's look for another one. */
@@ -422,8 +422,8 @@ bh=get_last_bh (&path); ih=get_ih (&path); item =get_item (&path); -// Itempos is still the same -continue ; + itempos = path.pos_in_item; + goto retry; } modifying_this_item =1 ; }
@@ -856,8 +856,12 @@/* Try to find next item */ res =search_for_position_by_key (inode->i_sb, &key, &path);/* Abort if no more items */ -if ( res !=POSITION_FOUND ) +if ( res !=POSITION_FOUND ) { +/* make sure later loops don't use this item */ + itembuf =NULL ; + item =NULL ;break ; + }/* Update information about current indirect item */ itembuf =get_last_bh ( &path );
Am Mittwoch, 3. März 2004 21:34 schrieb Chris Mason:
Quoted 4 lines
Hello everyone,
These two patches fix corruption problems I've been hitting on 2.6. Both bugs are present in the vanilla and suse kernels.
Both do NOT fix the "lilo" problem.
But mkinitrd works.
Thanks,
Dieter
Quoted 9 lines · Dieter Nützel
Am Mittwoch, 3. März 2004 21:34 schrieb Chris Mason:
Quoted 4 lines
Hello everyone,
These two patches fix corruption problems I've been hitting on 2.6. Both bugs are present in the vanilla and suse kernels.
Both do NOT fix the "lilo" problem.
But mkinitrd works.
No, neither patch fixes the lilo problem with the data=ordered patches. These two bugs were much more important to work on. lilo fix on its way.
-chris