summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorJens Axboe <jaxboe@fusionio.com>2011-01-11 22:16:49 +0100
committerJens Axboe <jaxboe@fusionio.com>2011-01-11 22:16:49 +0100
commit7d9fb455aadc0c0363489591775496f27f4a560a (patch)
tree10f99c7ffb0b3a123c5ea4cc7898e80213b370da /lib
parent3f46e64fbd2c76cc89ef8ddfc9189bac285ef638 (diff)
downloadfio-7d9fb455aadc0c0363489591775496f27f4a560a.tar.gz
fio-7d9fb455aadc0c0363489591775496f27f4a560a.tar.bz2
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>
Diffstat (limited to 'lib')
-rw-r--r--lib/rand.c23
-rw-r--r--lib/rand.h3
2 files changed, 17 insertions, 9 deletions
diff --git a/lib/rand.c b/lib/rand.c
index 839a6a94..06812823 100644
--- a/lib/rand.c
+++ b/lib/rand.c
@@ -59,18 +59,25 @@ void init_rand(struct frand_state *state)
__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))
- r *= (unsigned long) __rand(&__fio_rand_state);
-
while ((void *) ptr - buf < len) {
- *ptr = r;
+ *ptr = seed;
ptr++;
- r *= GOLDEN_RATIO_PRIME;
- r >>= 3;
+ 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);
+
+ __fill_random_buf(buf, len, r);
+ return r;
+}
diff --git a/lib/rand.h b/lib/rand.h
index 573116cb..02e68585 100644
--- a/lib/rand.h
+++ b/lib/rand.h
@@ -19,6 +19,7 @@ static inline unsigned int __rand(struct frand_state *state)
}
extern void init_rand(struct frand_state *);
-extern void fill_random_buf(void *buf, unsigned int len);
+extern void __fill_random_buf(void *buf, unsigned int len, unsigned long seed);
+extern unsigned long fill_random_buf(void *buf, unsigned int len);
#endif