Skip to content

Commit

Permalink
erofs: clean up erofs_register_sysfs()
Browse files Browse the repository at this point in the history
After commit 684b290 ("erofs: add support for
FS_IOC_GETFSSYSFSPATH"), `sb->s_sysfs_name` is now valid.

Just use it to get rid of duplicated logic.

Signed-off-by: Gao Xiang <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
  • Loading branch information
hsiangkao committed Aug 28, 2024
1 parent 5be63fc commit b45adcb
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 25 deletions.
2 changes: 1 addition & 1 deletion fs/erofs/super.c
Original file line number Diff line number Diff line change
Expand Up @@ -644,7 +644,6 @@ static int erofs_fc_fill_super(struct super_block *sb, struct fs_context *fc)
sb->s_flags |= SB_POSIXACL;
else
sb->s_flags &= ~SB_POSIXACL;
erofs_set_sysfs_name(sb);

#ifdef CONFIG_EROFS_FS_ZIP
xa_init(&sbi->managed_pslots);
Expand Down Expand Up @@ -682,6 +681,7 @@ static int erofs_fc_fill_super(struct super_block *sb, struct fs_context *fc)
if (err)
return err;

erofs_set_sysfs_name(sb);
err = erofs_register_sysfs(sb);
if (err)
return err;
Expand Down
30 changes: 6 additions & 24 deletions fs/erofs/sysfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -205,34 +205,16 @@ static struct kobject erofs_feat = {
int erofs_register_sysfs(struct super_block *sb)
{
struct erofs_sb_info *sbi = EROFS_SB(sb);
char *name;
char *str = NULL;
int err;

if (erofs_is_fscache_mode(sb)) {
if (sbi->domain_id) {
str = kasprintf(GFP_KERNEL, "%s,%s", sbi->domain_id,
sbi->fsid);
if (!str)
return -ENOMEM;
name = str;
} else {
name = sbi->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", name);
kfree(str);
if (err)
goto put_sb_kobj;
return 0;

put_sb_kobj:
kobject_put(&sbi->s_kobj);
wait_for_completion(&sbi->s_kobj_unregister);
err = kobject_init_and_add(&sbi->s_kobj, &erofs_sb_ktype, NULL, "%s",
sb->s_sysfs_name);
if (err) {
kobject_put(&sbi->s_kobj);
wait_for_completion(&sbi->s_kobj_unregister);
}
return err;
}

Expand Down

0 comments on commit b45adcb

Please sign in to comment.