Fio 1.43
[fio.git] / filesetup.c
index b90d12ae8f17aefb4aeb11c1dac3a45b697c9546..5a8105a6032e24b2e45a8a9d028c2a0b7e2552fe 100644 (file)
@@ -71,9 +71,9 @@ static int extend_file(struct thread_data *td, struct fio_file *f)
                                                        f->real_file_size);
 
                r = posix_fallocate(f->fd, 0, f->real_file_size);
-               if (r < 0) {
+               if (r > 0) {
                        log_err("fio: posix_fallocate fails: %s\n",
-                                       strerror(-r));
+                                       strerror(r));
                }
        }
 #endif
@@ -909,6 +909,7 @@ int add_file(struct thread_data *td, const char *fname)
        }
 
        f->fd = -1;
+       fio_file_reset(f);
 
        if (td->files_size <= td->files_index) {
                int new_size = td->o.nr_files + 1;
@@ -962,6 +963,19 @@ int add_file(struct thread_data *td, const char *fname)
        return cur_files;
 }
 
+int add_file_exclusive(struct thread_data *td, const char *fname)
+{
+       struct fio_file *f;
+       unsigned int i;
+
+       for_each_file(td, f, i) {
+               if (!strcmp(f->file_name, fname))
+                       return i;
+       }
+
+       return add_file(td, fname);
+}
+
 void get_file(struct fio_file *f)
 {
        dprint(FD_FILE, "get file %s, ref=%d\n", f->file_name, f->references);
@@ -1136,6 +1150,7 @@ void dup_files(struct thread_data *td, struct thread_data *org)
                        assert(0);
                }
                __f->fd = -1;
+               fio_file_reset(__f);
 
                if (f->file_name) {
                        __f->file_name = smalloc_strdup(f->file_name);