From: Jens Axboe Date: Tue, 11 Feb 2014 16:12:06 +0000 (-0700) Subject: Enfore that lockfile= must precede filename= X-Git-Tag: fio-2.1.5~3 X-Git-Url: https://git.kernel.dk/?p=fio.git;a=commitdiff_plain;h=f2a2803a4982a1516eb75d9f98de68cf21d1ae7d Enfore that lockfile= must precede filename= The way fio parses options, we need to have the file locking defined before we start adding files. Normally we can handle this with option priorities, but that doesn't work across job section boundaries. So catch this case and error out, otherwise fio will segfault when it attempts to unlock files at the end of a job. Signed-off-by: Jens Axboe --- diff --git a/filesetup.c b/filesetup.c index bae60929..544ecb1c 100644 --- a/filesetup.c +++ b/filesetup.c @@ -1266,7 +1266,7 @@ void unlock_file(struct thread_data *td, struct fio_file *f) void unlock_file_all(struct thread_data *td, struct fio_file *f) { - if (td->o.file_lock_mode == FILE_LOCK_NONE) + if (td->o.file_lock_mode == FILE_LOCK_NONE || !td->file_locks) return; if (td->file_locks[f->fileno] != FILE_LOCK_NONE) unlock_file(td, f); diff --git a/options.c b/options.c index 57e9af5b..29b181a0 100644 --- a/options.c +++ b/options.c @@ -821,6 +821,18 @@ static int str_directory_cb(void *data, const char fio_unused *str) return 0; } +static int str_lockfile_cb(void *data, const char fio_unused *str) +{ + struct thread_data *td = data; + + if (td->files_index) { + log_err("fio: lockfile= option must precede filename=\n"); + return 1; + } + + return 0; +} + static int str_opendir_cb(void *data, const char fio_unused *str) { struct thread_data *td = data; @@ -1231,6 +1243,7 @@ struct fio_option fio_options[FIO_MAX_OPTS] = { .parent = "filename", .hide = 0, .def = "none", + .cb = str_lockfile_cb, .category = FIO_OPT_C_FILE, .group = FIO_OPT_G_FILENAME, .posval = {