Re: [PATCH v2 3/6] exfat: use exfat_fat_walk helper to simplify fat entry walking

From: Chi Zhiling

Date: Thu Apr 02 2026 - 22:43:56 EST


On 4/2/26 10:22 PM, Sungjong Seo wrote:
Hi, Chi Zhiling,
Replace the custom exfat_walk_fat_chain() function and open-coded FAT
chain walking logic with the exfat_fat_walk() helper across
exfat_find_location, __exfat_get_dentry_set, and exfat_map_cluster.

Signed-off-by: Chi Zhiling <chizhiling@xxxxxxxxxx>
---
fs/exfat/dir.c | 39 +++------------------------------------
fs/exfat/inode.c | 11 ++---------
2 files changed, 5 insertions(+), 45 deletions(-)

diff --git a/fs/exfat/dir.c b/fs/exfat/dir.c index
7619410d668e..cfc6f16a5fb2 100644
--- a/fs/exfat/dir.c
+++ b/fs/exfat/dir.c
@@ -562,38 +562,6 @@ int exfat_put_dentry_set(struct
exfat_entry_set_cache *es, int sync)
return err;
}

-static int exfat_walk_fat_chain(struct super_block *sb,
- struct exfat_chain *p_dir, unsigned int byte_offset,
- unsigned int *clu)
-{
- struct exfat_sb_info *sbi = EXFAT_SB(sb);
- unsigned int clu_offset;
- unsigned int cur_clu;
-
- clu_offset = EXFAT_B_TO_CLU(byte_offset, sbi);
- cur_clu = p_dir->dir;
-
- if (p_dir->flags == ALLOC_NO_FAT_CHAIN) {
- cur_clu += clu_offset;
- } else {
- while (clu_offset > 0) {
- if (exfat_get_next_cluster(sb, &cur_clu))
- return -EIO;
- if (cur_clu == EXFAT_EOF_CLUSTER) {

The intentional exfat_fs_error() call for chain damage conditions is lost.
Instead of removing the error handling for this condition, it had better be
moved to exfat_find_location().

Wow, you’re right, I did miss that.
and your suggestion is great.

Thanks,