From f4e62a5f3640dfe2d2119bbe1e40bf57747f6564 Mon Sep 17 00:00:00 2001 From: Jens Axboe Date: Wed, 11 Apr 2007 21:20:03 +0200 Subject: [PATCH] For non-file engines, set ->real_file_size if total size is known Fixes a segfault with rand* directions. Signed-off-by: Jens Axboe --- engines/cpu.c | 12 ++++++++---- engines/net.c | 8 ++++++-- engines/null.c | 9 ++++++--- 3 files changed, 20 insertions(+), 9 deletions(-) diff --git a/engines/cpu.c b/engines/cpu.c index cfdf281d..dd69cede 100644 --- a/engines/cpu.c +++ b/engines/cpu.c @@ -18,8 +18,12 @@ static int fio_cpuio_setup(struct thread_data fio_unused *td) struct fio_file *f; unsigned int i; - for_each_file(td, f, i) - f->real_file_size = -1ULL; + 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; } @@ -47,9 +51,9 @@ static int fio_cpuio_init(struct thread_data *td) return 0; } -static int fio_cpuio_open(struct thread_data fio_unused *td, struct fio_file *f) +static int fio_cpuio_open(struct thread_data fio_unused *td, + struct fio_file fio_unused *f) { - f->fd = 0; return 0; } diff --git a/engines/net.c b/engines/net.c index 4de86c12..cc707db9 100644 --- a/engines/net.c +++ b/engines/net.c @@ -279,8 +279,12 @@ static int fio_netio_setup(struct thread_data *td) nd->listenfd = -1; td->io_ops->data = nd; - for_each_file(td, f, i) - f->real_file_size = -1ULL; + 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 70d1fa78..318952c2 100644 --- a/engines/null.c +++ b/engines/null.c @@ -70,8 +70,12 @@ static int fio_null_setup(struct thread_data *td) struct fio_file *f; unsigned int i; - for_each_file(td, f, i) - f->real_file_size = -1ULL; + 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; } @@ -79,7 +83,6 @@ static int fio_null_setup(struct thread_data *td) static int fio_null_open(struct thread_data fio_unused *td, struct fio_file fio_unused *f) { - f->fd = 0; return 0; } -- 2.25.1