Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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.

Signed-off-by: Jianpeng Ma <majianpeng@gmail.com>
Signed-off-by: Namjae Jeon <namjae.jeon@samsung.com>
Signed-off-by: Amit Sahrawat <a.sahrawat@samsung.com>
Signed-off-by: Jaegeuk Kim <jaegeuk.kim@samsung.com>

authored by

Namjae Jeon and committed by
Jaegeuk Kim
4589d25d 66af62ce

+19 -21
+10 -17
fs/f2fs/debug.c
··· 300 300 .release = single_release, 301 301 }; 302 302 303 - static int init_stats(struct f2fs_sb_info *sbi) 303 + int f2fs_build_stats(struct f2fs_sb_info *sbi) 304 304 { 305 305 struct f2fs_super_block *raw_super = F2FS_RAW_SUPER(sbi); 306 306 struct f2fs_stat_info *si; ··· 327 327 return 0; 328 328 } 329 329 330 - int f2fs_build_stats(struct f2fs_sb_info *sbi) 331 - { 332 - int retval; 333 - 334 - retval = init_stats(sbi); 335 - if (retval) 336 - return retval; 337 - 338 - if (!debugfs_root) 339 - debugfs_root = debugfs_create_dir("f2fs", NULL); 340 - 341 - debugfs_create_file("status", S_IRUGO, debugfs_root, NULL, &stat_fops); 342 - return 0; 343 - } 344 - 345 330 void f2fs_destroy_stats(struct f2fs_sb_info *sbi) 346 331 { 347 332 struct f2fs_stat_info *si = sbi->stat_info; ··· 338 353 kfree(sbi->stat_info); 339 354 } 340 355 341 - void destroy_root_stats(void) 356 + void __init f2fs_create_root_stats(void) 357 + { 358 + debugfs_root = debugfs_create_dir("f2fs", NULL); 359 + if (debugfs_root) 360 + debugfs_create_file("status", S_IRUGO, debugfs_root, 361 + NULL, &stat_fops); 362 + } 363 + 364 + void f2fs_destroy_root_stats(void) 342 365 { 343 366 debugfs_remove_recursive(debugfs_root); 344 367 debugfs_root = NULL;
+4 -2
fs/f2fs/f2fs.h
··· 1060 1060 1061 1061 int f2fs_build_stats(struct f2fs_sb_info *); 1062 1062 void f2fs_destroy_stats(struct f2fs_sb_info *); 1063 - void destroy_root_stats(void); 1063 + void f2fs_create_root_stats(void); 1064 + void f2fs_destroy_root_stats(void); 1064 1065 #else 1065 1066 #define stat_inc_call_count(si) 1066 1067 #define stat_inc_seg_count(si, type) ··· 1071 1070 1072 1071 static inline int f2fs_build_stats(struct f2fs_sb_info *sbi) { return 0; } 1073 1072 static inline void f2fs_destroy_stats(struct f2fs_sb_info *sbi) { } 1074 - static inline void destroy_root_stats(void) { } 1073 + static inline void f2fs_create_root_stats(void) { } 1074 + static inline void f2fs_destroy_root_stats(void) { } 1075 1075 #endif 1076 1076 1077 1077 extern const struct file_operations f2fs_dir_operations;
+5 -2
fs/f2fs/super.c
··· 675 675 err = create_checkpoint_caches(); 676 676 if (err) 677 677 goto fail; 678 - return register_filesystem(&f2fs_fs_type); 678 + err = register_filesystem(&f2fs_fs_type); 679 + if (err) 680 + goto fail; 681 + f2fs_create_root_stats(); 679 682 fail: 680 683 return err; 681 684 } 682 685 683 686 static void __exit exit_f2fs_fs(void) 684 687 { 685 - destroy_root_stats(); 688 + f2fs_destroy_root_stats(); 686 689 unregister_filesystem(&f2fs_fs_type); 687 690 destroy_checkpoint_caches(); 688 691 destroy_gc_caches();