Skip to contentSkip to conversation

f2fs: remove bulk remove_proc_entry() and unnecessary kobject_del()

PATCH Applied Yangtao Li 4 participants 5 messages Apr 6, 2023 – Apr 17, 2023 F2FS file system

lore
Share & tools
lore

Yangtao Li

author
#0 lore raw

PATCH 1/1 f2fs: remove bulk remove_proc_entry() and unnecessary kobject_del()

Convert to use remove_proc_subtree() and kill kobject_del() directly. kobject_put() actually covers kobject removal automatically, which is single stage removal.

---
 fs/f2fs/sysfs.c | 15 ++-------------
 1 file changed, 2 insertions(+), 13 deletions(-)
fs/f2fs/sysfs.c +2 -13
index dfbd17802549..3aad3500a701 100644
@@ -1461,25 +1461,14 @@ int f2fs_register_sysfs(struct f2fs_sb_info *sbi)
 
 void f2fs_unregister_sysfs(struct f2fs_sb_info *sbi)
 {
-	if (sbi->s_proc) {
-#ifdef CONFIG_F2FS_IOSTAT
-		remove_proc_entry("iostat_info", sbi->s_proc);
-#endif
-		remove_proc_entry("segment_info", sbi->s_proc);
-		remove_proc_entry("segment_bits", sbi->s_proc);
-		remove_proc_entry("victim_bits", sbi->s_proc);
-		remove_proc_entry("discard_plist_info", sbi->s_proc);
-		remove_proc_entry(sbi->sb->s_id, f2fs_proc_root);
-	}
+	if (sbi->s_proc)
+		remove_proc_subtree(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
maintainer
#1 lore raw
Quoted 21 lines · Yangtao Li

Convert to use remove_proc_subtree() and kill kobject_del() directly. kobject_put() actually covers kobject removal automatically, which is single stage removal.

---
  fs/f2fs/sysfs.c | 15 ++-------------
  1 file changed, 2 insertions(+), 13 deletions(-)
fs/f2fs/sysfs.c +0 -4
index dfbd17802549..3aad3500a701 100644
@@ -1461,25 +1461,14 @@ int f2fs_register_sysfs(struct f2fs_sb_info *sbi)
 
  void f2fs_unregister_sysfs(struct f2fs_sb_info *sbi)
  {
-	if (sbi->s_proc) {
-#ifdef CONFIG_F2FS_IOSTAT
-		remove_proc_entry("iostat_info", sbi->s_proc);
-#endif

fs/f2fs/sysfs.c int f2fs_register_sysfs(struct f2fs_sb_info *sbi) · line 1475

Quoted 10 lines
fs/f2fs/sysfs.c +2 -7
-		remove_proc_entry("segment_info", sbi->s_proc);
-		remove_proc_entry("segment_bits", sbi->s_proc);
-		remove_proc_entry("victim_bits", sbi->s_proc);
-		remove_proc_entry("discard_plist_info", sbi->s_proc);
-		remove_proc_entry(sbi->sb->s_id, f2fs_proc_root);
-	}
+	if (sbi->s_proc)
+		remove_proc_subtree(sbi->sb->s_id, f2fs_proc_root);
 
-	kobject_del(&sbi->s_stat_kobj);

- f2fs_register_sysfs
- kobject_init_and_add(&sbi->s_stat_kobj, ..)

/**
* kobject_init_and_add() - Initialize a kobject structure and add it to
* the kobject hierarchy.
...
*
* This function combines the call to kobject_init() and kobject_add().
...
*/

/**
* kobject_del() - Unlink kobject from hierarchy.
* @kobj: object.
*
* This is the function that should be called to delete an object
* successfully added via kobject_add().
*/

Am I missing something?

Thanks,

fs/f2fs/sysfs.c int f2fs_register_sysfs(struct f2fs_sb_info *sbi) · line 1474

Quoted 10 lines
fs/f2fs/sysfs.c +0 -2
  	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);
  }

_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

maintainer
#2 lore raw
Quoted 51 lines · Chao Yu
Quoted 19 lines · Yangtao Li

Convert to use remove_proc_subtree() and kill kobject_del() directly. kobject_put() actually covers kobject removal automatically, which is single stage removal.

---
  fs/f2fs/sysfs.c | 15 ++-------------
  1 file changed, 2 insertions(+), 13 deletions(-)
fs/f2fs/sysfs.c +0 -3
index dfbd17802549..3aad3500a701 100644
@@ -1461,25 +1461,14 @@ int f2fs_register_sysfs(struct f2fs_sb_info *sbi)
  void f2fs_unregister_sysfs(struct f2fs_sb_info *sbi)
  {
-	if (sbi->s_proc) {
-#ifdef CONFIG_F2FS_IOSTAT
-		remove_proc_entry("iostat_info", sbi->s_proc);

fs/f2fs/sysfs.c int f2fs_register_sysfs(struct f2fs_sb_info *sbi) · line 1473

Quoted 10 lines
fs/f2fs/sysfs.c +2 -8
-#endif
-		remove_proc_entry("segment_info", sbi->s_proc);
-		remove_proc_entry("segment_bits", sbi->s_proc);
-		remove_proc_entry("victim_bits", sbi->s_proc);
-		remove_proc_entry("discard_plist_info", sbi->s_proc);
-		remove_proc_entry(sbi->sb->s_id, f2fs_proc_root);
-	}
+	if (sbi->s_proc)
+		remove_proc_subtree(sbi->sb->s_id, f2fs_proc_root);
-	kobject_del(&sbi->s_stat_kobj);

- f2fs_register_sysfs
- kobject_init_and_add(&sbi->s_stat_kobj, ..)

/**
* kobject_init_and_add() - Initialize a kobject structure and add it to
* the kobject hierarchy.
...
*
* This function combines the call to kobject_init() and kobject_add().
...
*/

/**
* kobject_del() - Unlink kobject from hierarchy.
* @kobj: object.
*
* This is the function that should be called to delete an object
* successfully added via kobject_add().
*/

Quoted 1 line

Am I missing something?

kobject_put -> kobject_cleanup was supposed to do it?

Quoted 12 lines

Thanks,

Quoted 9 lines
fs/f2fs/sysfs.c +0 -2
  	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);
  }
maintainer Reviewed-by
#3 lore raw
Quoted 52 lines · Jaegeuk Kim
Quoted 51 lines · Chao Yu
Quoted 19 lines · Yangtao Li

Convert to use remove_proc_subtree() and kill kobject_del() directly. kobject_put() actually covers kobject removal automatically, which is single stage removal.

---
   fs/f2fs/sysfs.c | 15 ++-------------
   1 file changed, 2 insertions(+), 13 deletions(-)
fs/f2fs/sysfs.c +0 -3
index dfbd17802549..3aad3500a701 100644
@@ -1461,25 +1461,14 @@ int f2fs_register_sysfs(struct f2fs_sb_info *sbi)
   void f2fs_unregister_sysfs(struct f2fs_sb_info *sbi)
   {
-	if (sbi->s_proc) {
-#ifdef CONFIG_F2FS_IOSTAT
-		remove_proc_entry("iostat_info", sbi->s_proc);

fs/f2fs/sysfs.c int f2fs_register_sysfs(struct f2fs_sb_info *sbi) · line 1473

Quoted 10 lines
fs/f2fs/sysfs.c +2 -8
-#endif
-		remove_proc_entry("segment_info", sbi->s_proc);
-		remove_proc_entry("segment_bits", sbi->s_proc);
-		remove_proc_entry("victim_bits", sbi->s_proc);
-		remove_proc_entry("discard_plist_info", sbi->s_proc);
-		remove_proc_entry(sbi->sb->s_id, f2fs_proc_root);
-	}
+	if (sbi->s_proc)
+		remove_proc_subtree(sbi->sb->s_id, f2fs_proc_root);
-	kobject_del(&sbi->s_stat_kobj);

- f2fs_register_sysfs
- kobject_init_and_add(&sbi->s_stat_kobj, ..)

/**
* kobject_init_and_add() - Initialize a kobject structure and add it to
* the kobject hierarchy.
...
*
* This function combines the call to kobject_init() and kobject_add().
...
*/

/**
* kobject_del() - Unlink kobject from hierarchy.
* @kobj: object.
*
* This is the function that should be called to delete an object
* successfully added via kobject_add().
*/

Quoted 3 lines
Quoted 1 line

Am I missing something?

kobject_put -> kobject_cleanup was supposed to do it?

Yes, it seems so.

Thanks,

Quoted 13 lines
Quoted 13 lines

Thanks,

Quoted 9 lines
fs/f2fs/sysfs.c +0 -2
   	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);
   }
#4 lore raw
In reply to Yangtao Li
This patch was applied to jaegeuk/f2fs.git (dev) by Jaegeuk Kim <[email protected]>:

Hello:

This patch was applied to jaegeuk/f2fs.git (dev)
by Jaegeuk Kim <[email protected]>:

Quoted 8 lines · On Fri, 7 Apr 2023 03:16:29 +0800 you wrote:

Convert to use remove_proc_subtree() and kill kobject_del() directly. kobject_put() actually covers kobject removal automatically, which is single stage removal.

---
 fs/f2fs/sysfs.c | 15 ++-------------
 1 file changed, 2 insertions(+), 13 deletions(-)

Here is the summary with links:
- [f2fs-dev] f2fs: remove bulk remove_proc_entry() and unnecessary kobject_del()

    https://git.kernel.org/jaegeuk/f2fs/c/33560f8020c2

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html