Skip to content

Commit

Permalink
UBIFS: correct data corruption range
Browse files Browse the repository at this point in the history
With power-cut emulation, it is possible that sometimes no data at all is
corrupted and that confusing messages are printed due to errors in the
computation of data corruption range.

[1] The start of the range should be [0..len-1], not [0..len].
[2] The end of the range should always be at least 1 greater than the start.

Signed-off-by: Mats Karrman <mats.karrman@tritech.se>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
  • Loading branch information
Mats Kärrman authored and Artem Bityutskiy committed Oct 26, 2013
1 parent 7203db9 commit 58a4e23
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions fs/ubifs/debug.c
Original file line number Diff line number Diff line change
Expand Up @@ -2563,9 +2563,9 @@ static int corrupt_data(const struct ubifs_info *c, const void *buf,
unsigned int from, to, ffs = chance(1, 2);
unsigned char *p = (void *)buf;

from = prandom_u32() % (len + 1);
/* Corruption may only span one max. write unit */
to = min(len, ALIGN(from, c->max_write_size));
from = prandom_u32() % len;
/* Corruption span max to end of write unit */
to = min(len, ALIGN(from + 1, c->max_write_size));

ubifs_warn("filled bytes %u-%u with %s", from, to - 1,
ffs ? "0xFFs" : "random data");
Expand Down

0 comments on commit 58a4e23

Please sign in to comment.