From: Jens Axboe Date: Wed, 28 Mar 2007 07:57:01 +0000 (+0200) Subject: Fix size setting on raw devices X-Git-Tag: fio-1.15~5 X-Git-Url: https://git.kernel.dk/?p=fio.git;a=commitdiff_plain;h=409b3417e46cc3ce7041f042bcc26c3feb46e9e9;hp=d5ed68ea91e3f6a6b366cc2dcf2b1e7b9ce2b8d0 Fix size setting on raw devices Signed-off-by: Jens Axboe --- 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 */ }; /*