Re: [PATCH v7] exfat: add EXFAT_IOC_COMBINE to append a file's clusters to another

From: Shaopei Zhu

Date: Thu Nov 26 2026 - 07:26:09 EST


On Thu, Nov 26, 2026 at 5:54 PM Namjae Jeon <linkinjeon@xxxxxxxxxx> wrote:
> Unlinking in the ioctl does not make the operation atomic against
> power loss. It only avoids the interval between a successful ioctl and
> a later userspace unlink. I don't think that is a reason for the
> kernel to perform the unlink. exfatcombine already has the source path
> and opens the file to pass its file descriptor to the ioctl. It can
> unlink the source file after the ioctl succeeds and report an error if
> that fails. The ioctl should only append the source file's cluster
> chain to the destination file. Callers must prevent concurrent renames
> or replacements if they need the pathname to continue referring to the
> same file.

Hi Namjae,

Thank you, that is a fair point and a valuable suggestion. I will
rework the interface as you suggest in the next version.

I went through it again. You are right that the unlink does not make
the operation atomic: a power loss in the middle can still leave both
entries referencing the clusters until fsck.exfat has run, so it only
removed the interval after the ioctl. The state user space has to
handle instead, an empty source next to a destination that already
holds its data, is harmless and easy to recognize. I also looked at
the existing interfaces that move or share data between files,
FICLONERANGE, copy_file_range(), F2FS_IOC_MOVE_RANGE, EXT4_IOC_MOVE_EXT
and XFS_IOC_EXCHANGE_RANGE, and none of them removes the source; that
is left to the caller, which already has the path and the permission
checks of unlink(2).

So in v8 the ioctl only appends the cluster chain of the source and
leaves it as an empty file, written to disk after the destination.
The unlink code in the kernel goes away, and with it the bind mount,
dead parent and failed-unlink handling it needed. exfatcombine
unlinks the source after the ioctl succeeds and reports an error if
that fails, and the uapi header documents that the caller unlinks the
source and has to prevent concurrent renames if it relies on the name.
The fstests case and the exfatprogs PR will be updated to match.

Thanks again for the review.

Shaopei