From f01b34ae759afccf39c1bf47972e45d91448e7bb Mon Sep 17 00:00:00 2001 From: Jens Axboe Date: Thu, 21 Nov 2013 11:13:12 -0700 Subject: [PATCH] Error out gracefully if we don't find the replay device for log replay It would segfault before because no files got added to replay against. Handle this more gracefully and ensure that fio exits with a non-zero exit status. Signed-off-by: Jens Axboe --- blktrace.c | 8 +++++++- iolog.c | 3 +++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/blktrace.c b/blktrace.c index 04648a08..9e4e5998 100644 --- a/blktrace.c +++ b/blktrace.c @@ -220,6 +220,7 @@ static int trace_add_file(struct thread_data *td, __u32 device) trace_add_open_close_event(td, fileno, FIO_LOG_OPEN_FILE); last_fileno = fileno; } + return last_fileno; } @@ -450,13 +451,18 @@ int load_blktrace(struct thread_data *td, const char *filename, int need_swap) } while (1); for (i = 0; i < td->files_index; i++) { - f= td->files[i]; + f = td->files[i]; trace_add_open_close_event(td, f->fileno, FIO_LOG_CLOSE_FILE); } fifo_free(fifo); close(fd); + if (!td->files_index) { + log_err("fio: did not find replay device(s)\n"); + return 1; + } + if (skipped_writes) log_err("fio: %s skips replay of %lu writes due to read-only\n", td->o.name, skipped_writes); diff --git a/iolog.c b/iolog.c index dadbf0fa..65933672 100644 --- a/iolog.c +++ b/iolog.c @@ -493,6 +493,9 @@ int init_iolog(struct thread_data *td) } else if (td->o.write_iolog_file) ret = init_iolog_write(td); + if (ret) + td_verror(td, EINVAL, "failed initializing iolog"); + return ret; } -- 2.25.1