Re: [PATCH v2] exfat: clean up new entry on add entry failure

Namjae Jeon <[email protected]> Wed, 29 Jul 2026 18:10:21 +0900
Newsgroups dev.linux.lists.exfat,org.kernel.vger.linux-kernel
Message-ID <CAKYAXd_MFU7+U8hwByFj4UPN6JUUtH_VQWe-gxX71saJ2BP5GA@mail.gmail.com>
On Wed, Jul 29, 2026 at 11:26=E2=80=AFAM Yichong Chen <chenyichong@uniontec=
h.com> wrote:
>
> exfat_add_entry() initializes a new directory entry set before writing it
> with exfat_put_dentry_set().  If the write fails, mkdir/create returns an
> error but a partially written entry may be left behind.
>
> For non-zero-size directories, the failure also happens after a cluster
> has been allocated for the new directory.  Clean up the new entry
> best-effort, and free the newly allocated directory cluster only when the
> cleanup writeback succeeds.  This avoids freeing a cluster that may still
> be referenced by an on-disk entry if the cleanup fails.
>
> Signed-off-by: Yichong Chen <[email protected]>
Applied it to #dev.
Thanks!