io_u: tweak small content buffer scramble
[fio.git] / io_u.c
diff --git a/io_u.c b/io_u.c
index 6ec04fa30607ba755835bf96034bff1edcf34bd5..c25854273a68d279a9265ec1780cc4fc260da4d2 100644 (file)
--- a/io_u.c
+++ b/io_u.c
@@ -162,8 +162,7 @@ static int __get_next_rand_offset_zoned_abs(struct thread_data *td,
                                            enum fio_ddir ddir, uint64_t *b)
 {
        struct zone_split_index *zsi;
                                            enum fio_ddir ddir, uint64_t *b)
 {
        struct zone_split_index *zsi;
-       uint64_t offset, lastb;
-       uint64_t send, stotal;
+       uint64_t lastb, send, stotal;
        static int warned;
        unsigned int v;
 
        static int warned;
        unsigned int v;
 
@@ -181,6 +180,10 @@ bail:
         */
        v = rand32_between(&td->zone_state, 1, 100);
 
         */
        v = rand32_between(&td->zone_state, 1, 100);
 
+       /*
+        * Find our generated table. 'send' is the end block of this zone,
+        * 'stotal' is our start offset.
+        */
        zsi = &td->zone_state_index[ddir][v - 1];
        stotal = zsi->size_prev / td->o.ba[ddir];
        send = zsi->size / td->o.ba[ddir];
        zsi = &td->zone_state_index[ddir][v - 1];
        stotal = zsi->size_prev / td->o.ba[ddir];
        send = zsi->size / td->o.ba[ddir];
@@ -205,29 +208,12 @@ bail:
        }
 
        /*
        }
 
        /*
-        * 'send' is some percentage below or equal to 100 that
-        * marks the end of the current IO range. 'stotal' marks
-        * the start, in percent.
+        * Generate index from 0..send-stotal
         */
         */
-       if (stotal)
-               offset = stotal;
-       else
-               offset = 0;
-
-       lastb = send - stotal;
-
-       /*
-        * Generate index from 0..send-of-lastb
-        */
-       if (__get_next_rand_offset(td, f, ddir, b, lastb) == 1)
+       if (__get_next_rand_offset(td, f, ddir, b, send - stotal) == 1)
                return 1;
 
                return 1;
 
-       /*
-        * Add our start offset, if any
-        */
-       if (offset)
-               *b += offset;
-
+       *b += stotal;
        return 0;
 }
 
        return 0;
 }
 
@@ -1423,10 +1409,10 @@ static long set_io_u_file(struct thread_data *td, struct io_u *io_u)
 }
 
 static void lat_fatal(struct thread_data *td, struct io_completion_data *icd,
 }
 
 static void lat_fatal(struct thread_data *td, struct io_completion_data *icd,
-                     unsigned long tusec, unsigned long max_usec)
+                     unsigned long long tnsec, unsigned long long max_nsec)
 {
        if (!td->error)
 {
        if (!td->error)
-               log_err("fio: latency of %lu usec exceeds specified max (%lu usec)\n", tusec, max_usec);
+               log_err("fio: latency of %llu nsec exceeds specified max (%llu nsec)\n", tnsec, max_nsec);
        td_verror(td, ETIMEDOUT, "max latency exceeded");
        icd->error = ETIMEDOUT;
 }
        td_verror(td, ETIMEDOUT, "max latency exceeded");
        icd->error = ETIMEDOUT;
 }
@@ -1687,8 +1673,8 @@ static bool check_get_verify(struct thread_data *td, struct io_u *io_u)
 static void small_content_scramble(struct io_u *io_u)
 {
        unsigned int i, nr_blocks = io_u->buflen / 512;
 static void small_content_scramble(struct io_u *io_u)
 {
        unsigned int i, nr_blocks = io_u->buflen / 512;
-       uint64_t boffset;
        unsigned int offset;
        unsigned int offset;
+       uint64_t boffset;
        char *p, *end;
 
        if (!nr_blocks)
        char *p, *end;
 
        if (!nr_blocks)
@@ -1701,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
        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/1000) ^ 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));
 
                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;
                end = p + 512 - sizeof(io_u->start_time);
                memcpy(end, &io_u->start_time, sizeof(io_u->start_time));
                p += 512;
@@ -1882,14 +1868,14 @@ static void account_io_completion(struct thread_data *td, struct io_u *io_u,
                        struct prof_io_ops *ops = &td->prof_io_ops;
 
                        if (ops->io_u_lat)
                        struct prof_io_ops *ops = &td->prof_io_ops;
 
                        if (ops->io_u_lat)
-                               icd->error = ops->io_u_lat(td, tnsec/1000);
+                               icd->error = ops->io_u_lat(td, tnsec);
                }
 
                }
 
-               if (td->o.max_latency && tnsec/1000 > td->o.max_latency)
-                       lat_fatal(td, icd, tnsec/1000, td->o.max_latency);
-               if (td->o.latency_target && tnsec/1000 > td->o.latency_target) {
+               if (td->o.max_latency && tnsec > td->o.max_latency)
+                       lat_fatal(td, icd, tnsec, td->o.max_latency);
+               if (td->o.latency_target && tnsec > td->o.latency_target) {
                        if (lat_target_failed(td))
                        if (lat_target_failed(td))
-                               lat_fatal(td, icd, tnsec/1000, td->o.latency_target);
+                               lat_fatal(td, icd, tnsec, td->o.latency_target);
                }
        }
 
                }
        }