parse: get rid of raw option offsets
[fio.git] / profiles / act.c
index 73cde8565c78236a6ddf258f6bf90eb4ad91c881..4d2ec5c33c2a4d9a99b34b686be0e1649b9731da 100644 (file)
@@ -74,12 +74,25 @@ static unsigned int org_idx;
 
 static int act_add_opt(const char *format, ...) __attribute__ ((__format__ (__printf__, 1, 2)));
 
+struct act_options {
+       unsigned int pad;
+       char *device_names;
+       unsigned int load;
+       unsigned int prep;
+       unsigned int threads_per_queue;
+       unsigned int num_read_blocks;
+       unsigned int write_size;
+       unsigned long long test_duration;
+};
+
+static struct act_options act_options;
+
 static struct fio_option options[] = {
        {
                .name   = "device-names",
                .lname  = "device-names",
                .type   = FIO_OPT_STR_STORE,
-               .roff1  = &device_names,
+               .off1   = offsetof(struct act_options, device_names),
                .help   = "Devices to use",
                .category = FIO_OPT_C_PROFILE,
                .group  = FIO_OPT_G_ACT,
@@ -88,7 +101,7 @@ static struct fio_option options[] = {
                .name   = "load",
                .lname  = "Load multiplier",
                .type   = FIO_OPT_INT,
-               .roff1  = &load,
+               .off1   = offsetof(struct act_options, load),
                .help   = "ACT load multipler (default 1x)",
                .def    = "1",
                .category = FIO_OPT_C_PROFILE,
@@ -98,7 +111,7 @@ static struct fio_option options[] = {
                .name   = "test-duration",
                .lname  = "Test duration",
                .type   = FIO_OPT_STR_VAL_TIME,
-               .roff1  = &test_duration,
+               .off1   = offsetof(struct act_options, test_duration),
                .help   = "How long the entire test takes to run",
                .def    = "24h",
                .category = FIO_OPT_C_PROFILE,
@@ -108,7 +121,7 @@ static struct fio_option options[] = {
                .name   = "threads-per-queue",
                .lname  = "Number of read IO threads per device",
                .type   = FIO_OPT_INT,
-               .roff1  = &threads_per_queue,
+               .off1   = offsetof(struct act_options, threads_per_queue),
                .help   = "Number of read IO threads per device",
                .def    = "8",
                .category = FIO_OPT_C_PROFILE,
@@ -118,7 +131,7 @@ static struct fio_option options[] = {
                .name   = "read-req-num-512-blocks",
                .lname  = "Number of 512b blocks to read",
                .type   = FIO_OPT_INT,
-               .roff1  = &num_read_blocks,
+               .off1   = offsetof(struct act_options, num_read_blocks),
                .help   = "Number of 512b blocks to read at the time",
                .def    = "3",
                .category = FIO_OPT_C_PROFILE,
@@ -128,7 +141,7 @@ static struct fio_option options[] = {
                .name   = "large-block-op-kbytes",
                .lname  = "Size of large block ops (writes)",
                .type   = FIO_OPT_INT,
-               .roff1  = &write_size,
+               .off1   = offsetof(struct act_options, write_size),
                .help   = "Size of large block ops (writes)",
                .def    = "128k",
                .category = FIO_OPT_C_PROFILE,
@@ -138,7 +151,7 @@ static struct fio_option options[] = {
                .name   = "prep",
                .lname  = "Run ACT prep phase",
                .type   = FIO_OPT_STR_SET,
-               .roff1  = &prep,
+               .off1   = offsetof(struct act_options, prep),
                .help   = "Set to run ACT prep phase",
                .category = FIO_OPT_C_PROFILE,
                .group  = FIO_OPT_G_ACT,
@@ -389,7 +402,7 @@ static void put_act_ref(struct thread_data *td)
        fio_mutex_down(act_run_data->mutex);
 
        if (!act_run_data->slices) {
-               act_run_data->slices = calloc(sizeof(struct act_slice), apd->nr_slices);
+               act_run_data->slices = calloc(apd->nr_slices, sizeof(struct act_slice));
                act_run_data->nr_slices = apd->nr_slices;
        }
 
@@ -416,9 +429,9 @@ static int act_td_init(struct thread_data *td)
 
        get_act_ref();
 
-       apd = calloc(sizeof(*apd), 1);
+       apd = calloc(1, sizeof(*apd));
        nr_slices = (test_duration + SAMPLE_SEC - 1) / SAMPLE_SEC;
-       apd->slices = calloc(sizeof(struct act_slice), nr_slices);
+       apd->slices = calloc(nr_slices, sizeof(struct act_slice));
        apd->nr_slices = nr_slices;
        fio_gettime(&apd->sample_tv, NULL);
        td->prof_data = apd;
@@ -445,6 +458,7 @@ static struct profile_ops act_profile = {
        .name           = "act",
        .desc           = "ACT Aerospike like benchmark",
        .options        = options,
+       .opt_data       = &act_options,
        .prep_cmd       = act_prep_cmdline,
        .cmdline        = act_opts,
        .io_ops         = &act_io_ops,
@@ -452,7 +466,7 @@ static struct profile_ops act_profile = {
 
 static void fio_init act_register(void)
 {
-       act_run_data = calloc(sizeof(*act_run_data), 1);
+       act_run_data = calloc(1, sizeof(*act_run_data));
        act_run_data->mutex = fio_mutex_init(FIO_MUTEX_UNLOCKED);
 
        if (register_profile(&act_profile))