Error out gracefully if we don't find the replay device for log replay
authorJens Axboe <axboe@kernel.dk>
Thu, 21 Nov 2013 18:13:12 +0000 (11:13 -0700)
committerJens Axboe <axboe@kernel.dk>
Thu, 21 Nov 2013 18:13:12 +0000 (11:13 -0700)
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 <axboe@kernel.dk>
blktrace.c
iolog.c

index 04648a08ffdf8005fe87fbddf9a9ca542c823396..9e4e5998a73246cfa9a1df5e2adb2926777c056b 100644 (file)
@@ -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 dadbf0fa7b3f302792c3b69eeedb8e1e3f9faf94..65933672fa3e3da4ef8a5b59b6f70636f076a955 100644 (file)
--- 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;
 }