mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Chi Zhiling <chizhiling@163.com>
To: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: Namjae Jeon <linkinjeon@kernel.org>,
	Sungjong Seo <sj1557.seo@samsung.com>,
	Yuezhang Mo <yuezhang.mo@sony.com>,
	Chi Zhiling <chizhiling@kylinos.cn>
Subject: [PATCH v2 3/6] exfat: use readahead helper in exfat_get_dentry
Date: Tue,  3 Mar 2026 11:14:06 +0800	[thread overview]
Message-ID: <20260303031409.129136-4-chizhiling@163.com> (raw)
In-Reply-To: <20260303031409.129136-1-chizhiling@163.com>

From: Chi Zhiling <chizhiling@kylinos.cn>

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>
---
 fs/exfat/dir.c | 52 ++++++++++++++------------------------------------
 1 file changed, 14 insertions(+), 38 deletions(-)

diff --git a/fs/exfat/dir.c b/fs/exfat/dir.c
index 3a4853693d8b..5e59c2a7853e 100644
--- a/fs/exfat/dir.c
+++ b/fs/exfat/dir.c
@@ -623,44 +623,11 @@ static int exfat_find_location(struct super_block *sb, struct exfat_chain *p_dir
 	return 0;
 }
 
-#define EXFAT_MAX_RA_SIZE     (128*1024)
-static int exfat_dir_readahead(struct super_block *sb, sector_t sec)
-{
-	struct exfat_sb_info *sbi = EXFAT_SB(sb);
-	struct buffer_head *bh;
-	unsigned int max_ra_count = EXFAT_MAX_RA_SIZE >> sb->s_blocksize_bits;
-	unsigned int page_ra_count = PAGE_SIZE >> sb->s_blocksize_bits;
-	unsigned int adj_ra_count = max(sbi->sect_per_clus, page_ra_count);
-	unsigned int ra_count = min(adj_ra_count, max_ra_count);
-
-	/* Read-ahead is not required */
-	if (sbi->sect_per_clus == 1)
-		return 0;
-
-	if (sec < sbi->data_start_sector) {
-		exfat_err(sb, "requested sector is invalid(sect:%llu, root:%llu)",
-			  (unsigned long long)sec, sbi->data_start_sector);
-		return -EIO;
-	}
-
-	/* Not sector aligned with ra_count, resize ra_count to page size */
-	if ((sec - sbi->data_start_sector) & (ra_count - 1))
-		ra_count = page_ra_count;
-
-	bh = sb_find_get_block(sb, sec);
-	if (!bh || !buffer_uptodate(bh)) {
-		unsigned int i;
-
-		for (i = 0; i < ra_count; i++)
-			sb_breadahead(sb, (sector_t)(sec + i));
-	}
-	brelse(bh);
-	return 0;
-}
-
 struct exfat_dentry *exfat_get_dentry(struct super_block *sb,
 		struct exfat_chain *p_dir, int entry, struct buffer_head **bh)
 {
+	struct exfat_sb_info *sbi = EXFAT_SB(sb);
+	unsigned int sect_per_clus = sbi->sect_per_clus;
 	unsigned int dentries_per_page = EXFAT_B_TO_DEN(PAGE_SIZE);
 	int off;
 	sector_t sec;
@@ -673,9 +640,18 @@ struct exfat_dentry *exfat_get_dentry(struct super_block *sb,
 	if (exfat_find_location(sb, p_dir, entry, &sec, &off))
 		return NULL;
 
-	if (p_dir->dir != EXFAT_FREE_CLUSTER &&
-			!(entry & (dentries_per_page - 1)))
-		exfat_dir_readahead(sb, sec);
+	if (sect_per_clus > 1 &&
+	    (entry & (dentries_per_page - 1)) == 0) {
+		sector_t ra = sec;
+		blkcnt_t cnt = 0;
+		unsigned int ra_count = sect_per_clus;
+
+		/* Not sector aligned with ra_count, resize ra_count to page size */
+		if ((sec - sbi->data_start_sector) & (ra_count - 1))
+			ra_count = PAGE_SIZE >> sb->s_blocksize_bits;
+
+		exfat_blk_readahead(sb, sec, &ra, &cnt, sec + ra_count - 1);
+	}
 
 	*bh = sb_bread(sb, sec);
 	if (!*bh)
-- 
2.43.0


  parent reply	other threads:[~2026-03-03  3:15 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-03  3:14 [PATCH v2 0/6] exfat: improve performance of NO_FAT_CHAIN to FAT_CHAIN conversion Chi Zhiling
2026-03-03  3:14 ` [PATCH v2 1/6] exfat: add block readahead in exfat_chain_cont_cluster Chi Zhiling
2026-03-03  3:14 ` [PATCH v2 2/6] exfat: use readahead helper in exfat_allocate_bitmap Chi Zhiling
2026-03-03  3:14 ` Chi Zhiling [this message]
2026-03-03  3:14 ` [PATCH v2 4/6] exfat: drop redundant sec parameter from exfat_mirror_bh Chi Zhiling
2026-03-03  3:14 ` [PATCH v2 5/6] exfat: optimize exfat_chain_cont_cluster with cached buffer heads Chi Zhiling
2026-03-03  3:14 ` [PATCH v2 6/6] exfat: fix error handling for FAT table operations Chi Zhiling
2026-03-05 12:15 ` [PATCH v2 0/6] exfat: improve performance of NO_FAT_CHAIN to FAT_CHAIN conversion Namjae Jeon

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260303031409.129136-4-chizhiling@163.com \
    --to=chizhiling@163.com \
    --cc=chizhiling@kylinos.cn \
    --cc=linkinjeon@kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=sj1557.seo@samsung.com \
    --cc=yuezhang.mo@sony.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®