Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

exfat: use readahead helper in exfat_get_dentry

Replace the custom exfat_dir_readahead() function with the unified
exfat_blk_readahead() helper in exfat_get_dentry(). This removes
the duplicate readahead implementation and uses the common interface,
also reducing code complexity.

Signed-off-by: Chi Zhiling <chizhiling@kylinos.cn>
Signed-off-by: Namjae Jeon <linkinjeon@kernel.org>

authored by

Chi Zhiling and committed by
Namjae Jeon
7094b09e a2999001

+14 -38
+14 -38
fs/exfat/dir.c
··· 623 623 return 0; 624 624 } 625 625 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 - 661 626 struct exfat_dentry *exfat_get_dentry(struct super_block *sb, 662 627 struct exfat_chain *p_dir, int entry, struct buffer_head **bh) 663 628 { 629 + struct exfat_sb_info *sbi = EXFAT_SB(sb); 630 + unsigned int sect_per_clus = sbi->sect_per_clus; 664 631 unsigned int dentries_per_page = EXFAT_B_TO_DEN(PAGE_SIZE); 665 632 int off; 666 633 sector_t sec; ··· 640 673 if (exfat_find_location(sb, p_dir, entry, &sec, &off)) 641 674 return NULL; 642 675 643 - if (p_dir->dir != EXFAT_FREE_CLUSTER && 644 - !(entry & (dentries_per_page - 1))) 645 - exfat_dir_readahead(sb, sec); 676 + if (sect_per_clus > 1 && 677 + (entry & (dentries_per_page - 1)) == 0) { 678 + sector_t ra = sec; 679 + blkcnt_t cnt = 0; 680 + unsigned int ra_count = sect_per_clus; 681 + 682 + /* Not sector aligned with ra_count, resize ra_count to page size */ 683 + if ((sec - sbi->data_start_sector) & (ra_count - 1)) 684 + ra_count = PAGE_SIZE >> sb->s_blocksize_bits; 685 + 686 + exfat_blk_readahead(sb, sec, &ra, &cnt, sec + ra_count - 1); 687 + } 646 688 647 689 *bh = sb_bread(sb, sec); 648 690 if (!*bh)