From: Giuseppe Scrivano <gscrivan@redhat.com>
To: Gao Xiang <hsiangkao@linux.alibaba.com>
Cc: Aleksa Sarai <cyphar@cyphar.com>,
Christian Brauner <brauner@kernel.org>,
linux-erofs@lists.ozlabs.org, linux-fsdevel@vger.kernel.org
Subject: Re: [PATCH v2] erofs: accept source file descriptor via fsconfig
Date: Tue, 14 Jul 2026 12:09:15 +0200 [thread overview]
Message-ID: <87ldbd3mt0.fsf@redhat.com> (raw)
In-Reply-To: <c812e638-8a66-4dc0-b8d9-c971134bb413@linux.alibaba.com> (Gao Xiang's message of "Tue, 14 Jul 2026 14:45:09 +0800")
Gao Xiang <hsiangkao@linux.alibaba.com> writes:
> On 2026/7/14 14:36, Giuseppe Scrivano wrote:
>> Gao Xiang <hsiangkao@linux.alibaba.com> writes:
>>
>>> On 2026/7/14 08:49, Aleksa Sarai wrote:
>>>> On 2026-07-13, Giuseppe Scrivano <gscrivan@redhat.com> wrote:
>>>>> thanks for the hints.
>>>>>
>>>>> I'll prepare a v3 if you are fine with the version below:
>>>> No worries, and this seems more reasonable at a first glance.
>>>>
>>>>> diff --git a/fs/erofs/super.c b/fs/erofs/super.c
>>>>> index 86fa5c6a0c70..72c85cc53085 100644
>>>>> --- a/fs/erofs/super.c
>>>>> +++ b/fs/erofs/super.c
>>>> ...
>>>>> @@ -437,6 +439,38 @@ static bool erofs_fc_set_dax_mode(struct fs_context *fc, unsigned int mode)
>>>>> return false;
>>>>> }
>>>>> +static int erofs_fc_parse_source(struct fs_context *fc,
>>>>> + struct fs_parameter *param)
>>>>> +{
>>>>> + struct erofs_sb_info *sbi = fc->s_fs_info;
>>>>> +
>>>>> + if (fc->source || sbi->dif0.file)
>>>>> + return invalf(fc, "Multiple sources");
>>>>> +
>>>>> + switch (param->type) {
>>>>> + case fs_value_is_string:
>>>>> + fc->source = param->string;
>>>>> + param->string = NULL;
>>>>> + return 0;
>>>>> + case fs_value_is_file: {
>>>>> + char *buf, *p;
>>>>> +
>>>>> + sbi->dif0.file = get_file(param->file);
>>>> A very minor nit, but you can actually steal the file reference here
>>>> with
>>>> sbi->dif0.file = no_free_ptr(param->file);
>>>> A few other places do this. (You'll also need to change the
>>>> param->file
>>>> reference below.)
>>>>
>>>>> + buf = kmalloc(PATH_MAX, GFP_KERNEL);
>>>>> + if (!buf)
>>>>> + return -ENOMEM;
>>>>> + p = file_path(param->file, buf, PATH_MAX);
>>>>> + fc->source = kstrdup(IS_ERR(p) ? "(fd)" : p, GFP_KERNEL);
>>>> I think that /proc/self/fd/%d would be a more useful name for
>>>> debugging
>>>> if file_path() fails (not that it is really possible here AFAICS). But
>>>> I'm not really too fussed.
>>>
>>> Not quite sure if we should get in agreement with the format of this
>>> one in advance (IOWs, users use source_fd and how fc->source looks like;
>>> since other fses may follow the same practice if source_fd becomes common
>>> later) since it's a user-visible field and I believe we shouldn't treat
>>> this one as a dontcare field as some pseudo fses (since those fses don't
>>> rely on `fc->source` by design but typically EROFS can rely on.)
>>>
>>> I hope Christian and others could share move thought on this part too
>>> before I land this feature for the next cycle.
>> would it be better to just return the error from file_path without
>> any
>> fallback?
>
> I hope Christian or other vfs folks can decide how to handle fc->source
> string here, since in the long term, how to deal with source_fd should
> be unique among different fses: just our current short-term
> implementation lands into erofs directly for file-backed mounts to
> fulfill composefs needs.
>
overlayfs is already handling such a case, and it resolves the path using d_path:
static int ovl_parse_layer(struct fs_context *fc, struct fs_parameter *param,
enum ovl_opt layer)
{
struct path layer_path __free(path_put) = {};
int err = 0;
switch (param->type) {
case fs_value_is_string:
err = ovl_kern_path(param->string, &layer_path, layer);
if (err)
return err;
err = ovl_do_parse_layer(fc, param->string, &layer_path, layer);
break;
case fs_value_is_file: {
char *buf __free(kfree);
char *layer_name;
buf = kmalloc(PATH_MAX, GFP_KERNEL_ACCOUNT);
if (!buf)
return -ENOMEM;
layer_path = param->file->f_path;
path_get(&layer_path);
layer_name = d_path(&layer_path, buf, PATH_MAX);
if (IS_ERR(layer_name))
return PTR_ERR(layer_name);
err = ovl_do_parse_layer(fc, layer_name, &layer_path, layer);
break;
}
default:
WARN_ON_ONCE(true);
err = -EINVAL;
}
return err;
}
If there are no objections, I'll change the code to match what overlay
does and return the error instead of using a fallback.
Regards,
Giuseppe
prev parent reply other threads:[~2026-07-14 10:09 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-11 7:10 [PATCH v2] erofs: accept source file descriptor via fsconfig Giuseppe Scrivano
2026-07-13 3:57 ` Gao Xiang
2026-07-13 4:52 ` Aleksa Sarai
2026-07-13 5:45 ` Gao Xiang
2026-07-13 8:06 ` Giuseppe Scrivano
2026-07-13 8:33 ` Aleksa Sarai
2026-07-13 10:24 ` Giuseppe Scrivano
2026-07-14 0:49 ` Aleksa Sarai
2026-07-14 1:56 ` Gao Xiang
2026-07-14 6:36 ` Giuseppe Scrivano
2026-07-14 6:45 ` Gao Xiang
2026-07-14 10:09 ` Giuseppe Scrivano [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=87ldbd3mt0.fsf@redhat.com \
--to=gscrivan@redhat.com \
--cc=brauner@kernel.org \
--cc=cyphar@cyphar.com \
--cc=hsiangkao@linux.alibaba.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.