diff options
author | Mats Kärrman <Mats.Karrman@tritech.se> | 2013-08-21 09:24:49 -0400 |
---|---|---|
committer | Artem Bityutskiy <artem.bityutskiy@linux.intel.com> | 2013-10-26 06:33:38 -0400 |
commit | 58a4e23703b22c331b01fbd0c12161aadaa6d50b (patch) | |
tree | b7fde07e8a87483be5d9398d3a8f7b2e1e75f5b2 /fs | |
parent | 7203db97b7378c2571797c13aa89327a2c487ea1 (diff) |
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: Mats Karrman <mats.karrman@tritech.se>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/ubifs/debug.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/fs/ubifs/debug.c b/fs/ubifs/debug.c index 6e025e02ffde..cc1febd8fadf 100644 --- a/fs/ubifs/debug.c +++ b/fs/ubifs/debug.c | |||
@@ -2563,9 +2563,9 @@ static int corrupt_data(const struct ubifs_info *c, const void *buf, | |||
2563 | unsigned int from, to, ffs = chance(1, 2); | 2563 | unsigned int from, to, ffs = chance(1, 2); |
2564 | unsigned char *p = (void *)buf; | 2564 | unsigned char *p = (void *)buf; |
2565 | 2565 | ||
2566 | from = prandom_u32() % (len + 1); | 2566 | from = prandom_u32() % len; |
2567 | /* Corruption may only span one max. write unit */ | 2567 | /* Corruption span max to end of write unit */ |
2568 | to = min(len, ALIGN(from, c->max_write_size)); | 2568 | to = min(len, ALIGN(from + 1, c->max_write_size)); |
2569 | 2569 | ||
2570 | ubifs_warn("filled bytes %u-%u with %s", from, to - 1, | 2570 | ubifs_warn("filled bytes %u-%u with %s", from, to - 1, |
2571 | ffs ? "0xFFs" : "random data"); | 2571 | ffs ? "0xFFs" : "random data"); |