Re: [PATCH] exfat: fix a large buffered write failing when the volume is nearly full

From: Namjae Jeon

Date: Sat Oct 10 2026 - 09:07:56 EST


On Sat, Oct 10, 2026 at 1:44 PM Hengyu Liang <hengyul@xxxxxxxxxx> wrote:
>
> Commit 82a81a7352bc ("exfat: add iomap buffered I/O support") made a
> buffered write map the whole range of the write in one step, so the
> clusters for all of it are allocated at once.
>
> However, exfat_alloc_cluster() returns -ENOSPC when fewer clusters are
> free than it is asked for. As of now, a write() that is larger than the
> free space writes nothing and fails with ENOSPC, while it used to write
> as much as fits and return a short count.
>
> The issue can be reproduced with a 16M image made by mkfs.exfat that is
> filled except for 256K:
>
> mount -o loop /img /mnt
> dd if=/dev/zero of=/mnt/hole bs=256k count=1
> dd if=/dev/zero of=/mnt/fill bs=4k
> rm /mnt/hole
> dd if=/dev/zero of=/mnt/f bs=1M count=1
> wc -c < /mnt/f
>
> Before commit 82a81a7352bc ("exfat: add iomap buffered I/O support"),
> the result is:
>
> 262144
>
> After that commit, the result is:
>
> 0
>
> This patch will map a single cluster when the clusters for the whole
> range cannot be allocated, so that the write goes on until the volume is
> full. Direct I/O is not changed, it still fails without writing as it
> did before that commit.
>
> Fixes: 82a81a7352bc ("exfat: add iomap buffered I/O support")
> Cc: stable@xxxxxxxxxxxxxxx
> Signed-off-by: Hengyu Liang <hengyul@xxxxxxxxxx>
Applied it to #dev.
Thanks!