Get rid of __ prefix for internal frand state
[fio.git] / filesetup.c
index 2049fd6502cc80ec8c0214c55029c5cad7fb1786..4026f4de1bdb9ddbec833e251c9e99309ec5d16d 100644 (file)
@@ -59,7 +59,7 @@ static int extend_file(struct thread_data *td, struct fio_file *f)
 
        if (unlink_file || new_layout) {
                dprint(FD_FILE, "layout unlink %s\n", f->file_name);
-               if ((unlink(f->file_name) < 0) && (errno != ENOENT)) {
+               if ((td_io_unlink_file(td, f) < 0) && (errno != ENOENT)) {
                        td_verror(td, errno, "unlink");
                        return 1;
                }
@@ -172,7 +172,7 @@ static int extend_file(struct thread_data *td, struct fio_file *f)
 
        if (td->terminate) {
                dprint(FD_FILE, "terminate unlink %s\n", f->file_name);
-               unlink(f->file_name);
+               td_io_unlink_file(td, f);
        } else if (td->o.create_fsync) {
                if (fsync(f->fd) < 0) {
                        td_verror(td, errno, "fsync");
@@ -261,16 +261,9 @@ static unsigned long long get_rand_file_size(struct thread_data *td)
        unsigned long long ret, sized;
        unsigned long r;
 
-       if (td->o.use_os_rand) {
-               r = os_random_long(&td->file_size_state);
-               sized = td->o.file_size_high - td->o.file_size_low;
-               ret = (unsigned long long) ((double) sized * (r / (OS_RAND_MAX + 1.0)));
-       } else {
-               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)));
-       }
-
+       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 += td->o.file_size_low;
        ret -= (ret % td->o.rw_min_bs);
        return ret;
@@ -390,6 +383,10 @@ static int __file_invalidate_cache(struct thread_data *td, struct fio_file *f,
 {
        int ret = 0;
 
+#ifdef CONFIG_ESX
+       return 0;
+#endif
+
        if (len == -1ULL)
                len = f->io_size;
        if (off == -1ULL)
@@ -605,6 +602,7 @@ open_again:
                }
 
                td_verror(td, __e, buf);
+               return 1;
        }
 
        if (!from_hash && f->fd != -1) {
@@ -657,6 +655,7 @@ static int get_file_sizes(struct thread_data *td)
                        if (td->error != ENOENT) {
                                log_err("%s\n", td->verror);
                                err = 1;
+                               break;
                        }
                        clear_error(td);
                }
@@ -752,7 +751,7 @@ uint64_t get_start_offset(struct thread_data *td, struct fio_file *f)
                return f->real_file_size;
 
        return td->o.start_offset +
-               (td->thread_number - 1) * td->o.offset_increment;
+               td->subjob_number * td->o.offset_increment;
 }
 
 /*
@@ -892,7 +891,7 @@ int setup_files(struct thread_data *td)
                }
        }
 
-       if (!o->size || o->size > total_size)
+       if (!o->size || (total_size && o->size > total_size))
                o->size = total_size;
 
        if (o->size < td_min_bs(td)) {
@@ -1094,6 +1093,11 @@ void close_and_free_files(struct thread_data *td)
        dprint(FD_FILE, "close files\n");
 
        for_each_file(td, f, i) {
+               if (td->o.unlink && f->filetype == FIO_TYPE_FILE) {
+                       dprint(FD_FILE, "free unlink %s\n", f->file_name);
+                       td_io_unlink_file(td, f);
+               }
+
                if (fio_file_open(f))
                        td_io_close_file(td, f);
 
@@ -1101,7 +1105,7 @@ void close_and_free_files(struct thread_data *td)
 
                if (td->o.unlink && f->filetype == FIO_TYPE_FILE) {
                        dprint(FD_FILE, "free unlink %s\n", f->file_name);
-                       unlink(f->file_name);
+                       td_io_unlink_file(td, f);
                }
 
                sfree(f->file_name);