diff options
author | Artem Bityutskiy <Artem.Bityutskiy@nokia.com> | 2011-06-01 10:43:43 -0400 |
---|---|---|
committer | Artem Bityutskiy <dedekind1@gmail.com> | 2011-07-04 03:54:32 -0400 |
commit | e7717060ddd509e6c305ad7bf5a090a95e91c8cf (patch) | |
tree | 03869be56858dfc5226a94129d528714838e4dc0 /fs/ubifs/debug.c | |
parent | 28488fc28aa39815b78c2cbeaaf25f33fef92ce8 (diff) |
UBIFS: add global debugfs knobs
Now we have per-FS (superblock) debugfs knobs, but they have one drawback - you
have to first mount the FS and only after this you can switch self-checks
on/off. But often we want to have the checks enabled during the mount.
Introduce global debugging knobs for this purpose.
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
Diffstat (limited to 'fs/ubifs/debug.c')
-rw-r--r-- | fs/ubifs/debug.c | 138 |
1 files changed, 129 insertions, 9 deletions
diff --git a/fs/ubifs/debug.c b/fs/ubifs/debug.c index b98638eb0fcb..15bec635bf3e 100644 --- a/fs/ubifs/debug.c +++ b/fs/ubifs/debug.c | |||
@@ -3064,7 +3064,7 @@ out_remove: | |||
3064 | debugfs_remove_recursive(d->dfs_dir); | 3064 | debugfs_remove_recursive(d->dfs_dir); |
3065 | out: | 3065 | out: |
3066 | err = dent ? PTR_ERR(dent) : -ENODEV; | 3066 | err = dent ? PTR_ERR(dent) : -ENODEV; |
3067 | ubifs_err("cannot create \"%s\" debugfs filr or directory, error %d\n", | 3067 | ubifs_err("cannot create \"%s\" debugfs file or directory, error %d\n", |
3068 | fname, err); | 3068 | fname, err); |
3069 | return err; | 3069 | return err; |
3070 | } | 3070 | } |
@@ -3078,6 +3078,74 @@ void dbg_debugfs_exit_fs(struct ubifs_info *c) | |||
3078 | debugfs_remove_recursive(c->dbg->dfs_dir); | 3078 | debugfs_remove_recursive(c->dbg->dfs_dir); |
3079 | } | 3079 | } |
3080 | 3080 | ||
3081 | struct ubifs_global_debug_info ubifs_dbg; | ||
3082 | |||
3083 | static struct dentry *dfs_chk_gen; | ||
3084 | static struct dentry *dfs_chk_index; | ||
3085 | static struct dentry *dfs_chk_orph; | ||
3086 | static struct dentry *dfs_chk_lprops; | ||
3087 | static struct dentry *dfs_chk_fs; | ||
3088 | static struct dentry *dfs_tst_rcvry; | ||
3089 | |||
3090 | static ssize_t dfs_global_file_read(struct file *file, char __user *u, | ||
3091 | size_t count, loff_t *ppos) | ||
3092 | { | ||
3093 | struct dentry *dent = file->f_path.dentry; | ||
3094 | int val; | ||
3095 | |||
3096 | if (dent == dfs_chk_gen) | ||
3097 | val = ubifs_dbg.chk_gen; | ||
3098 | else if (dent == dfs_chk_index) | ||
3099 | val = ubifs_dbg.chk_index; | ||
3100 | else if (dent == dfs_chk_orph) | ||
3101 | val = ubifs_dbg.chk_orph; | ||
3102 | else if (dent == dfs_chk_lprops) | ||
3103 | val = ubifs_dbg.chk_lprops; | ||
3104 | else if (dent == dfs_chk_fs) | ||
3105 | val = ubifs_dbg.chk_fs; | ||
3106 | else if (dent == dfs_tst_rcvry) | ||
3107 | val = ubifs_dbg.tst_rcvry; | ||
3108 | else | ||
3109 | return -EINVAL; | ||
3110 | |||
3111 | return provide_user_output(val, u, count, ppos); | ||
3112 | } | ||
3113 | |||
3114 | static ssize_t dfs_global_file_write(struct file *file, const char __user *u, | ||
3115 | size_t count, loff_t *ppos) | ||
3116 | { | ||
3117 | struct dentry *dent = file->f_path.dentry; | ||
3118 | int val; | ||
3119 | |||
3120 | val = interpret_user_input(u, count); | ||
3121 | if (val < 0) | ||
3122 | return val; | ||
3123 | |||
3124 | if (dent == dfs_chk_gen) | ||
3125 | ubifs_dbg.chk_gen = val; | ||
3126 | else if (dent == dfs_chk_index) | ||
3127 | ubifs_dbg.chk_index = val; | ||
3128 | else if (dent == dfs_chk_orph) | ||
3129 | ubifs_dbg.chk_orph = val; | ||
3130 | else if (dent == dfs_chk_lprops) | ||
3131 | ubifs_dbg.chk_lprops = val; | ||
3132 | else if (dent == dfs_chk_fs) | ||
3133 | ubifs_dbg.chk_fs = val; | ||
3134 | else if (dent == dfs_tst_rcvry) | ||
3135 | ubifs_dbg.tst_rcvry = val; | ||
3136 | else | ||
3137 | return -EINVAL; | ||
3138 | |||
3139 | return count; | ||
3140 | } | ||
3141 | |||
3142 | static const struct file_operations dfs_global_fops = { | ||
3143 | .read = dfs_global_file_read, | ||
3144 | .write = dfs_global_file_write, | ||
3145 | .owner = THIS_MODULE, | ||
3146 | .llseek = no_llseek, | ||
3147 | }; | ||
3148 | |||
3081 | /** | 3149 | /** |
3082 | * dbg_debugfs_init - initialize debugfs file-system. | 3150 | * dbg_debugfs_init - initialize debugfs file-system. |
3083 | * | 3151 | * |
@@ -3088,15 +3156,67 @@ void dbg_debugfs_exit_fs(struct ubifs_info *c) | |||
3088 | */ | 3156 | */ |
3089 | int dbg_debugfs_init(void) | 3157 | int dbg_debugfs_init(void) |
3090 | { | 3158 | { |
3091 | dfs_rootdir = debugfs_create_dir("ubifs", NULL); | 3159 | int err; |
3092 | if (IS_ERR_OR_NULL(dfs_rootdir)) { | 3160 | const char *fname; |
3093 | int err = dfs_rootdir ? PTR_ERR(dfs_rootdir) : -ENODEV; | 3161 | struct dentry *dent; |
3094 | ubifs_err("cannot create \"ubifs\" debugfs directory, " | 3162 | |
3095 | "error %d\n", err); | 3163 | fname = "ubifs"; |
3096 | return err; | 3164 | dent = debugfs_create_dir(fname, NULL); |
3097 | } | 3165 | if (IS_ERR_OR_NULL(dent)) |
3166 | goto out; | ||
3167 | dfs_rootdir = dent; | ||
3168 | |||
3169 | fname = "chk_general"; | ||
3170 | dent = debugfs_create_file(fname, S_IRUSR | S_IWUSR, dfs_rootdir, NULL, | ||
3171 | &dfs_global_fops); | ||
3172 | if (IS_ERR_OR_NULL(dent)) | ||
3173 | goto out_remove; | ||
3174 | dfs_chk_gen = dent; | ||
3175 | |||
3176 | fname = "chk_index"; | ||
3177 | dent = debugfs_create_file(fname, S_IRUSR | S_IWUSR, dfs_rootdir, NULL, | ||
3178 | &dfs_global_fops); | ||
3179 | if (IS_ERR_OR_NULL(dent)) | ||
3180 | goto out_remove; | ||
3181 | dfs_chk_index = dent; | ||
3182 | |||
3183 | fname = "chk_orphans"; | ||
3184 | dent = debugfs_create_file(fname, S_IRUSR | S_IWUSR, dfs_rootdir, NULL, | ||
3185 | &dfs_global_fops); | ||
3186 | if (IS_ERR_OR_NULL(dent)) | ||
3187 | goto out_remove; | ||
3188 | dfs_chk_orph = dent; | ||
3189 | |||
3190 | fname = "chk_lprops"; | ||
3191 | dent = debugfs_create_file(fname, S_IRUSR | S_IWUSR, dfs_rootdir, NULL, | ||
3192 | &dfs_global_fops); | ||
3193 | if (IS_ERR_OR_NULL(dent)) | ||
3194 | goto out_remove; | ||
3195 | dfs_chk_lprops = dent; | ||
3196 | |||
3197 | fname = "chk_fs"; | ||
3198 | dent = debugfs_create_file(fname, S_IRUSR | S_IWUSR, dfs_rootdir, NULL, | ||
3199 | &dfs_global_fops); | ||
3200 | if (IS_ERR_OR_NULL(dent)) | ||
3201 | goto out_remove; | ||
3202 | dfs_chk_fs = dent; | ||
3203 | |||
3204 | fname = "tst_recovery"; | ||
3205 | dent = debugfs_create_file(fname, S_IRUSR | S_IWUSR, dfs_rootdir, NULL, | ||
3206 | &dfs_global_fops); | ||
3207 | if (IS_ERR_OR_NULL(dent)) | ||
3208 | goto out_remove; | ||
3209 | dfs_tst_rcvry = dent; | ||
3098 | 3210 | ||
3099 | return 0; | 3211 | return 0; |
3212 | |||
3213 | out_remove: | ||
3214 | debugfs_remove_recursive(dfs_rootdir); | ||
3215 | out: | ||
3216 | err = dent ? PTR_ERR(dent) : -ENODEV; | ||
3217 | ubifs_err("cannot create \"%s\" debugfs file or directory, error %d\n", | ||
3218 | fname, err); | ||
3219 | return err; | ||
3100 | } | 3220 | } |
3101 | 3221 | ||
3102 | /** | 3222 | /** |
@@ -3104,7 +3224,7 @@ int dbg_debugfs_init(void) | |||
3104 | */ | 3224 | */ |
3105 | void dbg_debugfs_exit(void) | 3225 | void dbg_debugfs_exit(void) |
3106 | { | 3226 | { |
3107 | debugfs_remove(dfs_rootdir); | 3227 | debugfs_remove_recursive(dfs_rootdir); |
3108 | } | 3228 | } |
3109 | 3229 | ||
3110 | /** | 3230 | /** |