lfsr: don't pass in last value to lfsr_next()
authorJens Axboe <axboe@fb.com>
Mon, 24 Nov 2014 01:41:11 +0000 (18:41 -0700)
committerJens Axboe <axboe@fb.com>
Mon, 24 Nov 2014 01:41:11 +0000 (18:41 -0700)
It's cached in the 'fl' struct. This means we can move the max
block calculation outside if the lfsr part, too.

Signed-off-by: Jens Axboe <axboe@fb.com>
io_u.c
lib/lfsr.c
lib/lfsr.h

diff --git a/io_u.c b/io_u.c
index c51982d88a2468254dda05796db69143c16f1142..33c82f2c4e9e85f692be0c03a0f1c241dd4539c2 100644 (file)
--- a/io_u.c
+++ b/io_u.c
@@ -83,13 +83,15 @@ struct rand_off {
 static int __get_next_rand_offset(struct thread_data *td, struct fio_file *f,
                                  enum fio_ddir ddir, uint64_t *b)
 {
-       uint64_t r, lastb;
-
-       lastb = last_block(td, f, ddir);
-       if (!lastb)
-               return 1;
+       uint64_t r;
 
        if (td->o.random_generator == FIO_RAND_GEN_TAUSWORTHE) {
+               uint64_t lastb;
+
+               lastb = last_block(td, f, ddir);
+               if (!lastb)
+                       return 1;
+
                r = __rand(&td->random_state);
 
                dprint(FD_RANDOM, "off rand %llu\n", (unsigned long long) r);
@@ -98,7 +100,7 @@ static int __get_next_rand_offset(struct thread_data *td, struct fio_file *f,
        } else {
                uint64_t off = 0;
 
-               if (lfsr_next(&f->lfsr, &off, lastb))
+               if (lfsr_next(&f->lfsr, &off))
                        return 1;
 
                *b = off;
index 9fff50d77fe83d5a32afacbf67876e09ca5705fe..0c0072ccb39b15e970eeb6bd92342b67a85cd8bb 100644 (file)
@@ -124,7 +124,7 @@ static inline void __lfsr_next(struct fio_lfsr *fl, unsigned int spin)
  * c. Check if the calculated value exceeds the desirable range. In this case,
  *    go back to b, else return.
  */
-int lfsr_next(struct fio_lfsr *fl, uint64_t *off, uint64_t last)
+int lfsr_next(struct fio_lfsr *fl, uint64_t *off)
 {
        if (fl->num_vals++ > fl->max_val)
                return 1;
index 187abf2fc0f2438562f8ae1d4b82b0e506d2d0e3..c2d55693e89aa4869eec1280ea1e431cc039689c 100644 (file)
@@ -22,7 +22,7 @@ struct fio_lfsr {
        unsigned int spin;
 };
 
-int lfsr_next(struct fio_lfsr *fl, uint64_t *off, uint64_t);
+int lfsr_next(struct fio_lfsr *fl, uint64_t *off);
 int lfsr_init(struct fio_lfsr *fl, uint64_t size,
                unsigned long seed, unsigned int spin);
 int lfsr_reset(struct fio_lfsr *fl, unsigned long seed);