buflen = (buflen + td->min_bs - 1) & ~(td->min_bs - 1);
}
- if (buflen > td->io_size - td->this_io_bytes[td->ddir])
+ if (buflen > td->io_size - td->this_io_bytes[td->ddir]) {
+ /*
+ * if using direct/raw io, we may not be able to
+ * shrink the size. so just fail it.
+ */
+ if (td->io_ops->flags & FIO_RAWIO)
+ return 0;
+
buflen = td->io_size - td->this_io_bytes[td->ddir];
+ }
return buflen;
}
return NULL;
}
- if (io_u->buflen + io_u->offset > f->file_size)
+ if (io_u->buflen + io_u->offset > f->file_size) {
+ if (td->io_ops->flags & FIO_RAWIO) {
+ put_io_u(td, io_u);
+ return NULL;
+ }
+
io_u->buflen = f->file_size - io_u->offset;
+ }
if (!io_u->buflen) {
put_io_u(td, io_u);
static struct fio_file *get_next_file(struct thread_data *td)
{
- struct fio_file *f = &td->files[td->next_file];
+ int old_next_file = td->next_file;
+ struct fio_file *f;
- td->next_file++;
- if (td->next_file >= td->nr_files)
- td->next_file = 0;
+ do {
+ f = &td->files[td->next_file];
+
+ td->next_file++;
+ if (td->next_file >= td->nr_files)
+ td->next_file = 0;
+
+ if (f->fd != -1)
+ break;
+
+ f = NULL;
+ } while (td->next_file != old_next_file);
return f;
}
return 0;
}
-static int io_u_getevents(struct thread_data *td, int min, int max,
+static int td_io_getevents(struct thread_data *td, int min, int max,
struct timespec *t)
{
return td->io_ops->getevents(td, min, max, t);
}
-static int io_u_queue(struct thread_data *td, struct io_u *io_u)
+static int td_io_queue(struct thread_data *td, struct io_u *io_u)
{
gettimeofday(&io_u->issue_time, NULL);
/*
* get immediately available events, if any
*/
- r = io_u_getevents(td, 0, td->cur_depth, &ts);
+ r = td_io_getevents(td, 0, td->cur_depth, &ts);
if (r > 0) {
icd.nr = r;
ios_completed(td, &icd);
}
if (td->cur_depth) {
- r = io_u_getevents(td, td->cur_depth, td->cur_depth, NULL);
+ r = td_io_getevents(td, td->cur_depth, td->cur_depth, NULL);
if (r > 0) {
icd.nr = r;
ios_completed(td, &icd);
break;
}
- ret = io_u_queue(td, io_u);
+ ret = td_io_queue(td, io_u);
if (ret) {
put_io_u(td, io_u);
td_verror(td, ret);
if (do_io_u_verify(td, &v_io_u))
break;
- ret = io_u_getevents(td, 1, 1, NULL);
+ ret = td_io_getevents(td, 1, 1, NULL);
if (ret != 1) {
if (ret < 0)
td_verror(td, ret);
memcpy(&s, &io_u->start_time, sizeof(s));
- ret = io_u_queue(td, io_u);
+ ret = td_io_queue(td, io_u);
if (ret) {
put_io_u(td, io_u);
td_verror(td, ret);
min_evts = 1;
}
- ret = io_u_getevents(td, min_evts, td->cur_depth, timeout);
+ ret = td_io_getevents(td, min_evts, td->cur_depth, timeout);
if (ret < 0) {
td_verror(td, ret);
break;
}
}
-static int init_io(struct thread_data *td)
+static int td_io_init(struct thread_data *td)
{
if (td->io_ops->init)
return td->io_ops->init(td);
goto err;
}
- if (init_io(td))
+ if (td_io_init(td))
goto err;
if (init_iolog(td))
bytes_total = td->total_io_size;
- /*
- * if writing, bytes_total will be twice the size. If mixing,
- * assume a 50/50 split and thus bytes_total will be 50% larger.
- */
- if (td->verify) {
- if (td_rw(td))
- bytes_total = bytes_total * 3 / 2;
- else
- bytes_total <<= 1;
- }
if (td->zone_size && td->zone_skip)
bytes_total /= (td->zone_skip / td->zone_size);