- td->io_size = td->total_file_size;
- if (td->io_size == 0) {
- log_err("%s: no io blocks\n", td->name);
- td_verror(td, EINVAL, "total_file_size");
+ td->files_index++;
+ if (f->filetype == FIO_TYPE_FILE)
+ td->nr_normal_files++;
+
+ return cur_files;
+}
+
+void get_file(struct fio_file *f)
+{
+ assert(f->flags & FIO_FILE_OPEN);
+ f->references++;
+}
+
+void put_file(struct thread_data *td, struct fio_file *f)
+{
+ if (!(f->flags & FIO_FILE_OPEN))
+ return;
+
+ assert(f->references);
+ if (--f->references)
+ return;
+
+ if (should_fsync(td) && td->o.fsync_on_close)
+ fsync(f->fd);
+
+ if (td->io_ops->close_file)
+ td->io_ops->close_file(td, f);
+
+ td->nr_open_files--;
+ f->flags &= ~FIO_FILE_OPEN;
+}
+
+static int recurse_dir(struct thread_data *td, const char *dirname)
+{
+ struct dirent *dir;
+ int ret = 0;
+ DIR *D;
+
+ D = opendir(dirname);
+ if (!D) {
+ char buf[FIO_VERROR_SIZE];
+
+ snprintf(buf, FIO_VERROR_SIZE - 1, "opendir(%s)", dirname);
+ td_verror(td, errno, buf);