Commit 58a4e237 authored by Mats Kärrman's avatar Mats Kärrman Committed by Artem Bityutskiy

UBIFS: correct data corruption range

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: default avatarMats Karrman <mats.karrman@tritech.se>
Signed-off-by: default avatarArtem Bityutskiy <artem.bityutskiy@linux.intel.com>
parent 7203db97
...@@ -2563,9 +2563,9 @@ static int corrupt_data(const struct ubifs_info *c, const void *buf, ...@@ -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 int from, to, ffs = chance(1, 2);
unsigned char *p = (void *)buf; unsigned char *p = (void *)buf;
from = prandom_u32() % (len + 1); from = prandom_u32() % len;
/* Corruption may only span one max. write unit */ /* Corruption span max to end of write unit */
to = min(len, ALIGN(from, c->max_write_size)); to = min(len, ALIGN(from + 1, c->max_write_size));
ubifs_warn("filled bytes %u-%u with %s", from, to - 1, ubifs_warn("filled bytes %u-%u with %s", from, to - 1,
ffs ? "0xFFs" : "random data"); ffs ? "0xFFs" : "random data");
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment