[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20251118082208.1034186-2-chizhiling@163.com>
Date: Tue, 18 Nov 2025 16:22:02 +0800
From: Chi Zhiling <chizhiling@....com>
To: linux-fsdevel@...r.kernel.org,
linux-kernel@...r.kernel.org
Cc: Alexander Viro <viro@...iv.linux.org.uk>,
Christian Brauner <brauner@...nel.org>,
Jan Kara <jack@...e.cz>,
Matthew Wilcox <willy@...radead.org>,
Namjae Jeon <linkinjeon@...nel.org>,
Sungjong Seo <sj1557.seo@...sung.com>,
Yuezhang Mo <yuezhang.mo@...y.com>,
Chi Zhiling <chizhiling@...inos.cn>
Subject: [RFC PATCH 1/7] exfat: add cache option for __exfat_ent_get
From: Chi Zhiling <chizhiling@...inos.cn>
When multiple entries are obtained consecutively, these entries are mostly
stored adjacent to each other. this patch introduces a "last" parameter to
cache the last opened buffer head, and reuse it when possible, which
reduces the number of sb_bread() calls.
When the passed parameter "last" is NULL, it means cache option is
disabled, the behavior unchanged as it was.
Signed-off-by: Chi Zhiling <chizhiling@...inos.cn>
---
fs/exfat/fatent.c | 20 +++++++++++++-------
1 file changed, 13 insertions(+), 7 deletions(-)
diff --git a/fs/exfat/fatent.c b/fs/exfat/fatent.c
index 825083634ba2..f9c5d3485865 100644
--- a/fs/exfat/fatent.c
+++ b/fs/exfat/fatent.c
@@ -36,18 +36,21 @@ static int exfat_mirror_bh(struct super_block *sb, sector_t sec,
}
static int __exfat_ent_get(struct super_block *sb, unsigned int loc,
- unsigned int *content)
+ unsigned int *content, struct buffer_head **last)
{
unsigned int off;
sector_t sec;
- struct buffer_head *bh;
+ struct buffer_head *bh = last ? *last : NULL;
sec = FAT_ENT_OFFSET_SECTOR(sb, loc);
off = FAT_ENT_OFFSET_BYTE_IN_SECTOR(sb, loc);
- bh = sb_bread(sb, sec);
- if (!bh)
- return -EIO;
+ if (!bh || bh->b_blocknr != sec || !buffer_uptodate(bh)) {
+ brelse(bh);
+ bh = sb_bread(sb, sec);
+ if (!bh)
+ return -EIO;
+ }
*content = le32_to_cpu(*(__le32 *)(&bh->b_data[off]));
@@ -55,7 +58,10 @@ static int __exfat_ent_get(struct super_block *sb, unsigned int loc,
if (*content > EXFAT_BAD_CLUSTER)
*content = EXFAT_EOF_CLUSTER;
- brelse(bh);
+ if (last)
+ *last = bh;
+ else
+ brelse(bh);
return 0;
}
@@ -95,7 +101,7 @@ int exfat_ent_get(struct super_block *sb, unsigned int loc,
return -EIO;
}
- err = __exfat_ent_get(sb, loc, content);
+ err = __exfat_ent_get(sb, loc, content, NULL);
if (err) {
exfat_fs_error_ratelimit(sb,
"failed to access to FAT (entry 0x%08x, err:%d)",
--
2.43.0
Powered by blists - more mailing lists