options: get rid of more .cb option usage we don't need
authorJens Axboe <axboe@kernel.dk>
Thu, 29 Mar 2012 19:17:12 +0000 (21:17 +0200)
committerJens Axboe <axboe@kernel.dk>
Thu, 29 Mar 2012 19:17:12 +0000 (21:17 +0200)
- The lat/bw/iops log does not need two ways of storing whether
  they are enabled or not. Just change the option to a string
  storing variant, and use the existance of a filename to see
  if it's set or not.

- The trim_percentage option need not have a callback, the
  parser knows the limits and can store it appropriately.

- The verify_offset option can express it's minimum value
  directly, it doesn't need a callback to set it on its own.

Signed-off-by: Jens Axboe <axboe@kernel.dk>
cconv.c
init.c
options.c
thread_options.h

diff --git a/cconv.c b/cconv.c
index 285db4ebb3cea26396ad1201dfd5fecb7825d7c9..ae34e5490672925bae4bfbdd07a13da9db4ecbd3 100644 (file)
--- a/cconv.c
+++ b/cconv.c
@@ -112,9 +112,6 @@ void convert_thread_options_to_cpu(struct thread_options *o,
        o->override_sync = le32_to_cpu(top->override_sync);
        o->rand_repeatable = le32_to_cpu(top->rand_repeatable);
        o->use_os_rand = le32_to_cpu(top->use_os_rand);
-       o->write_lat_log = le32_to_cpu(top->write_lat_log);
-       o->write_bw_log = le32_to_cpu(top->write_bw_log);
-       o->write_iops_log = le32_to_cpu(top->write_iops_log);
        o->log_avg_msec = le32_to_cpu(top->log_avg_msec);
        o->norandommap = le32_to_cpu(top->norandommap);
        o->softrandommap = le32_to_cpu(top->softrandommap);
@@ -263,9 +260,6 @@ void convert_thread_options_to_net(struct thread_options_pack *top,
        top->override_sync = cpu_to_le32(o->override_sync);
        top->rand_repeatable = cpu_to_le32(o->rand_repeatable);
        top->use_os_rand = cpu_to_le32(o->use_os_rand);
-       top->write_lat_log = cpu_to_le32(o->write_lat_log);
-       top->write_bw_log = cpu_to_le32(o->write_bw_log);
-       top->write_iops_log = cpu_to_le32(o->write_iops_log);
        top->log_avg_msec = cpu_to_le32(o->log_avg_msec);
        top->norandommap = cpu_to_le32(o->norandommap);
        top->softrandommap = cpu_to_le32(o->softrandommap);
diff --git a/init.c b/init.c
index aa76733d9043d6038ee05c7ef81729503ee58096..742262867a3d51ecd529b033264789ee00c947d0 100644 (file)
--- a/init.c
+++ b/init.c
@@ -842,14 +842,14 @@ static int add_job(struct thread_data *td, const char *jobname, int job_add_num,
        if (setup_rate(td))
                goto err;
 
-       if (td->o.write_lat_log) {
+       if (td->o.lat_log_file) {
                setup_log(&td->lat_log, td->o.log_avg_msec, IO_LOG_TYPE_LAT);
                setup_log(&td->slat_log, td->o.log_avg_msec, IO_LOG_TYPE_SLAT);
                setup_log(&td->clat_log, td->o.log_avg_msec, IO_LOG_TYPE_CLAT);
        }
-       if (td->o.write_bw_log)
+       if (td->o.bw_log_file)
                setup_log(&td->bw_log, td->o.log_avg_msec, IO_LOG_TYPE_BW);
-       if (td->o.write_iops_log)
+       if (td->o.iops_log_file)
                setup_log(&td->iops_log, td->o.log_avg_msec, IO_LOG_TYPE_IOPS);
 
        if (!td->o.name)
index 962ca1981f0995c0a2d7ae2f9ded72c15cbaa643..5f73c102717bd52cc01340b445c097cc8c5fca2d 100644 (file)
--- a/options.c
+++ b/options.c
@@ -401,16 +401,6 @@ static int str_verify_cpus_allowed_cb(void *data, const char *input)
 }
 #endif
 
-#ifdef FIO_HAVE_TRIM
-static int str_verify_trim_cb(void *data, unsigned long long *val)
-{
-       struct thread_data *td = data;
-
-       td->o.trim_percentage = *val;
-       return 0;
-}
-#endif
-
 static int str_fst_cb(void *data, const char *str)
 {
        struct thread_data *td = data;
@@ -441,45 +431,6 @@ static int str_sfr_cb(void *data, const char *str)
 }
 #endif
 
-static int check_dir(struct thread_data *td, char *fname)
-{
-#if 0
-       char file[PATH_MAX], *dir;
-       int elen = 0;
-
-       if (td->o.directory) {
-               strcpy(file, td->o.directory);
-               strcat(file, "/");
-               elen = strlen(file);
-       }
-
-       sprintf(file + elen, "%s", fname);
-       dir = dirname(file);
-
-       {
-       struct stat sb;
-       /*
-        * We can't do this on FIO_DISKLESSIO engines. The engine isn't loaded
-        * yet, so we can't do this check right here...
-        */
-       if (lstat(dir, &sb) < 0) {
-               int ret = errno;
-
-               log_err("fio: %s is not a directory\n", dir);
-               td_verror(td, ret, "lstat");
-               return 1;
-       }
-
-       if (!S_ISDIR(sb.st_mode)) {
-               log_err("fio: %s is not a directory\n", dir);
-               return 1;
-       }
-       }
-#endif
-
-       return 0;
-}
-
 /*
  * Return next file in the string. Files are separated with ':'. If the ':'
  * is escaped with a '\', then that ':' is part of the filename and does not
@@ -542,10 +493,6 @@ static int str_filename_cb(void *data, const char *input)
        while ((fname = get_next_file_name(&str)) != NULL) {
                if (!strlen(fname))
                        break;
-               if (check_dir(td, fname)) {
-                       free(p);
-                       return 1;
-               }
                add_file(td, fname);
                td->o.nr_files++;
        }
@@ -584,19 +531,6 @@ static int str_opendir_cb(void *data, const char fio_unused *str)
        return add_dir_files(td, td->o.opendir);
 }
 
-static int str_verify_offset_cb(void *data, unsigned long long *off)
-{
-       struct thread_data *td = data;
-
-       if (*off && *off < sizeof(struct verify_header)) {
-               log_err("fio: verify_offset too small\n");
-               return 1;
-       }
-
-       td->o.verify_offset = *off;
-       return 0;
-}
-
 static int str_verify_pattern_cb(void *data, const char *input)
 {
        struct thread_data *td = data;
@@ -678,39 +612,6 @@ static int str_lockfile_cb(void *data, const char *str)
        return 0;
 }
 
-static int str_write_bw_log_cb(void *data, const char *str)
-{
-       struct thread_data *td = data;
-
-       if (str)
-               td->o.bw_log_file = strdup(str);
-
-       td->o.write_bw_log = 1;
-       return 0;
-}
-
-static int str_write_lat_log_cb(void *data, const char *str)
-{
-       struct thread_data *td = data;
-
-       if (str)
-               td->o.lat_log_file = strdup(str);
-
-       td->o.write_lat_log = 1;
-       return 0;
-}
-
-static int str_write_iops_log_cb(void *data, const char *str)
-{
-       struct thread_data *td = data;
-
-       if (str)
-               td->o.iops_log_file = strdup(str);
-
-       td->o.write_iops_log = 1;
-       return 0;
-}
-
 static int str_gtod_reduce_cb(void *data, int *il)
 {
        struct thread_data *td = data;
@@ -1835,8 +1736,8 @@ struct fio_option fio_options[FIO_MAX_OPTS] = {
                .lname  = "Verify offset",
                .type   = FIO_OPT_INT,
                .help   = "Offset verify header location by N bytes",
-               .def    = "0",
-               .cb     = str_verify_offset_cb,
+               .off1   = td_var_offset(verify_offset),
+               .minval = sizeof(struct verify_header),
                .parent = "verify",
                .hide   = 1,
                .category = FIO_OPT_C_IO,
@@ -1929,7 +1830,7 @@ struct fio_option fio_options[FIO_MAX_OPTS] = {
                .name   = "trim_percentage",
                .lname  = "Trim percentage",
                .type   = FIO_OPT_INT,
-               .cb     = str_verify_trim_cb,
+               .off1   = td_var_offset(trim_percentage),
                .minval = 0,
                .maxval = 100,
                .help   = "Number of verify blocks to discard/trim",
@@ -2406,9 +2307,8 @@ struct fio_option fio_options[FIO_MAX_OPTS] = {
        {
                .name   = "write_bw_log",
                .lname  = "Write bandwidth log",
-               .type   = FIO_OPT_STR,
-               .off1   = td_var_offset(write_bw_log),
-               .cb     = str_write_bw_log_cb,
+               .type   = FIO_OPT_STR_STORE,
+               .off1   = td_var_offset(bw_log_file),
                .help   = "Write log of bandwidth during run",
                .category = FIO_OPT_C_LOG,
                .group  = FIO_OPT_G_INVALID,
@@ -2416,9 +2316,8 @@ struct fio_option fio_options[FIO_MAX_OPTS] = {
        {
                .name   = "write_lat_log",
                .lname  = "Write latency log",
-               .type   = FIO_OPT_STR,
-               .off1   = td_var_offset(write_lat_log),
-               .cb     = str_write_lat_log_cb,
+               .type   = FIO_OPT_STR_STORE,
+               .off1   = td_var_offset(lat_log_file),
                .help   = "Write log of latency during run",
                .category = FIO_OPT_C_LOG,
                .group  = FIO_OPT_G_INVALID,
@@ -2427,8 +2326,7 @@ struct fio_option fio_options[FIO_MAX_OPTS] = {
                .name   = "write_iops_log",
                .lname  = "Write IOPS log",
                .type   = FIO_OPT_STR,
-               .off1   = td_var_offset(write_iops_log),
-               .cb     = str_write_iops_log_cb,
+               .off1   = td_var_offset(iops_log_file),
                .help   = "Write log of IOPS during run",
                .category = FIO_OPT_C_LOG,
                .group  = FIO_OPT_G_INVALID,
index 4b5f9578b7dd75feea086c37ead325adccfdb479..a5d06aad5a80aaceb848fa2b46eaf3013ec15712 100644 (file)
@@ -99,9 +99,6 @@ struct thread_options {
        unsigned int override_sync;
        unsigned int rand_repeatable;
        unsigned int use_os_rand;
-       unsigned int write_lat_log;
-       unsigned int write_bw_log;
-       unsigned int write_iops_log;
        unsigned int log_avg_msec;
        unsigned int norandommap;
        unsigned int softrandommap;
@@ -286,9 +283,6 @@ struct thread_options_pack {
        uint32_t override_sync;
        uint32_t rand_repeatable;
        uint32_t use_os_rand;
-       uint32_t write_lat_log;
-       uint32_t write_bw_log;
-       uint32_t write_iops_log;
        uint32_t log_avg_msec;
        uint32_t norandommap;
        uint32_t softrandommap;