From 922a5be82ca50f7c89a1f9c4b84757ba8636e2d1 Mon Sep 17 00:00:00 2001 From: Jens Axboe Date: Mon, 23 May 2016 08:37:19 -0600 Subject: [PATCH] options: add 'unique_filename' Allows the user to disable the prefixing of network clients source IP. Signed-off-by: Jens Axboe --- HOWTO | 5 +++++ filesetup.c | 3 ++- fio.1 | 5 +++++ options.c | 16 ++++++++++++++-- options.h | 2 +- thread_options.h | 8 +++++--- 6 files changed, 32 insertions(+), 7 deletions(-) diff --git a/HOWTO b/HOWTO index 9ed2c5f5..cec4e427 100644 --- a/HOWTO +++ b/HOWTO @@ -374,6 +374,11 @@ filename_format=str default of $jobname.$jobnum.$filenum will be used if no other format specifier is given. +unique_filename=bool To avoid collisions between networked clients, fio + defaults to prefixing any generated filenames (with a directory + specified) with the source of the client connecting. To disable + this behavior, set this option to 0. + opendir=str Tell fio to recursively add any file it can find in this directory and down the file system tree. diff --git a/filesetup.c b/filesetup.c index f721c36a..012773b9 100644 --- a/filesetup.c +++ b/filesetup.c @@ -1335,7 +1335,8 @@ int add_file(struct thread_data *td, const char *fname, int numjob, int inc) dprint(FD_FILE, "add file %s\n", fname); if (td->o.directory) - len = set_name_idx(file_name, PATH_MAX, td->o.directory, numjob); + len = set_name_idx(file_name, PATH_MAX, td->o.directory, numjob, + td->o.unique_filename); sprintf(file_name + len, "%s", fname); diff --git a/fio.1 b/fio.1 index 5e4cd4ff..839a3592 100644 --- a/fio.1 +++ b/fio.1 @@ -247,6 +247,11 @@ will be used if no other format specifier is given. .RE .P .TP +.BI unique_filename \fR=\fPbool +To avoid collisions between networked clients, fio defaults to prefixing +any generated filenames (with a directory specified) with the source of +the client connecting. To disable this behavior, set this option to 0. +.TP .BI lockfile \fR=\fPstr Fio defaults to not locking any files before it does IO to them. If a file or file descriptor is shared, fio can serialize IO to that file to make the end diff --git a/options.c b/options.c index 07589c47..294cb449 100644 --- a/options.c +++ b/options.c @@ -1124,7 +1124,8 @@ static int get_max_name_idx(char *input) * Returns the directory at the index, indexes > entires will be * assigned via modulo division of the index */ -int set_name_idx(char *target, size_t tlen, char *input, int index) +int set_name_idx(char *target, size_t tlen, char *input, int index, + bool unique_filename) { unsigned int cur_idx; int len; @@ -1136,7 +1137,7 @@ int set_name_idx(char *target, size_t tlen, char *input, int index) for (cur_idx = 0; cur_idx <= index; cur_idx++) fname = get_next_name(&str); - if (client_sockaddr_str[0]) { + if (client_sockaddr_str[0] && unique_filename) { len = snprintf(target, tlen, "%s/%s.", fname, client_sockaddr_str); } else @@ -1390,6 +1391,7 @@ struct fio_option fio_options[FIO_MAX_OPTS] = { }, { .name = "filename_format", + .lname = "Filename Format", .type = FIO_OPT_STR_STORE, .off1 = td_var_offset(filename_format), .prio = -1, /* must come after "directory" */ @@ -1398,6 +1400,16 @@ struct fio_option fio_options[FIO_MAX_OPTS] = { .category = FIO_OPT_C_FILE, .group = FIO_OPT_G_FILENAME, }, + { + .name = "unique_filename", + .lname = "Unique Filename", + .type = FIO_OPT_BOOL, + .off1 = td_var_offset(unique_filename), + .help = "For network clients, prefix file with source IP", + .def = "1", + .category = FIO_OPT_C_FILE, + .group = FIO_OPT_G_FILENAME, + }, { .name = "lockfile", .lname = "Lockfile", diff --git a/options.h b/options.h index 6a5db076..4727bac2 100644 --- a/options.h +++ b/options.h @@ -20,7 +20,7 @@ void del_opt_posval(const char *, const char *); struct thread_data; void fio_options_free(struct thread_data *); char *get_name_idx(char *, int); -int set_name_idx(char *, size_t, char *, int); +int set_name_idx(char *, size_t, char *, int, bool); extern char client_sockaddr_str[]; /* used with --client option */ diff --git a/thread_options.h b/thread_options.h index 10d7ba61..edf090da 100644 --- a/thread_options.h +++ b/thread_options.h @@ -65,6 +65,8 @@ struct thread_options { unsigned int iodepth_batch_complete_min; unsigned int iodepth_batch_complete_max; + unsigned int unique_filename; + unsigned long long size; unsigned long long io_limit; unsigned int size_percent; @@ -325,6 +327,7 @@ struct thread_options_pack { uint32_t size_percent; uint32_t fill_device; uint32_t file_append; + uint32_t unique_filename; uint64_t file_size_low; uint64_t file_size_high; uint64_t start_offset; @@ -388,6 +391,7 @@ struct thread_options_pack { uint32_t bs_unaligned; uint32_t fsync_on_close; uint32_t bs_is_seq_rand; + uint32_t pad1; uint32_t random_distribution; uint32_t exitall_error; @@ -411,7 +415,6 @@ struct thread_options_pack { uint32_t fsync_blocks; uint32_t fdatasync_blocks; uint32_t barrier_blocks; - uint32_t pad1; uint64_t start_delay; uint64_t start_delay_high; uint64_t timeout; @@ -476,7 +479,6 @@ struct thread_options_pack { uint64_t trim_backlog; uint32_t clat_percentiles; uint32_t percentile_precision; - uint32_t pad2; fio_fp64_t percentile_list[FIO_IO_U_LIST_MAX_LEN]; uint8_t read_iolog_file[FIO_TOP_STR_MAX]; @@ -531,7 +533,7 @@ struct thread_options_pack { uint64_t number_ios; uint32_t sync_file_range; - uint32_t pad3; + uint32_t pad2; uint64_t latency_target; uint64_t latency_window; -- 2.25.1