void io_u_fill_buffer(struct thread_data *td, struct io_u *io_u,
unsigned int max_bs)
{
- long *ptr = io_u->buf;
-
- if (!td->o.zero_buffers) {
- unsigned long r = __rand(&__fio_rand_state);
-
- if (sizeof(int) != sizeof(*ptr))
- r *= (unsigned long) __rand(&__fio_rand_state);
-
- while ((void *) ptr - io_u->buf < max_bs) {
- *ptr = r;
- ptr++;
- r *= GOLDEN_RATIO_PRIME;
- r >>= 3;
- }
- } else
- memset(ptr, 0, max_bs);
+ if (!td->o.zero_buffers)
+ fill_random_buf(io_u->buf, max_bs);
+ else
+ memset(io_u->buf, 0, max_bs);
}
*/
#include "rand.h"
+#include "../hash.h"
struct frand_state __fio_rand_state;
__rand(state);
__rand(state);
}
+
+void fill_random_buf(void *buf, unsigned int len)
+{
+ 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++;
+ r *= GOLDEN_RATIO_PRIME;
+ r >>= 3;
+ }
+}
}
extern void init_rand(struct frand_state *);
+extern void fill_random_buf(void *buf, unsigned int len);
#endif
#include "fio.h"
#include "verify.h"
#include "smalloc.h"
+#include "lib/rand.h"
#include "crc/md5.h"
#include "crc/crc64.h"
#include "crc/sha512.h"
#include "crc/sha1.h"
-static void fill_random_bytes(struct thread_data *td, void *p, unsigned int len)
-{
- unsigned int todo;
- int r;
-
- while (len) {
- r = os_random_long(&td->verify_state);
-
- /*
- * lrand48_r seems to be broken and only fill the bottom
- * 32-bits, even on 64-bit archs with 64-bit longs
- */
- todo = sizeof(r);
- if (todo > len)
- todo = len;
-
- memcpy(p, &r, todo);
-
- len -= todo;
- p += todo;
- }
-}
-
static void fill_pattern(struct thread_data *td, void *p, unsigned int len)
{
switch (td->o.verify_pattern_bytes) {
case 0:
dprint(FD_VERIFY, "fill random bytes len=%u\n", len);
- fill_random_bytes(td, p, len);
+ fill_random_buf(p, len);
break;
case 1:
dprint(FD_VERIFY, "fill verify pattern b=0 len=%u\n", len);