[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <babdb60b-227a-ac37-8fda-367556987c3f@bytedance.com>
Date: Tue, 13 Sep 2022 12:35:58 +0800
From: Jia Zhu <zhujia.zj@...edance.com>
To: JeffleXu <jefflexu@...ux.alibaba.com>,
linux-erofs@...ts.ozlabs.org, xiang@...nel.org, chao@...nel.org
Cc: linux-fsdevel@...r.kernel.org, huyue2@...lpad.com,
linux-kernel@...r.kernel.org, yinxin.x@...edance.com
Subject: Re: [External] Re: [PATCH V2 3/5] erofs: add 'domain_id' prefix when
register sysfs
在 2022/9/9 17:26, JeffleXu 写道:
>
>
> On 9/9/22 5:23 PM, JeffleXu wrote:
>>
>>
>> On 9/2/22 6:53 PM, Jia Zhu wrote:
>>> In shared domain mount procedure, add 'domain_id' prefix to register
>>> sysfs entry. Thus we could distinguish mounts that don't use shared
>>> domain.
>>>
>>> Signed-off-by: Jia Zhu <zhujia.zj@...edance.com>
>>> ---
>>> fs/erofs/sysfs.c | 11 ++++++++++-
>>> 1 file changed, 10 insertions(+), 1 deletion(-)
>>>
>>> diff --git a/fs/erofs/sysfs.c b/fs/erofs/sysfs.c
>>> index c1383e508bbe..c0031d7bd817 100644
>>> --- a/fs/erofs/sysfs.c
>>> +++ b/fs/erofs/sysfs.c
>>> @@ -201,12 +201,21 @@ static struct kobject erofs_feat = {
>>> int erofs_register_sysfs(struct super_block *sb)
>>> {
>>> struct erofs_sb_info *sbi = EROFS_SB(sb);
>>> + char *name = NULL;
>>> int err;
>>>
>>> + if (erofs_is_fscache_mode(sb)) {
>>> + name = kasprintf(GFP_KERNEL, "%s%s%s", sbi->opt.domain_id ?
>>> + sbi->opt.domain_id : "", sbi->opt.domain_id ? "," : "",
>>> + sbi->opt.fsid);
>>> + if (!name)
>>> + return -ENOMEM;
>>> + }
>>
>>
>> How about:
>>
>> name = erofs_is_fscache_mode(sb) ? sbi->opt.fsid : sb->s_id;
>> if (sbi->opt.domain_id) {
>> str = kasprintf(GFP_KERNEL, "%s,%s", sbi->opt.domain_id, sbi->opt.fsid);
>> name = str;
>> }
>
> Another choice:
>
> if (erofs_is_fscache_mode(sb)) {
> if (sbi->opt.domain_id) {
> str = kasprintf(GFP_KERNEL, "%s,%s", sbi->opt.domain_id, sbi->opt.fsid);
> name = str;
> } else {
> name = sbi->opt.fsid;
> }
> } else {
> name = sb->s_id;
> }
>
>
Thanks for your advise, this version looks more intuitive. I'll apply it
in next version.
>
>
>>
>>
>>> sbi->s_kobj.kset = &erofs_root;
>>> init_completion(&sbi->s_kobj_unregister);
>>> err = kobject_init_and_add(&sbi->s_kobj, &erofs_sb_ktype, NULL, "%s",
>>> - erofs_is_fscache_mode(sb) ? sbi->opt.fsid : sb->s_id);
>>> + name ? name : sb->s_id);
>>
>> kobject_init_and_add(..., "%s", name);
>> kfree(str);
>>
>> though it's still not such straightforward...
>>
>> Any better idea?
>>
>>
>>> + kfree(name);
>>> if (err)
>>> goto put_sb_kobj;
>>> return 0;
>>
>
Powered by blists - more mailing lists