aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ubifs
diff options
context:
space:
mode:
Diffstat (limited to 'fs/ubifs')
-rw-r--r--fs/ubifs/debug.c11
-rw-r--r--fs/ubifs/debug.h5
-rw-r--r--fs/ubifs/dir.c2
-rw-r--r--fs/ubifs/orphan.c4
-rw-r--r--fs/ubifs/replay.c20
5 files changed, 25 insertions, 17 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
3001out_remove: 3012out_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 */
83struct ubifs_debug_info { 87struct 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/**
diff --git a/fs/ubifs/dir.c b/fs/ubifs/dir.c
index b1cca89aeb68..c95681cf1b71 100644
--- a/fs/ubifs/dir.c
+++ b/fs/ubifs/dir.c
@@ -969,7 +969,7 @@ static int ubifs_rename(struct inode *old_dir, struct dentry *old_dentry,
969 struct ubifs_budget_req ino_req = { .dirtied_ino = 1, 969 struct ubifs_budget_req ino_req = { .dirtied_ino = 1,
970 .dirtied_ino_d = ALIGN(old_inode_ui->data_len, 8) }; 970 .dirtied_ino_d = ALIGN(old_inode_ui->data_len, 8) };
971 struct timespec time; 971 struct timespec time;
972 unsigned int saved_nlink; 972 unsigned int uninitialized_var(saved_nlink);
973 973
974 /* 974 /*
975 * Budget request settings: deletion direntry, new direntry, removing 975 * Budget request settings: deletion direntry, new direntry, removing
diff --git a/fs/ubifs/orphan.c b/fs/ubifs/orphan.c
index b02734db187c..cebf17ea0458 100644
--- a/fs/ubifs/orphan.c
+++ b/fs/ubifs/orphan.c
@@ -176,7 +176,7 @@ int ubifs_orphan_start_commit(struct ubifs_info *c)
176 *last = orphan; 176 *last = orphan;
177 last = &orphan->cnext; 177 last = &orphan->cnext;
178 } 178 }
179 *last = orphan->cnext; 179 *last = NULL;
180 c->cmt_orphans = c->new_orphans; 180 c->cmt_orphans = c->new_orphans;
181 c->new_orphans = 0; 181 c->new_orphans = 0;
182 dbg_cmt("%d orphans to commit", c->cmt_orphans); 182 dbg_cmt("%d orphans to commit", c->cmt_orphans);
@@ -382,7 +382,7 @@ static int consolidate(struct ubifs_info *c)
382 last = &orphan->cnext; 382 last = &orphan->cnext;
383 cnt += 1; 383 cnt += 1;
384 } 384 }
385 *last = orphan->cnext; 385 *last = NULL;
386 ubifs_assert(cnt == c->tot_orphans - c->new_orphans); 386 ubifs_assert(cnt == c->tot_orphans - c->new_orphans);
387 c->cmt_orphans = cnt; 387 c->cmt_orphans = cnt;
388 c->ohead_lnum = c->orph_first; 388 c->ohead_lnum = c->orph_first;
diff --git a/fs/ubifs/replay.c b/fs/ubifs/replay.c
index 3a2da7e476e5..eba46d4a7619 100644
--- a/fs/ubifs/replay.c
+++ b/fs/ubifs/replay.c
@@ -1007,7 +1007,7 @@ out:
1007 */ 1007 */
1008int ubifs_replay_journal(struct ubifs_info *c) 1008int ubifs_replay_journal(struct ubifs_info *c)
1009{ 1009{
1010 int err, i, lnum, offs, free; 1010 int err, lnum, free;
1011 1011
1012 BUILD_BUG_ON(UBIFS_TRUN_KEY > 5); 1012 BUILD_BUG_ON(UBIFS_TRUN_KEY > 5);
1013 1013
@@ -1025,25 +1025,17 @@ int ubifs_replay_journal(struct ubifs_info *c)
1025 dbg_mnt("start replaying the journal"); 1025 dbg_mnt("start replaying the journal");
1026 c->replaying = 1; 1026 c->replaying = 1;
1027 lnum = c->ltail_lnum = c->lhead_lnum; 1027 lnum = c->ltail_lnum = c->lhead_lnum;
1028 offs = c->lhead_offs;
1029 1028
1030 for (i = 0; i < c->log_lebs; i++, lnum++) { 1029 lnum = UBIFS_LOG_LNUM;
1031 if (lnum >= UBIFS_LOG_LNUM + c->log_lebs) { 1030 do {
1032 /* 1031 err = replay_log_leb(c, lnum, 0, c->sbuf);
1033 * The log is logically circular, we reached the last
1034 * LEB, switch to the first one.
1035 */
1036 lnum = UBIFS_LOG_LNUM;
1037 offs = 0;
1038 }
1039 err = replay_log_leb(c, lnum, offs, c->sbuf);
1040 if (err == 1) 1032 if (err == 1)
1041 /* We hit the end of the log */ 1033 /* We hit the end of the log */
1042 break; 1034 break;
1043 if (err) 1035 if (err)
1044 goto out; 1036 goto out;
1045 offs = 0; 1037 lnum = ubifs_next_log_lnum(c, lnum);
1046 } 1038 } while (lnum != UBIFS_LOG_LNUM);
1047 1039
1048 err = replay_buds(c); 1040 err = replay_buds(c);
1049 if (err) 1041 if (err)