Improve LFSR implementation
[fio.git] / filesetup.c
index 5aadf126311b9322668c3e835b673126949fa4d5..57553c962ce9fdc65429207231c3dcd786bb9a13 100644 (file)
@@ -79,7 +79,8 @@ static int extend_file(struct thread_data *td, struct fio_file *f)
                        break;
                case FIO_FALLOCATE_POSIX:
                        dprint(FD_FILE, "posix_fallocate file %s size %llu\n",
-                                f->file_name, f->real_file_size);
+                                f->file_name,
+                                (unsigned long long) f->real_file_size);
 
                        r = posix_fallocate(f->fd, 0, f->real_file_size);
                        if (r > 0) {
@@ -91,8 +92,8 @@ static int extend_file(struct thread_data *td, struct fio_file *f)
                case FIO_FALLOCATE_KEEP_SIZE:
                        dprint(FD_FILE,
                                "fallocate(FALLOC_FL_KEEP_SIZE) "
-                               "file %s size %llu\n",
-                               f->file_name, f->real_file_size);
+                               "file %s size %llu\n", f->file_name,
+                               (unsigned long long) f->real_file_size);
 
                        r = fallocate(f->fd, FALLOC_FL_KEEP_SIZE, 0,
                                        f->real_file_size);
@@ -118,7 +119,7 @@ static int extend_file(struct thread_data *td, struct fio_file *f)
         */
        if (!td->o.fill_device) {
                dprint(FD_FILE, "truncate file %s, size %llu\n", f->file_name,
-                                                       f->real_file_size);
+                                       (unsigned long long) f->real_file_size);
                if (ftruncate(f->fd, f->real_file_size) == -1) {
                        td_verror(td, errno, "ftruncate");
                        goto err;
@@ -958,14 +959,14 @@ int init_random_map(struct thread_data *td)
        for_each_file(td, f, i) {
                uint64_t file_size = min(f->real_file_size, f->io_size);
 
-               blocks = (file_size + td->o.rw_min_bs - 1) /
-                               (unsigned long long) td->o.rw_min_bs;
+               blocks = file_size / (unsigned long long) td->o.rw_min_bs;
+
                if (td->o.random_generator == FIO_RAND_GEN_LFSR) {
                        unsigned long seed;
 
                        seed = td->rand_seeds[FIO_RAND_BLOCK_OFF];
                        
-                       if (!lfsr_init(&f->lfsr, blocks, seed))
+                       if (!lfsr_init(&f->lfsr, blocks, seed, seed & 0xF))
                                continue;
                } else if (!td->o.norandommap) {
                        f->io_axmap = axmap_new(blocks);