summaryrefslogtreecommitdiff
path: root/io_u.c
diff options
context:
space:
mode:
authorJens Axboe <axboe@kernel.dk>2017-11-30 06:50:36 -0700
committerJens Axboe <axboe@kernel.dk>2017-11-30 06:50:36 -0700
commit63f87de888df01e7ed93dc0afee0d0193e43a084 (patch)
treeb67f2512f440387386b1accf2fb8dcbc01ce594a /io_u.c
parentfc9d5a6ae0c29ae26a8db15f553c7197a3ba9440 (diff)
downloadfio-63f87de888df01e7ed93dc0afee0d0193e43a084.tar.gz
fio-63f87de888df01e7ed93dc0afee0d0193e43a084.tar.bz2
io_u: tweak small content buffer scramble
We currently generate a 'random' offset in a 512b chunk to fill in the offset. Since we don't want the later time scramble to overwrite it, we check and adjust for that. Instead just ensure that we generate a random offset in the first half of the 512b chunk, then we know we never overlap. Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'io_u.c')
-rw-r--r--io_u.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/io_u.c b/io_u.c
index 8087bd6a..c2585427 100644
--- a/io_u.c
+++ b/io_u.c
@@ -1687,15 +1687,15 @@ static void small_content_scramble(struct io_u *io_u)
for (i = 0; i < nr_blocks; i++) {
/*
* Fill the byte offset into a "random" start offset of
- * the buffer, given by the product of the usec time
- * and the actual offset.
+ * the first half of the buffer.
*/
- offset = (io_u->start_time.tv_nsec ^ boffset) & 511;
- offset &= ~(sizeof(uint64_t) - 1);
- if (offset >= 512 - sizeof(uint64_t))
- offset -= sizeof(uint64_t);
+ offset = (io_u->start_time.tv_nsec ^ boffset) & 255;
+ offset &= ~(sizeof(boffset) - 1);
memcpy(p + offset, &boffset, sizeof(boffset));
+ /*
+ * Fill the start time into the end of the buffer
+ */
end = p + 512 - sizeof(io_u->start_time);
memcpy(end, &io_u->start_time, sizeof(io_u->start_time));
p += 512;