From: Jens Axboe Date: Thu, 20 Aug 2015 19:02:05 +0000 (-0700) Subject: Add --aux-path support X-Git-Tag: fio-2.2.10~14 X-Git-Url: https://git.kernel.dk/?p=fio.git;a=commitdiff_plain;h=d264264a084e4989f7be577001484981bd606669 Add --aux-path support 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 --- diff --git a/README b/README index ed8545b1..9d0863d3 100644 --- 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 + --aux-path=path Use this path for fio state generated files Any parameters following the options will be assumed to be job files, diff --git a/backend.c b/backend.c index 76994d90..d41c742b 100644 --- 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->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); @@ -1897,7 +1889,7 @@ void check_trigger_file(void) 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); } diff --git a/client.c b/client.c index 110a01bd..147ee389 100644 --- 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; - 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; } diff --git a/fio.h b/fio.h index 17bc02bc..53d82560 100644 --- 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 *aux_path; extern struct thread_data *threads; diff --git a/init.c b/init.c index 6d8dcffd..7261248f 100644 --- 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 *aux_path = NULL; + 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', }, + { + .name = (char *) "aux-path", + .has_arg = required_argument, + .val = 'K', + }, { .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(" --aux-path=path\tUse this path for fio state generated files\n"); printf("\nFio was written by Jens Axboe "); printf("\n Jens Axboe "); printf("\n Jens Axboe \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; + 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); diff --git a/verify.c b/verify.c index f833e85b..3e92d15c 100644 --- 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); - 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) { @@ -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; - state = get_all_io_list(IO_LIST_ALL, &sz); + state = get_all_io_list(mask, &sz); 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); } } diff --git a/verify.h b/verify.h index c37b1d56..8305eeba 100644 --- 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 *); -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 *);