Re: [PATCH v2] exfat: free directory cluster when zeroing fails
From: Namjae Jeon
Date: Sun Nov 29 2026 - 19:04:12 EST
On Mon, Nov 30, 2026 at 7:31 AM Wesley Atwell <atwellwea@xxxxxxxxx> wrote:
>
> 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@xxxxxxxxx/
> Signed-off-by: Wesley Atwell <atwellwea@xxxxxxxxx>
Applied it to #dev.
Thanks!