projects
/
fio.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
[PATCH] Don't put_job() on def_thread
[fio.git]
/
filesetup.c
diff --git
a/filesetup.c
b/filesetup.c
index 3f9bdb8333f989057529652eee34f5a6a0378116..0b9564044d14135d662363219471c674c2670714 100644
(file)
--- a/
filesetup.c
+++ b/
filesetup.c
@@
-44,6
+44,11
@@
static int create_file(struct thread_data *td, struct fio_file *f)
goto err;
}
goto err;
}
+ if (posix_fallocate(f->fd, 0, f->file_size) < 0) {
+ td_verror(td, errno);
+ goto err;
+ }
+
b = malloc(td->max_bs);
memset(b, 0, td->max_bs);
b = malloc(td->max_bs);
memset(b, 0, td->max_bs);
@@
-99,13
+104,9
@@
static int create_files(struct thread_data *td)
}
need_create = 0;
}
need_create = 0;
- for_each_file(td, f, i) {
- if (td->filetype == FIO_TYPE_FILE) {
- f->file_size = td->total_file_size / td->nr_files;
+ if (td->filetype == FIO_TYPE_FILE)
+ for_each_file(td, f, i)
need_create += file_ok(td, f);
need_create += file_ok(td, f);
- } else
- td->total_file_size += f->file_size;
- }
if (!need_create)
return 0;
if (!need_create)
return 0;
@@
-118,8
+119,8
@@
static int create_files(struct thread_data *td)
temp_stall_ts = 1;
fprintf(f_out, "%s: Laying out IO file(s) (%d x %LuMiB == %LuMiB)\n",
temp_stall_ts = 1;
fprintf(f_out, "%s: Laying out IO file(s) (%d x %LuMiB == %LuMiB)\n",
- td->name, td->nr_files,
- (td->total_file_size >> 20) / td->nr_files,
+ td->name, td->nr_
uniq_
files,
+ (td->total_file_size >> 20) / td->nr_
uniq_
files,
td->total_file_size >> 20);
err = 0;
td->total_file_size >> 20);
err = 0;
@@
-348,7
+349,6
@@
static int setup_file(struct thread_data *td, struct fio_file *f)
if (get_file_size(td, f))
return 1;
if (get_file_size(td, f))
return 1;
- td->total_file_size += f->file_size;
return 0;
}
return 0;
}
@@
-377,6
+377,13
@@
int setup_files(struct thread_data *td)
if (err)
return err;
if (err)
return err;
+ /*
+ * Recalculate the total file size now that files are set up.
+ */
+ td->total_file_size = 0;
+ for_each_file(td, f, i)
+ td->total_file_size += f->file_size;
+
td->io_size = td->total_file_size;
if (td->io_size == 0) {
log_err("%s: no io blocks\n", td->name);
td->io_size = td->total_file_size;
if (td->io_size == 0) {
log_err("%s: no io blocks\n", td->name);
@@
-402,8
+409,13
@@
void close_files(struct thread_data *td)
for_each_file(td, f, i) {
if (f->fd != -1) {
for_each_file(td, f, i) {
if (f->fd != -1) {
- if (td->unlink && td->filetype == FIO_TYPE_FILE)
+ if (td->unlink && td->filetype == FIO_TYPE_FILE &&
+ td->filename) {
unlink(f->file_name);
unlink(f->file_name);
+ td->filename = NULL;
+ }
+ free(f->file_name);
+ f->file_name = NULL;
close(f->fd);
f->fd = -1;
}
close(f->fd);
f->fd = -1;
}
@@
-412,4
+424,8
@@
void close_files(struct thread_data *td)
f->mmap = NULL;
}
}
f->mmap = NULL;
}
}
+
+ free(td->files);
+ td->files = NULL;
+ td->nr_files = 0;
}
}