Skip to content

Commit 06bef94

Browse files
committed
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>
1 parent 782759b commit 06bef94

2 files changed

Lines changed: 16 additions & 0 deletions

File tree

‎fs/ubifs/debug.c‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2802,6 +2802,8 @@ static ssize_t dfs_file_read(struct file *file, char __user *u, size_t count,
28022802
val = d->chk_fs;
28032803
else if (dent == d->dfs_tst_rcvry)
28042804
val = d->tst_rcvry;
2805+
else if (dent == d->dfs_ro_error)
2806+
val = c->ro_error;
28052807
else
28062808
return -EINVAL;
28072809

@@ -2885,6 +2887,8 @@ static ssize_t dfs_file_write(struct file *file, const char __user *u,
28852887
d->chk_fs = val;
28862888
else if (dent == d->dfs_tst_rcvry)
28872889
d->tst_rcvry = val;
2890+
else if (dent == d->dfs_ro_error)
2891+
c->ro_error = !!val;
28882892
else
28892893
return -EINVAL;
28902894

@@ -2996,6 +3000,13 @@ int dbg_debugfs_init_fs(struct ubifs_info *c)
29963000
goto out_remove;
29973001
d->dfs_tst_rcvry = dent;
29983002

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+
29993010
return 0;
30003011

30013012
out_remove:

‎fs/ubifs/debug.h‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,10 @@ typedef int (*dbg_znode_callback)(struct ubifs_info *c,
7979
* @dfs_chk_lprops: debugfs knob to enable UBIFS LEP properties extra checks
8080
* @dfs_chk_fs: debugfs knob to enable UBIFS contents extra checks
8181
* @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)
8286
*/
8387
struct ubifs_debug_info {
8488
struct ubifs_zbranch old_zroot;
@@ -122,6 +126,7 @@ struct ubifs_debug_info {
122126
struct dentry *dfs_chk_lprops;
123127
struct dentry *dfs_chk_fs;
124128
struct dentry *dfs_tst_rcvry;
129+
struct dentry *dfs_ro_error;
125130
};
126131

127132
/**

0 commit comments

Comments
 (0)