$clientuid keyword to differentiate clients in client/server mode.
authorTaras Glek <taras@purestorage.com>
Wed, 10 Feb 2021 19:08:52 +0000 (11:08 -0800)
committerTaras Glek <taras@purestorage.com>
Wed, 10 Feb 2021 20:19:47 +0000 (12:19 -0800)
Prior to this change getting fio to include IP as part of filename was a struggle. One had to use directory=/ to trigger IP-inclusion code and there was no way to customize that.

Signed-off-by: Taras Glek <taras@glek.net>
HOWTO
fio.1
init.c

diff --git a/HOWTO b/HOWTO
index b6d1b58a3af46147091fb1a3828362fff10b0e0a..52812cc7de37e7d5d95c34c45e757c8126643709 100644 (file)
--- a/HOWTO
+++ b/HOWTO
@@ -809,6 +809,8 @@ Target file/device
 
                **$jobname**
                                The name of the worker thread or process.
+               **$clientuid**
+                               IP of the fio process when using client/server mode.
                **$jobnum**
                                The incremental number of the worker thread or process.
                **$filenum**
diff --git a/fio.1 b/fio.1
index aa248a3b6da62172a2ee0a27e5b345034ebfe7fd..accc6a329a12fa98b65cd7fcd443b06faaef8fcf 100644 (file)
--- a/fio.1
+++ b/fio.1
@@ -584,6 +584,9 @@ string:
 .B $jobname
 The name of the worker thread or process.
 .TP
+.B $clientuid
+IP of the fio process when using client/server mode.
+.TP
 .B $jobnum
 The incremental number of the worker thread or process.
 .TP
diff --git a/init.c b/init.c
index d6dbaf7cb437d894ab990fa4531bd44ef05872c7..eea6e54692b177036dce001134f8ed1baeb62ca8 100644 (file)
--- a/init.c
+++ b/init.c
@@ -1238,7 +1238,8 @@ enum {
        FPRE_NONE = 0,
        FPRE_JOBNAME,
        FPRE_JOBNUM,
-       FPRE_FILENUM
+       FPRE_FILENUM,
+       FPRE_CLIENTUID
 };
 
 static struct fpre_keyword {
@@ -1249,6 +1250,7 @@ static struct fpre_keyword {
        { .keyword = "$jobname",        .key = FPRE_JOBNAME, },
        { .keyword = "$jobnum",         .key = FPRE_JOBNUM, },
        { .keyword = "$filenum",        .key = FPRE_FILENUM, },
+       { .keyword = "$clientuid",      .key = FPRE_CLIENTUID, },
        { .keyword = NULL, },
        };
 
@@ -1338,6 +1340,21 @@ static char *make_filename(char *buf, size_t buf_size,struct thread_options *o,
                                }
                                break;
                                }
+                       case FPRE_CLIENTUID: {
+                               int ret;
+                               ret = snprintf(dst, dst_left, "%s", client_sockaddr_str);
+                               if (ret < 0)
+                                       break;
+                               else if (ret > dst_left) {
+                                       log_err("fio: truncated filename\n");
+                                       dst += dst_left;
+                                       dst_left = 0;
+                               } else {
+                                       dst += ret;
+                                       dst_left -= ret;
+                               }
+                               break;
+                               }
                        default:
                                assert(0);
                                break;