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 <axboe@fb.com>
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);
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;
.parent = "filename",
.hide = 0,
.def = "none",
+ .cb = str_lockfile_cb,
.category = FIO_OPT_C_FILE,
.group = FIO_OPT_G_FILENAME,
.posval = {