From: Namjae Jeon <linkinjeon@kernel.org>
To: Shaopei Zhu <shaopei_1012@163.com>
Cc: Sungjong Seo <sj1557.seo@samsung.com>,
Yuezhang Mo <yuezhang.mo@sony.com>,
exfat@lists.linux.dev, linux-fsdevel@vger.kernel.org,
linux-api@vger.kernel.org, linux-doc@vger.kernel.org,
linux-kernel@vger.kernel.org,
Matthew Wilcox <willy@infradead.org>
Subject: Re: [PATCH v7] exfat: add EXFAT_IOC_COMBINE to append a file's clusters to another
Date: Thu, 26 Nov 2026 17:54:42 +0900 [thread overview]
Message-ID: <CAKYAXd_Xc0XbehABVUOncbcDYxvfFg037+FxDivkM0NZMg29qQ@mail.gmail.com> (raw)
In-Reply-To: <20261126075247.850895-1-shaopei_1012@163.com>
On Thu, Nov 26, 2026 at 4:53 PM Shaopei Zhu <shaopei_1012@163.com> wrote:
>
> On Wed, Nov 25, 2026 at 11:18 AM Namjae Jeon <linkinjeon@kernel.org> wrote:
> > Is there a specific device or product expected to use this feature, or
> > is it being added as a potentially useful capability without a
> > concrete use case? If there is a target device or workflow, could you
> > share some details?
>
> Hi Namjae,
Hi Shaopei,
>
> Thanks for the review. Yes, it is going to be used in camera products
> that record to exFAT SD cards. The open source user is exfatcombine,
> posted for exfatprogs [1], and a test for fstests (exfat/002) is posted
> as well.
>
> The workflow: cameras and dashcams keep motion or position data with
> the video, e.g. gyroscope and accelerometer samples for stabilization,
> or GPS.
>
> The products on the market keep that data in one of three ways:
>
> - as a timed metadata track inside the MP4, e.g. GoPro's GPMF, muxed
> while recording, so that the samples are interleaved with the video
> in the mdat box and indexed in the moov box;
> - as a separate sidecar file next to the video, e.g. the GPS logs of
> dashcams;
> - as a trailer appended after the MP4 boxes when recording stops,
> which players ignore and stabilization tools read.
>
> A sidecar file is lost in practice: users copy, share or import only
> the video file, and matching the two by name breaks once either is
> renamed or moved. A track needs the muxer to take the samples in real
> time along with the video. Where the sensor data comes from another
> writer, at a few hundred samples per second, it cannot go into the file
> the muxer is writing, so it is written to a separate file in the same
> directory during recording and appended as a trailer when recording
> stops.
>
> That last step is what this ioctl is for. Today the sensor file is
> copied into the video file, up to tens of MiB per recording, while the
> user waits for the camera to be ready again, with flash wear and free
> space needed for the copy. With this ioctl its clusters are appended
> to the video file instead, and the sensor file is removed.
Okay.
>
> > I suggest changing EXFAT_IOC_COMBINE to transfer only the source's
> > cluster chain to the destination, leaving the source linked as an
> > empty file. Userspace can unlink it afterward if desired.
>
> The sensor file is only a temporary part of the recording. With the
> unlink in the same call, a power loss, e.g. the battery being pulled
> right after recording stops, leaves one of the two states the
> recording application already handles: not combined yet, or combined.
> With the unlink in user space there is a third one, the combined video
> next to an empty sensor file, which looks like the first one unless
> every application also checks the size of the file. It would be easy
> to append the sensor data a second time, or to leave an empty file on
> a card that users read directly.
>
> Doing it in the same call also refuses the whole call before anything
> is changed if the source may not be removed, instead of leaving an
> emptied file that cannot be deleted, and it removes the file that was
> passed in, not whatever its name refers to by the time user space gets
> to unlink it. The unlink goes through start_removing_dentry(),
> security_path_unlink() and vfs_unlink(), so it gets the same checks as
> unlink(2).
>
> Does this address your concern?
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.
next prev parent reply other threads:[~2026-11-26 8:54 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-24 23:07 Shaopei Zhu
2026-11-25 2:18 ` Namjae Jeon
2026-11-26 7:52 ` Shaopei Zhu
2026-11-26 8:54 ` Namjae Jeon [this message]
2026-11-26 12:24 ` Shaopei Zhu
2026-11-26 14:26 ` David Timber
2026-11-26 15:26 ` Shaopei Zhu
2026-11-26 19:07 ` Shaopei Zhu
2026-11-27 5:32 ` David Timber
2026-11-27 6:08 ` Shaopei Zhu
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=CAKYAXd_Xc0XbehABVUOncbcDYxvfFg037+FxDivkM0NZMg29qQ@mail.gmail.com \
--to=linkinjeon@kernel.org \
--cc=exfat@lists.linux.dev \
--cc=linux-api@vger.kernel.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=shaopei_1012@163.com \
--cc=sj1557.seo@samsung.com \
--cc=willy@infradead.org \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®