From 409b3417e46cc3ce7041f042bcc26c3feb46e9e9 Mon Sep 17 00:00:00 2001 From: Jens Axboe Date: Wed, 28 Mar 2007 09:57:01 +0200 Subject: [PATCH 1/1] Fix size setting on raw devices Signed-off-by: Jens Axboe --- filesetup.c | 10 +++++++++- fio.h | 1 + 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/filesetup.c b/filesetup.c index 40a16638..161f63e7 100644 --- a/filesetup.c +++ b/filesetup.c @@ -138,6 +138,9 @@ static int get_file_size(struct thread_data *td, struct fio_file *f) { int ret = 0; + if (f->flags & FIO_SIZE_KNOWN) + return 0; + if (f->filetype == FIO_TYPE_FILE) ret = file_size(td, f); else if (f->filetype == FIO_TYPE_BD) @@ -153,6 +156,7 @@ static int get_file_size(struct thread_data *td, struct fio_file *f) return 1; } + f->flags |= FIO_SIZE_KNOWN; return 0; } @@ -280,6 +284,9 @@ static void get_file_sizes(struct thread_data *td) clear_error(td); else 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; } } @@ -321,7 +328,7 @@ int setup_files(struct thread_data *td) /* * device/file sizes are zero and no size given, punt */ - if (!total_size && !td->o.size) { + if ((!total_size || total_size == -1ULL) && !td->o.size) { log_err("%s: you need to specify size=\n", td->o.name); td_verror(td, EINVAL, "total_file_size"); return 1; @@ -386,6 +393,7 @@ int setup_files(struct thread_data *td) if (!(f->flags & FIO_FILE_EXTEND)) continue; + assert(f->filetype == FIO_TYPE_FILE); f->flags &= ~FIO_FILE_EXTEND; f->real_file_size = f->io_size; err = extend_file(td, f); diff --git a/fio.h b/fio.h index 5ca72c59..d8911ef5 100644 --- a/fio.h +++ b/fio.h @@ -241,6 +241,7 @@ enum fio_file_flags { FIO_FILE_EXTEND = 1 << 4, /* needs extend */ FIO_FILE_NOSORT = 1 << 5, /* don't sort verify blocks */ FIO_FILE_DONE = 1 << 6, /* io completed to this file */ + FIO_SIZE_KNOWN = 1 << 7, /* size has been set */ }; /* -- 2.25.1