linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: JeffleXu <jefflexu@linux.alibaba.com>
To: Jia Zhu <zhujia.zj@bytedance.com>,
	linux-erofs@lists.ozlabs.org, xiang@kernel.org, chao@kernel.org
Cc: linux-fsdevel@vger.kernel.org, huyue2@coolpad.com,
	linux-kernel@vger.kernel.org, yinxin.x@bytedance.com
Subject: Re: [PATCH V2 3/5] erofs: add 'domain_id' prefix when register sysfs
Date: Fri, 9 Sep 2022 17:26:55 +0800	[thread overview]
Message-ID: <fc63c7ed-bffe-4127-7622-a7ce0c4b4378@linux.alibaba.com> (raw)
In-Reply-To: <539dcc26-a250-5bf4-0f3c-a3f7cdc2ce48@linux.alibaba.com>



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@bytedance.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;
}




> 
> 
>>  	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;
> 

-- 
Thanks,
Jingbo

  reply	other threads:[~2022-09-09  9:29 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-02 10:53 [PATCH V2 0/5] Introduce erofs shared domain Jia Zhu
2022-09-02 10:53 ` [PATCH V2 1/5] erofs: add 'domain_id' mount option for on-demand read sementics Jia Zhu
2022-09-02 10:53 ` [PATCH V2 2/5] erofs: introduce fscache-based domain Jia Zhu
2022-09-09  8:42   ` JeffleXu
2022-09-13  4:31     ` [External] " Jia Zhu
2022-09-13  6:34       ` JeffleXu
2022-09-14  3:02   ` JeffleXu
2022-09-14  3:15     ` [External] " Jia Zhu
2022-09-02 10:53 ` [PATCH V2 3/5] erofs: add 'domain_id' prefix when register sysfs Jia Zhu
2022-09-09  9:23   ` JeffleXu
2022-09-09  9:26     ` JeffleXu [this message]
2022-09-13  4:35       ` [External] " Jia Zhu
2022-09-02 10:53 ` [PATCH V2 4/5] erofs: remove duplicated unregister_cookie Jia Zhu
2022-09-09  9:55   ` JeffleXu
2022-09-09 10:28     ` JeffleXu
2022-09-13  4:52       ` [External] " Jia Zhu
2022-09-13  4:37     ` Jia Zhu
2022-09-02 10:53 ` [PATCH V2 5/5] erofs: support fscache based shared domain Jia Zhu
2022-09-13  6:27   ` JeffleXu
2022-09-13 12:59     ` [External] " Jia Zhu
2022-09-08  6:49 ` [PATCH V2 0/5] Introduce erofs " Jia 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=fc63c7ed-bffe-4127-7622-a7ce0c4b4378@linux.alibaba.com \
    --to=jefflexu@linux.alibaba.com \
    --cc=chao@kernel.org \
    --cc=huyue2@coolpad.com \
    --cc=linux-erofs@lists.ozlabs.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=xiang@kernel.org \
    --cc=yinxin.x@bytedance.com \
    --cc=zhujia.zj@bytedance.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;
as well as URLs for NNTP newsgroup(s).