From 07eb79dfa0e3801875d1c2907cfdb5da7c9d2cb3 Mon Sep 17 00:00:00 2001 From: Jens Axboe Date: Thu, 12 Apr 2007 13:02:38 +0200 Subject: [PATCH 1/1] Put the ->real_file_size handling into fio Then we can remove it from the io engines, where the disk-less IO engines provided a ->setup() hook just to set that. Signed-off-by: Jens Axboe --- engines/cpu.c | 16 ---------------- engines/net.c | 9 --------- engines/null.c | 16 ---------------- filesetup.c | 12 ++++++++++-- init.c | 7 +++++++ 5 files changed, 17 insertions(+), 43 deletions(-) diff --git a/engines/cpu.c b/engines/cpu.c index dd69cede..14ad9717 100644 --- a/engines/cpu.c +++ b/engines/cpu.c @@ -13,21 +13,6 @@ static int fio_cpuio_queue(struct thread_data *td, struct io_u fio_unused *io_u) return FIO_Q_COMPLETED; } -static int fio_cpuio_setup(struct thread_data fio_unused *td) -{ - struct fio_file *f; - unsigned int i; - - for_each_file(td, f, i) { - if (td->o.size) - f->real_file_size = td->o.size / td->o.nr_files; - else - f->real_file_size = -1ULL; - } - - return 0; -} - static int fio_cpuio_init(struct thread_data *td) { struct thread_options *o = &td->o; @@ -62,7 +47,6 @@ static struct ioengine_ops ioengine = { .version = FIO_IOOPS_VERSION, .queue = fio_cpuio_queue, .init = fio_cpuio_init, - .setup = fio_cpuio_setup, .open_file = fio_cpuio_open, .flags = FIO_SYNCIO | FIO_DISKLESSIO, }; diff --git a/engines/net.c b/engines/net.c index cc707db9..2b48b0ab 100644 --- a/engines/net.c +++ b/engines/net.c @@ -269,8 +269,6 @@ static void fio_netio_cleanup(struct thread_data *td) static int fio_netio_setup(struct thread_data *td) { struct netio_data *nd; - struct fio_file *f; - unsigned int i; if (!td->io_ops->data) { nd = malloc(sizeof(*nd));; @@ -278,13 +276,6 @@ static int fio_netio_setup(struct thread_data *td) memset(nd, 0, sizeof(*nd)); nd->listenfd = -1; td->io_ops->data = nd; - - for_each_file(td, f, i) { - if (td->o.size) - f->real_file_size = td->o.size / td->o.nr_files; - else - f->real_file_size = -1ULL; - } } return 0; diff --git a/engines/null.c b/engines/null.c index 318952c2..823d40de 100644 --- a/engines/null.c +++ b/engines/null.c @@ -65,21 +65,6 @@ static int fio_null_queue(struct thread_data fio_unused *td, struct io_u *io_u) return FIO_Q_QUEUED; } -static int fio_null_setup(struct thread_data *td) -{ - struct fio_file *f; - unsigned int i; - - for_each_file(td, f, i) { - if (td->o.size) - f->real_file_size = td->o.size / td->o.nr_files; - else - f->real_file_size = -1ULL; - } - - return 0; -} - static int fio_null_open(struct thread_data fio_unused *td, struct fio_file fio_unused *f) { @@ -117,7 +102,6 @@ static int fio_null_init(struct thread_data *td) static struct ioengine_ops ioengine = { .name = "null", .version = FIO_IOOPS_VERSION, - .setup = fio_null_setup, .queue = fio_null_queue, .commit = fio_null_commit, .getevents = fio_null_getevents, diff --git a/filesetup.c b/filesetup.c index 62d048ea..bd975d82 100644 --- a/filesetup.c +++ b/filesetup.c @@ -288,8 +288,10 @@ static int get_file_sizes(struct thread_data *td) err = 1; } clear_error(td); - } else - td->io_ops->close_file(td, f); + } else { + if (td->io_ops->close_file) + td->io_ops->close_file(td, f); + } if (f->real_file_size == -1ULL && td->o.size) f->real_file_size = td->o.size / td->o.nr_files; @@ -499,6 +501,12 @@ void add_file(struct thread_data *td, const char *fname) memset(f, 0, sizeof(*f)); f->fd = -1; + /* + * init function, io engine may not be loaded yet + */ + if (td->io_ops && (td->io_ops->flags & FIO_DISKLESSIO)) + f->real_file_size = -1ULL; + if (td->o.directory) len = sprintf(file_name, "%s/", td->o.directory); diff --git a/init.c b/init.c index 0151c9bd..bc33f4fe 100644 --- a/init.c +++ b/init.c @@ -427,6 +427,13 @@ static int add_job(struct thread_data *td, const char *jobname, int job_add_num) if (fixup_options(td)) goto err; + if (td->io_ops->flags & FIO_DISKLESSIO) { + struct fio_file *f; + + for_each_file(td, f, i) + f->real_file_size = -1ULL; + } + td->mutex = fio_sem_init(0); td->ts.clat_stat[0].min_val = td->ts.clat_stat[1].min_val = ULONG_MAX; -- 2.25.1