Skip to contentSkip to conversation

f2fs:avoid creaing multi debugfs when mount more disks.

PATCH Jaegeuk Kim 2 participants 6 messages Jan 15, 2013 1 message not in the archive

Subsystems (2)
lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw

Hi Jianpeng,

Could you review the following patch that was originally written by you? I added some description and fixed typos.
Thanks,

From e80c3ff6f7cab22cb866a05f63897e950c5a6f9e Mon Sep 17 00:00:00 2001
From: majianpeng <[email protected]>
Date: Mon, 14 Jan 2013 19:29:10 +0800
Subject: [PATCH] f2fs: avoid creating multi debugfs entries when mounting many disks

When f2fs is mounted on multiple disks, it should avoid redundant status files.
One status file contains the whole f2fs information.

[[email protected]: fix subject and add description]
---
 fs/f2fs/debug.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
fs/f2fs/debug.c +1 -3
index b8ed7a7..0c374d1 100644
@@ -336,10 +336,11 @@ int f2fs_build_stats(struct f2fs_sb_info *sbi)
 	if (retval)
 		return retval;
 
-	if (!debugfs_root)
+	if (!debugfs_root) {
 		debugfs_root = debugfs_create_dir("f2fs", NULL);
-
-	debugfs_create_file("status", S_IRUGO, debugfs_root, NULL,

&stat_fops);
+ debugfs_create_file("status", S_IRUGO, debugfs_root, NULL,
+ &stat_fops);
+ }
return 0;
}

Signature · 7 lines
1.8.0.1.250.gb7973fb



-- 
Jaegeuk Kim
Samsung
#2 lore raw

2013/1/15, Jaegeuk Kim <[email protected]>:

Quoted 5 lines

Hi Jianpeng,

Could you review the following patch that was originally written by you? I added some description and fixed typos.
Thanks,

Hi Jaegeuk.

How about change like this ?

--------------------------------------------------------------------------------------
Subject: [PATCH] f2fs: fix the debugfs entry creation path

As the "status" debugfs entry will be maintained for entire F2FS filesystem irrespective of the number of partitions.
So, we can move the initialization to the init part of the f2fs and destroy will be done from exit part. After making changes, for individual partition mount - entry creation code will not be executed.

---
 fs/f2fs/debug.c |   27 ++++++++++-----------------
 fs/f2fs/f2fs.h  |    6 ++++--
 fs/f2fs/super.c |    7 +++++--
 3 files changed, 19 insertions(+), 21 deletions(-)
fs/f2fs/debug.c +10 -17
index 0e0380a..5164fba 100644
@@ -303,7 +303,7 @@ static const struct file_operations stat_fops = {
 	.release = single_release,
 };
 
-static int init_stats(struct f2fs_sb_info *sbi)
+int f2fs_build_stats(struct f2fs_sb_info *sbi)
 {
 	struct f2fs_super_block *raw_super = F2FS_RAW_SUPER(sbi);
 	struct f2fs_stat_info *si;
@@ -328,21 +328,6 @@ static int init_stats(struct f2fs_sb_info *sbi)
 	return 0;
 }
 
-int f2fs_build_stats(struct f2fs_sb_info *sbi)
-{
-	int retval;
-
-	retval = init_stats(sbi);
-	if (retval)
-		return retval;
-
-	if (!debugfs_root)
-		debugfs_root = debugfs_create_dir("f2fs", NULL);
-
-	debugfs_create_file("status", S_IRUGO, debugfs_root, NULL, &stat_fops);
-	return 0;
-}
-
 void f2fs_destroy_stats(struct f2fs_sb_info *sbi)
 {
 	struct f2fs_stat_info *si = sbi->stat_info;
@@ -354,7 +339,15 @@ void f2fs_destroy_stats(struct f2fs_sb_info *sbi)
 	kfree(sbi->stat_info);
 }
 
-void destroy_root_stats(void)
+void __init f2fs_create_root_stats(void)
+{
+	debugfs_root = debugfs_create_dir("f2fs", NULL);
+	if (debugfs_root)
+		debugfs_create_file("status", S_IRUGO, debugfs_root,
+					 NULL, &stat_fops);
+}
+
+void f2fs_destroy_root_stats(void)
 {
 	debugfs_remove_recursive(debugfs_root);
 	debugfs_root = NULL;
fs/f2fs/f2fs.h +4 -2
index ee967fd..6278ff9 100644
@@ -1060,7 +1060,8 @@ struct f2fs_stat_info {
 
 int f2fs_build_stats(struct f2fs_sb_info *);
 void f2fs_destroy_stats(struct f2fs_sb_info *);
-void destroy_root_stats(void);
+void f2fs_create_root_stats(void);
+void f2fs_destroy_root_stats(void);
 #else
 #define stat_inc_call_count(si)
 #define stat_inc_seg_count(si, type)
@@ -1070,7 +1071,8 @@ void destroy_root_stats(void);
 
 static inline int f2fs_build_stats(struct f2fs_sb_info *sbi) { return 0; }
 static inline void f2fs_destroy_stats(struct f2fs_sb_info *sbi) { }
-static inline void destroy_root_stats(void) { }
+static inline void f2fs_create_root_stats(void) { }
+static inline void f2fs_destroy_root_stats(void) { }
 #endif
 
 extern const struct file_operations f2fs_dir_operations;
fs/f2fs/super.c +5 -2
index 6cdaa69..f6714e2 100644
@@ -671,14 +671,17 @@ static int __init init_f2fs_fs(void)
 	err = create_checkpoint_caches();
 	if (err)
 		goto fail;
-	return register_filesystem(&f2fs_fs_type);
+	err = register_filesystem(&f2fs_fs_type);
+	if (err)
+		goto fail;
+	f2fs_create_root_stats();
 fail:
 	return err;
 }
 
 static void __exit exit_f2fs_fs(void)
 {
-	destroy_root_stats();
+	f2fs_destroy_root_stats();
 	unregister_filesystem(&f2fs_fs_type);
 	destroy_checkpoint_caches();
 	destroy_gc_caches();
Signature · 5 lines
1.7.2.3



-----------------------
Quoted 47 lines

From e80c3ff6f7cab22cb866a05f63897e950c5a6f9e Mon Sep 17 00:00:00 2001
From: majianpeng <[email protected]>
Date: Mon, 14 Jan 2013 19:29:10 +0800
Subject: [PATCH] f2fs: avoid creating multi debugfs entries when mounting many disks

When f2fs is mounted on multiple disks, it should avoid redundant status files.
One status file contains the whole f2fs information.

[[email protected]: fix subject and add description]
---
 fs/f2fs/debug.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
fs/f2fs/debug.c +4 -4
index b8ed7a7..0c374d1 100644
@@ -336,10 +336,11 @@ int f2fs_build_stats(struct f2fs_sb_info *sbi)
 	if (retval)
 		return retval;
 
-	if (!debugfs_root)
+	if (!debugfs_root) {
 		debugfs_root = debugfs_create_dir("f2fs", NULL);
-
-	debugfs_create_file("status", S_IRUGO, debugfs_root, NULL,
 &stat_fops);
+		debugfs_create_file("status", S_IRUGO, debugfs_root, NULL,
+							&stat_fops);
+	}
 	return 0;
 }
 
--

1.8.0.1.250.gb7973fb

--
Jaegeuk Kim
Samsung

#3 lore raw

[snip]

fs/f2fs/debug.c void f2fs_destroy_stats(struct f2fs_sb_info *sbi) · line 342

Quoted 9 lines

void f2fs_destroy_stats(struct f2fs_sb_info *sbi) {

fs/f2fs/debug.c +1 -1
 	struct f2fs_stat_info *si = sbi->stat_info;
@@ -354,7 +339,15 @@ void f2fs_destroy_stats(struct f2fs_sb_info *sbi)
 	kfree(sbi->stat_info);
 }
 
-void destroy_root_stats(void)
+void __init f2fs_create_root_stats(void)

We don't need to add __init here, right?
Anyway, this patch looks much better to me.

Jianpeng, how do you think about this?

Signature · 2 lines
Jaegeuk Kim
Samsung
#4 lore raw

2013/1/15, Jaegeuk Kim <[email protected]>:

Quoted 9 lines

[snip]

Quoted 7 lines

void f2fs_destroy_stats(struct f2fs_sb_info *sbi) {

fs/f2fs/debug.c +0 -0
 	struct f2fs_stat_info *si = sbi->stat_info;
@@ -354,7 +339,15 @@ void f2fs_destroy_stats(struct f2fs_sb_info *sbi)
 	kfree(sbi->stat_info);
 }
 
Quoted 4 lines

fs/f2fs/debug.c void f2fs_destroy_stats(struct f2fs_sb_info *sbi) · line 342

Quoted 2 lines
fs/f2fs/debug.c +1 -1
-void destroy_root_stats(void)
+void __init f2fs_create_root_stats(void)

We don't need to add __init here, right?

As you know, the function f2fs_create_root_stats will only be needed at the init time of F2FS filesystem. So, there is no harm making this function part of __init section, as this function will never be called again.
Thanks.

Quoted 8 lines

Anyway, this patch looks much better to me.

Jianpeng, how do you think about this?

--
Jaegeuk Kim
Samsung

#5 lore raw

2013-01-15 (화), 20:50 +0900, Namjae Jeon:

Quoted 10 lines

2013/1/15, Jaegeuk Kim <[email protected]>:

Quoted 9 lines

[snip]

Quoted 7 lines

void f2fs_destroy_stats(struct f2fs_sb_info *sbi) {

fs/f2fs/debug.c +0 -0
 	struct f2fs_stat_info *si = sbi->stat_info;
@@ -354,7 +339,15 @@ void f2fs_destroy_stats(struct f2fs_sb_info *sbi)
 	kfree(sbi->stat_info);
 }
 
Quoted 8 lines
Quoted 4 lines

fs/f2fs/debug.c void f2fs_destroy_stats(struct f2fs_sb_info *sbi) · line 342

Quoted 2 lines
fs/f2fs/debug.c +1 -1
-void destroy_root_stats(void)
+void __init f2fs_create_root_stats(void)

We don't need to add __init here, right?

As you know, the function f2fs_create_root_stats will only be needed at the init time of F2FS filesystem. So, there is no harm making this function part of __init section, as this function will never be called again.

Oh, I meant it for code consistency at this moment. No other functions declare that though.
Do we need to write another patch to add __init globally?

Quoted 9 lines

Thanks.

Quoted 8 lines

Anyway, this patch looks much better to me.

Jianpeng, how do you think about this?

--
Jaegeuk Kim
Samsung

Signature · 2 lines
Jaegeuk Kim
Samsung
#6 lore raw

2013/1/15, Jaegeuk Kim <[email protected]>:

Quoted 15 lines

2013-01-15 (화), 20:50 +0900, Namjae Jeon:

Quoted 14 lines

2013/1/15, Jaegeuk Kim <[email protected]>:

Quoted 13 lines

[snip]

fs/f2fs/debug.c void f2fs_destroy_stats(struct f2fs_sb_info *sbi) · line 342

Quoted 9 lines

void f2fs_destroy_stats(struct f2fs_sb_info *sbi) {

fs/f2fs/debug.c +1 -1
 	struct f2fs_stat_info *si = sbi->stat_info;
@@ -354,7 +339,15 @@ void f2fs_destroy_stats(struct f2fs_sb_info *sbi)
 	kfree(sbi->stat_info);
 }
 
-void destroy_root_stats(void)
+void __init f2fs_create_root_stats(void)

We don't need to add __init here, right?

Quoted 8 lines
Quoted 4 lines

As you know, the function f2fs_create_root_stats will only be needed at the init time of F2FS filesystem. So, there is no harm making this function part of __init section, as this function will never be called again.

Oh, I meant it for code consistency at this moment. No other functions declare that though.
Do we need to write another patch to add __init globally?

Yes, needed. I will send you another patch for __init today.

Thank you !

Quoted 6 lines
Quoted 6 lines

Thanks.

Quoted 4 lines

Anyway, this patch looks much better to me.

Jianpeng, how do you think about this?

Quoted 9 lines
Quoted 4 lines
Quoted 4 lines

--
Jaegeuk Kim
Samsung

--
Jaegeuk Kim
Samsung

--
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html