@@ -623,44 +623,11 @@ static int exfat_find_location(struct super_block *sb, struct exfat_chain *p_dir
623623 return 0 ;
624624}
625625
626- #define EXFAT_MAX_RA_SIZE (128*1024)
627- static int exfat_dir_readahead (struct super_block * sb , sector_t sec )
628- {
629- struct exfat_sb_info * sbi = EXFAT_SB (sb );
630- struct buffer_head * bh ;
631- unsigned int max_ra_count = EXFAT_MAX_RA_SIZE >> sb -> s_blocksize_bits ;
632- unsigned int page_ra_count = PAGE_SIZE >> sb -> s_blocksize_bits ;
633- unsigned int adj_ra_count = max (sbi -> sect_per_clus , page_ra_count );
634- unsigned int ra_count = min (adj_ra_count , max_ra_count );
635-
636- /* Read-ahead is not required */
637- if (sbi -> sect_per_clus == 1 )
638- return 0 ;
639-
640- if (sec < sbi -> data_start_sector ) {
641- exfat_err (sb , "requested sector is invalid(sect:%llu, root:%llu)" ,
642- (unsigned long long )sec , sbi -> data_start_sector );
643- return - EIO ;
644- }
645-
646- /* Not sector aligned with ra_count, resize ra_count to page size */
647- if ((sec - sbi -> data_start_sector ) & (ra_count - 1 ))
648- ra_count = page_ra_count ;
649-
650- bh = sb_find_get_block (sb , sec );
651- if (!bh || !buffer_uptodate (bh )) {
652- unsigned int i ;
653-
654- for (i = 0 ; i < ra_count ; i ++ )
655- sb_breadahead (sb , (sector_t )(sec + i ));
656- }
657- brelse (bh );
658- return 0 ;
659- }
660-
661626struct exfat_dentry * exfat_get_dentry (struct super_block * sb ,
662627 struct exfat_chain * p_dir , int entry , struct buffer_head * * bh )
663628{
629+ struct exfat_sb_info * sbi = EXFAT_SB (sb );
630+ unsigned int sect_per_clus = sbi -> sect_per_clus ;
664631 unsigned int dentries_per_page = EXFAT_B_TO_DEN (PAGE_SIZE );
665632 int off ;
666633 sector_t sec ;
@@ -673,9 +640,18 @@ struct exfat_dentry *exfat_get_dentry(struct super_block *sb,
673640 if (exfat_find_location (sb , p_dir , entry , & sec , & off ))
674641 return NULL ;
675642
676- if (p_dir -> dir != EXFAT_FREE_CLUSTER &&
677- !(entry & (dentries_per_page - 1 )))
678- exfat_dir_readahead (sb , sec );
643+ if (sect_per_clus > 1 &&
644+ (entry & (dentries_per_page - 1 )) == 0 ) {
645+ sector_t ra = sec ;
646+ blkcnt_t cnt = 0 ;
647+ unsigned int ra_count = sect_per_clus ;
648+
649+ /* Not sector aligned with ra_count, resize ra_count to page size */
650+ if ((sec - sbi -> data_start_sector ) & (ra_count - 1 ))
651+ ra_count = PAGE_SIZE >> sb -> s_blocksize_bits ;
652+
653+ exfat_blk_readahead (sb , sec , & ra , & cnt , sec + ra_count - 1 );
654+ }
679655
680656 * bh = sb_bread (sb , sec );
681657 if (!* bh )
0 commit comments