Add --aux-path support
authorJens Axboe <axboe@fb.com>
Thu, 20 Aug 2015 19:02:05 +0000 (12:02 -0700)
committerJens Axboe <axboe@fb.com>
Thu, 20 Aug 2015 19:02:05 +0000 (12:02 -0700)
For certain files, fio just stores them in the current working
directory. This can create a bit of a mess. These files might
be verification dump files, or verification state saves.

Add --aux-path to enable storing these files in an arbitrary
directory instead.

Signed-off-by: Jens Axboe <axboe@fb.com>
README
backend.c
client.c
fio.h
init.c
verify.c
verify.h

diff --git a/README b/README
index ed8545b139b750ee0ec27bf9573e11176d7c230c..9d0863d3af4160888e860330e64e66a4610ecb4c 100644 (file)
--- a/README
+++ b/README
@@ -183,6 +183,7 @@ $ fio
        --trigger-timeout=t     Execute trigger af this time
        --trigger=cmd           Set this command as local trigger
        --trigger-remote=cmd    Set this command as remote trigger
        --trigger-timeout=t     Execute trigger af this time
        --trigger=cmd           Set this command as local trigger
        --trigger-remote=cmd    Set this command as remote trigger
+       --aux-path=path         Use this path for fio state generated files
 
 
 Any parameters following the options will be assumed to be job files,
 
 
 Any parameters following the options will be assumed to be job files,
index 76994d90b9c59b3ae059dbae99d12f7e77ce1c6d..d41c742b9edd070b48da42712bc86d4ab63bf9f8 100644 (file)
--- a/backend.c
+++ b/backend.c
@@ -1638,16 +1638,8 @@ static void *thread_main(void *data)
        td->ts.io_bytes[DDIR_TRIM] = td->io_bytes[DDIR_TRIM];
 
        if (td->o.verify_state_save && !(td->flags & TD_F_VSTATE_SAVED) &&
        td->ts.io_bytes[DDIR_TRIM] = td->io_bytes[DDIR_TRIM];
 
        if (td->o.verify_state_save && !(td->flags & TD_F_VSTATE_SAVED) &&
-           (td->o.verify != VERIFY_NONE && td_write(td))) {
-               struct all_io_list *state;
-               size_t sz;
-
-               state = get_all_io_list(td->thread_number, &sz);
-               if (state) {
-                       __verify_save_state(state, "local");
-                       free(state);
-               }
-       }
+           (td->o.verify != VERIFY_NONE && td_write(td)))
+               verify_save_state(td->thread_number);
 
        fio_unpin_memory(td);
 
 
        fio_unpin_memory(td);
 
@@ -1897,7 +1889,7 @@ void check_trigger_file(void)
                if (nr_clients)
                        fio_clients_send_trigger(trigger_remote_cmd);
                else {
                if (nr_clients)
                        fio_clients_send_trigger(trigger_remote_cmd);
                else {
-                       verify_save_state();
+                       verify_save_state(IO_LIST_ALL);
                        fio_terminate_threads(TERMINATE_ALL);
                        exec_trigger(trigger_cmd);
                }
                        fio_terminate_threads(TERMINATE_ALL);
                        exec_trigger(trigger_cmd);
                }
index 110a01bd99564280245cd59ca7ff27759bf3e936..147ee38969d09fd146bd4754288a028041a311ee 100644 (file)
--- a/client.c
+++ b/client.c
@@ -1497,9 +1497,15 @@ int fio_handle_client(struct fio_client *client)
                break;
        case FIO_NET_CMD_VTRIGGER: {
                struct all_io_list *pdu = (struct all_io_list *) cmd->payload;
                break;
        case FIO_NET_CMD_VTRIGGER: {
                struct all_io_list *pdu = (struct all_io_list *) cmd->payload;
-               char buf[64];
+               char buf[128];
+               int off = 0;
 
 
-               __verify_save_state(pdu, server_name(client, buf, sizeof(buf)));
+               if (aux_path) {
+                       strcpy(buf, aux_path);
+                       off = strlen(buf);
+               }
+
+               __verify_save_state(pdu, server_name(client, &buf[off], sizeof(buf) - off));
                exec_trigger(trigger_cmd);
                break;
                }
                exec_trigger(trigger_cmd);
                break;
                }
diff --git a/fio.h b/fio.h
index 17bc02bc59f0eba2a39aa40b5b5142407b1bc02b..53d82560053ba95ab768f1aedc78f6275a780233 100644 (file)
--- a/fio.h
+++ b/fio.h
@@ -434,6 +434,7 @@ extern char *trigger_file;
 extern char *trigger_cmd;
 extern char *trigger_remote_cmd;
 extern long long trigger_timeout;
 extern char *trigger_cmd;
 extern char *trigger_remote_cmd;
 extern long long trigger_timeout;
+extern char *aux_path;
 
 extern struct thread_data *threads;
 
 
 extern struct thread_data *threads;
 
diff --git a/init.c b/init.c
index 6d8dcffde9100f0001e5dba7a0912033d98ab166..7261248fd4349f54f128e0656667b2eeaef10777 100644 (file)
--- a/init.c
+++ b/init.c
@@ -69,6 +69,8 @@ long long trigger_timeout = 0;
 char *trigger_cmd = NULL;
 char *trigger_remote_cmd = NULL;
 
 char *trigger_cmd = NULL;
 char *trigger_remote_cmd = NULL;
 
+char *aux_path = NULL;
+
 static int prev_group_jobs;
 
 unsigned long fio_debug = 0;
 static int prev_group_jobs;
 
 unsigned long fio_debug = 0;
@@ -266,6 +268,11 @@ static struct option l_opts[FIO_NR_OPTIONS] = {
                .has_arg        = required_argument,
                .val            = 'J',
        },
                .has_arg        = required_argument,
                .val            = 'J',
        },
+       {
+               .name           = (char *) "aux-path",
+               .has_arg        = required_argument,
+               .val            = 'K',
+       },
        {
                .name           = NULL,
        },
        {
                .name           = NULL,
        },
@@ -1793,6 +1800,7 @@ static void usage(const char *name)
        printf("  --trigger-timeout=t\tExecute trigger af this time\n");
        printf("  --trigger=cmd\t\tSet this command as local trigger\n");
        printf("  --trigger-remote=cmd\tSet this command as remote trigger\n");
        printf("  --trigger-timeout=t\tExecute trigger af this time\n");
        printf("  --trigger=cmd\t\tSet this command as local trigger\n");
        printf("  --trigger-remote=cmd\tSet this command as remote trigger\n");
+       printf("  --aux-path=path\tUse this path for fio state generated files\n");
        printf("\nFio was written by Jens Axboe <jens.axboe@oracle.com>");
        printf("\n                   Jens Axboe <jaxboe@fusionio.com>");
        printf("\n                   Jens Axboe <axboe@fb.com>\n");
        printf("\nFio was written by Jens Axboe <jens.axboe@oracle.com>");
        printf("\n                   Jens Axboe <jaxboe@fusionio.com>");
        printf("\n                   Jens Axboe <axboe@fb.com>\n");
@@ -2383,6 +2391,11 @@ int parse_cmd_line(int argc, char *argv[], int client_type)
                                free(trigger_remote_cmd);
                        trigger_remote_cmd = strdup(optarg);
                        break;
                                free(trigger_remote_cmd);
                        trigger_remote_cmd = strdup(optarg);
                        break;
+               case 'K':
+                       if (aux_path)
+                               free(aux_path);
+                       aux_path = strdup(optarg);
+                       break;
                case 'B':
                        if (check_str_time(optarg, &trigger_timeout, 1)) {
                                log_err("fio: failed parsing time %s\n", optarg);
                case 'B':
                        if (check_str_time(optarg, &trigger_timeout, 1)) {
                                log_err("fio: failed parsing time %s\n", optarg);
index f833e85b23539e6bafda0876adf13ef0576f0ff7..3e92d15c32bba5b50b0252cc541bdcccedc36a23 100644 (file)
--- a/verify.c
+++ b/verify.c
@@ -231,8 +231,11 @@ static void dump_buf(char *buf, unsigned int len, unsigned long long offset,
 
        ptr = strdup(f->file_name);
 
 
        ptr = strdup(f->file_name);
 
-       fname[DUMP_BUF_SZ - 1] = '\0';
-       strncpy(fname, basename(ptr), DUMP_BUF_SZ - 1);
+       memset(fname, 0, sizeof(fname));
+       if (aux_path)
+               sprintf(fname, "%s%s", aux_path, FIO_OS_PATH_SEPARATOR);
+
+       strncpy(fname + strlen(fname), basename(ptr), buf_left - 1);
 
        buf_left -= strlen(fname);
        if (buf_left <= 0) {
 
        buf_left -= strlen(fname);
        if (buf_left <= 0) {
@@ -1477,14 +1480,21 @@ void __verify_save_state(struct all_io_list *state, const char *prefix)
        }
 }
 
        }
 }
 
-void verify_save_state(void)
+void verify_save_state(int mask)
 {
        struct all_io_list *state;
        size_t sz;
 
 {
        struct all_io_list *state;
        size_t sz;
 
-       state = get_all_io_list(IO_LIST_ALL, &sz);
+       state = get_all_io_list(mask, &sz);
        if (state) {
        if (state) {
-               __verify_save_state(state, "local");
+               char prefix[PATH_MAX];
+
+               if (aux_path)
+                       sprintf(aux_path, "%s%slocal", aux_path, FIO_OS_PATH_SEPARATOR);
+               else
+                       strcpy(aux_path, "local");
+
+               __verify_save_state(state, prefix);
                free(state);
        }
 }
                free(state);
        }
 }
index c37b1d56acd10d9dfcc7f310a697c2881ff431d6..8305eebaa7c60f2c0ec19b8a7c8f44447ad06cd9 100644 (file)
--- a/verify.h
+++ b/verify.h
@@ -145,7 +145,7 @@ struct verify_state_hdr {
 #define IO_LIST_ALL            0xffffffff
 extern struct all_io_list *get_all_io_list(int, size_t *);
 extern void __verify_save_state(struct all_io_list *, const char *);
 #define IO_LIST_ALL            0xffffffff
 extern struct all_io_list *get_all_io_list(int, size_t *);
 extern void __verify_save_state(struct all_io_list *, const char *);
-extern void verify_save_state(void);
+extern void verify_save_state(int mask);
 extern int verify_load_state(struct thread_data *, const char *);
 extern void verify_free_state(struct thread_data *);
 extern int verify_state_should_stop(struct thread_data *, struct io_u *);
 extern int verify_load_state(struct thread_data *, const char *);
 extern void verify_free_state(struct thread_data *);
 extern int verify_state_should_stop(struct thread_data *, struct io_u *);