t/debug: fix 'fio_debug' declaration
[fio.git] / filesetup.c
index cf8ae94c86b83c516411396b336f720e5ab03931..212a126b94aed73c83319763298f573051af4413 100644 (file)
@@ -267,11 +267,13 @@ error:
 static unsigned long long get_rand_file_size(struct thread_data *td)
 {
        unsigned long long ret, sized;
+       uint64_t frand_max;
        unsigned long r;
 
+       frand_max = rand_max(&td->file_size_state);
        r = __rand(&td->file_size_state);
        sized = td->o.file_size_high - td->o.file_size_low;
-       ret = (unsigned long long) ((double) sized * (r / (FRAND_MAX + 1.0)));
+       ret = (unsigned long long) ((double) sized * (r / (frand_max + 1.0)));
        ret += td->o.file_size_low;
        ret -= (ret % td->o.rw_min_bs);
        return ret;
@@ -730,7 +732,7 @@ static unsigned long long get_fs_free_counts(struct thread_data *td)
                fm = flist_entry(n, struct fio_mount, list);
                flist_del(&fm->list);
 
-               sz = get_fs_size(fm->base);
+               sz = get_fs_free_size(fm->base);
                if (sz && sz != -1ULL)
                        ret += sz;
 
@@ -1065,6 +1067,16 @@ int init_random_map(struct thread_data *td)
 
                blocks = fsize / (unsigned long long) td->o.rw_min_bs;
 
+               if (blocks > FRAND32_MAX &&
+                   td->o.random_generator == FIO_RAND_GEN_TAUSWORTHE &&
+                   !fio_option_is_set(&td->o, random_generator)) {
+                       log_err("fio: file %s exceeds 32-bit tausworthe "
+                                "random generator. Use lfsr or "
+                                "tausworthe64.\n", f->file_name);
+                       td_verror(td, EINVAL, "init file random");
+                       return 1;
+               }
+
                if (td->o.random_generator == FIO_RAND_GEN_LFSR) {
                        unsigned long seed;