summaryrefslogtreecommitdiff
path: root/fs/ubifs/debug.c
diff options
context:
space:
mode:
authorArtem Bityutskiy <Artem.Bityutskiy@nokia.com>2011-06-03 15:10:33 +0300
committerArtem Bityutskiy <dedekind1@gmail.com>2011-07-04 10:54:34 +0300
commitd27462a518c31a4b1093ad866229f85b2b765e7e (patch)
treee2663f6294ad516bc3debebf394fc437a84d0de5 /fs/ubifs/debug.c
parentf57cb188ccd9c0242111d99b7283eda7827746c4 (diff)
downloadlinux-3.10-d27462a518c31a4b1093ad866229f85b2b765e7e.tar.gz
linux-3.10-d27462a518c31a4b1093ad866229f85b2b765e7e.tar.bz2
linux-3.10-d27462a518c31a4b1093ad866229f85b2b765e7e.zip
UBIFS: rename recovery testing variables
Since the recovery testing is effectively about emulating power cuts by UBIFS, use "power cut" as the base term for all the related variables and name them correspondingly. This is just a minor clean-up for the sake of readability. Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
Diffstat (limited to 'fs/ubifs/debug.c')
-rw-r--r--fs/ubifs/debug.c52
1 files changed, 28 insertions, 24 deletions
diff --git a/fs/ubifs/debug.c b/fs/ubifs/debug.c
index 1e880cedefa..b801af7837e 100644
--- a/fs/ubifs/debug.c
+++ b/fs/ubifs/debug.c
@@ -2548,39 +2548,36 @@ static int simple_rand(void)
return (next >> 16) & 32767;
}
-static int do_fail(struct ubifs_info *c, int lnum, int write)
+static int power_cut_emulated(struct ubifs_info *c, int lnum, int write)
{
struct ubifs_debug_info *d = c->dbg;
ubifs_assert(dbg_is_tst_rcvry(c));
- if (d->failure_mode)
- return 1;
-
- if (!d->fail_cnt) {
- /* First call - decide delay to failure */
+ if (!d->pc_cnt) {
+ /* First call - decide delay to the power cut */
if (chance(1, 2)) {
unsigned int delay = 1 << (simple_rand() >> 11);
if (chance(1, 2)) {
- d->fail_delay = 1;
- d->fail_timeout = jiffies +
+ d->pc_delay = 1;
+ d->pc_timeout = jiffies +
msecs_to_jiffies(delay);
ubifs_warn("failing after %ums", delay);
} else {
- d->fail_delay = 2;
- d->fail_cnt_max = delay;
+ d->pc_delay = 2;
+ d->pc_cnt_max = delay;
ubifs_warn("failing after %u calls", delay);
}
}
- d->fail_cnt += 1;
+ d->pc_cnt += 1;
}
/* Determine if failure delay has expired */
- if (d->fail_delay == 1) {
- if (time_before(jiffies, d->fail_timeout))
+ if (d->pc_delay == 1) {
+ if (time_before(jiffies, d->pc_timeout))
return 0;
- } else if (d->fail_delay == 2)
- if (d->fail_cnt++ < d->fail_cnt_max)
+ } else if (d->pc_delay == 2)
+ if (d->pc_cnt++ < d->pc_cnt_max)
return 0;
if (lnum == UBIFS_SB_LNUM) {
if (write) {
@@ -2638,7 +2635,7 @@ static int do_fail(struct ubifs_info *c, int lnum, int write)
ubifs_warn("failing in bud LEB %d commit not running", lnum);
}
- d->failure_mode = 1;
+ d->pc_happened = 1;
dump_stack();
return 1;
}
@@ -2658,9 +2655,10 @@ int dbg_leb_write(struct ubifs_info *c, int lnum, const void *buf,
{
int err, failing;
- if (c->dbg->failure_mode)
+ if (c->dbg->pc_happened)
return -EROFS;
- failing = do_fail(c, lnum, 1);
+
+ failing = power_cut_emulated(c, lnum, 1);
if (failing)
cut_data(buf, len);
err = ubi_leb_write(c->ubi, lnum, buf, offs, len, dtype);
@@ -2676,12 +2674,14 @@ int dbg_leb_change(struct ubifs_info *c, int lnum, const void *buf,
{
int err;
- if (do_fail(c, lnum, 1))
+ if (c->dbg->pc_happened)
+ return -EROFS;
+ if (power_cut_emulated(c, lnum, 1))
return -EROFS;
err = ubi_leb_change(c->ubi, lnum, buf, len, dtype);
if (err)
return err;
- if (do_fail(c, lnum, 1))
+ if (power_cut_emulated(c, lnum, 1))
return -EROFS;
return 0;
}
@@ -2690,12 +2690,14 @@ int dbg_leb_unmap(struct ubifs_info *c, int lnum)
{
int err;
- if (do_fail(c, lnum, 0))
+ if (c->dbg->pc_happened)
+ return -EROFS;
+ if (power_cut_emulated(c, lnum, 0))
return -EROFS;
err = ubi_leb_unmap(c->ubi, lnum);
if (err)
return err;
- if (do_fail(c, lnum, 0))
+ if (power_cut_emulated(c, lnum, 0))
return -EROFS;
return 0;
}
@@ -2704,12 +2706,14 @@ int dbg_leb_map(struct ubifs_info *c, int lnum, int dtype)
{
int err;
- if (do_fail(c, lnum, 0))
+ if (c->dbg->pc_happened)
+ return -EROFS;
+ if (power_cut_emulated(c, lnum, 0))
return -EROFS;
err = ubi_leb_map(c->ubi, lnum, dtype);
if (err)
return err;
- if (do_fail(c, lnum, 0))
+ if (power_cut_emulated(c, lnum, 0))
return -EROFS;
return 0;
}