f2fs: report error of f2fs_create_root_stats

f2fs_create_root_stats can fail due to no memory, report it to user.

Signed-off-by: Chao Yu <chao2.yu@samsung.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
This commit is contained in:
Chao Yu 2015-10-29 09:13:04 +08:00 committed by Jaegeuk Kim
parent fb39cbda14
commit 787c7b8cb3
3 changed files with 12 additions and 5 deletions

View File

@ -406,20 +406,23 @@ void f2fs_destroy_stats(struct f2fs_sb_info *sbi)
kfree(si); kfree(si);
} }
void __init f2fs_create_root_stats(void) int __init f2fs_create_root_stats(void)
{ {
struct dentry *file; struct dentry *file;
f2fs_debugfs_root = debugfs_create_dir("f2fs", NULL); f2fs_debugfs_root = debugfs_create_dir("f2fs", NULL);
if (!f2fs_debugfs_root) if (!f2fs_debugfs_root)
return; return -ENOMEM;
file = debugfs_create_file("status", S_IRUGO, f2fs_debugfs_root, file = debugfs_create_file("status", S_IRUGO, f2fs_debugfs_root,
NULL, &stat_fops); NULL, &stat_fops);
if (!file) { if (!file) {
debugfs_remove(f2fs_debugfs_root); debugfs_remove(f2fs_debugfs_root);
f2fs_debugfs_root = NULL; f2fs_debugfs_root = NULL;
return -ENOMEM;
} }
return 0;
} }
void f2fs_destroy_root_stats(void) void f2fs_destroy_root_stats(void)

View File

@ -1987,7 +1987,7 @@ static inline struct f2fs_stat_info *F2FS_STAT(struct f2fs_sb_info *sbi)
int f2fs_build_stats(struct f2fs_sb_info *); int f2fs_build_stats(struct f2fs_sb_info *);
void f2fs_destroy_stats(struct f2fs_sb_info *); void f2fs_destroy_stats(struct f2fs_sb_info *);
void __init f2fs_create_root_stats(void); int __init f2fs_create_root_stats(void);
void f2fs_destroy_root_stats(void); void f2fs_destroy_root_stats(void);
#else #else
#define stat_inc_cp_count(si) #define stat_inc_cp_count(si)
@ -2015,7 +2015,7 @@ void f2fs_destroy_root_stats(void);
static inline int f2fs_build_stats(struct f2fs_sb_info *sbi) { return 0; } 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 f2fs_destroy_stats(struct f2fs_sb_info *sbi) { }
static inline void __init f2fs_create_root_stats(void) { } static inline int __init f2fs_create_root_stats(void) { return 0; }
static inline void f2fs_destroy_root_stats(void) { } static inline void f2fs_destroy_root_stats(void) { }
#endif #endif

View File

@ -1478,10 +1478,14 @@ static int __init init_f2fs_fs(void)
err = register_filesystem(&f2fs_fs_type); err = register_filesystem(&f2fs_fs_type);
if (err) if (err)
goto free_shrinker; goto free_shrinker;
f2fs_create_root_stats(); err = f2fs_create_root_stats();
if (err)
goto free_filesystem;
f2fs_proc_root = proc_mkdir("fs/f2fs", NULL); f2fs_proc_root = proc_mkdir("fs/f2fs", NULL);
return 0; return 0;
free_filesystem:
unregister_filesystem(&f2fs_fs_type);
free_shrinker: free_shrinker:
unregister_shrinker(&f2fs_shrinker_info); unregister_shrinker(&f2fs_shrinker_info);
free_crypto: free_crypto: