Merge branch 'sphinx-doc' of https://github.com/termim/fio
authorJens Axboe <axboe@fb.com>
Thu, 26 Jan 2017 17:04:40 +0000 (10:04 -0700)
committerJens Axboe <axboe@fb.com>
Thu, 26 Jan 2017 17:04:40 +0000 (10:04 -0700)
22 files changed:
backend.c
diskutil.c
diskutil.h
engines/binject.c
engines/cpu.c
engines/mmap.c
engines/sg.c
file.h
filesetup.c
fio.h
gclient.c
gfio.c
init.c
ioengine.h
ioengines.c
lib/memalign.c
lib/num2str.c
optgroup.c
options.c
parse.c
parse.h
smalloc.c

index a46101ca5aebc04d51523f3e4eb61c01c907c368..1c1f2f9a1e603c084160165eb6596945de344d7a 100644 (file)
--- a/backend.c
+++ b/backend.c
@@ -76,9 +76,6 @@ int shm_id = 0;
 int temp_stall_ts;
 unsigned long done_secs = 0;
 
-#define PAGE_ALIGN(buf)        \
-       (char *) (((uintptr_t) (buf) + page_mask) & ~page_mask)
-
 #define JOB_START_TIMEOUT      (5 * 1000)
 
 static void sig_int(int sig)
@@ -1198,7 +1195,7 @@ static int init_io_u(struct thread_data *td)
 
        if (td->o.odirect || td->o.mem_align || td->o.oatomic ||
            td_ioengine_flagged(td, FIO_RAWIO))
-               p = PAGE_ALIGN(td->orig_buffer) + td->o.mem_align;
+               p = PTR_ALIGN(td->orig_buffer, page_mask) + td->o.mem_align;
        else
                p = td->orig_buffer;
 
@@ -1264,6 +1261,10 @@ static int init_io_u(struct thread_data *td)
        return 0;
 }
 
+/*
+ * This function is Linux specific.
+ * FIO_HAVE_IOSCHED_SWITCH enabled currently means it's Linux.
+ */
 static int switch_ioscheduler(struct thread_data *td)
 {
 #ifdef FIO_HAVE_IOSCHED_SWITCH
@@ -1274,7 +1275,8 @@ static int switch_ioscheduler(struct thread_data *td)
        if (td_ioengine_flagged(td, FIO_DISKLESSIO))
                return 0;
 
-       sprintf(tmp, "%s/queue/scheduler", td->sysfs_root);
+       assert(td->files && td->files[0]);
+       sprintf(tmp, "%s/queue/scheduler", td->files[0]->du->sysfs_root);
 
        f = fopen(tmp, "r+");
        if (!f) {
@@ -1362,7 +1364,7 @@ static bool keep_running(struct thread_data *td)
                uint64_t diff;
 
                /*
-                * If the difference is less than the minimum IO size, we
+                * If the difference is less than the maximum IO size, we
                 * are done.
                 */
                diff = limit - ddir_rw_sum(td->io_bytes);
@@ -2055,7 +2057,7 @@ static bool check_mount_writes(struct thread_data *td)
                return false;
 
        for_each_file(td, f, i) {
-               if (f->filetype != FIO_TYPE_BD)
+               if (f->filetype != FIO_TYPE_BLOCK)
                        continue;
                if (device_is_mounted(f->file_name))
                        goto mounted;
index 27ddb46b7fecdae75114874210ed2ae135d21bd6..c3bcec928ac29a6a2b753b3ccf2eaeb583a29dab 100644 (file)
@@ -37,6 +37,7 @@ static void disk_util_free(struct disk_util *du)
        }
 
        fio_mutex_remove(du->lock);
+       free(du->sysfs_root);
        sfree(du);
 }
 
@@ -305,7 +306,7 @@ static struct disk_util *disk_util_add(struct thread_data *td, int majdev,
                return NULL;
        }
        strncpy((char *) du->dus.name, basename(path), FIO_DU_NAME_SZ - 1);
-       du->sysfs_root = path;
+       du->sysfs_root = strdup(path);
        du->major = majdev;
        du->minor = mindev;
        INIT_FLIST_HEAD(&du->slavelist);
@@ -430,9 +431,6 @@ static struct disk_util *__init_per_file_disk_util(struct thread_data *td,
                sprintf(path, "%s", tmp);
        }
 
-       if (td->o.ioscheduler && !td->sysfs_root)
-               td->sysfs_root = strdup(path);
-
        return disk_util_add(td, majdev, mindev, path);
 }
 
@@ -451,12 +449,8 @@ static struct disk_util *init_per_file_disk_util(struct thread_data *td,
                        mindev);
 
        du = disk_util_exists(majdev, mindev);
-       if (du) {
-               if (td->o.ioscheduler && !td->sysfs_root)
-                       td->sysfs_root = strdup(du->sysfs_root);
-
+       if (du)
                return du;
-       }
 
        /*
         * for an fs without a device, we will repeatedly stat through
index ff8a5b065f5d8b9914a4160df53218cdab3d8e80..04fdde2953d3dd9cafc1a5b8713f6900c5531c49 100644 (file)
@@ -46,7 +46,6 @@ struct disk_util {
         */
        struct flist_head slavelist;
 
-       char *name;
        char *sysfs_root;
        char path[PATH_MAX];
        int major, minor;
index 7d20a3fd7b9ce15d52d86f4b28dc494ba7b24e93..932534a03987eb85fbe1241f35944a4fc287dbed 100644 (file)
@@ -351,7 +351,7 @@ static int fio_binject_open_file(struct thread_data *td, struct fio_file *f)
        if (ret)
                return 1;
 
-       if (f->filetype != FIO_TYPE_BD) {
+       if (f->filetype != FIO_TYPE_BLOCK) {
                log_err("fio: binject only works with block devices\n");
                goto err_close;
        }
index 3d855e363c3212ba3d0c656ac5e2e92de1da1c05..d0b4a895afcb78c3619adebb15854236a324785c 100644 (file)
@@ -22,7 +22,7 @@ static struct fio_option options[] = {
                .type   = FIO_OPT_INT,
                .off1   = offsetof(struct cpu_options, cpuload),
                .help   = "Use this percentage of CPU",
-               .category = FIO_OPT_C_GENERAL,
+               .category = FIO_OPT_C_ENGINE,
                .group  = FIO_OPT_G_INVALID,
        },
        {
@@ -34,7 +34,7 @@ static struct fio_option options[] = {
                .def    = "50000",
                .parent = "cpuload",
                .hide   = 1,
-               .category = FIO_OPT_C_GENERAL,
+               .category = FIO_OPT_C_ENGINE,
                .group  = FIO_OPT_G_INVALID,
        },
        {
@@ -44,7 +44,7 @@ static struct fio_option options[] = {
                .off1   = offsetof(struct cpu_options, exit_io_done),
                .help   = "Exit when IO threads finish",
                .def    = "0",
-               .category = FIO_OPT_C_GENERAL,
+               .category = FIO_OPT_C_ENGINE,
                .group  = FIO_OPT_G_INVALID,
        },
        {
index 99e1d6a4b35861ccb8be485cf4831d36c72ce40a..bc038f4febac88d68167f30e09d212942bbce582 100644 (file)
@@ -67,7 +67,7 @@ static int fio_mmap_file(struct thread_data *td, struct fio_file *f,
        }
 
 #ifdef FIO_MADV_FREE
-       if (f->filetype == FIO_TYPE_BD)
+       if (f->filetype == FIO_TYPE_BLOCK)
                (void) posix_madvise(fmd->mmap_ptr, fmd->mmap_sz, FIO_MADV_FREE);
 #endif
 
index 3f7d9110e71fdff6740869f9cd956f020dc72fb2..2148e87c190f8c1dfc4f648aecb99796888ca777 100644 (file)
@@ -252,7 +252,7 @@ static int fio_sgio_doio(struct thread_data *td, struct io_u *io_u, int do_sync)
        struct fio_file *f = io_u->file;
        int ret;
 
-       if (f->filetype == FIO_TYPE_BD) {
+       if (f->filetype == FIO_TYPE_BLOCK) {
                ret = fio_sgio_ioctl_doio(td, f, io_u);
                td->error = io_u->error;
        } else {
@@ -504,7 +504,7 @@ static int fio_sgio_type_check(struct thread_data *td, struct fio_file *f)
        unsigned int bs = 0;
        unsigned long long max_lba = 0;
 
-       if (f->filetype == FIO_TYPE_BD) {
+       if (f->filetype == FIO_TYPE_BLOCK) {
                if (ioctl(f->fd, BLKSSZGET, &bs) < 0) {
                        td_verror(td, errno, "ioctl");
                        return 1;
@@ -537,7 +537,7 @@ static int fio_sgio_type_check(struct thread_data *td, struct fio_file *f)
                        MAX_10B_LBA, max_lba);
        }
 
-       if (f->filetype == FIO_TYPE_BD) {
+       if (f->filetype == FIO_TYPE_BLOCK) {
                td->io_ops->getevents = NULL;
                td->io_ops->event = NULL;
        }
@@ -789,7 +789,7 @@ static int fio_sgio_get_file_size(struct thread_data *td, struct fio_file *f)
        if (fio_file_size_known(f))
                return 0;
 
-       if (f->filetype != FIO_TYPE_BD && f->filetype != FIO_TYPE_CHAR) {
+       if (f->filetype != FIO_TYPE_BLOCK && f->filetype != FIO_TYPE_CHAR) {
                td_verror(td, EINVAL, "wrong file type");
                log_err("ioengine sg only works on block or character devices\n");
                return 1;
diff --git a/file.h b/file.h
index 6f34dd5c3d315608778f638e6be45ef7f4726cd1..ac00ff877997531f2879fcc9e4dbe167f2da7634 100644 (file)
--- a/file.h
+++ b/file.h
@@ -15,7 +15,7 @@
  */
 enum fio_filetype {
        FIO_TYPE_FILE = 1,              /* plain file */
-       FIO_TYPE_BD,                    /* block device */
+       FIO_TYPE_BLOCK,                 /* block device */
        FIO_TYPE_CHAR,                  /* character device */
        FIO_TYPE_PIPE,                  /* pipe */
 };
index ef94bd285210d5009e6498d233375317971917ad..eb28826698811058a317fa6544b92bd8f388a368 100644 (file)
@@ -370,7 +370,7 @@ static int get_file_size(struct thread_data *td, struct fio_file *f)
 
        if (f->filetype == FIO_TYPE_FILE)
                ret = file_size(td, f);
-       else if (f->filetype == FIO_TYPE_BD)
+       else if (f->filetype == FIO_TYPE_BLOCK)
                ret = bdev_size(td, f);
        else if (f->filetype == FIO_TYPE_CHAR)
                ret = char_size(td, f);
@@ -420,7 +420,7 @@ static int __file_invalidate_cache(struct thread_data *td, struct fio_file *f,
                ret = posix_fadvise(f->fd, off, len, POSIX_FADV_DONTNEED);
                if (ret)
                        errval = ret;
-       } else if (f->filetype == FIO_TYPE_BD) {
+       } else if (f->filetype == FIO_TYPE_BLOCK) {
                int retry_count = 0;
 
                ret = blockdev_invalidate_cache(f);
@@ -709,7 +709,7 @@ static unsigned long long get_fs_free_counts(struct thread_data *td)
                struct stat sb;
                char buf[256];
 
-               if (f->filetype == FIO_TYPE_BD || f->filetype == FIO_TYPE_CHAR) {
+               if (f->filetype == FIO_TYPE_BLOCK || f->filetype == FIO_TYPE_CHAR) {
                        if (f->real_file_size != -1ULL)
                                ret += f->real_file_size;
                        continue;
@@ -1228,12 +1228,12 @@ static void get_file_type(struct fio_file *f)
        /* \\.\ is the device namespace in Windows, where every file is
         * a block device */
        if (strncmp(f->file_name, "\\\\.\\", 4) == 0)
-               f->filetype = FIO_TYPE_BD;
+               f->filetype = FIO_TYPE_BLOCK;
 #endif
 
        if (!stat(f->file_name, &sb)) {
                if (S_ISBLK(sb.st_mode))
-                       f->filetype = FIO_TYPE_BD;
+                       f->filetype = FIO_TYPE_BLOCK;
                else if (S_ISCHR(sb.st_mode))
                        f->filetype = FIO_TYPE_CHAR;
                else if (S_ISFIFO(sb.st_mode))
diff --git a/fio.h b/fio.h
index 62ff7abba5f1a25d7c52ecb5aa1e3a877464161a..19ac0af1f9a6ff68adf6cbdc01d04bbbb9ab8526 100644 (file)
--- a/fio.h
+++ b/fio.h
@@ -205,8 +205,6 @@ struct thread_data {
        void *iolog_buf;
        FILE *iolog_f;
 
-       char *sysfs_root;
-
        unsigned long rand_seeds[FIO_RAND_NR_OFFS];
 
        struct frand_state bsrange_state;
@@ -518,7 +516,6 @@ extern int fio_show_option_help(const char *);
 extern void fio_options_set_ioengine_opts(struct option *long_options, struct thread_data *td);
 extern void fio_options_dup_and_init(struct option *);
 extern void fio_options_mem_dupe(struct thread_data *);
-extern void options_mem_dupe(void *data, struct fio_option *options);
 extern void td_fill_rand_seeds(struct thread_data *);
 extern void td_fill_verify_state_seed(struct thread_data *);
 extern void add_job_opts(const char **, int);
@@ -620,6 +617,11 @@ extern int __must_check allocate_io_mem(struct thread_data *);
 extern void free_io_mem(struct thread_data *);
 extern void free_threads_shm(void);
 
+#ifdef FIO_INTERNAL
+#define PTR_ALIGN(ptr, mask)   \
+       (char *) (((uintptr_t) (ptr) + (mask)) & ~(mask))
+#endif
+
 /*
  * Reset stats after ramp time completes
  */
index 5ce33d0c56244cb55d5ea0716085b3b9a583951e..928a1b7641da2976c64c9709aaa7314030410a4f 100644 (file)
--- a/gclient.c
+++ b/gclient.c
@@ -48,7 +48,7 @@ static GtkActionEntry results_menu_items[] = {
        { "PrintFile", GTK_STOCK_PRINT, "Print", "<Control>P", NULL, G_CALLBACK(results_print) },
        { "CloseFile", GTK_STOCK_CLOSE, "Close", "<Control>W", NULL, G_CALLBACK(results_close) },
 };
-static gint results_nmenu_items = sizeof(results_menu_items) / sizeof(results_menu_items[0]);
+static gint results_nmenu_items = ARRAY_SIZE(results_menu_items);
 
 static const gchar *results_ui_string = " \
        <ui> \
diff --git a/gfio.c b/gfio.c
index 9ccf78c423b22df655f874682918c0a2819a2f61..9c917cb6a955f167738fa5ab8dbbb32bf82a3703 100644 (file)
--- a/gfio.c
+++ b/gfio.c
@@ -1271,7 +1271,7 @@ static GtkActionEntry menu_items[] = {
        { "Quit", GTK_STOCK_QUIT, NULL,   "<Control>Q", NULL, G_CALLBACK(quit_clicked) },
        { "About", GTK_STOCK_ABOUT, NULL,  NULL, NULL, G_CALLBACK(about_dialog) },
 };
-static gint nmenu_items = sizeof(menu_items) / sizeof(menu_items[0]);
+static gint nmenu_items = ARRAY_SIZE(menu_items);
 
 static const gchar *ui_string = " \
        <ui> \
diff --git a/init.c b/init.c
index ae20d619018ea9847e8033522513c024375b3e36..c3cc3e54a38f514804a3b095c175f2a23e9b32ff 100644 (file)
--- a/init.c
+++ b/init.c
@@ -1020,7 +1020,7 @@ int ioengine_load(struct thread_data *td)
                 */
                if (origeo) {
                        memcpy(td->eo, origeo, td->io_ops->option_struct_size);
-                       options_mem_dupe(td->eo, td->io_ops->options);
+                       options_mem_dupe(td->io_ops->options, td->eo);
                } else {
                        memset(td->eo, 0, td->io_ops->option_struct_size);
                        fill_default_options(td->eo, td->io_ops->options);
@@ -2717,9 +2717,6 @@ int parse_cmd_line(int argc, char *argv[], int client_type)
        }
 
 out_free:
-       if (pid_file)
-               free(pid_file);
-
        return ini_idx;
 }
 
@@ -2788,7 +2785,7 @@ int parse_options(int argc, char *argv[])
                if (did_arg)
                        return 0;
 
-               log_err("No jobs(s) defined\n\n");
+               log_err("No job(s) defined\n\n");
 
                if (!did_arg) {
                        usage(argv[0]);
index 89873e72e1a3099d4541de2a62540f2a59335425..7249df6a9705c5089dab08d732835c6643fe35e0 100644 (file)
@@ -123,7 +123,6 @@ struct io_u {
                struct ibv_mr *mr;
 #endif
                void *mmap_data;
-               uint64_t null;
        };
 };
 
index a1f8756d086ca5d06c5e1de063ec702f8294a228..95013d1daaaa07d9bd26ed2899a81d7fd1b45244 100644 (file)
@@ -449,7 +449,7 @@ int td_io_open_file(struct thread_data *td, struct fio_file *f)
                goto err;
 
        if (td->o.fadvise_hint != F_ADV_NONE &&
-           (f->filetype == FIO_TYPE_BD || f->filetype == FIO_TYPE_FILE)) {
+           (f->filetype == FIO_TYPE_BLOCK || f->filetype == FIO_TYPE_FILE)) {
                int flags;
 
                if (td->o.fadvise_hint == F_ADV_TYPE) {
@@ -474,7 +474,7 @@ int td_io_open_file(struct thread_data *td, struct fio_file *f)
        }
 #ifdef FIO_HAVE_STREAMID
        if (td->o.fadvise_stream &&
-           (f->filetype == FIO_TYPE_BD || f->filetype == FIO_TYPE_FILE)) {
+           (f->filetype == FIO_TYPE_BLOCK || f->filetype == FIO_TYPE_FILE)) {
                off_t stream = td->o.fadvise_stream;
 
                if (posix_fadvise(f->fd, stream, f->io_size, POSIX_FADV_STREAMID) < 0) {
@@ -618,15 +618,15 @@ int fio_show_ioengine_help(const char *engine)
 {
        struct flist_head *entry;
        struct thread_data td;
+       struct ioengine_ops *io_ops;
        char *sep;
        int ret = 1;
 
        if (!engine || !*engine) {
                log_info("Available IO engines:\n");
                flist_for_each(entry, &engine_list) {
-                       td.io_ops = flist_entry(entry, struct ioengine_ops,
-                                               list);
-                       log_info("\t%s\n", td.io_ops->name);
+                       io_ops = flist_entry(entry, struct ioengine_ops, list);
+                       log_info("\t%s\n", io_ops->name);
                }
                return 0;
        }
@@ -638,16 +638,16 @@ int fio_show_ioengine_help(const char *engine)
 
        memset(&td, 0, sizeof(td));
 
-       td.io_ops = load_ioengine(&td, engine);
-       if (!td.io_ops) {
+       io_ops = load_ioengine(&td, engine);
+       if (!io_ops) {
                log_info("IO engine %s not found\n", engine);
                return 1;
        }
 
-       if (td.io_ops->options)
-               ret = show_cmd_help(td.io_ops->options, sep);
+       if (io_ops->options)
+               ret = show_cmd_help(io_ops->options, sep);
        else
-               log_info("IO engine %s has no options\n", td.io_ops->name);
+               log_info("IO engine %s has no options\n", io_ops->name);
 
        free_ioengine(&td);
 
index cfd6e463ff924682d44346d130283094b7de3a07..1d1ba9ba2013ea2c3fdba579931ff1743989cdd7 100644 (file)
@@ -3,14 +3,12 @@
 #include <inttypes.h>
 
 #include "memalign.h"
+#include "../fio.h"
 
 struct align_footer {
        unsigned int offset;
 };
 
-#define PTR_ALIGN(ptr, mask)   \
-       (char *) (((uintptr_t) ((ptr) + (mask)) & ~(mask)))
-
 void *fio_memalign(size_t alignment, size_t size)
 {
        struct align_footer *f;
index 940d4a5e289133a03c89569dc3cca01a5e604b4c..ed3545d95634553640d3ccaf537e0e436d432ac2 100644 (file)
@@ -4,8 +4,6 @@
 
 #include "../fio.h"
 
-#define ARRAY_LENGTH(arr)      sizeof(arr) / sizeof((arr)[0])
-
 /**
  * num2str() - Cheesy number->string conversion, complete with carry rounding error.
  * @num: quantity (e.g., number of blocks, bytes or bits)
@@ -75,7 +73,7 @@ char *num2str(uint64_t num, int maxlen, int base, int pow2, int units)
 
        if (modulo == -1U) {
 done:
-               if (post_index >= ARRAY_LENGTH(sistr))
+               if (post_index >= ARRAY_SIZE(sistr))
                        post_index = 0;
 
                sprintf(buf, "%llu%s%s", (unsigned long long) num,
index 5f9ca961f93f7c6af0600e568481b2bee01b6015..122d24e98bbb80710df3ab3a7a32e7596be71984 100644 (file)
@@ -30,16 +30,16 @@ static const struct opt_group fio_opt_groups[] = {
                .name   = "Profiles",
                .mask   = FIO_OPT_C_PROFILE,
        },
+       {
+               .name   = "I/O engines",
+               .mask   = FIO_OPT_C_ENGINE,
+       },
        {
                .name   = NULL,
        },
 };
 
 static const struct opt_group fio_opt_cat_groups[] = {
-       {
-               .name   = "Latency profiling",
-               .mask   = FIO_OPT_G_LATPROF,
-       },
        {
                .name   = "Rate",
                .mask   = FIO_OPT_G_RATE,
@@ -125,13 +125,52 @@ static const struct opt_group fio_opt_cat_groups[] = {
                .mask   = FIO_OPT_G_TIOBENCH,
        },
        {
-               .name   = "MTD",
+               .name   = "Error handling",
+               .mask   = FIO_OPT_G_ERR,
+       },
+       {
+               .name   = "Ext4 defrag I/O engine", /* e4defrag */
+               .mask   = FIO_OPT_G_E4DEFRAG,
+       },
+       {
+               .name   = "Network I/O engine", /* net */
+               .mask   = FIO_OPT_G_NETIO,
+       },
+       {
+               .name   = "RDMA I/O engine", /* rdma */
+               .mask   = FIO_OPT_G_RDMA,
+       },
+       {
+               .name   = "libaio I/O engine", /* libaio */
+               .mask   = FIO_OPT_G_LIBAIO,
+       },
+       {
+               .name   = "ACT Aerospike like benchmark profile",
+               .mask   = FIO_OPT_G_ACT,
+       },
+       {
+               .name   = "Latency profiling",
+               .mask   = FIO_OPT_G_LATPROF,
+       },
+       {
+               .name   = "RBD I/O engine", /* rbd */
+               .mask   = FIO_OPT_G_RBD,
+       },
+       {
+               .name   = "GlusterFS I/O engine", /* gfapi,gfapi_async */
+               .mask   = FIO_OPT_G_GFAPI,
+       },
+       {
+               .name   = "MTD I/O engine", /* mtd */
                .mask   = FIO_OPT_G_MTD,
        },
-
+       {
+               .name   = "libhdfs I/O engine", /* libhdfs */
+               .mask   = FIO_OPT_G_HDFS,
+       },
        {
                .name   = NULL,
-       }
+       },
 };
 
 static const struct opt_group *group_from_mask(const struct opt_group *ogs,
index 1ca16e84ad15a5c916bf832f03d7c6f4a9c94a62..713112f6de5d6cc7c5a8b59e3f151e49db740fee 100644 (file)
--- a/options.c
+++ b/options.c
@@ -4772,34 +4772,19 @@ int fio_show_option_help(const char *opt)
        return show_cmd_help(fio_options, opt);
 }
 
-void options_mem_dupe(void *data, struct fio_option *options)
-{
-       struct fio_option *o;
-       char **ptr;
-
-       for (o = &options[0]; o->name; o++) {
-               if (o->type != FIO_OPT_STR_STORE)
-                       continue;
-
-               ptr = td_var(data, o, o->off1);
-               if (*ptr)
-                       *ptr = strdup(*ptr);
-       }
-}
-
 /*
  * dupe FIO_OPT_STR_STORE options
  */
 void fio_options_mem_dupe(struct thread_data *td)
 {
-       options_mem_dupe(&td->o, fio_options);
+       options_mem_dupe(fio_options, &td->o);
 
        if (td->eo && td->io_ops) {
                void *oldeo = td->eo;
 
                td->eo = malloc(td->io_ops->option_struct_size);
                memcpy(td->eo, oldeo, td->io_ops->option_struct_size);
-               options_mem_dupe(td->eo, td->io_ops->options);
+               options_mem_dupe(td->io_ops->options, td->eo);
        }
 }
 
diff --git a/parse.c b/parse.c
index 518c2dff45f0052c1a7c7da01f61db751b7835d2..fc508b674cff11555d2f3e5f73aea7a32d7cd101 100644 (file)
--- a/parse.c
+++ b/parse.c
@@ -1319,6 +1319,23 @@ void options_init(struct fio_option *options)
        }
 }
 
+void options_mem_dupe(struct fio_option *options, void *data)
+{
+       struct fio_option *o;
+       char **ptr;
+
+       dprint(FD_PARSE, "dup options\n");
+
+       for (o = &options[0]; o->name; o++) {
+               if (o->type != FIO_OPT_STR_STORE)
+                       continue;
+
+               ptr = td_var(data, o, o->off1);
+               if (*ptr)
+                       *ptr = strdup(*ptr);
+       }
+}
+
 void options_free(struct fio_option *options, void *data)
 {
        struct fio_option *o;
diff --git a/parse.h b/parse.h
index 7ba4e37b984bd46b17092acbc0c03d120f0c1f57..fb6abd1b22a21447562acd5b8d02014be95ca0bd 100644 (file)
--- a/parse.h
+++ b/parse.h
@@ -86,6 +86,7 @@ extern int parse_cmd_option(const char *t, const char *l, struct fio_option *, v
 extern int show_cmd_help(struct fio_option *, const char *);
 extern void fill_default_options(void *, struct fio_option *);
 extern void options_init(struct fio_option *);
+extern void options_mem_dupe(struct fio_option *, void *);
 extern void options_free(struct fio_option *, void *);
 
 extern void strip_blank_front(char **);
@@ -106,8 +107,7 @@ typedef int (fio_opt_str_val_fn)(void *, long long *);
 typedef int (fio_opt_int_fn)(void *, int *);
 
 struct thread_options;
-static inline void *td_var(struct thread_options *to, struct fio_option *o,
-                          unsigned int offset)
+static inline void *td_var(void *to, struct fio_option *o, unsigned int offset)
 {
        void *ret;
 
index d038ac64ccfb8dedbe2801ed3630dafbb121b97c..e48cfe8b1c11339d8e566743472795606668d588 100644 (file)
--- a/smalloc.c
+++ b/smalloc.c
@@ -13,6 +13,7 @@
 #include <limits.h>
 #include <fcntl.h>
 
+#include "fio.h"
 #include "mutex.h"
 #include "arch/arch.h"
 #include "os/os.h"
@@ -248,7 +249,7 @@ static void *postred_ptr(struct block_hdr *hdr)
        uintptr_t ptr;
 
        ptr = (uintptr_t) hdr + hdr->size - sizeof(unsigned int);
-       ptr = (ptr + int_mask) & ~int_mask;
+       ptr = (uintptr_t) PTR_ALIGN(ptr, int_mask);
 
        return (void *) ptr;
 }