From 8d53c5f80ac3c5709dcc4fb5332335870f8ec692 Mon Sep 17 00:00:00 2001 From: Taras Glek Date: Wed, 10 Feb 2021 11:08:52 -0800 Subject: [PATCH] $clientuid keyword to differentiate clients in client/server mode. 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 --- HOWTO | 2 ++ fio.1 | 3 +++ init.c | 19 ++++++++++++++++++- 3 files changed, 23 insertions(+), 1 deletion(-) diff --git a/HOWTO b/HOWTO index b6d1b58a..52812cc7 100644 --- 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 aa248a3b..accc6a32 100644 --- 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 d6dbaf7c..eea6e546 100644 --- 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; -- 2.25.1