[PATCH Various fixes
- Multiple files fixes
- Fix for unaligned io issued for raw io
Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
diff --git a/fio.c b/fio.c
index dc228a8..405346b 100644
--- a/fio.c
+++ b/fio.c
@@ -219,8 +219,16 @@
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;
}
@@ -526,8 +534,14 @@
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);
@@ -577,11 +591,21 @@
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;
}