X-Git-Url: https://git.kernel.dk/?p=fio.git;a=blobdiff_plain;f=filesetup.c;h=8b04560907b911f8bcc7a484f71964e36d055708;hp=60eaeb057a7e0a144ee27fccd1b1f2da49fbe0ac;hb=bc3456fa06cc7777c4764da8c7b1c0fd0a3c3772;hpb=739097e6e145afb98057846c419c60c2cc2dd9c0 diff --git a/filesetup.c b/filesetup.c index 60eaeb05..8b045609 100644 --- a/filesetup.c +++ b/filesetup.c @@ -68,11 +68,13 @@ static int extend_file(struct thread_data *td, struct fio_file *f) goto err; } +#ifdef FIO_HAVE_FALLOCATE dprint(FD_FILE, "fallocate file %s, size %llu\n", f->file_name, f->real_file_size); r = posix_fallocate(f->fd, 0, f->real_file_size); if (r < 0) - td_verror(td, -r, "posix_fallocate"); + log_err("fio: posix_fallocate fails: %s\n", strerror(-r)); +#endif b = malloc(td->o.max_bs[DDIR_WRITE]); memset(b, 0, td->o.max_bs[DDIR_WRITE]); @@ -119,12 +121,12 @@ err: static unsigned long long get_rand_file_size(struct thread_data *td) { - unsigned long long ret, size_d; + unsigned long long ret, sized; long r; r = os_random_long(&td->file_size_state); - size_d = td->o.file_size_high - td->o.file_size_low; - ret = (unsigned long long) ((double) size_d * (r / (RAND_MAX + 1.0))); + sized = td->o.file_size_high - td->o.file_size_low; + ret = (unsigned long long) ((double) sized * (r / (OS_RAND_MAX + 1.0))); ret += td->o.file_size_low; ret -= (ret % td->o.rw_min_bs); return ret; @@ -601,7 +603,7 @@ int init_random_map(struct thread_data *td) (unsigned long long) td->o.rw_min_bs; num_maps = (blocks + BLOCKS_PER_MAP - 1) / (unsigned long long) BLOCKS_PER_MAP; - f->file_map = smalloc(num_maps * sizeof(long)); + f->file_map = smalloc(num_maps * sizeof(int)); if (f->file_map) { f->num_maps = num_maps; continue; @@ -904,8 +906,10 @@ void dup_files(struct thread_data *td, struct thread_data *org) __f = smalloc(sizeof(*__f)); - if (f->file_name) + if (f->file_name) { __f->file_name = smalloc_strdup(f->file_name); + __f->filetype = f->filetype; + } td->files[i] = __f; }