- Multiple files fixes
- Fix for unaligned io issued for raw io
Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
.event = fio_sgio_event,
.cleanup = fio_sgio_cleanup,
.sync = fio_sgio_sync,
.event = fio_sgio_event,
.cleanup = fio_sgio_cleanup,
.sync = fio_sgio_sync,
+ .flags = FIO_SYNCIO | FIO_RAWIO,
{
unsigned long long left;
unsigned int bs;
{
unsigned long long left;
unsigned int bs;
+ if (td->filetype != FIO_TYPE_FILE)
+ return 0;
+
+ if (stat(f->file_name, &st) == -1) {
+ if (!td->create_file) {
+ td_verror(td, ENOENT);
+ return 1;
+ }
+ } else if (st.st_size >= (off_t) f->file_size)
+ return 0;
+
f->fd = open(f->file_name, O_WRONLY | O_CREAT | O_TRUNC, 0644);
if (f->fd < 0) {
td_verror(td, errno);
f->fd = open(f->file_name, O_WRONLY | O_CREAT | O_TRUNC, 0644);
if (f->fd < 0) {
td_verror(td, errno);
for_each_file(td, f, i) {
f->file_size = td->total_file_size / td->nr_files;
err = create_file(td, f);
for_each_file(td, f, i) {
f->file_size = td->total_file_size / td->nr_files;
err = create_file(td, f);
break;
td->io_size += f->file_size;
break;
td->io_size += f->file_size;
static int setup_file(struct thread_data *td, struct fio_file *f)
{
static int setup_file(struct thread_data *td, struct fio_file *f)
{
- if (stat(f->file_name, &st) == -1) {
- if (errno != ENOENT) {
- td_verror(td, errno);
- return 1;
- }
- if (!td->create_file) {
- td_verror(td, ENOENT);
- return 1;
- }
- if (create_file(td, f))
- return 1;
- } else if (td->filetype == FIO_TYPE_FILE &&
- st.st_size < (off_t) f->file_size) {
- if (create_file(td, f))
- return 1;
- }
-
if (td->odirect)
flags |= OS_O_DIRECT;
if (td->odirect)
flags |= OS_O_DIRECT;
buflen = (buflen + td->min_bs - 1) & ~(td->min_bs - 1);
}
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];
buflen = td->io_size - td->this_io_bytes[td->ddir];
- 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;
io_u->buflen = f->file_size - io_u->offset;
if (!io_u->buflen) {
put_io_u(td, io_u);
if (!io_u->buflen) {
put_io_u(td, io_u);
static struct fio_file *get_next_file(struct thread_data *td)
{
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;
+
+ 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;
- td->next_file++;
- if (td->next_file >= td->nr_files)
- td->next_file = 0;
+ f = NULL;
+ } while (td->next_file != old_next_file);
FIO_SYNCIO = 1 << 0,
FIO_CPUIO = 1 << 1,
FIO_MMAPIO = 1 << 2,
FIO_SYNCIO = 1 << 0,
FIO_CPUIO = 1 << 1,
FIO_MMAPIO = 1 << 2,
unsigned long *file_map;
unsigned int num_maps;
unsigned long *file_map;
unsigned int num_maps;
#define fio_unused __attribute((__unused__))
#define for_each_file(td, f, i) \
#define fio_unused __attribute((__unused__))
#define for_each_file(td, f, i) \
- for ((i) = 0, (f) = &(td)->files[(i)]; (i) < (td)->nr_files; (i)++, (f) = &(td)->files[(i)])
+ for ((i) = 0, (f) = &(td)->files[0]; (i) < (td)->nr_files; (i)++, (f) = &(td)->files[(i)])
td->filetype = FIO_TYPE_CHAR;
}
td->filetype = FIO_TYPE_CHAR;
}
+ if (td->odirect)
+ td->io_ops->flags |= FIO_RAWIO;
+
if (td->filetype == FIO_TYPE_FILE) {
char tmp[PATH_MAX];
int len = 0;
if (td->filetype == FIO_TYPE_FILE) {
char tmp[PATH_MAX];
int len = 0;
for_each_file(td, f, i) {
memset(f, 0, sizeof(*f));
f->fd = -1;
for_each_file(td, f, i) {
memset(f, 0, sizeof(*f));
f->fd = -1;
sprintf(tmp + len, "%s.%d.%d", jobname, td->thread_number, i);
f->file_name = strdup(tmp);
sprintf(tmp + len, "%s.%d.%d", jobname, td->thread_number, i);
f->file_name = strdup(tmp);