f2fs: remove unnecessary kobject_del()
Subsystems (2)
PATCH 1/2 f2fs: remove unnecessary kobject_del()
kobject_put() actually covers kobject removal automatically, which is single stage removal. So it is safe to kill kobject_del() directly.
--- fs/f2fs/sysfs.c | 3 --- 1 file changed, 3 deletions(-)
fs/f2fs/sysfs.c +0 -3
@@ -1472,14 +1472,11 @@ void f2fs_unregister_sysfs(struct f2fs_sb_info *sbi)remove_proc_entry (sbi->sb->s_id, f2fs_proc_root); } -kobject_del (&sbi->s_stat_kobj);kobject_put (&sbi->s_stat_kobj);wait_for_completion (&sbi->s_stat_kobj_unregister); -kobject_del (&sbi->s_feature_list_kobj);kobject_put (&sbi->s_feature_list_kobj);wait_for_completion (&sbi->s_feature_list_kobj_unregister); -kobject_del (&sbi->s_kobj);kobject_put (&sbi->s_kobj);wait_for_completion (&sbi->s_kobj_unregister); }
Signature · 1 line
2.35.1
PATCH 2/2 erofs: remove unnecessary kobject_del()
kobject_put() actually covers kobject removal automatically, which is single stage removal. So it is safe to kill kobject_del() directly.
--- fs/erofs/sysfs.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-)
fs/erofs/sysfs.c +2 -5
@@ -240,11 +240,8 @@ void erofs_unregister_sysfs(struct super_block *sb) {struct erofs_sb_info *sbi =EROFS_SB (sb); -if (sbi->s_kobj.state_in_sysfs) { -kobject_del (&sbi->s_kobj); -kobject_put (&sbi->s_kobj); -wait_for_completion (&sbi->s_kobj_unregister); - } +kobject_put (&sbi->s_kobj); +wait_for_completion (&sbi->s_kobj_unregister); }int __init erofs_init_sysfs (void )
Signature · 1 line
2.35.1
Re: [PATCH 2/2] erofs: remove unnecessary kobject_del()
Hi Yangtao,
Quoted 4 lines · Yangtao Li
kobject_put()actually covers kobject removal automatically, which is single stage removal. So it is safe to killkobject_del()directly.Signed-off-by Yangtao Li <[email protected]>
Would you mind taking a look at
commit a942da24abc5 ("fs: erofs: add sanity check for kobject in erofs_unregister_sysfs")
, which could be "git-blame"ed (I'd suggest looking into these blame first), and the related discussion was:
https://lore.kernel.org/r/CAD-N9QXNx=p3-QoWzk6pCznF32CZy8kM3vvo8mamfZZ9CpUKdw@mail.gmail.com
https://lore.kernel.org/r/[email protected]
TL;DR: I guess it could be fixed as below if kobject_del() could be killed safely:
if (sbi->s_kobj.state_in_sysfs) {
kobject_put(&sbi->s_kobj);
wait_for_completion(&sbi->s_kobj_unregister);
}Thanks,
Gao Xiang
Quoted 22 lines
--- fs/erofs/sysfs.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-)fs/erofs/sysfs.c +2
-5@@ -240,11 +240,8 @@ void erofs_unregister_sysfs(struct super_block *sb) {struct erofs_sb_info *sbi =EROFS_SB (sb); -if (sbi->s_kobj.state_in_sysfs) { -kobject_del (&sbi->s_kobj); -kobject_put (&sbi->s_kobj); -wait_for_completion (&sbi->s_kobj_unregister); - } +kobject_put (&sbi->s_kobj); +wait_for_completion (&sbi->s_kobj_unregister); }int __init erofs_init_sysfs (void )
Re: [PATCH 2/2] erofs: remove unnecessary kobject_del()
HI Gao Xiang,
Quoted 9 lines
Would you mind taking a look at
commita942da24abc5("fs: erofs: add sanity check for kobject inerofs_unregister_sysfs"), which could be "git-blame"ed (I'd suggest looking into these blame first), and the related discussion was:
https://lore.kernel.org/r/CAD-N9QXNx=p3-QoWzk6pCznF32CZy8kM3vvo8mamfZZ9CpUKdw@mail.gmail.com
https://lore.kernel.org/r/[email protected]
Quoted 7 lines
TL;DR: I guess it could be fixed as below if
kobject_del()could : be killed safely:if (sbi->s_kobj.state_in_sysfs) { kobject_put(&sbi->s_kobj); wait_for_completion(&sbi->s_kobj_unregister); }
Thanks for your review and detailed explanation.
MBR,
Yangtao