options: add 'unique_filename'
authorJens Axboe <axboe@fb.com>
Mon, 23 May 2016 14:37:19 +0000 (08:37 -0600)
committerJens Axboe <axboe@fb.com>
Mon, 23 May 2016 14:37:19 +0000 (08:37 -0600)
Allows the user to disable the prefixing of network clients source
IP.

Signed-off-by: Jens Axboe <axboe@fb.com>
HOWTO
filesetup.c
fio.1
options.c
options.h
thread_options.h

diff --git a/HOWTO b/HOWTO
index 9ed2c5f5580365c69664eecb651f7e1b4065df7b..cec4e42758aed7e4783e03199f20afe55fa9e49c 100644 (file)
--- 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.
 
index f721c36abbb045ca7b4e4a618c64b0199d5148e3..012773b95eba7ff27c714e7a5085f15a939c0fb7 100644 (file)
@@ -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 5e4cd4ff2663df1bff00eabcdf7382673cc5a453..839a3592d5832ebf8788d7ffec3f28509345d21e 100644 (file)
--- 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
index 07589c47509787719362f0b6b2d0fefe2b3eb4f2..294cb44985a16e6261039bf843742f8000490eb8 100644 (file)
--- 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",
index 6a5db0762183c2818a0b55afa888da768188ae28..4727bac222ce33169b5f3dd213b5c931365c8f80 100644 (file)
--- 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 */
 
index 10d7ba61334a08045e26e0fe9447314f11461761..edf090da28d45880474badb129e6cbc2a08103f6 100644 (file)
@@ -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;