projects
/
fio.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
e4f26f0
)
[PATCH] Remove last remnants of file extending
author
Jens Axboe
<axboe@suse.de>
Tue, 13 Jun 2006 07:11:18 +0000
(09:11 +0200)
committer
Jens Axboe
<axboe@suse.de>
Tue, 13 Jun 2006 07:11:18 +0000
(09:11 +0200)
fio.c
patch
|
blob
|
blame
|
history
init.c
patch
|
blob
|
blame
|
history
diff --git
a/fio.c
b/fio.c
index af167832ed43aefcc76f01f88a143fc51e7658f7..5bced2469ceaa217fbb67af80e9e29fc532f7582 100644
(file)
--- a/
fio.c
+++ b/
fio.c
@@
-941,18
+941,17
@@
static int init_io_u(struct thread_data *td)
return 0;
}
return 0;
}
-static int create_file(struct thread_data *td, unsigned long long size,
- int extend)
+static int create_file(struct thread_data *td, unsigned long long size)
{
unsigned long long left;
unsigned int bs;
{
unsigned long long left;
unsigned int bs;
- int r, oflags;
char *b;
char *b;
+ int r;
/*
* unless specifically asked for overwrite, let normal io extend it
*/
/*
* unless specifically asked for overwrite, let normal io extend it
*/
- if (
td_write(td) &&
!td->overwrite) {
+ if (!td->overwrite) {
td->real_file_size = size;
return 0;
}
td->real_file_size = size;
return 0;
}
@@
-964,19
+963,15
@@
static int create_file(struct thread_data *td, unsigned long long size,
}
temp_stall_ts = 1;
}
temp_stall_ts = 1;
+ fprintf(f_out, "%s: Laying out IO file (%LuMiB)\n",td->name,size >> 20);
- if (!extend) {
- oflags = O_CREAT | O_TRUNC;
- fprintf(f_out, "%s: Laying out IO file (%LuMiB)\n", td->name, size >> 20);
- }
-
- td->fd = open(td->file_name, O_WRONLY | oflags, 0644);
+ td->fd = open(td->file_name, O_WRONLY | O_CREAT | O_TRUNC, 0644);
if (td->fd < 0) {
td_verror(td, errno);
goto done_noclose;
}
if (td->fd < 0) {
td_verror(td, errno);
goto done_noclose;
}
- if (
!extend &&
ftruncate(td->fd, td->file_size) == -1) {
+ if (ftruncate(td->fd, td->file_size) == -1) {
td_verror(td, errno);
goto done;
}
td_verror(td, errno);
goto done;
}
@@
-1177,13
+1172,12
@@
static int setup_file(struct thread_data *td)
td_verror(td, ENOENT);
return 1;
}
td_verror(td, ENOENT);
return 1;
}
- if (create_file(td, td->file_size, 0))
+ if (create_file(td, td->file_size))
+ return 1;
+ } else if (td->filetype == FIO_TYPE_FILE &&
+ st.st_size < (off_t) td->file_size) {
+ if (create_file(td, td->file_size))
return 1;
return 1;
- } else if (td->filetype == FIO_TYPE_FILE) {
- if (st.st_size < (off_t) td->file_size) {
- if (create_file(td, td->file_size, 1))
- return 1;
- }
}
if (td->odirect)
}
if (td->odirect)
diff --git
a/init.c
b/init.c
index 40fcf1c35f61a5426648ee19dcfa9f680147bcf1..32d1e5cdecaa999509651d931924bbd2f576bf5f 100644
(file)
--- a/
init.c
+++ b/
init.c
@@
-122,6
+122,12
@@
static int add_job(struct thread_data *td, const char *jobname, int job_add_num)
if (td->zone_size && !td->sequential)
td->zone_size = 0;
if (td->zone_size && !td->sequential)
td->zone_size = 0;
+ /*
+ * Reads can do overwrites, we always need to pre-create the file
+ */
+ if (td_read(td) || td_rw(td))
+ td->overwrite = 1;
+
td->filetype = FIO_TYPE_FILE;
if (!stat(jobname, &sb)) {
if (S_ISBLK(sb.st_mode))
td->filetype = FIO_TYPE_FILE;
if (!stat(jobname, &sb)) {
if (S_ISBLK(sb.st_mode))