return 1;
}
-int reopen_file(struct thread_data *td, struct fio_file *f)
-{
- f->last_free_lookup = 0;
- f->last_completed_pos = 0;
- f->last_pos = 0;
-
- if (f->file_map)
- memset(f->file_map, 0, f->num_maps * sizeof(long));
-
- return td_io_open_file(td, f);
-}
-
int open_files(struct thread_data *td)
{
struct fio_file *f;
return 0;
}
-static void clear_io_state(struct thread_data *td)
+static int clear_io_state(struct thread_data *td)
{
struct fio_file *f;
- int i;
+ int i, ret;
td->ts.stat_io_bytes[0] = td->ts.stat_io_bytes[1] = 0;
td->this_io_bytes[0] = td->this_io_bytes[1] = 0;
td->last_was_sync = 0;
- for_each_file(td, f, i) {
- f->last_completed_pos = 0;
-
- f->last_pos = 0;
- if (td->io_ops->flags & FIO_SYNCIO)
- lseek(f->fd, SEEK_SET, 0);
+ for_each_file(td, f, i)
+ td_io_close_file(td, f);
- if (f->file_map)
- memset(f->file_map, 0, f->num_maps * sizeof(long));
+ ret = 0;
+ for_each_file(td, f, i) {
+ ret = td_io_open_file(td, f);
+ if (ret)
+ break;
}
+
+ return ret;
}
/*
{
unsigned long long runtime[2];
struct thread_data *td = data;
+ int clear_state;
if (!td->use_thread)
setsid();
getrusage(RUSAGE_SELF, &td->ts.ru_start);
runtime[0] = runtime[1] = 0;
+ clear_state = 0;
while (td->loops--) {
fio_gettime(&td->start, NULL);
memcpy(&td->ts.stat_sample_time, &td->start, sizeof(td->start));
if (td->ratemin)
memcpy(&td->lastrate, &td->ts.stat_sample_time, sizeof(td->lastrate));
- clear_io_state(td);
+ if (clear_state && clear_io_state(td))
+ break;
+
prune_io_piece_log(td);
if (td->io_ops->flags & FIO_CPUIO)
else
do_io(td);
+ clear_state = 1;
+
if (td_read(td) && td->io_bytes[DDIR_READ])
runtime[DDIR_READ] += utime_since_now(&td->start);
if (td_write(td) && td->io_bytes[DDIR_WRITE])
if (td->verify == VERIFY_NONE)
continue;
- clear_io_state(td);
+ if (clear_io_state(td))
+ break;
+
fio_gettime(&td->start, NULL);
do_verify(td);
extern void close_files(struct thread_data *);
extern int __must_check setup_files(struct thread_data *);
extern int __must_check open_files(struct thread_data *);
-extern int reopen_file(struct thread_data *, struct fio_file *);
extern int __must_check file_invalidate_cache(struct thread_data *, struct fio_file *);
extern int __must_check generic_open_file(struct thread_data *, struct fio_file *);
extern void generic_close_file(struct thread_data *, struct fio_file *);
* if we need to open a new file
*/
if (td->nr_open_files < td->nr_files &&
- td->open_files != td->nr_files)
- reopen_file(td, f);
+ td->open_files != td->nr_files) {
+ int ret = td_io_open_file(td, f);
+
+ if (ret) {
+ put_io_u(td, io_u);
+ return NULL;
+ }
+ }
} while (1);
if (td->zone_bytes >= td->zone_size) {
int td_io_open_file(struct thread_data *td, struct fio_file *f)
{
- if (!td->io_ops->open_file(td, f)) {
- f->open = 1;
- td->nr_open_files++;
- return 0;
- }
+ if (td->io_ops->open_file(td, f))
+ return 1;
- return 1;
+ f->last_free_lookup = 0;
+ f->last_completed_pos = 0;
+ f->last_pos = 0;
+ f->open = 1;
+
+ if (f->file_map)
+ memset(f->file_map, 0, f->num_maps * sizeof(long));
+
+ td->nr_open_files++;
+ return 0;
}
void td_io_close_file(struct thread_data *td, struct fio_file *f)