Recent changes (master)
The following changes since commit ea66e04fe1a803f6a9ddf31cb999641d4396d67c:
Fix issue with td->mutex being used-after-free (2014-02-10 13:57:09 -0700)
are available in the git repository at:
git://git.kernel.dk/fio.git master
for you to fetch changes up to f0fdbcafc3a62b84250e5ccdcaec47e3ffa93a00:
parse: cleanup difference between profile and normal options (2014-02-11 15:44:50 -0700)
----------------------------------------------------------------
Jens Axboe (6):
Fix issue with openfiles= and file sizing
Enfore that lockfile= must precede filename=
Plug a free basic memory leaks
parse: get rid of raw option offsets
Fio 2.1.5
parse: cleanup difference between profile and normal options
FIO-VERSION-GEN | 2 +- backend.c | 20 ++++++- cconv.c | 25 +++++++++ err.h | 44 +++++++++++++++ file.h | 1 + filesetup.c | 45 +++++++++++++-- goptions.c | 68 +++++++++++----------- init.c | 1 + io_u.c | 25 +++++++-- options.c | 21 ++++++- os/windows/install.wxs | 2 +- parse.c | 146 +++++++++++++++--------------------------------- parse.h | 14 ++++- profile.c | 1 + profile.h | 1 + profiles/act.c | 28 +++++++--- profiles/tiobench.c | 23 ++++++-- 17 files changed, 305 insertions(+), 162 deletions(-) create mode 100644 err.h
---
Diff of recent changes:
FIO-VERSION-GEN +1 -1
@@ -1,7 +1,7 @@ #!/bin/sh GVF=FIO-VERSION-FILE -DEF_VER=fio-2.1.4 +DEF_VER=fio-2.1.5 LF=' '
backend.c +19 -1
@@ -52,6 +52,7 @@#include "server.h" #include "lib/getrusage.h" #include "idletime.h" +#include "err.h" static pthread_t disk_util_thread;static struct fio_mutex *disk_thread_mutex;
@@ -478,6 +479,12 @@ static void do_verify(struct thread_data *td, uint64_t verify_bytes)break ;while ((io_u =get_io_u (td)) !=NULL ) { +if (IS_ERR (io_u)) { + io_u =NULL ; + ret =FIO_Q_BUSY ; + goto reap; + } +/* * We are only interested in the places where * we wrote or trimmed IOs. Turn those into
@@ -574,6 +581,7 @@ sync_done:* completed io_u's first. Note that we can get BUSY even * without IO queued, if the system is resource starved. */ +reap: full =queue_full (td) || (ret ==FIO_Q_BUSY && td->cur_depth);if (full || !td->o.iodepth_batch_complete) { min_events = min(td->o.iodepth_batch_complete,
@@ -692,7 +700,14 @@ static uint64_t do_io(struct thread_data *td)break ; io_u =get_io_u (td); -if (!io_u) { +if (IS_ERR_OR_NULL (io_u)) { +int err =PTR_ERR (io_u); + + io_u =NULL ; +if (err == -EBUSY ) { + ret =FIO_Q_BUSY ; + goto reap; + }if (td->o.latency_target) goto reap;break ;
@@ -1124,6 +1139,9 @@ static int keep_running(struct thread_data *td)if (diff <td_max_bs (td))return 0 ; +if (fio_files_done (td)) +return 0 ; +return 1 ; }
cconv.c +25 -0
@@ -18,6 +18,29 @@ static void string_to_net(uint8_t *dst, const char *src) dst[0 ] ='\0' ; } +void free_thread_options_to_cpu (struct thread_options *o) +{ +free (o->description); +free (o->name); +free (o->directory); +free (o->filename); +free (o->filename_format); +free (o->opendir); +free (o->ioengine); +free (o->mmapfile); +free (o->read_iolog_file); +free (o->write_iolog_file); +free (o->bw_log_file); +free (o->lat_log_file); +free (o->iops_log_file); +free (o->replay_redirect); +free (o->exec_prerun); +free (o->exec_postrun); +free (o->ioscheduler); +free (o->profile); +free (o->cgroup); +} +void convert_thread_options_to_cpu (struct thread_options *o,struct thread_options_pack *top) {
@@ -438,5 +461,7 @@ int fio_test_cconv(struct thread_options *__o)convert_thread_options_to_cpu (&o, &top1);convert_thread_options_to_net (&top2, &o); +free_thread_options_to_cpu (&o); +return memcmp (&top1, &top2,sizeof (top1)); }
err.h new file +44 -0
44 lines not on this page · raw message
file.h +1 -0
@@ -176,5 +176,6 @@ extern void dup_files(struct thread_data *, struct thread_data *);extern int get_fileno (struct thread_data *,const char *);extern void free_release_files (struct thread_data *);void fio_file_reset (struct thread_data *,struct fio_file *); +int fio_files_done (struct thread_data *);#endif
filesetup.c +40 -5
75 lines not on this page · raw message
goptions.c +34 -34
218 lines not on this page · raw message
init.c +1 -0
@@ -250,6 +250,7 @@ void free_shm(void)free_threads_shm (); } +options_free (fio_options, &def_thread);scleanup (); }
io_u.c +21 -4
@@ -11,6 +11,7 @@#include "trim.h" #include "lib/rand.h" #include "lib/axmap.h" +#include "err.h" struct io_completion_data {int nr;/* input */
@@ -985,6 +986,9 @@ static struct fio_file *get_next_file_rand(struct thread_data *td,if (!fio_file_open (f)) {int err; +if (td->nr_open_files >= td->o.open_files) +return ERR_PTR (-EBUSY ); + err =td_io_open_file (td, f);if (err)continue ;
@@ -1027,6 +1031,9 @@ static struct fio_file *get_next_file_rr(struct thread_data *td, int goodf,if (!fio_file_open (f)) {int err; +if (td->nr_open_files >= td->o.open_files) +return ERR_PTR (-EBUSY ); + err =td_io_open_file (td, f);if (err) { dprint(FD_FILE, "error %d on open of %s\n",
@@ -1080,6 +1087,9 @@ static struct fio_file *__get_next_file(struct thread_data *td)else f =get_next_file_rand (td, FIO_FILE_open, FIO_FILE_closing); +if (IS_ERR (f)) +return f; + td->file_service_file = f; td->file_service_left = td->file_service_nr -1 ; out:
@@ -1099,14 +1109,14 @@ static struct fio_file *get_next_file(struct thread_data *td)return __get_next_file (td); } -static int set_io_u_file (struct thread_data *td,struct io_u *io_u) +static long set_io_u_file (struct thread_data *td,struct io_u *io_u) {struct fio_file *f; do { f = get_next_file(td); - if (!f) - return 1; + if (IS_ERR_OR_NULL(f)) + return PTR_ERR(f); io_u->file = f; get_file(f);
@@ -1400,6 +1410,7 @@ struct io_u *get_io_u(struct thread_data *td)struct fio_file *f;struct io_u *io_u;int do_scramble =0 ; +long ret =0 ; io_u =__get_io_u (td);if (!io_u) {
@@ -1425,11 +1436,17 @@ struct io_u *get_io_u(struct thread_data *td)if (read_iolog_get (td, io_u)) goto err_put; }else if (set_io_u_file (td, io_u)) { + ret = -EBUSY ;dprint (FD_IO ,"io_u %p, setting file failed\n" , io_u); goto err_put; } f = io_u->file; +if (!f) { +dprint (FD_IO ,"io_u %p, setting file failed\n" , io_u); + goto err_put; + } +assert (fio_file_open (f));if (ddir_rw (io_u->ddir)) {
@@ -1478,7 +1495,7 @@ out: err_put:dprint (FD_IO ,"get_io_u failed\n" );put_io_u (td, io_u); -return NULL ; +return ERR_PTR (ret); }void io_u_log_error (struct thread_data *td,struct io_u *io_u)
options.c +20 -1
@@ -821,6 +821,18 @@ static int str_directory_cb(void *data, const char fio_unused *str)return 0 ; } +static int str_lockfile_cb(void *data, const char fio_unused *str) +{ +struct thread_data *td = data; + +if (td->files_index) { +log_err ("fio: lockfile= option must precede filename=\n" ); +return 1 ; + } + +return 0 ; +} + static int str_opendir_cb(void *data, const char fio_unused *str) {struct thread_data *td = data;
@@ -1231,6 +1243,7 @@ struct fio_option fio_options[FIO_MAX_OPTS] = { .parent = "filename", .hide = 0, .def = "none", + .cb = str_lockfile_cb, .category = FIO_OPT_C_FILE, .group = FIO_OPT_G_FILENAME, .posval = {
@@ -3727,7 +3740,7 @@ void options_mem_dupe(void *data, struct fio_option *options)if (o->type !=FIO_OPT_STR_STORE )continue ; - ptr =td_var (data, o->off1); + ptr =td_var (data, o, o->off1);if (*ptr) *ptr =strdup (*ptr); }
@@ -3773,7 +3786,13 @@ int add_option(struct fio_option *o) __o++; } +if (opt_index +1 ==FIO_MAX_OPTS ) { +log_err ("fio: FIO_MAX_OPTS is too small\n" ); +return 1 ; + } +memcpy (&fio_options[opt_index], o,sizeof (*o)); + fio_options[opt_index +1 ].name =NULL ;return 0 ; }
os/windows/install.wxs +1 -1
@@ -10,7 +10,7 @@ <Product Id="*" Codepage="1252" Language="1033" Manufacturer="fio" Name="fio" - UpgradeCode="2338A332-5511-43CF-B9BD-5C60496CCFCC" Version="2.1.4"> + UpgradeCode="2338A332-5511-43CF-B9BD-5C60496CCFCC" Version="2.1.5"> <Package Description="Flexible IO Tester" InstallerVersion="301" Keywords="Installer,MSI,Database"
parse.c +45 -101
248 lines not on this page · raw message
parse.h +12 -2
@@ -49,7 +49,6 @@ struct fio_option {unsigned int off4;unsigned int off5;unsigned int off6; -void *roff1, *roff2, *roff3, *roff4, *roff5, *roff6;unsigned int maxval;/* max and min value */ int minval;double maxfp;/* max and min floating value */
@@ -69,6 +68,7 @@ struct fio_option {struct fio_option *inv_opt;/* cached lookup */ int (*verify)(struct fio_option *,void *);const char *prof_name;/* only valid for specific profile */ +void *prof_opts;unsigned int category;/* what type of option */ unsigned int group;/* who to group with */ void *gui_data;
@@ -100,7 +100,17 @@ typedef int (fio_opt_str_val_fn)(void *, long long *);typedef int (fio_opt_int_fn )(void *,int *);typedef int (fio_opt_str_set_fn )(void *); -#define td_var (start, offset) ((void *) start + (offset)) +#define __td_var (start, offset) ((void *) start + (offset)) + +struct thread_options ; +static inline void *td_var (struct thread_options *to,struct fio_option *o, +unsigned int offset) +{ +if (o->prof_opts) +return __td_var (o->prof_opts, offset); + +return __td_var (to, offset); +}static inline int parse_is_percent (unsigned long long val) {
profile.c +1 -0
@@ -52,6 +52,7 @@ static int add_profile_options(struct profile_ops *ops) o = ops->options;while (o->name) { o->prof_name = ops->name; + o->prof_opts = ops->opt_data;if (add_option (o))return 1 ; o++;
profile.h +1 -0
@@ -27,6 +27,7 @@ struct profile_ops {* Profile specific options */ struct fio_option *options; +void *opt_data;/* * Called after parsing options, to prepare 'cmdline'
profiles/act.c +21 -7
@@ -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,
@@ -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,
profiles/tiobench.c +18 -5
@@ -21,12 +21,23 @@ static const char *tb_opts[] = { "name=randread", "stonewall", "rw=randread", NULL, }; +struct tiobench_options { +unsigned int pad; +unsigned long long size; +unsigned int loops; +unsigned int bs; +unsigned int nthreads; +char *dir; +}; + +static struct tiobench_options tiobench_options; +static struct fio_option options[] = { { .name ="size" , .lname ="Tiobench size" , .type =FIO_OPT_STR_VAL , - .roff1 = &size, + .off1 = offsetof(struct tiobench_options , size), .help ="Size in MB" , .category =FIO_OPT_C_PROFILE , .group =FIO_OPT_G_TIOBENCH ,
@@ -35,7 +46,7 @@ static struct fio_option options[] = { .name = "block", .lname = "Tiobench block", .type = FIO_OPT_INT, - .roff1 = &bs, + .off1 = offsetof(struct tiobench_options, bs), .help = "Block size in bytes", .def = "4k", .category = FIO_OPT_C_PROFILE,
@@ -45,7 +56,7 @@ static struct fio_option options[] = { .name = "numruns", .lname = "Tiobench numruns", .type = FIO_OPT_INT, - .roff1 = &loops, + .off1 = offsetof(struct tiobench_options, loops), .help = "Number of runs", .category = FIO_OPT_C_PROFILE, .group = FIO_OPT_G_TIOBENCH,
@@ -54,7 +65,7 @@ static struct fio_option options[] = { .name = "dir", .lname = "Tiobench directory", .type = FIO_OPT_STR_STORE, - .roff1 = &dir, + .off1 = offsetof(struct tiobench_options, dir), .help = "Test directory", .category = FIO_OPT_C_PROFILE, .group = FIO_OPT_G_TIOBENCH,
@@ -63,7 +74,7 @@ static struct fio_option options[] = { .name = "threads", .lname = "Tiobench threads", .type = FIO_OPT_INT, - .roff1 = &nthreads, + .off1 = offsetof(struct tiobench_options, nthreads), .help = "Number of Threads", .category = FIO_OPT_C_PROFILE, .group = FIO_OPT_G_TIOBENCH,
@@ -105,6 +116,8 @@ static struct profile_ops tiobench_profile = { .options = options, .prep_cmd = tb_prep_cmdline, .cmdline = tb_opts, + .options = options, + .opt_data = &tiobench_options, }; static void fio_init tiobench_register(void)