X-Git-Url: https://git.kernel.dk/?p=fio.git;a=blobdiff_plain;f=io_u.c;h=06fb3cef80c7fb71c1c6aad29e1936b27e1b9b19;hp=92cdd71701a9df3973eb4158b0a8fcb6bab4eed5;hb=5973cafb37fbf24c3ca2cdf86a3d03f1b00d6d2b;hpb=60f2c658b923afdd491d556e15a655584b9db306 diff --git a/io_u.c b/io_u.c index 92cdd717..06fb3cef 100644 --- a/io_u.c +++ b/io_u.c @@ -6,6 +6,7 @@ #include #include "fio.h" +#include "hash.h" /* * Change this define to play with the timeout handling @@ -780,6 +781,9 @@ struct io_u *get_io_u(struct thread_data *td) io_u->endpos = io_u->offset + io_u->buflen; io_u->xfer_buf = io_u->buf; io_u->xfer_buflen = io_u->buflen; + + if (td->o.refill_buffers && io_u->ddir == DDIR_WRITE) + io_u_fill_buffer(td, io_u, io_u->xfer_buflen); out: if (!td_io_prep(td, io_u)) { fio_gettime(&io_u->start_time, NULL); @@ -943,6 +947,23 @@ void io_u_queued(struct thread_data *td, struct io_u *io_u) add_slat_sample(td, io_u->ddir, slat_time); } +/* + * "randomly" fill the buffer contents + */ +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) { + while ((void *) ptr - io_u->buf < max_bs) { + *ptr = rand() * GOLDEN_RATIO_PRIME; + ptr++; + } + } else + memset(ptr, 0, max_bs); +} + #ifdef FIO_USE_TIMEOUT void io_u_set_timeout(struct thread_data *td) {