Don't use ->fd == -1 to check for the file being open or not,
an io engine could be non-fd based.
Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
unsigned int last_free_lookup;
unsigned int unlink;
+ unsigned int open;
};
/*
fileno = (unsigned int) ((double) (td->open_files * r) / (RAND_MAX + 1.0));
f = &td->files[fileno];
- if (f->fd != -1)
+ if (f->open)
return f;
} while (1);
}
if (td->next_file >= td->open_files)
td->next_file = 0;
- if (f->fd != -1)
+ if (f->open)
break;
f = NULL;
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;
}
void td_io_close_file(struct thread_data *td, struct fio_file *f)
{
- if (td->io_ops->close_file)
- td->io_ops->close_file(td, f);
- td->nr_open_files--;
+ if (f->open) {
+ if (td->io_ops->close_file)
+ td->io_ops->close_file(td, f);
+ td->nr_open_files--;
+ f->open = 0;
+ }
}