From: Gao Xiang <hsiangkao@linux.alibaba.com>
To: Giuseppe Scrivano <gscrivan@redhat.com>
Cc: Christian Brauner <brauner@kernel.org>,
linux-erofs@lists.ozlabs.org, cyphar@cyphar.com,
linux-fsdevel@vger.kernel.org
Subject: Re: [PATCH v4] erofs: accept source file descriptor via fsconfig
Date: Tue, 28 Jul 2026 20:33:52 +0800 [thread overview]
Message-ID: <ba39c0d9-1b7a-43d6-9a91-e729cb3a2731@linux.alibaba.com> (raw)
In-Reply-To: <87mrvckgip.fsf@redhat.com>
Hi Giuseppe,
On 2026/7/27 16:01, Giuseppe Scrivano wrote:
> Gao Xiang <hsiangkao@linux.alibaba.com> writes:
>
>> Hi Christian,
>>
>> On 2026/7/23 22:46, Christian Brauner wrote:
>>>> I'm not quite sure if I catched the point, I think Giuseppe's patch here
>>>> tried to record `file` into `sbi->dif0.file` (which indicates the primary
>>>> "device" later.)
>>>>
>>>> And if `sbi->dif0.file` is set up by erofs_fc_parse_source(),
>>>> erofs_fc_get_tree() will just use `sbi->dif0.file` instead of
>>>> `fc->source` according to this patch.
>>> Oh, so you only do it for file-backed mounts. Do you only allow
>>> regular
>>> files or do you also support block devices with
>>> CONFIG_EROFS_FS_BACKED_BY_FILE?
>>
>> Block devices with CONFIG_EROFS_FS_BACKED_BY_FILE are supported,
>> but with only `fc->source` (not this way.)
>>
>> That is the limitation I see in Giuseppe's patch. I'd hoped
>> bdev-backed mounts could work the same way, but that would require
>> changes to the VFS flow.
>>
>> Since this is a side improvement, I think it's fine as long as
>> it's documented somewhere, and I do hope Giuseppe can at least
>> address the documentation.
>
> would something like the following be enough?
>
> diff --git a/Documentation/filesystems/erofs.rst b/Documentation/filesystems/erofs.rst
> index 4230884fb359..768e1d43dfcc 100644
> --- a/Documentation/filesystems/erofs.rst
> +++ b/Documentation/filesystems/erofs.rst
> @@ -139,6 +139,29 @@ inode_share Enable inode page sharing for this filesystem. Inodes wi
> page cache.
> =================== =========================================================
>
> +File-backed mounts
> +==================
> +
> +When ``CONFIG_EROFS_FS_BACKED_BY_FILE`` is enabled, EROFS can mount filesystem
> +images stored as regular files directly, without requiring a loopback block
> +device. The source can be specified either by path or by passing an
> +already-opened file descriptor via ``fsconfig(fd, FSCONFIG_SET_FD, "source",
> +NULL, source_fd)``. Only regular files are accepted; block devices must use
File-backed mounts
==================
When ``CONFIG_EROFS_FS_BACKED_BY_FILE`` is enabled, EROFS file-backed images
can be mounted directly without a loopback block device. The backing file
can be given either as a path, or as an already-opened file descriptor via
``fsconfig(fd, FSCONFIG_SET_FD, "source", NULL, source_fd)``.
Only regular files are accepted as backing files; to mount an image that
resides on a block device, use the traditional block device mount path
instead.
It's just my own sketch of this; you could just fold this into this patch
with modification (I'm not quite good at English.)
Also it lacks how `fc->source is filled` when source_fd is specified, we
may need to document here as well (and hopefully vfs maintainers can ack
on this so it can be stable.)
> +the standard block device mount path.
> +
> +The backing file content must remain stable for the lifetime of the mount.
> +EROFS never writes to it, but concurrent modifications by other processes lead
> +to undefined behavior.
Yes, I explained to Christian but I don't think it should be included
in this patch, maybe we need to document this as a new section
in a seperate patch later (possibly as a formal security model.)
> +
> +Ioctls
> +======
> +
> +``EROFS_IOC_GET_SOURCE_FD``
> + Return a read-only file descriptor (``O_CLOEXEC``) for the backing file of a
> + file-backed mount. Returns ``-ENOENT`` on block-device-backed mounts.
> + Requires ``CAP_SYS_ADMIN`` in the initial user namespace (returns ``-EPERM``
> + otherwise).
I hope document this part in the corresponding patch but I guess we have
to get a consensus between filesystems first.
Thanks,
Gao Xiang
prev parent reply other threads:[~2026-07-28 12:34 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-17 13:41 [PATCH v4] erofs: accept source file descriptor via fsconfig Giuseppe Scrivano
2026-07-20 9:45 ` Gao Xiang
2026-07-22 16:11 ` Christian Brauner
2026-07-22 16:25 ` Gao Xiang
2026-07-23 14:46 ` Christian Brauner
2026-07-23 22:38 ` Gao Xiang
2026-07-27 8:01 ` Giuseppe Scrivano
2026-07-28 12:33 ` Gao Xiang [this message]
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=ba39c0d9-1b7a-43d6-9a91-e729cb3a2731@linux.alibaba.com \
--to=hsiangkao@linux.alibaba.com \
--cc=brauner@kernel.org \
--cc=cyphar@cyphar.com \
--cc=gscrivan@redhat.com \
--cc=linux-erofs@lists.ozlabs.org \
--cc=linux-fsdevel@vger.kernel.org \
/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