===== fs/reiserfs/stree.c 1.19 vs edited ===== --- 1.19/fs/reiserfs/stree.c Tue Jul 16 09:58:57 2002 +++ edited/fs/reiserfs/stree.c Wed Jul 17 12:02:17 2002 @@ -598,26 +598,32 @@ -#ifdef SEARCH_BY_KEY_READA +#define SEARCH_BY_KEY_READA 32 /* The function is NOT SCHEDULE-SAFE! */ -static void search_by_key_reada (struct super_block * s, int blocknr) +static void search_by_key_reada (struct super_block * s, + struct buffer_head **bh, + unsigned long *b, int num) { - struct buffer_head * bh; + int i,j; - if (blocknr == 0) - return; - - bh = getblk (s->s_dev, blocknr, s->s_blocksize); - - if (!buffer_uptodate (bh)) { - ll_rw_block (READA, 1, &bh); + for (i = 0 ; i < num ; i++) { + bh[i] = sb_getblk (s, b[i]); + if (buffer_uptodate(bh[i])) { + brelse(bh[i]); + break; + } + touch_buffer(bh[i]); + } + if (i) { + ll_rw_block(READA, i, bh); + } + for(j = 0 ; j < i ; j++) { + if (bh[j]) + brelse(bh[j]); } - bh->b_count --; } -#endif - /************************************************************************** * Algorithm SearchByKey * * look for item in the Disk S+Tree by its key * @@ -660,6 +666,9 @@ int n_node_level, n_retval; int right_neighbor_of_leaf_node; int fs_gen; + struct buffer_head *reada_bh[SEARCH_BY_KEY_READA]; + unsigned long reada_blocks[SEARCH_BY_KEY_READA]; + int reada_count = 0; #ifdef CONFIG_REISERFS_CHECK int n_repeat_counter = 0; @@ -694,11 +703,11 @@ fs_gen = get_generation (p_s_sb); expected_level --; -#ifdef SEARCH_BY_KEY_READA - /* schedule read of right neighbor */ - search_by_key_reada (p_s_sb, right_neighbor_of_leaf_node); -#endif - + /* schedule read of right neighbors */ + if (reada_count) { + search_by_key_reada (p_s_sb, reada_bh, reada_blocks, reada_count); + reada_count = 0; + } /* Read the next tree node, and set the last element in the path to have a pointer to it. */ if ( ! (p_s_bh = p_s_last_element->pe_buffer = @@ -786,11 +795,19 @@ position in the node. */ n_block_number = B_N_CHILD_NUM(p_s_bh, p_s_last_element->pe_position); -#ifdef SEARCH_BY_KEY_READA - /* if we are going to read leaf node, then calculate its right neighbor if possible */ - if (n_node_level == DISK_LEAF_NODE_LEVEL + 1 && p_s_last_element->pe_position < B_NR_ITEMS (p_s_bh)) - right_neighbor_of_leaf_node = B_N_CHILD_NUM(p_s_bh, p_s_last_element->pe_position + 1); -#endif + /* if we are going to read leaf node, then try to find good leaves + ** for read ahead as well. Don't bother for stat data though + */ + if (n_node_level == DISK_LEAF_NODE_LEVEL + 1 && + p_s_last_element->pe_position < B_NR_ITEMS (p_s_bh) && + !is_statdata_cpu_key(p_s_key)) + { + int pos = p_s_last_element->pe_position; + int limit = B_NR_ITEMS(p_s_bh); + while(pos <= limit && reada_count < SEARCH_BY_KEY_READA) { + reada_blocks[reada_count++] = B_N_CHILD_NUM(p_s_bh, pos++); + } + } } }