diff options
author | Artem Bityutskiy <Artem.Bityutskiy@linux.intel.com> | 2012-07-14 07:19:46 -0400 |
---|---|---|
committer | Artem Bityutskiy <artem.bityutskiy@linux.intel.com> | 2012-07-20 03:27:25 -0400 |
commit | 06bef9451a4c5ad882cd15fd7a0df9890c0249f3 (patch) | |
tree | abd269a573e5ffce8b7e92c39cc3000ca1ecb944 /fs/ubifs | |
parent | 782759b9f5f5223e0962af60c3457c912fab755f (diff) |
UBIFS: add debugfs knob to switch to R/O mode
This patch adds another debugfs knob which switches UBIFS to R/O mode.
I needed it while trying to reproduce the 'first log node is not CS node'
bug. Without this debugfs knob you have to perform a power cut to repruduce
the bug. The knob is named 'ro_error' and all it does is it sets the
'ro_error' UBIFS flag which makes UBIFS disallow any further writes - even
write-back will fail with -EROFS. Useful for debugging.
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@linux.intel.com>
Diffstat (limited to 'fs/ubifs')
-rw-r--r-- | fs/ubifs/debug.c | 11 | ||||
-rw-r--r-- | fs/ubifs/debug.h | 5 |
2 files changed, 16 insertions, 0 deletions
diff --git a/fs/ubifs/debug.c b/fs/ubifs/debug.c index 92df3b081539..bb3167257aab 100644 --- a/fs/ubifs/debug.c +++ b/fs/ubifs/debug.c | |||
@@ -2802,6 +2802,8 @@ static ssize_t dfs_file_read(struct file *file, char __user *u, size_t count, | |||
2802 | val = d->chk_fs; | 2802 | val = d->chk_fs; |
2803 | else if (dent == d->dfs_tst_rcvry) | 2803 | else if (dent == d->dfs_tst_rcvry) |
2804 | val = d->tst_rcvry; | 2804 | val = d->tst_rcvry; |
2805 | else if (dent == d->dfs_ro_error) | ||
2806 | val = c->ro_error; | ||
2805 | else | 2807 | else |
2806 | return -EINVAL; | 2808 | return -EINVAL; |
2807 | 2809 | ||
@@ -2885,6 +2887,8 @@ static ssize_t dfs_file_write(struct file *file, const char __user *u, | |||
2885 | d->chk_fs = val; | 2887 | d->chk_fs = val; |
2886 | else if (dent == d->dfs_tst_rcvry) | 2888 | else if (dent == d->dfs_tst_rcvry) |
2887 | d->tst_rcvry = val; | 2889 | d->tst_rcvry = val; |
2890 | else if (dent == d->dfs_ro_error) | ||
2891 | c->ro_error = !!val; | ||
2888 | else | 2892 | else |
2889 | return -EINVAL; | 2893 | return -EINVAL; |
2890 | 2894 | ||
@@ -2996,6 +3000,13 @@ int dbg_debugfs_init_fs(struct ubifs_info *c) | |||
2996 | goto out_remove; | 3000 | goto out_remove; |
2997 | d->dfs_tst_rcvry = dent; | 3001 | d->dfs_tst_rcvry = dent; |
2998 | 3002 | ||
3003 | fname = "ro_error"; | ||
3004 | dent = debugfs_create_file(fname, S_IRUSR | S_IWUSR, d->dfs_dir, c, | ||
3005 | &dfs_fops); | ||
3006 | if (IS_ERR_OR_NULL(dent)) | ||
3007 | goto out_remove; | ||
3008 | d->dfs_ro_error = dent; | ||
3009 | |||
2999 | return 0; | 3010 | return 0; |
3000 | 3011 | ||
3001 | out_remove: | 3012 | out_remove: |
diff --git a/fs/ubifs/debug.h b/fs/ubifs/debug.h index 486a8e024fb6..8b8cc4e945f4 100644 --- a/fs/ubifs/debug.h +++ b/fs/ubifs/debug.h | |||
@@ -79,6 +79,10 @@ typedef int (*dbg_znode_callback)(struct ubifs_info *c, | |||
79 | * @dfs_chk_lprops: debugfs knob to enable UBIFS LEP properties extra checks | 79 | * @dfs_chk_lprops: debugfs knob to enable UBIFS LEP properties extra checks |
80 | * @dfs_chk_fs: debugfs knob to enable UBIFS contents extra checks | 80 | * @dfs_chk_fs: debugfs knob to enable UBIFS contents extra checks |
81 | * @dfs_tst_rcvry: debugfs knob to enable UBIFS recovery testing | 81 | * @dfs_tst_rcvry: debugfs knob to enable UBIFS recovery testing |
82 | * @dfs_ro_error: debugfs knob to switch UBIFS to R/O mode (different to | ||
83 | * re-mounting to R/O mode because it does not flush any buffers | ||
84 | * and UBIFS just starts returning -EROFS on all write | ||
85 | * operations) | ||
82 | */ | 86 | */ |
83 | struct ubifs_debug_info { | 87 | struct ubifs_debug_info { |
84 | struct ubifs_zbranch old_zroot; | 88 | struct ubifs_zbranch old_zroot; |
@@ -122,6 +126,7 @@ struct ubifs_debug_info { | |||
122 | struct dentry *dfs_chk_lprops; | 126 | struct dentry *dfs_chk_lprops; |
123 | struct dentry *dfs_chk_fs; | 127 | struct dentry *dfs_chk_fs; |
124 | struct dentry *dfs_tst_rcvry; | 128 | struct dentry *dfs_tst_rcvry; |
129 | struct dentry *dfs_ro_error; | ||
125 | }; | 130 | }; |
126 | 131 | ||
127 | /** | 132 | /** |