Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
return FIO_Q_COMPLETED;
}
return FIO_Q_COMPLETED;
}
-static int fio_mmapio_init(struct thread_data *td)
-{
- struct fio_file *f;
- int i;
-
- if (!td_write(td))
- return 0;
-
- /*
- * We need to truncate the files to the right size, if
- * we are writing to it.
- */
- for_each_file(td, f, i) {
- if (ftruncate(f->fd, f->file_size) < 0) {
- td_verror(td, errno, "ftruncate");
- return 1;
- }
- }
-
- return 0;
-}
-
static int fio_mmapio_open(struct thread_data *td, struct fio_file *f)
{
int ret, flags;
static int fio_mmapio_open(struct thread_data *td, struct fio_file *f)
{
int ret, flags;
- if (f->mmap)
- munmap(f->mmap, f->file_size);
- generic_close_file(td, f);
+ td->io_ops->close_file(td, f);
munmap(f->mmap, f->file_size);
f->mmap = NULL;
}
munmap(f->mmap, f->file_size);
f->mmap = NULL;
}
+ generic_close_file(td, f);
}
static struct ioengine_ops ioengine = {
.name = "mmap",
.version = FIO_IOOPS_VERSION,
.queue = fio_mmapio_queue,
}
static struct ioengine_ops ioengine = {
.name = "mmap",
.version = FIO_IOOPS_VERSION,
.queue = fio_mmapio_queue,
- .init = fio_mmapio_init,
.open_file = fio_mmapio_open,
.close_file = fio_mmapio_close,
.open_file = fio_mmapio_open,
.close_file = fio_mmapio_close,
+ .flags = FIO_SYNCIO | FIO_NOEXTEND,
};
static void fio_init fio_mmapio_register(void)
};
static void fio_init fio_mmapio_register(void)
static int create_files(struct thread_data *td)
{
struct fio_file *f;
static int create_files(struct thread_data *td)
{
struct fio_file *f;
- int i, err, need_create;
+ int i, err, need_create, can_extend;
for_each_file(td, f, i)
f->file_size = td->total_file_size / td->nr_files;
for_each_file(td, f, i)
f->file_size = td->total_file_size / td->nr_files;
/*
* unless specifically asked for overwrite, let normal io extend it
*/
/*
* unless specifically asked for overwrite, let normal io extend it
*/
+ can_extend = !td->overwrite && !(td->io_ops->flags & FIO_NOEXTEND);
+ if (can_extend)
return 0;
need_create = 0;
return 0;
need_create = 0;
for_each_file(td, f, i) {
int file_there = !file_ok(td, f);
for_each_file(td, f, i) {
int file_there = !file_ok(td, f);
- if (file_there && td_write(td) && !td->overwrite) {
+ if (file_there && td_write(td) && !can_extend) {
unlink(f->file_name);
file_there = 0;
}
unlink(f->file_name);
file_there = 0;
}
- if (!td->invalidate_cache)
- return 0;
if (td->odirect)
return 0;
if (td->odirect)
return 0;
if (td_write(td) || td_rw(td)) {
flags |= O_RDWR;
if (td_write(td) || td_rw(td)) {
flags |= O_RDWR;
- if (td->filetype == FIO_TYPE_FILE) {
- if (!td->overwrite)
- flags |= O_TRUNC;
-
+ if (td->filetype == FIO_TYPE_FILE)
f->fd = open(f->file_name, flags, 0600);
} else {
f->fd = open(f->file_name, flags, 0600);
} else {
if (get_file_size(td, f))
goto err;
if (get_file_size(td, f))
goto err;
- if (file_invalidate_cache(td, f))
+ if (td->invalidate_cache && file_invalidate_cache(td, f))
goto err;
if (!td_random(td)) {
goto err;
if (!td_random(td)) {
FIO_SYNCIO = 1 << 0, /* io engine has synchronous ->queue */
FIO_RAWIO = 1 << 1, /* some sort of direct/raw io */
FIO_DISKLESSIO = 1 << 2, /* no disk involved */
FIO_SYNCIO = 1 << 0, /* io engine has synchronous ->queue */
FIO_RAWIO = 1 << 1, /* some sort of direct/raw io */
FIO_DISKLESSIO = 1 << 2, /* no disk involved */
+ FIO_NOEXTEND = 1 << 3, /* engine can't extend file */