Merge branch 'client-hostfile' of git://github.com/bengland2/fio
authorJens Axboe <axboe@fb.com>
Thu, 7 May 2015 19:46:24 +0000 (13:46 -0600)
committerJens Axboe <axboe@fb.com>
Thu, 7 May 2015 19:46:24 +0000 (13:46 -0600)
README
fio.1
init.c

diff --git a/README b/README
index 18d1c4fc66215a9eb80f462592b692b1b59a27a7..3d8fcbff675d5285fef513e0a5e18083d19ccc5e 100644 (file)
--- a/README
+++ b/README
@@ -172,7 +172,7 @@ $ fio
        --warnings-fatal        Fio parser warnings are fatal
        --max-jobs              Maximum number of threads/processes to support
        --server=args           Start backend server. See Client/Server section.
-       --client=host           Connect to specified backend.
+       --client=host           Connect to specified backend(s).
        --remote-config=file    Tell fio server to load this local file
        --idle-prof=option      Report cpu idleness on a system or percpu basis
                                (option=system,percpu) or run unit work
@@ -311,9 +311,34 @@ to load a local file as well. This is done by using --remote-config:
 
 fio --client=server --remote-config /path/to/file.fio
 
-Then the fio server will open this local (to the server) job file instead
+Then fio will open this local (to the server) job file instead
 of being passed one from the client.
 
+If you have many servers (example: 100 VMs/containers), 
+you can input a pathname of a file containing host IPs/names as the parameter 
+value for the --client option.  For example, here is an example "host.list" 
+file containing 2 hostnames:
+
+host1.your.dns.domain
+host2.your.dns.domain
+
+The fio command would then be:
+
+fio --client=host.list <job file(s)>
+
+In this mode, you cannot input server-specific parameters or job files -- all
+servers receive the same job file.  
+
+In order to let fio --client runs use a shared filesystem 
+from multiple hosts, fio  --client now prepends the IP address of the 
+server to the filename.  For example, if fio is using directory /mnt/nfs/fio 
+and is writing filename fileio.tmp, with a --client hostfile containing 
+two hostnames h1 and h2 with IP addresses 192.168.10.120 and  192.168.10.121,
+then fio will create two files:
+
+       /mnt/nfs/fio/192.168.10.120.fileio.tmp
+       /mnt/nfs/fio/192.168.10.121.fileio.tmp
+
 
 Platforms
 ---------
diff --git a/fio.1 b/fio.1
index e54e419b2f5852733c7312a44defcf0345be7591..e5451b1696f7a6b16754bf576a3531a8f81fd321 100644 (file)
--- a/fio.1
+++ b/fio.1
@@ -93,7 +93,7 @@ Start a backend server, with \fIargs\fP specifying what to listen to. See client
 Background a fio server, writing the pid to the given pid file.
 .TP
 .BI \-\-client \fR=\fPhost
-Instead of running the jobs locally, send and run them on the given host.
+Instead of running the jobs locally, send and run them on the given host or set of hosts.  See client/server section.
 .TP
 .BI \-\-idle\-prof \fR=\fPoption
 Report cpu idleness on a system or percpu basis (\fIoption\fP=system,percpu) or run unit work calibration only (\fIoption\fP=calibrate).
@@ -1911,8 +1911,35 @@ to load a local file as well. This is done by using \-\-remote-config:
 
 fio \-\-client=server \-\-remote-config /path/to/file.fio
 
-Then the fio serer will open this local (to the server) job file instead
+Then fio will open this local (to the server) job file instead
 of being passed one from the client.
+
+If you have many servers (example: 100 VMs/containers), you can input a pathname 
+of a file containing host IPs/names as the parameter value for the \-\-client option.
+For example, here is an example "host.list" file containing 2 hostnames:
+
+host1.your.dns.domain
+.br
+host2.your.dns.domain
+
+The fio command would then be:
+
+fio \-\-client=host.list <job file>
+
+In this mode, you cannot input server-specific parameters or job files, and all
+servers receive the same job file.
+
+In order to enable fio \-\-client runs utilizing a shared filesystem from multiple hosts,
+fio \-\-client now prepends the IP address of the server to the filename. For example, 
+if fio is using directory /mnt/nfs/fio and is writing filename fileio.tmp, 
+with a \-\-client hostfile
+containing two hostnames h1 and h2 with IP addresses 192.168.10.120 and 192.168.10.121, then
+fio will create two files:
+
+/mnt/nfs/fio/192.168.10.120.fileio.tmp
+.br
+/mnt/nfs/fio/192.168.10.121.fileio.tmp
+
 .SH AUTHORS
 
 .B fio
diff --git a/init.c b/init.c
index 1a5d4c9ed0919648f6f5c79c009c599b4f3386a6..5e6d54f3e89a97c4a415e028b438e9419143e44d 100644 (file)
--- a/init.c
+++ b/init.c
@@ -2242,6 +2242,32 @@ int parse_cmd_line(int argc, char *argv[], int client_type)
                                exit_val = 1;
                                break;
                        }
+                       /* if --client parameter contains a pathname */
+                       if (0 == access(optarg, R_OK)) {
+                               /* file contains a list of host addrs or names */
+                               char hostaddr[_POSIX_HOST_NAME_MAX] = {0};
+                               char formatstr[8];
+                               FILE * hostf = fopen(optarg, "r");
+                               if (!hostf) {
+                                       log_err("fio: could not open client list file %s for read\n", optarg);
+                                       do_exit++;
+                                       exit_val = 1;
+                                       break;
+                               }
+                               sprintf(formatstr, "%%%ds", _POSIX_HOST_NAME_MAX-1);
+                               /* read at most _POSIX_HOST_NAME_MAX-1 chars from each record in this file */
+                               while (fscanf(hostf, formatstr, hostaddr) == 1) {
+                                       /* expect EVERY host in file to be valid */
+                                       if (fio_client_add(&fio_client_ops, hostaddr, &cur_client)) {
+                                               log_err("fio: failed adding client %s from file %s\n", hostaddr, optarg);
+                                               do_exit++;
+                                               exit_val = 1;
+                                               break;
+                                       }
+                               }
+                               fclose(hostf);
+                               break; /* no possibility of job file for "this client only" */
+                       }
                        if (fio_client_add(&fio_client_ops, optarg, &cur_client)) {
                                log_err("fio: failed adding client %s\n", optarg);
                                do_exit++;