projects
/
fio.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Fio 1.29
[fio.git]
/
filesetup.c
diff --git
a/filesetup.c
b/filesetup.c
index 7ed47a25b5846108125e1028f30fa51d9cb87425..1a5a7eccb1b8c95c545c7b94923990d6a005e23c 100644
(file)
--- a/
filesetup.c
+++ b/
filesetup.c
@@
-13,6
+13,12
@@
static int root_warn;
static int root_warn;
+static inline void clear_error(struct thread_data *td)
+{
+ td->error = 0;
+ td->verror[0] = '\0';
+}
+
/*
* Leaves f->fd open on success, caller must close
*/
/*
* Leaves f->fd open on success, caller must close
*/
@@
-126,7
+132,7
@@
static int extend_file(struct thread_data *td, struct fio_file *f)
goto err;
}
}
goto err;
}
}
- if (td->o.fill_device) {
+ if (td->o.fill_device
&& !td_write(td)
) {
fio_file_clear_size_known(f);
if (td_io_get_file_size(td, f))
goto err;
fio_file_clear_size_known(f);
if (td_io_get_file_size(td, f))
goto err;
@@
-150,6
+156,9
@@
static int pre_read_file(struct thread_data *td, struct fio_file *f)
unsigned int bs;
char *b;
unsigned int bs;
char *b;
+ if (td->io_ops->flags & FIO_PIPEIO)
+ return 0;
+
if (!fio_file_open(f)) {
if (td->io_ops->open_file(td, f)) {
log_err("fio: cannot pre-read, failed to open file\n");
if (!fio_file_open(f)) {
if (td->io_ops->open_file(td, f)) {
log_err("fio: cannot pre-read, failed to open file\n");
@@
-240,6
+249,7
@@
static int bdev_size(struct thread_data *td, struct fio_file *f)
}
f->real_file_size = bytes;
}
f->real_file_size = bytes;
+ td->io_ops->close_file(td, f);
return 0;
err:
td->io_ops->close_file(td, f);
return 0;
err:
td->io_ops->close_file(td, f);
@@
-284,6
+294,9
@@
static int __file_invalidate_cache(struct thread_data *td, struct fio_file *f,
if (off == -1ULL)
off = f->file_offset;
if (off == -1ULL)
off = f->file_offset;
+ if (len == -1ULL || off == -1ULL)
+ return 0;
+
dprint(FD_IO, "invalidate cache %s: %llu/%llu\n", f->file_name, off,
len);
dprint(FD_IO, "invalidate cache %s: %llu/%llu\n", f->file_name, off,
len);
@@
-426,7
+439,7
@@
open_again:
char buf[FIO_VERROR_SIZE];
int __e = errno;
char buf[FIO_VERROR_SIZE];
int __e = errno;
- if (
errno
== EPERM && (flags & FIO_O_NOATIME)) {
+ if (
__e
== EPERM && (flags & FIO_O_NOATIME)) {
flags &= ~FIO_O_NOATIME;
goto open_again;
}
flags &= ~FIO_O_NOATIME;
goto open_again;
}
@@
-700,8
+713,10
@@
void close_files(struct thread_data *td)
struct fio_file *f;
unsigned int i;
struct fio_file *f;
unsigned int i;
- for_each_file(td, f, i)
- td_io_close_file(td, f);
+ for_each_file(td, f, i) {
+ if (fio_file_open(f))
+ td_io_close_file(td, f);
+ }
}
void close_and_free_files(struct thread_data *td)
}
void close_and_free_files(struct thread_data *td)
@@
-717,7
+732,9
@@
void close_and_free_files(struct thread_data *td)
unlink(f->file_name);
}
unlink(f->file_name);
}
- td_io_close_file(td, f);
+ if (fio_file_open(f))
+ td_io_close_file(td, f);
+
remove_file_hash(f);
sfree(f->file_name);
remove_file_hash(f);
sfree(f->file_name);
@@
-838,8
+855,10
@@
int put_file(struct thread_data *td, struct fio_file *f)
dprint(FD_FILE, "put file %s, ref=%d\n", f->file_name, f->references);
dprint(FD_FILE, "put file %s, ref=%d\n", f->file_name, f->references);
- if (!fio_file_open(f))
+ if (!fio_file_open(f)) {
+ assert(f->fd == -1);
return 0;
return 0;
+ }
assert(f->references);
if (--f->references)
assert(f->references);
if (--f->references)
@@
-856,6
+875,7
@@
int put_file(struct thread_data *td, struct fio_file *f)
td->nr_open_files--;
fio_file_clear_open(f);
td->nr_open_files--;
fio_file_clear_open(f);
+ assert(f->fd == -1);
return ret;
}
return ret;
}
@@
-995,6
+1015,7
@@
void dup_files(struct thread_data *td, struct thread_data *org)
log_err("fio: smalloc OOM\n");
assert(0);
}
log_err("fio: smalloc OOM\n");
assert(0);
}
+ __f->fd = -1;
if (f->file_name) {
__f->file_name = smalloc_strdup(f->file_name);
if (f->file_name) {
__f->file_name = smalloc_strdup(f->file_name);