From 13f8e2d2e3e5ec7d8c18b70fb2a2e2a026190020 Mon Sep 17 00:00:00 2001 From: Jens Axboe Date: Tue, 24 Oct 2006 09:29:45 +0200 Subject: [PATCH 1/1] [PATCH] Add option to specify the exact file used Fio typically just makes up a filename for a job, but sometimes you want to explicitly reuse the same file for multiple jobs. Add a filename= option to cater to that. Signed-off-by: Jens Axboe --- filesetup.c | 4 ++-- fio.h | 2 ++ init.c | 17 +++++++++++++++-- 3 files changed, 19 insertions(+), 4 deletions(-) diff --git a/filesetup.c b/filesetup.c index 2e81a1d1..4310a79f 100644 --- a/filesetup.c +++ b/filesetup.c @@ -114,8 +114,8 @@ static int create_files(struct thread_data *td) temp_stall_ts = 1; fprintf(f_out, "%s: Laying out IO file(s) (%d x %LuMiB == %LuMiB)\n", - td->name, td->nr_files, - (td->total_file_size >> 20) / td->nr_files, + td->name, td->nr_uniq_files, + (td->total_file_size >> 20) / td->nr_uniq_files, td->total_file_size >> 20); err = 0; diff --git a/fio.h b/fio.h index 3817fc9a..015af8db 100644 --- a/fio.h +++ b/fio.h @@ -161,6 +161,7 @@ struct fio_file { struct thread_data { char name[32]; char *directory; + char *filename; char verror[80]; pthread_t thread; int thread_number; @@ -168,6 +169,7 @@ struct thread_data { enum fio_filetype filetype; struct fio_file *files; unsigned int nr_files; + unsigned int nr_uniq_files; unsigned int next_file; int error; pid_t pid; diff --git a/init.c b/init.c index a0ab7d22..e314d6c0 100644 --- a/init.c +++ b/init.c @@ -169,7 +169,12 @@ static int add_job(struct thread_data *td, const char *jobname, int job_add_num) if (td->odirect) td->io_ops->flags |= FIO_RAWIO; - if (td->filetype == FIO_TYPE_FILE) { + if (td->filename) + td->nr_uniq_files = 1; + else + td->nr_uniq_files = td->nr_files; + + if (td->filetype == FIO_TYPE_FILE || td->filename) { char tmp[PATH_MAX]; int len = 0; int i; @@ -184,7 +189,10 @@ static int add_job(struct thread_data *td, const char *jobname, int job_add_num) f->fd = -1; f->fileno = i; - sprintf(tmp + len, "%s.%d.%d", jobname, td->thread_number, i); + if (td->filename) + sprintf(tmp + len, "%s", td->filename); + else + sprintf(tmp + len, "%s.%d.%d", jobname, td->thread_number, i); f->file_name = strdup(tmp); } } else { @@ -898,6 +906,11 @@ int parse_jobs_ini(char *file, int stonewall_flag) fgetpos(f, &off); continue; } + if (!check_strstore(p, "filename", tmpbuf)) { + td->filename = strdup(tmpbuf); + fgetpos(f, &off); + continue; + } if (!check_strstore(p, "name", tmpbuf)) { snprintf(td->name, sizeof(td->name)-1, "%s%d", tmpbuf, td->thread_number); fgetpos(f, &off); -- 2.25.1