allow --client parameter to be pathname containing client host IPs/names
[fio.git] / init.c
diff --git a/init.c b/init.c
index bb53a1e2bc097a256172db7e46075bd5658704da..5e6d54f3e89a97c4a415e028b438e9419143e44d 100644 (file)
--- a/init.c
+++ b/init.c
@@ -596,8 +596,7 @@ static int fixup_options(struct thread_data *td)
        if (o->norandommap && o->verify != VERIFY_NONE
            && !fixed_block_size(o))  {
                log_err("fio: norandommap given for variable block sizes, "
-                       "verify disabled\n");
-               o->verify = VERIFY_NONE;
+                       "verify limited\n");
                ret = warnings_fatal;
        }
        if (o->bs_unaligned && (o->odirect || td->io_ops->flags & FIO_RAWIO))
@@ -764,6 +763,17 @@ static int fixup_options(struct thread_data *td)
                fio_gtod_offload = 1;
        }
 
+       td->loops = o->loops;
+       if (!td->loops)
+               td->loops = 1;
+
+       if (td->o.block_error_hist && td->o.nr_files != 1) {
+               log_err("fio: block error histogram only available with "
+                       "with a single file per job, but %d files "
+                       "provided\n", td->o.nr_files);
+               ret = 1;
+       }
+
        return ret;
 }
 
@@ -946,6 +956,9 @@ static void init_flags(struct thread_data *td)
                td->flags |= TD_F_SCRAMBLE_BUFFERS;
        if (o->verify != VERIFY_NONE)
                td->flags |= TD_F_VER_NONE;
+
+       if (o->verify_async || o->io_submit_mode == IO_MODE_OFFLOAD)
+               td->flags |= TD_F_NEED_LOCK;
 }
 
 static int setup_random_seeds(struct thread_data *td)
@@ -2132,6 +2145,7 @@ int parse_cmd_line(int argc, char *argv[], int client_type)
                                                td = NULL;
                                        }
                                        do_exit++;
+                                       exit_val = 1;
                                        break;
                                }
                                fio_options_set_ioengine_opts(l_opts, td);
@@ -2150,6 +2164,7 @@ int parse_cmd_line(int argc, char *argv[], int client_type)
                                        td = NULL;
                                }
                                do_exit++;
+                               exit_val = 1;
                        }
 
                        if (!ret && !strcmp(opt, "ioengine")) {
@@ -2158,6 +2173,7 @@ int parse_cmd_line(int argc, char *argv[], int client_type)
                                        put_job(td);
                                        td = NULL;
                                        do_exit++;
+                                       exit_val = 1;
                                        break;
                                }
                                fio_options_set_ioengine_opts(l_opts, td);
@@ -2226,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++;