When verify fails, dump the good/bad blocks to files
This makes it easy to compare afterwards to see what kind of
corruption was experienced.
Signed-off-by: Jens Axboe <jaxboe@fusionio.com>
diff --git a/lib/rand.c b/lib/rand.c
index 839a6a9..0681282 100644
--- a/lib/rand.c
+++ b/lib/rand.c
@@ -59,18 +59,25 @@
__rand(state);
}
-void fill_random_buf(void *buf, unsigned int len)
+void __fill_random_buf(void *buf, unsigned int len, unsigned long seed)
{
- unsigned long r = __rand(&__fio_rand_state);
long *ptr = buf;
- if (sizeof(int) != sizeof(*ptr))
+ while ((void *) ptr - buf < len) {
+ *ptr = seed;
+ ptr++;
+ seed *= GOLDEN_RATIO_PRIME;
+ seed >>= 3;
+ }
+}
+
+unsigned long fill_random_buf(void *buf, unsigned int len)
+{
+ unsigned long r = __rand(&__fio_rand_state);
+
+ if (sizeof(int) != sizeof(long *))
r *= (unsigned long) __rand(&__fio_rand_state);
- while ((void *) ptr - buf < len) {
- *ptr = r;
- ptr++;
- r *= GOLDEN_RATIO_PRIME;
- r >>= 3;
- }
+ __fill_random_buf(buf, len, r);
+ return r;
}