* [PATCH] ubifs: Correct data corruption range
@ 2013-08-21 13:24 Mats Kärrman
2013-10-26 10:35 ` Artem Bityutskiy
0 siblings, 1 reply; 2+ messages in thread
From: Mats Kärrman @ 2013-08-21 13:24 UTC (permalink / raw)
To: linux-mtd@lists.infradead.org; +Cc: Artem Bityutskiy
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>
diff --git a/fs/ubifs/debug.c b/fs/ubifs/debug.c
index 6e025e0..cc1febd 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,
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");
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] ubifs: Correct data corruption range
2013-08-21 13:24 [PATCH] ubifs: Correct data corruption range Mats Kärrman
@ 2013-10-26 10:35 ` Artem Bityutskiy
0 siblings, 0 replies; 2+ messages in thread
From: Artem Bityutskiy @ 2013-10-26 10:35 UTC (permalink / raw)
To: Mats Kärrman; +Cc: linux-mtd@lists.infradead.org
On Wed, 2013-08-21 at 13:24 +0000, Mats Kärrman wrote:
> 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>
Picked to linux-ubifs.git, thanks!
--
Best Regards,
Artem Bityutskiy
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2013-10-26 10:35 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-08-21 13:24 [PATCH] ubifs: Correct data corruption range Mats Kärrman
2013-10-26 10:35 ` Artem Bityutskiy
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).