From: Wesley Atwell <atwellwea@gmail.com>
To: Yuezhang Mo <yuezhang.mo@sony.com>,
Sungjong Seo <sj1557.seo@samsung.com>,
Namjae Jeon <linkinjeon@kernel.org>
Cc: exfat@lists.linux.dev, Wesley Atwell <atwellwea@gmail.com>,
linux-kernel@vger.kernel.org
Subject: [PATCH v2] exfat: free directory cluster when zeroing fails
Date: Sun, 29 Nov 2026 15:31:09 -0700 [thread overview]
Message-ID: <kernel-exfat-dir-growth-error-v2-002dfcf028dd@gmail.com> (raw)
When a synchronous exFAT directory needs another cluster,
exfat_find_empty_entry() allocates one and zeroes it before linking it
into the directory. If the zeroing write fails, the function returns an
error but leaves the new cluster allocated. The directory has not grown,
so the cluster is unreachable and its space remains unavailable.
In a QEMU guest on the exFAT dev tree, a tar extraction to a dirsync
volume hit a targeted block write error while extending a directory.
Tar reported EIO and the new file was absent, but the allocation bitmap
showed one extra 4 KiB cluster in use after remount. The default
fsck.exfat check and repair both called the volume clean.
Free only the newly allocated cluster if zeroing fails. Allocation can
mark the temporary cluster as a FAT chain before it is linked to the
directory, so set its flag to ALLOC_NO_FAT_CHAIN before freeing it.
Return EIO as before. With the fix, the failed extraction still reports
EIO, but the bitmap returns to its original free-cluster count after
remount. The healthy extraction still grows the directory.
This contribution was developed with AI assistance.
Fixes: 5f2aa075070c ("exfat: add inode operations")
Link: https://lore.kernel.org/all/kernel-7be3083ed7a0fec5-v1.atwellwea@gmail.com/
Signed-off-by: Wesley Atwell <atwellwea@gmail.com>
---
Changes since v1:
- Free only the new cluster when allocation switches to a FAT chain.
- Preserve the original EIO return and its callers' errno comments.
v1: https://lore.kernel.org/all/kernel-7be3083ed7a0fec5-v1.atwellwea@gmail.com/
fs/exfat/namei.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/fs/exfat/namei.c b/fs/exfat/namei.c
index 307a2130406e7..f7cc1b4f391cd 100644
--- a/fs/exfat/namei.c
+++ b/fs/exfat/namei.c
@@ -345,8 +345,11 @@ int exfat_find_empty_entry(struct inode *inode,
if (ret)
return ret;
- if (exfat_zeroed_cluster(inode, clu.dir))
+ if (exfat_zeroed_cluster(inode, clu.dir)) {
+ clu.flags = ALLOC_NO_FAT_CHAIN;
+ exfat_free_cluster(inode, &clu);
return -EIO;
+ }
if (ei->start_clu == EXFAT_EOF_CLUSTER) {
ei->start_clu = clu.dir;
base-commit: 36edb65f309977762fc001c17dcab748bad4b7c1
next reply other threads:[~2026-11-29 22:31 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-29 22:31 Wesley Atwell [this message]
2026-11-30 0:03 ` [PATCH v2] exfat: free directory cluster when zeroing fails 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=kernel-exfat-dir-growth-error-v2-002dfcf028dd@gmail.com \
--to=atwellwea@gmail.com \
--cc=exfat@lists.linux.dev \
--cc=linkinjeon@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.