Style cleanup
[fio.git] / filesetup.c
index faef907aeefd44429896aa156f2fa4944593cac4..5584a3665475e87bc02074b8328f887db8787d2c 100644 (file)
@@ -123,7 +123,7 @@ static int create_files(struct thread_data *td)
 {
        struct fio_file *f;
        int err, need_create, can_extend;
-       unsigned long long total_file_size, local_file_size;
+       unsigned long long total_file_size, local_file_size, create_size;
        unsigned int i, new_files;
 
        new_files = 0;
@@ -153,18 +153,22 @@ static int create_files(struct thread_data *td)
        if (can_extend)
                return 0;
 
-       need_create = 0;
        local_file_size = total_file_size;
        if (!local_file_size)
                local_file_size = -1;
 
+       total_file_size = 0;
+       need_create = 0;
+       create_size = 0;
        for_each_file(td, f, i) {
                int file_there;
 
                if (f->filetype != FIO_TYPE_FILE)
                        continue;
-               if (f->flags & FIO_FILE_EXISTS)
+               if (f->flags & FIO_FILE_EXISTS) {
+                       total_file_size += f->file_size;
                        continue;
+               }
 
                if (!td->file_size_low)
                        f->file_size = total_file_size / new_files;
@@ -184,6 +188,8 @@ static int create_files(struct thread_data *td)
                        local_file_size -= f->file_size;
                }
 
+               total_file_size += f->file_size;
+               create_size += f->file_size;
                file_there = !file_ok(td, f);
 
                if (file_there && td_write(td) && !td->overwrite) {
@@ -197,7 +203,7 @@ static int create_files(struct thread_data *td)
        if (!need_create)
                return 0;
 
-       if (!td->total_file_size) {
+       if (!td->total_file_size && !total_file_size) {
                log_err("Need size for create\n");
                td_verror(td, EINVAL, "file_size");
                return 1;
@@ -205,7 +211,7 @@ static int create_files(struct thread_data *td)
 
        temp_stall_ts = 1;
        log_info("%s: Laying out IO file(s) (%u files / %LuMiB)\n",
-                               td->name, new_files, total_file_size >> 20);
+                               td->name, new_files, create_size >> 20);
 
        err = 0;
        for_each_file(td, f, i) {
@@ -305,11 +311,11 @@ int file_invalidate_cache(struct thread_data *td, struct fio_file *f)
         */
        if (f->mmap)
                ret = madvise(f->mmap, f->file_size, MADV_DONTNEED);
-       else if (f->filetype == FIO_TYPE_FILE) {
+       else if (f->filetype == FIO_TYPE_FILE)
                ret = fadvise(f->fd, f->file_offset, f->file_size, POSIX_FADV_DONTNEED);
-       } else if (f->filetype == FIO_TYPE_BD) {
+       else if (f->filetype == FIO_TYPE_BD)
                ret = blockdev_invalidate_cache(f->fd);
-       else if (f->filetype == FIO_TYPE_CHAR)
+       else if (f->filetype == FIO_TYPE_CHAR)
                ret = 0;
 
        if (ret < 0) {