fileno = (unsigned int) ((double) (td->open_files * r) / (RAND_MAX + 1.0));
f = &td->files[fileno];
- if (f->open)
+ if ((f->flags & FIO_FILE_OPEN) &&
+ !(f->flags & FIO_FILE_CLOSING))
return f;
} while (1);
}
if (td->next_file >= td->open_files)
td->next_file = 0;
- if (f->open)
+ if ((f->flags & FIO_FILE_OPEN) &&
+ !(f->flags & FIO_FILE_CLOSING))
break;
f = NULL;
return NULL;
f = td->file_service_file;
- if (f && f->open && td->file_service_left--)
+ if (f && (f->flags & FIO_FILE_OPEN) && td->file_service_left--)
return f;
if (td->file_service_type == FIO_FSERVICE_RR)
assert(io_u->flags & IO_U_F_FLIGHT);
io_u->flags &= ~IO_U_F_FLIGHT;
+ put_file(td, io_u->file);
+
if (io_u->ddir == DDIR_SYNC) {
td->last_was_sync = 1;
return;