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 6/6] exfat: fix error handling for FAT table operations
Date: Tue, 3 Mar 2026 11:14:09 +0800 [thread overview]
Message-ID: <20260303031409.129136-7-chizhiling@163.com> (raw)
In-Reply-To: <20260303031409.129136-1-chizhiling@163.com>
From: Chi Zhiling <chizhiling@kylinos.cn>
Fix three error handling issues in FAT table operations:
1. Fix exfat_update_bh() to properly return errors from sync_dirty_buffer
2. Fix exfat_end_bh() to properly return errors from exfat_update_bh()
and exfat_mirror_bh()
3. Fix ignored return values from exfat_chain_cont_cluster() in inode.c
and namei.c
These fixes ensure that FAT table write errors are properly propagated
to the caller instead of being silently ignored.
Signed-off-by: Chi Zhiling <chizhiling@kylinos.cn>
---
fs/exfat/exfat_fs.h | 2 +-
fs/exfat/fatent.c | 8 ++++----
fs/exfat/inode.c | 5 +++--
fs/exfat/misc.c | 8 ++++++--
fs/exfat/namei.c | 3 ++-
5 files changed, 16 insertions(+), 10 deletions(-)
diff --git a/fs/exfat/exfat_fs.h b/fs/exfat/exfat_fs.h
index 090f25d1a418..9fed9fb33cae 100644
--- a/fs/exfat/exfat_fs.h
+++ b/fs/exfat/exfat_fs.h
@@ -584,7 +584,7 @@ void exfat_set_entry_time(struct exfat_sb_info *sbi, struct timespec64 *ts,
u8 *tz, __le16 *time, __le16 *date, u8 *time_cs);
u16 exfat_calc_chksum16(void *data, int len, u16 chksum, int type);
u32 exfat_calc_chksum32(void *data, int len, u32 chksum, int type);
-void exfat_update_bh(struct buffer_head *bh, int sync);
+int exfat_update_bh(struct buffer_head *bh, int sync);
int exfat_update_bhs(struct buffer_head **bhs, int nr_bhs, int sync);
void exfat_chain_set(struct exfat_chain *ec, unsigned int dir,
unsigned int size, unsigned char flags);
diff --git a/fs/exfat/fatent.c b/fs/exfat/fatent.c
index a973aa4de57b..f2e5d5dde393 100644
--- a/fs/exfat/fatent.c
+++ b/fs/exfat/fatent.c
@@ -25,7 +25,7 @@ static int exfat_mirror_bh(struct super_block *sb, struct buffer_head *bh)
if (!c_bh)
return -ENOMEM;
memcpy(c_bh->b_data, bh->b_data, sb->s_blocksize);
- exfat_update_bh(c_bh, sb->s_flags & SB_SYNCHRONOUS);
+ err = exfat_update_bh(c_bh, sb->s_flags & SB_SYNCHRONOUS);
brelse(c_bh);
}
@@ -36,10 +36,10 @@ static int exfat_end_bh(struct super_block *sb, struct buffer_head *bh)
{
int err;
- exfat_update_bh(bh, sb->s_flags & SB_SYNCHRONOUS);
- err = exfat_mirror_bh(sb, bh);
+ err = exfat_update_bh(bh, sb->s_flags & SB_SYNCHRONOUS);
+ if (!err)
+ err = exfat_mirror_bh(sb, bh);
brelse(bh);
-
return err;
}
diff --git a/fs/exfat/inode.c b/fs/exfat/inode.c
index 2fb2d2d5d503..cb13a197eee9 100644
--- a/fs/exfat/inode.c
+++ b/fs/exfat/inode.c
@@ -204,8 +204,9 @@ static int exfat_map_cluster(struct inode *inode, unsigned int clu_offset,
* so fat-chain should be synced with
* alloc-bitmap
*/
- exfat_chain_cont_cluster(sb, ei->start_clu,
- num_clusters);
+ if (exfat_chain_cont_cluster(sb, ei->start_clu,
+ num_clusters))
+ return -EIO;
ei->flags = ALLOC_FAT_CHAIN;
}
if (new_clu.flags == ALLOC_FAT_CHAIN)
diff --git a/fs/exfat/misc.c b/fs/exfat/misc.c
index fa8459828046..6f11a96a4ffa 100644
--- a/fs/exfat/misc.c
+++ b/fs/exfat/misc.c
@@ -161,13 +161,17 @@ u32 exfat_calc_chksum32(void *data, int len, u32 chksum, int type)
return chksum;
}
-void exfat_update_bh(struct buffer_head *bh, int sync)
+int exfat_update_bh(struct buffer_head *bh, int sync)
{
+ int err = 0;
+
set_buffer_uptodate(bh);
mark_buffer_dirty(bh);
if (sync)
- sync_dirty_buffer(bh);
+ err = sync_dirty_buffer(bh);
+
+ return err;
}
int exfat_update_bhs(struct buffer_head **bhs, int nr_bhs, int sync)
diff --git a/fs/exfat/namei.c b/fs/exfat/namei.c
index 670116ae9ec8..ef2a3488c1b3 100644
--- a/fs/exfat/namei.c
+++ b/fs/exfat/namei.c
@@ -365,7 +365,8 @@ int exfat_find_empty_entry(struct inode *inode,
/* no-fat-chain bit is disabled,
* so fat-chain should be synced with alloc-bitmap
*/
- exfat_chain_cont_cluster(sb, p_dir->dir, p_dir->size);
+ if (exfat_chain_cont_cluster(sb, p_dir->dir, p_dir->size))
+ return -EIO;
p_dir->flags = ALLOC_FAT_CHAIN;
hint_femp.cur.flags = ALLOC_FAT_CHAIN;
}
--
2.43.0
next prev 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 ` [PATCH v2 3/6] exfat: use readahead helper in exfat_get_dentry Chi Zhiling
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 ` Chi Zhiling [this message]
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-7-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®