allow a percent value for the offset parameter
[fio.git] / options.c
index b489e90210ae008be47b427195242a56272daa90..dcee7e55a90efe4fbe38dc250296d4849537def5 100644 (file)
--- a/options.c
+++ b/options.c
@@ -1381,6 +1381,21 @@ static int str_gtod_reduce_cb(void *data, int *il)
        return 0;
 }
 
+static int str_offset_cb(void *data, unsigned long long *__val)
+{
+       struct thread_data *td = cb_data_to_td(data);
+       unsigned long long v = *__val;
+
+       if (parse_is_percent(v)) {
+               td->o.start_offset = 0;
+               td->o.start_offset_percent = -1ULL - v;
+               dprint(FD_PARSE, "SET start_offset_percent %d\n", td->o.start_offset_percent);
+       } else
+               td->o.start_offset = v;
+
+       return 0;
+}
+
 static int str_size_cb(void *data, unsigned long long *__val)
 {
        struct thread_data *td = cb_data_to_td(data);
@@ -1938,6 +1953,7 @@ struct fio_option fio_options[FIO_MAX_OPTS] = {
                .lname  = "IO offset",
                .alias  = "fileoffset",
                .type   = FIO_OPT_STR_VAL,
+               .cb     = str_offset_cb,
                .off1   = offsetof(struct thread_options, start_offset),
                .help   = "Start IO from this offset",
                .def    = "0",