15184Sek110237 /*
25184Sek110237 * CDDL HEADER START
35184Sek110237 *
45184Sek110237 * The contents of this file are subject to the terms of the
55184Sek110237 * Common Development and Distribution License (the "License").
65184Sek110237 * You may not use this file except in compliance with the License.
75184Sek110237 *
85184Sek110237 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
95184Sek110237 * or http://www.opensolaris.org/os/licensing.
105184Sek110237 * See the License for the specific language governing permissions
115184Sek110237 * and limitations under the License.
125184Sek110237 *
135184Sek110237 * When distributing Covered Code, include this CDDL HEADER in each
145184Sek110237 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
155184Sek110237 * If applicable, add the following below this CDDL HEADER, with the
165184Sek110237 * fields enclosed by brackets "[]" replaced with your own identifying
175184Sek110237 * information: Portions Copyright [yyyy] [name of copyright owner]
185184Sek110237 *
195184Sek110237 * CDDL HEADER END
205184Sek110237 */
215184Sek110237 /*
228615SAndrew.W.Wilson@sun.com * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
235184Sek110237 * Use is subject to license terms.
246613Sek110237 *
256613Sek110237 * Portions Copyright 2008 Denis Cheng
265184Sek110237 */
275184Sek110237
285184Sek110237 %{
295184Sek110237
305184Sek110237 #include <stdlib.h>
315184Sek110237 #include <stdio.h>
325184Sek110237 #include <string.h>
335184Sek110237 #include <signal.h>
345184Sek110237 #include <errno.h>
355184Sek110237 #include <sys/types.h>
365184Sek110237 #include <locale.h>
375184Sek110237 #include <sys/utsname.h>
389513SAndrew.W.Wilson@sun.com #include <sys/statvfs.h>
395184Sek110237 #ifdef HAVE_STDINT_H
405184Sek110237 #include <stdint.h>
415184Sek110237 #endif
425184Sek110237 #include <fcntl.h>
435184Sek110237 #include <sys/mman.h>
445184Sek110237 #include <sys/wait.h>
455184Sek110237 #ifdef HAVE_LIBTECLA
465184Sek110237 #include <libtecla.h>
475184Sek110237 #endif
485184Sek110237 #include "parsertypes.h"
495184Sek110237 #include "filebench.h"
505184Sek110237 #include "utils.h"
515184Sek110237 #include "stats.h"
525184Sek110237 #include "vars.h"
535184Sek110237 #include "eventgen.h"
545184Sek110237 #ifdef HAVE_LIBTECLA
555184Sek110237 #include "auto_comp.h"
565184Sek110237 #endif
577736SAndrew.W.Wilson@sun.com #include "multi_client_sync.h"
585184Sek110237
595184Sek110237 int dofile = FS_FALSE;
605184Sek110237 static const char cmdname[] = "filebench";
615184Sek110237 static const char cmd_options[] = "pa:f:hi:s:m:";
625184Sek110237 static void usage(int);
635184Sek110237
645184Sek110237 static cmd_t *cmd = NULL; /* Command being processed */
655184Sek110237 #ifdef HAVE_LIBTECLA
665184Sek110237 static GetLine *gl; /* GetLine resource object */
675184Sek110237 #endif
685184Sek110237
695184Sek110237 char *execname;
709513SAndrew.W.Wilson@sun.com char *fbbasepath = FILEBENCHDIR;
715184Sek110237 char *fscriptname;
725184Sek110237 int noproc = 0;
735184Sek110237 var_t *var_list = NULL;
745184Sek110237 pidlist_t *pidlist = NULL;
755184Sek110237 char *cwd = NULL;
765184Sek110237 FILE *parentscript = NULL;
775673Saw148015
785673Saw148015 static int filecreate_done = 0;
795673Saw148015
805184Sek110237 /* yacc externals */
815184Sek110237 extern FILE *yyin;
825184Sek110237 extern int yydebug;
835184Sek110237 extern void yyerror(char *s);
845184Sek110237
855184Sek110237 /* utilities */
865184Sek110237 static void terminate(void);
875184Sek110237 static cmd_t *alloc_cmd(void);
885184Sek110237 static attr_t *alloc_attr(void);
896550Saw148015 static attr_t *alloc_lvar_attr(var_t *var);
905184Sek110237 static attr_t *get_attr(cmd_t *cmd, int64_t name);
918404SAndrew.W.Wilson@sun.com static attr_t *get_attr_fileset(cmd_t *cmd, int64_t name);
925184Sek110237 static attr_t *get_attr_integer(cmd_t *cmd, int64_t name);
935184Sek110237 static attr_t *get_attr_bool(cmd_t *cmd, int64_t name);
946550Saw148015 static void get_attr_lvars(cmd_t *cmd, flowop_t *flowop);
955184Sek110237 static var_t *alloc_var(void);
965184Sek110237 static var_t *get_var(cmd_t *cmd, int64_t name);
975184Sek110237 static list_t *alloc_list();
986212Saw148015 static probtabent_t *alloc_probtabent(void);
996550Saw148015 static void add_lvar_to_list(var_t *newlvar, var_t **lvar_list);
1005184Sek110237
1015184Sek110237 /* Info Commands */
1025184Sek110237 static void parser_list(cmd_t *);
1036212Saw148015 static void parser_flowop_list(cmd_t *);
1045184Sek110237
1055184Sek110237 /* Define Commands */
1065184Sek110237 static void parser_proc_define(cmd_t *);
1075184Sek110237 static void parser_thread_define(cmd_t *, procflow_t *, int instances);
1086212Saw148015 static void parser_flowop_define(cmd_t *, threadflow_t *, flowop_t **, int);
1095184Sek110237 static void parser_file_define(cmd_t *);
1105184Sek110237 static void parser_fileset_define(cmd_t *);
1116212Saw148015 static void parser_randvar_define(cmd_t *);
1126212Saw148015 static void parser_randvar_set(cmd_t *);
1136550Saw148015 static void parser_composite_flowop_define(cmd_t *);
1145184Sek110237
1155184Sek110237 /* Create Commands */
1165184Sek110237 static void parser_proc_create(cmd_t *);
1175184Sek110237 static void parser_thread_create(cmd_t *);
1185184Sek110237 static void parser_flowop_create(cmd_t *);
1195184Sek110237 static void parser_fileset_create(cmd_t *);
1205184Sek110237
1216212Saw148015 /* set commands */
122*9801SAndrew.W.Wilson@sun.com static void parser_set_integer(cmd_t *cmd);
123*9801SAndrew.W.Wilson@sun.com static void parser_set_var(cmd_t *cmd);
124*9801SAndrew.W.Wilson@sun.com static void parser_set_var_op_int(cmd_t *cmd);
125*9801SAndrew.W.Wilson@sun.com static void parser_set_int_op_var(cmd_t *cmd);
126*9801SAndrew.W.Wilson@sun.com static void parser_set_var_op_var(cmd_t *cmd);
1276212Saw148015
1285184Sek110237 /* Shutdown Commands */
1295184Sek110237 static void parser_proc_shutdown(cmd_t *);
1305184Sek110237 static void parser_filebench_shutdown(cmd_t *cmd);
1315184Sek110237
1325184Sek110237 /* Other Commands */
1339513SAndrew.W.Wilson@sun.com static void parser_echo(cmd_t *cmd);
1345184Sek110237 static void parser_foreach_integer(cmd_t *cmd);
1355184Sek110237 static void parser_foreach_string(cmd_t *cmd);
1369513SAndrew.W.Wilson@sun.com static void parser_fscheck(cmd_t *cmd);
1379513SAndrew.W.Wilson@sun.com static void parser_fsflush(cmd_t *cmd);
1385184Sek110237 static void parser_log(cmd_t *cmd);
1395184Sek110237 static void parser_statscmd(cmd_t *cmd);
1405184Sek110237 static void parser_statsdump(cmd_t *cmd);
1415184Sek110237 static void parser_statsxmldump(cmd_t *cmd);
1427736SAndrew.W.Wilson@sun.com static void parser_statsmultidump(cmd_t *cmd);
1435184Sek110237 static void parser_usage(cmd_t *cmd);
1445184Sek110237 static void parser_vars(cmd_t *cmd);
1455184Sek110237 static void parser_printvars(cmd_t *cmd);
1465184Sek110237 static void parser_system(cmd_t *cmd);
1475184Sek110237 static void parser_statssnap(cmd_t *cmd);
1485184Sek110237 static void parser_directory(cmd_t *cmd);
1495184Sek110237 static void parser_eventgen(cmd_t *cmd);
1507736SAndrew.W.Wilson@sun.com static void parser_enable_mc(cmd_t *cmd);
1517736SAndrew.W.Wilson@sun.com static void parser_domultisync(cmd_t *cmd);
1525184Sek110237 static void parser_run(cmd_t *cmd);
1535184Sek110237 static void parser_run_variable(cmd_t *cmd);
1549326SAndrew.W.Wilson@sun.com static void parser_sleep(cmd_t *cmd);
1559326SAndrew.W.Wilson@sun.com static void parser_sleep_variable(cmd_t *cmd);
1569326SAndrew.W.Wilson@sun.com static void parser_warmup(cmd_t *cmd);
1579326SAndrew.W.Wilson@sun.com static void parser_warmup_variable(cmd_t *cmd);
1585184Sek110237 static void parser_help(cmd_t *cmd);
1595184Sek110237 static void arg_parse(const char *command);
1605184Sek110237 static void parser_abort(int arg);
1616750Sek110237 static void parser_version(cmd_t *cmd);
1625184Sek110237
1635184Sek110237 %}
1645184Sek110237
1655184Sek110237 %union {
1666212Saw148015 int64_t ival;
1676212Saw148015 uchar_t bval;
1686212Saw148015 char * sval;
1696212Saw148015 fs_u val;
1706212Saw148015 avd_t avd;
1716212Saw148015 cmd_t *cmd;
1726212Saw148015 attr_t *attr;
1736212Saw148015 list_t *list;
1746212Saw148015 probtabent_t *rndtb;
1755184Sek110237 }
1765184Sek110237
1775184Sek110237 %start commands
1785184Sek110237
1795184Sek110237 %token FSC_LIST FSC_DEFINE FSC_EXEC FSC_QUIT FSC_DEBUG FSC_CREATE
1805184Sek110237 %token FSC_SLEEP FSC_STATS FSC_FOREACH FSC_SET FSC_SHUTDOWN FSC_LOG
1815184Sek110237 %token FSC_SYSTEM FSC_FLOWOP FSC_EVENTGEN FSC_ECHO FSC_LOAD FSC_RUN
1829513SAndrew.W.Wilson@sun.com %token FSC_WARMUP FSC_NOUSESTATS FSC_FSCHECK FSC_FSFLUSH
1837736SAndrew.W.Wilson@sun.com %token FSC_USAGE FSC_HELP FSC_VARS FSC_VERSION FSC_ENABLE FSC_DOMULTISYNC
1845184Sek110237 %token FSV_STRING FSV_VAL_INT FSV_VAL_BOOLEAN FSV_VARIABLE FSV_WHITESTRING
1856212Saw148015 %token FSV_RANDUNI FSV_RANDTAB FSV_RANDVAR FSV_URAND FSV_RAND48
1865184Sek110237 %token FST_INT FST_BOOLEAN
1875184Sek110237 %token FSE_FILE FSE_PROC FSE_THREAD FSE_CLEAR FSE_ALL FSE_SNAP FSE_DUMP
1886212Saw148015 %token FSE_DIRECTORY FSE_COMMAND FSE_FILESET FSE_XMLDUMP FSE_RAND FSE_MODE
1897736SAndrew.W.Wilson@sun.com %token FSE_MULTI FSE_MULTIDUMP
1905184Sek110237 %token FSK_SEPLST FSK_OPENLST FSK_CLOSELST FSK_ASSIGN FSK_IN FSK_QUOTE
191*9801SAndrew.W.Wilson@sun.com %token FSK_DIRSEPLST FSK_PLUS FSK_MINUS FSK_MULTIPLY FSK_DIVIDE
1925184Sek110237 %token FSA_SIZE FSA_PREALLOC FSA_PARALLOC FSA_PATH FSA_REUSE
1939326SAndrew.W.Wilson@sun.com %token FSA_PROCESS FSA_MEMSIZE FSA_RATE FSA_CACHED FSA_READONLY FSA_TRUSTTREE
1945184Sek110237 %token FSA_IOSIZE FSA_FILE FSA_WSS FSA_NAME FSA_RANDOM FSA_INSTANCES
1955184Sek110237 %token FSA_DSYNC FSA_TARGET FSA_ITERS FSA_NICE FSA_VALUE FSA_BLOCKING
1965184Sek110237 %token FSA_HIGHWATER FSA_DIRECTIO FSA_DIRWIDTH FSA_FD FSA_SRCFD FSA_ROTATEFD
1976212Saw148015 %token FSA_NAMELENGTH FSA_FILESIZE FSA_ENTRIES FSA_FILESIZEGAMMA FSA_DIRDEPTHRV
1986212Saw148015 %token FSA_DIRGAMMA FSA_USEISM FSA_TYPE FSA_RANDTABLE FSA_RANDSRC FSA_RANDROUND
1999513SAndrew.W.Wilson@sun.com %token FSA_LEAFDIRS FSA_INDEXED FSA_FSTYPE
2007736SAndrew.W.Wilson@sun.com %token FSA_RANDSEED FSA_RANDGAMMA FSA_RANDMEAN FSA_RANDMIN FSA_MASTER
2017736SAndrew.W.Wilson@sun.com %token FSA_CLIENT
2026212Saw148015 %token FSS_TYPE FSS_SEED FSS_GAMMA FSS_MEAN FSS_MIN FSS_SRC FSS_ROUND
2036550Saw148015 %token FSV_SET_LOCAL_VAR FSA_LVAR_ASSIGN
2046212Saw148015 %token FSA_ALLDONE FSA_FIRSTDONE FSA_TIMEOUT
2055184Sek110237
2065184Sek110237 %type <ival> FSV_VAL_INT
2075184Sek110237 %type <bval> FSV_VAL_BOOLEAN
2085184Sek110237 %type <sval> FSV_STRING
2095184Sek110237 %type <sval> FSV_WHITESTRING
2105184Sek110237 %type <sval> FSV_VARIABLE
2116212Saw148015 %type <sval> FSV_RANDVAR
2125184Sek110237 %type <sval> FSK_ASSIGN
2136550Saw148015 %type <sval> FSV_SET_LOCAL_VAR
2145184Sek110237
2157736SAndrew.W.Wilson@sun.com %type <ival> FSC_LIST FSC_DEFINE FSC_SET FSC_LOAD FSC_RUN FSC_ENABLE
2167736SAndrew.W.Wilson@sun.com %type <ival> FSC_DOMULTISYNC
2176750Sek110237 %type <ival> FSE_FILE FSE_PROC FSE_THREAD FSE_CLEAR FSC_HELP FSC_VERSION
2185184Sek110237
2195184Sek110237 %type <sval> name
2205184Sek110237 %type <ival> entity
2215184Sek110237 %type <val> value
2225184Sek110237
2236212Saw148015 %type <cmd> command inner_commands load_command run_command list_command
2246212Saw148015 %type <cmd> proc_define_command files_define_command randvar_define_command
2256550Saw148015 %type <cmd> fo_define_command debug_command create_command
2265184Sek110237 %type <cmd> sleep_command stats_command set_command shutdown_command
2275184Sek110237 %type <cmd> foreach_command log_command system_command flowop_command
2285184Sek110237 %type <cmd> eventgen_command quit_command flowop_list thread_list
2295184Sek110237 %type <cmd> thread echo_command usage_command help_command vars_command
2309513SAndrew.W.Wilson@sun.com %type <cmd> version_command enable_command multisync_command
2319513SAndrew.W.Wilson@sun.com %type <cmd> warmup_command fscheck_command fsflush_command
232*9801SAndrew.W.Wilson@sun.com %type <cmd> set_integer_command set_other_command
2335184Sek110237
2346212Saw148015 %type <attr> files_attr_op files_attr_ops pt_attr_op pt_attr_ops
2356212Saw148015 %type <attr> fo_attr_op fo_attr_ops ev_attr_op ev_attr_ops
2366212Saw148015 %type <attr> randvar_attr_op randvar_attr_ops randvar_attr_typop
2376212Saw148015 %type <attr> randvar_attr_srcop attr_value attr_list_value
2386550Saw148015 %type <attr> comp_lvar_def comp_attr_op comp_attr_ops
2397736SAndrew.W.Wilson@sun.com %type <attr> enable_multi_ops enable_multi_op multisync_op
2409513SAndrew.W.Wilson@sun.com %type <attr> fscheck_attr_op
2416212Saw148015 %type <list> integer_seplist string_seplist string_list var_string_list
2426212Saw148015 %type <list> var_string whitevar_string whitevar_string_list
2436212Saw148015 %type <ival> attrs_define_file attrs_define_thread attrs_flowop
2446550Saw148015 %type <ival> attrs_define_fileset attrs_define_proc attrs_eventgen attrs_define_comp
2456212Saw148015 %type <ival> files_attr_name pt_attr_name fo_attr_name ev_attr_name
2466212Saw148015 %type <ival> randvar_attr_name FSA_TYPE randtype_name randvar_attr_param
2477736SAndrew.W.Wilson@sun.com %type <ival> randsrc_name FSA_RANDSRC randvar_attr_tsp em_attr_name
2486212Saw148015 %type <ival> FSS_TYPE FSS_SEED FSS_GAMMA FSS_MEAN FSS_MIN FSS_SRC
249*9801SAndrew.W.Wilson@sun.com %type <ival> fscheck_attr_name FSA_FSTYPE binary_op
2506212Saw148015
2516212Saw148015 %type <rndtb> probtabentry_list probtabentry
2526212Saw148015 %type <avd> var_int_val
2535184Sek110237 %%
2545184Sek110237
2555184Sek110237 commands: commands command
2565184Sek110237 {
2575184Sek110237 list_t *list = NULL;
2585184Sek110237 list_t *list_end = NULL;
2595184Sek110237
2605184Sek110237 if ($2->cmd != NULL)
2615184Sek110237 $2->cmd($2);
2625184Sek110237
2635184Sek110237 free($2);
2645184Sek110237 }
2655184Sek110237 | commands error
2665184Sek110237 {
2675184Sek110237 if (dofile)
2685184Sek110237 YYABORT;
2695184Sek110237 }
2705184Sek110237 |;
2715184Sek110237
2725184Sek110237 inner_commands: command
2735184Sek110237 {
2745184Sek110237 filebench_log(LOG_DEBUG_IMPL, "inner_command %zx", $1);
2755184Sek110237 $$ = $1;
2765184Sek110237 }
2775184Sek110237 | inner_commands command
2785184Sek110237 {
2795184Sek110237 cmd_t *list = NULL;
2805184Sek110237 cmd_t *list_end = NULL;
2815184Sek110237
2825184Sek110237 /* Find end of list */
2835184Sek110237 for (list = $1; list != NULL;
2845184Sek110237 list = list->cmd_next)
2855184Sek110237 list_end = list;
2865184Sek110237
2875184Sek110237 list_end->cmd_next = $2;
2885184Sek110237
2895184Sek110237 filebench_log(LOG_DEBUG_IMPL,
2905184Sek110237 "inner_commands adding cmd %zx to list %zx", $2, $1);
2915184Sek110237
2925184Sek110237 $$ = $1;
2935184Sek110237 };
2945184Sek110237
2955184Sek110237 command:
2966212Saw148015 proc_define_command
2976212Saw148015 | files_define_command
2986212Saw148015 | randvar_define_command
2996550Saw148015 | fo_define_command
3005184Sek110237 | debug_command
3015184Sek110237 | eventgen_command
3025184Sek110237 | create_command
3035184Sek110237 | echo_command
3045184Sek110237 | usage_command
3055184Sek110237 | vars_command
3065184Sek110237 | foreach_command
3079513SAndrew.W.Wilson@sun.com | fscheck_command
3089513SAndrew.W.Wilson@sun.com | fsflush_command
3095184Sek110237 | help_command
3105184Sek110237 | list_command
3115184Sek110237 | load_command
3125184Sek110237 | log_command
3135184Sek110237 | run_command
3145184Sek110237 | set_command
3155184Sek110237 | shutdown_command
3165184Sek110237 | sleep_command
3179326SAndrew.W.Wilson@sun.com | warmup_command
3185184Sek110237 | stats_command
3195184Sek110237 | system_command
3206750Sek110237 | version_command
3217736SAndrew.W.Wilson@sun.com | enable_command
3227736SAndrew.W.Wilson@sun.com | multisync_command
3235184Sek110237 | quit_command;
3245184Sek110237
3255184Sek110237 foreach_command: FSC_FOREACH
3265184Sek110237 {
3275184Sek110237 if (($$ = alloc_cmd()) == NULL)
3285184Sek110237 YYERROR;
3295184Sek110237 filebench_log(LOG_DEBUG_IMPL, "foreach_command %zx", $$);
3305184Sek110237 }
3315184Sek110237 | foreach_command FSV_VARIABLE FSK_IN integer_seplist FSK_OPENLST inner_commands FSK_CLOSELST
3325184Sek110237 {
3335184Sek110237 cmd_t *cmd, *inner_cmd;
3345184Sek110237 list_t *list;
3355184Sek110237
3365184Sek110237 $$ = $1;
3375184Sek110237 $$->cmd_list = $6;
3385184Sek110237 $$->cmd_tgt1 = $2;
3395184Sek110237 $$->cmd_param_list = $4;
3405184Sek110237 $$->cmd = parser_foreach_integer;
3415184Sek110237
3425184Sek110237 for (list = $$->cmd_param_list; list != NULL;
3435184Sek110237 list = list->list_next) {
3445184Sek110237 for (inner_cmd = $$->cmd_list;
3455184Sek110237 inner_cmd != NULL;
3465184Sek110237 inner_cmd = inner_cmd->cmd_next) {
3475184Sek110237 filebench_log(LOG_DEBUG_IMPL,
3486286Saw148015 "packing foreach: %zx %s=%llu, cmd %zx",
3496212Saw148015 $$, $$->cmd_tgt1,
3506286Saw148015 (u_longlong_t)avd_get_int(list->list_integer),
3516286Saw148015 inner_cmd);
3525184Sek110237 }
3535184Sek110237 }
3545184Sek110237 }| foreach_command FSV_VARIABLE FSK_IN string_seplist FSK_OPENLST inner_commands FSK_CLOSELST
3555184Sek110237 {
3565184Sek110237 cmd_t *cmd, *inner_cmd;
3575184Sek110237 list_t *list;
3585184Sek110237
3595184Sek110237 $$ = $1;
3605184Sek110237 $$->cmd_list = $6;
3615184Sek110237 $$->cmd_tgt1 = $2;
3625184Sek110237 $$->cmd_param_list = $4;
3635184Sek110237 $$->cmd = parser_foreach_string;
3645184Sek110237
3655184Sek110237 for (list = $$->cmd_param_list; list != NULL;
3665184Sek110237 list = list->list_next) {
3675184Sek110237 for (inner_cmd = $$->cmd_list;
3685184Sek110237 inner_cmd != NULL;
3695184Sek110237 inner_cmd = inner_cmd->cmd_next) {
3705184Sek110237 filebench_log(LOG_DEBUG_IMPL,
3715184Sek110237 "packing foreach: %zx %s=%s, cmd %zx",
3725184Sek110237 $$,
3735184Sek110237 $$->cmd_tgt1,
3745184Sek110237 *list->list_string, inner_cmd);
3755184Sek110237 }
3765184Sek110237 }
3775184Sek110237 };
3785184Sek110237
3795184Sek110237 integer_seplist: FSV_VAL_INT
3805184Sek110237 {
3815184Sek110237 if (($$ = alloc_list()) == NULL)
3825184Sek110237 YYERROR;
3835184Sek110237
3846212Saw148015 $$->list_integer = avd_int_alloc($1);
3855184Sek110237 }
3865184Sek110237 | integer_seplist FSK_SEPLST FSV_VAL_INT
3875184Sek110237 {
3885184Sek110237 list_t *list = NULL;
3895184Sek110237 list_t *list_end = NULL;
3905184Sek110237
3915184Sek110237 if (($$ = alloc_list()) == NULL)
3925184Sek110237 YYERROR;
3935184Sek110237
3946212Saw148015 $$->list_integer = avd_int_alloc($3);
3955184Sek110237
3965184Sek110237 /* Find end of list */
3975184Sek110237 for (list = $1; list != NULL;
3985184Sek110237 list = list->list_next)
3995184Sek110237 list_end = list;
4005184Sek110237 list_end->list_next = $$;
4015184Sek110237 $$ = $1;
4025184Sek110237 };
4035184Sek110237
4045184Sek110237 string_seplist: FSK_QUOTE FSV_WHITESTRING FSK_QUOTE
4055184Sek110237 {
4065184Sek110237 if (($$ = alloc_list()) == NULL)
4075184Sek110237 YYERROR;
4085184Sek110237
4096212Saw148015 $$->list_string = avd_str_alloc($2);
4105184Sek110237 }
4115184Sek110237 | string_seplist FSK_SEPLST FSK_QUOTE FSV_WHITESTRING FSK_QUOTE
4125184Sek110237 {
4135184Sek110237 list_t *list = NULL;
4145184Sek110237 list_t *list_end = NULL;
4155184Sek110237
4165184Sek110237 if (($$ = alloc_list()) == NULL)
4175184Sek110237 YYERROR;
4185184Sek110237
4196212Saw148015 $$->list_string = avd_str_alloc($4);
4205184Sek110237
4215184Sek110237 /* Find end of list */
4225184Sek110237 for (list = $1; list != NULL;
4235184Sek110237 list = list->list_next)
4245184Sek110237 list_end = list;
4255184Sek110237 list_end->list_next = $$;
4265184Sek110237 $$ = $1;
4275184Sek110237 };
4285184Sek110237
4295184Sek110237 eventgen_command: FSC_EVENTGEN
4305184Sek110237 {
4315184Sek110237 if (($$ = alloc_cmd()) == NULL)
4325184Sek110237 YYERROR;
4335184Sek110237 $$->cmd = &parser_eventgen;
4345184Sek110237 }
4356212Saw148015 | eventgen_command ev_attr_ops
4365184Sek110237 {
4375184Sek110237 $1->cmd_attr_list = $2;
4385184Sek110237 };
4395184Sek110237
4405184Sek110237 system_command: FSC_SYSTEM whitevar_string_list
4415184Sek110237 {
4425184Sek110237 if (($$ = alloc_cmd()) == NULL)
4435184Sek110237 YYERROR;
4445184Sek110237
4455184Sek110237 $$->cmd_param_list = $2;
4465184Sek110237 $$->cmd = parser_system;
4475184Sek110237 };
4485184Sek110237
4495184Sek110237 echo_command: FSC_ECHO whitevar_string_list
4505184Sek110237 {
4515184Sek110237 if (($$ = alloc_cmd()) == NULL)
4525184Sek110237 YYERROR;
4535184Sek110237
4545184Sek110237 $$->cmd_param_list = $2;
4555184Sek110237 $$->cmd = parser_echo;
4565184Sek110237 };
4575184Sek110237
4586750Sek110237 version_command: FSC_VERSION
4596750Sek110237 {
4606750Sek110237 if (($$ = alloc_cmd()) == NULL)
4616750Sek110237 YYERROR;
4626750Sek110237 $$->cmd = parser_version;
4636750Sek110237 };
4646750Sek110237
4655184Sek110237 usage_command: FSC_USAGE whitevar_string_list
4665184Sek110237 {
4675184Sek110237 if (($$ = alloc_cmd()) == NULL)
4685184Sek110237 YYERROR;
4695184Sek110237
4705184Sek110237 $$->cmd_param_list = $2;
4715184Sek110237 $$->cmd = parser_usage;
4725184Sek110237 };
4735184Sek110237
4745184Sek110237 vars_command: FSC_VARS
4755184Sek110237 {
4765184Sek110237 if (($$ = alloc_cmd()) == NULL)
4775184Sek110237 YYERROR;
4785184Sek110237
4795184Sek110237 $$->cmd = parser_printvars;
4805184Sek110237 };
4815184Sek110237
4827736SAndrew.W.Wilson@sun.com enable_command: FSC_ENABLE FSE_MULTI
4837736SAndrew.W.Wilson@sun.com {
4847736SAndrew.W.Wilson@sun.com if (($$ = alloc_cmd()) == NULL)
4857736SAndrew.W.Wilson@sun.com YYERROR;
4867736SAndrew.W.Wilson@sun.com
4877736SAndrew.W.Wilson@sun.com $$->cmd = parser_enable_mc;
4887736SAndrew.W.Wilson@sun.com }
4897736SAndrew.W.Wilson@sun.com | enable_command enable_multi_ops
4907736SAndrew.W.Wilson@sun.com {
4917736SAndrew.W.Wilson@sun.com $1->cmd_attr_list = $2;
4927736SAndrew.W.Wilson@sun.com };
4937736SAndrew.W.Wilson@sun.com
4947736SAndrew.W.Wilson@sun.com multisync_command: FSC_DOMULTISYNC multisync_op
4957736SAndrew.W.Wilson@sun.com {
4967736SAndrew.W.Wilson@sun.com if (($$ = alloc_cmd()) == NULL)
4977736SAndrew.W.Wilson@sun.com YYERROR;
4987736SAndrew.W.Wilson@sun.com
4997736SAndrew.W.Wilson@sun.com $$->cmd = parser_domultisync;
5007736SAndrew.W.Wilson@sun.com $$->cmd_attr_list = $2;
5017736SAndrew.W.Wilson@sun.com }
5027736SAndrew.W.Wilson@sun.com
5035184Sek110237 string_list: FSV_VARIABLE
5045184Sek110237 {
5055184Sek110237 if (($$ = alloc_list()) == NULL)
5065184Sek110237 YYERROR;
5076212Saw148015 $$->list_string = avd_str_alloc($1);
5085184Sek110237 }
5095184Sek110237 | string_list FSK_SEPLST FSV_VARIABLE
5105184Sek110237 {
5115184Sek110237 list_t *list = NULL;
5125184Sek110237 list_t *list_end = NULL;
5135184Sek110237
5145184Sek110237 if (($$ = alloc_list()) == NULL)
5155184Sek110237 YYERROR;
5165184Sek110237
5176212Saw148015 $$->list_string = avd_str_alloc($3);
5185184Sek110237
5195184Sek110237 /* Find end of list */
5205184Sek110237 for (list = $1; list != NULL;
5215184Sek110237 list = list->list_next)
5225184Sek110237 list_end = list;
5235184Sek110237 list_end->list_next = $$;
5245184Sek110237 $$ = $1;
5255184Sek110237 };
5265184Sek110237
5275184Sek110237 var_string: FSV_VARIABLE
5285184Sek110237 {
5295184Sek110237 if (($$ = alloc_list()) == NULL)
5305184Sek110237 YYERROR;
5315184Sek110237
5326212Saw148015 $$->list_string = avd_str_alloc($1);
5335184Sek110237 }
5345184Sek110237 | FSV_STRING
5355184Sek110237 {
5365184Sek110237 if (($$ = alloc_list()) == NULL)
5375184Sek110237 YYERROR;
5385184Sek110237
5396212Saw148015 $$->list_string = avd_str_alloc($1);
5405184Sek110237 };
5415184Sek110237
5425184Sek110237 var_string_list: var_string
5435184Sek110237 {
5445184Sek110237 $$ = $1;
5455184Sek110237 }| var_string FSV_STRING
5465184Sek110237 {
5475184Sek110237 list_t *list = NULL;
5485184Sek110237 list_t *list_end = NULL;
5495184Sek110237
5505184Sek110237 /* Add string */
5515184Sek110237 if (($$ = alloc_list()) == NULL)
5525184Sek110237 YYERROR;
5535184Sek110237
5546212Saw148015 $$->list_string = avd_str_alloc($2);
5555184Sek110237
5565184Sek110237 /* Find end of list */
5575184Sek110237 for (list = $1; list != NULL;
5585184Sek110237 list = list->list_next)
5595184Sek110237 list_end = list;
5605184Sek110237 list_end->list_next = $$;
5615184Sek110237 $$ = $1;
5625184Sek110237
5635184Sek110237 }| var_string FSV_VARIABLE
5645184Sek110237 {
5655184Sek110237 list_t *list = NULL;
5665184Sek110237 list_t *list_end = NULL;
5675184Sek110237
5685184Sek110237 /* Add variable */
5695184Sek110237 if (($$ = alloc_list()) == NULL)
5705184Sek110237 YYERROR;
5715184Sek110237
5726212Saw148015 $$->list_string = avd_str_alloc($2);
5735184Sek110237
5745184Sek110237 /* Find end of list */
5755184Sek110237 for (list = $1; list != NULL;
5765184Sek110237 list = list->list_next)
5775184Sek110237 list_end = list;
5785184Sek110237 list_end->list_next = $$;
5795184Sek110237 $$ = $1;
5805184Sek110237 } |var_string_list FSV_STRING
5815184Sek110237 {
5825184Sek110237 list_t *list = NULL;
5835184Sek110237 list_t *list_end = NULL;
5845184Sek110237
5855184Sek110237 /* Add string */
5865184Sek110237 if (($$ = alloc_list()) == NULL)
5875184Sek110237 YYERROR;
5885184Sek110237
5896212Saw148015 $$->list_string = avd_str_alloc($2);
5905184Sek110237
5915184Sek110237 /* Find end of list */
5925184Sek110237 for (list = $1; list != NULL;
5935184Sek110237 list = list->list_next)
5945184Sek110237 list_end = list;
5955184Sek110237 list_end->list_next = $$;
5965184Sek110237 $$ = $1;
5975184Sek110237
5985184Sek110237 }| var_string_list FSV_VARIABLE
5995184Sek110237 {
6005184Sek110237 list_t *list = NULL;
6015184Sek110237 list_t *list_end = NULL;
6025184Sek110237
6035184Sek110237 /* Add variable */
6045184Sek110237 if (($$ = alloc_list()) == NULL)
6055184Sek110237 YYERROR;
6065184Sek110237
6076212Saw148015 $$->list_string = avd_str_alloc($2);
6085184Sek110237
6095184Sek110237 /* Find end of list */
6105184Sek110237 for (list = $1; list != NULL;
6115184Sek110237 list = list->list_next)
6125184Sek110237 list_end = list;
6135184Sek110237 list_end->list_next = $$;
6145184Sek110237 $$ = $1;
6155184Sek110237 };
6165184Sek110237
6175184Sek110237 whitevar_string: FSK_QUOTE FSV_VARIABLE
6185184Sek110237 {
6195184Sek110237 if (($$ = alloc_list()) == NULL)
6205184Sek110237 YYERROR;
6215184Sek110237
6226212Saw148015 $$->list_string = avd_str_alloc($2);
6235184Sek110237 }
6245184Sek110237 | FSK_QUOTE FSV_WHITESTRING
6255184Sek110237 {
6265184Sek110237 if (($$ = alloc_list()) == NULL)
6275184Sek110237 YYERROR;
6285184Sek110237
6296212Saw148015 $$->list_string = avd_str_alloc($2);
6305184Sek110237 };
6315184Sek110237
6325184Sek110237 whitevar_string_list: whitevar_string FSV_WHITESTRING
6335184Sek110237 {
6345184Sek110237 list_t *list = NULL;
6355184Sek110237 list_t *list_end = NULL;
6365184Sek110237
6375184Sek110237 /* Add string */
6385184Sek110237 if (($$ = alloc_list()) == NULL)
6395184Sek110237 YYERROR;
6405184Sek110237
6416212Saw148015 $$->list_string = avd_str_alloc($2);
6425184Sek110237
6435184Sek110237 /* Find end of list */
6445184Sek110237 for (list = $1; list != NULL;
6455184Sek110237 list = list->list_next)
6465184Sek110237 list_end = list;
6475184Sek110237 list_end->list_next = $$;
6485184Sek110237 $$ = $1;
6495184Sek110237
6505184Sek110237 }| whitevar_string FSV_VARIABLE
6515184Sek110237 {
6525184Sek110237 list_t *list = NULL;
6535184Sek110237 list_t *list_end = NULL;
6545184Sek110237
6555184Sek110237 /* Add variable */
6565184Sek110237 if (($$ = alloc_list()) == NULL)
6575184Sek110237 YYERROR;
6585184Sek110237
6596212Saw148015 $$->list_string = avd_str_alloc($2);
6605184Sek110237
6615184Sek110237 /* Find end of list */
6625184Sek110237 for (list = $1; list != NULL;
6635184Sek110237 list = list->list_next)
6645184Sek110237 list_end = list;
6655184Sek110237 list_end->list_next = $$;
6665184Sek110237 $$ = $1;
6676212Saw148015 }| whitevar_string FSV_RANDVAR randvar_attr_tsp
6686212Saw148015 {
6696212Saw148015 list_t *list = NULL;
6706212Saw148015 list_t *list_end = NULL;
6716212Saw148015
6726212Saw148015 /* Add variable */
6736212Saw148015 if (($$ = alloc_list()) == NULL)
6746212Saw148015 YYERROR;
6756212Saw148015
6766212Saw148015 $$->list_string = avd_str_alloc($2);
6776212Saw148015 $$->list_integer = avd_int_alloc($3);
6786212Saw148015
6796212Saw148015 /* Find end of list */
6806212Saw148015 for (list = $1; list != NULL;
6816212Saw148015 list = list->list_next)
6826212Saw148015 list_end = list;
6836212Saw148015 list_end->list_next = $$;
6846212Saw148015 $$ = $1;
6856212Saw148015 }| whitevar_string_list FSV_WHITESTRING
6865184Sek110237 {
6875184Sek110237 list_t *list = NULL;
6885184Sek110237 list_t *list_end = NULL;
6895184Sek110237
6905184Sek110237 /* Add string */
6915184Sek110237 if (($$ = alloc_list()) == NULL)
6925184Sek110237 YYERROR;
6935184Sek110237
6946212Saw148015 $$->list_string = avd_str_alloc($2);
6955184Sek110237
6965184Sek110237 /* Find end of list */
6975184Sek110237 for (list = $1; list != NULL;
6985184Sek110237 list = list->list_next)
6995184Sek110237 list_end = list;
7005184Sek110237 list_end->list_next = $$;
7015184Sek110237 $$ = $1;
7025184Sek110237
7035184Sek110237 }| whitevar_string_list FSV_VARIABLE
7045184Sek110237 {
7055184Sek110237 list_t *list = NULL;
7065184Sek110237 list_t *list_end = NULL;
7075184Sek110237
7085184Sek110237 /* Add variable */
7095184Sek110237 if (($$ = alloc_list()) == NULL)
7105184Sek110237 YYERROR;
7115184Sek110237
7126212Saw148015 $$->list_string = avd_str_alloc($2);
7136212Saw148015
7146212Saw148015 /* Find end of list */
7156212Saw148015 for (list = $1; list != NULL;
7166212Saw148015 list = list->list_next)
7176212Saw148015 list_end = list;
7186212Saw148015 list_end->list_next = $$;
7196212Saw148015 $$ = $1;
7206212Saw148015 }| whitevar_string_list FSV_RANDVAR randvar_attr_tsp
7216212Saw148015 {
7226212Saw148015 list_t *list = NULL;
7236212Saw148015 list_t *list_end = NULL;
7246212Saw148015
7256212Saw148015 /* Add variable */
7266212Saw148015 if (($$ = alloc_list()) == NULL)
7276212Saw148015 YYERROR;
7286212Saw148015
7296212Saw148015 $$->list_string = avd_str_alloc($2);
7306212Saw148015 $$->list_integer = avd_int_alloc($3);
7315184Sek110237
7325184Sek110237 /* Find end of list */
7335184Sek110237 for (list = $1; list != NULL;
7345184Sek110237 list = list->list_next)
7355184Sek110237 list_end = list;
7365184Sek110237 list_end->list_next = $$;
7375184Sek110237 $$ = $1;
7385184Sek110237 }| whitevar_string_list FSK_QUOTE
7395184Sek110237 {
7405184Sek110237 $$ = $1;
7415184Sek110237 }| whitevar_string FSK_QUOTE
7425184Sek110237 {
7435184Sek110237 $$ = $1;
7445184Sek110237 };
7455184Sek110237
7465184Sek110237 list_command: FSC_LIST
7475184Sek110237 {
7485184Sek110237 if (($$ = alloc_cmd()) == NULL)
7495184Sek110237 YYERROR;
7505184Sek110237 $$->cmd = &parser_list;
7516212Saw148015 }
7526212Saw148015 | list_command FSC_FLOWOP
7536212Saw148015 {
7546212Saw148015 $1->cmd = &parser_flowop_list;
7555184Sek110237 };
7565184Sek110237
7579513SAndrew.W.Wilson@sun.com fscheck_command: FSC_FSCHECK fscheck_attr_op
7589513SAndrew.W.Wilson@sun.com {
7599513SAndrew.W.Wilson@sun.com if (($$ = alloc_cmd()) == NULL)
7609513SAndrew.W.Wilson@sun.com YYERROR;
7619513SAndrew.W.Wilson@sun.com $$->cmd = &parser_fscheck;
7629513SAndrew.W.Wilson@sun.com
7639513SAndrew.W.Wilson@sun.com $$->cmd_attr_list = $2;
7649513SAndrew.W.Wilson@sun.com }
7659513SAndrew.W.Wilson@sun.com | fscheck_command fscheck_attr_op
7669513SAndrew.W.Wilson@sun.com {
7679513SAndrew.W.Wilson@sun.com $1->cmd_attr_list->attr_next = $2;
7689513SAndrew.W.Wilson@sun.com };
7699513SAndrew.W.Wilson@sun.com
7709513SAndrew.W.Wilson@sun.com fsflush_command: FSC_FSFLUSH fscheck_attr_op
7719513SAndrew.W.Wilson@sun.com {
7729513SAndrew.W.Wilson@sun.com if (($$ = alloc_cmd()) == NULL)
7739513SAndrew.W.Wilson@sun.com YYERROR;
7749513SAndrew.W.Wilson@sun.com $$->cmd = &parser_fsflush;
7759513SAndrew.W.Wilson@sun.com
7769513SAndrew.W.Wilson@sun.com $$->cmd_attr_list = $2;
7779513SAndrew.W.Wilson@sun.com };
7789513SAndrew.W.Wilson@sun.com
7795184Sek110237 log_command: FSC_LOG whitevar_string_list
7805184Sek110237 {
7815184Sek110237 if (($$ = alloc_cmd()) == NULL)
7825184Sek110237 YYERROR;
7835184Sek110237 $$->cmd = &parser_log;
7845184Sek110237 $$->cmd_param_list = $2;
7855184Sek110237 };
7865184Sek110237
7875184Sek110237 debug_command: FSC_DEBUG FSV_VAL_INT
7885184Sek110237 {
7895184Sek110237 if (($$ = alloc_cmd()) == NULL)
7905184Sek110237 YYERROR;
7915184Sek110237 $$->cmd = NULL;
7926391Saw148015 filebench_shm->shm_debug_level = $2;
7936391Saw148015 if (filebench_shm->shm_debug_level > 9)
7945184Sek110237 yydebug = 1;
7955184Sek110237 };
7965184Sek110237
797*9801SAndrew.W.Wilson@sun.com set_command:
798*9801SAndrew.W.Wilson@sun.com set_integer_command
799*9801SAndrew.W.Wilson@sun.com | set_other_command;
800*9801SAndrew.W.Wilson@sun.com
801*9801SAndrew.W.Wilson@sun.com set_integer_command: FSC_SET FSV_VARIABLE FSK_ASSIGN FSV_VAL_INT
802*9801SAndrew.W.Wilson@sun.com {
803*9801SAndrew.W.Wilson@sun.com if (($$ = alloc_cmd()) == NULL)
804*9801SAndrew.W.Wilson@sun.com YYERROR;
805*9801SAndrew.W.Wilson@sun.com $$->cmd_tgt1 = $2;
806*9801SAndrew.W.Wilson@sun.com $$->cmd_qty = $4;
807*9801SAndrew.W.Wilson@sun.com if (parentscript) {
808*9801SAndrew.W.Wilson@sun.com parser_vars($$);
809*9801SAndrew.W.Wilson@sun.com }
810*9801SAndrew.W.Wilson@sun.com $$->cmd = parser_set_integer;
811*9801SAndrew.W.Wilson@sun.com }| FSC_SET FSV_VARIABLE FSK_ASSIGN FSV_VARIABLE
8125184Sek110237 {
8135184Sek110237 if (($$ = alloc_cmd()) == NULL)
8145184Sek110237 YYERROR;
815*9801SAndrew.W.Wilson@sun.com var_assign_var($2, $4);
816*9801SAndrew.W.Wilson@sun.com $$->cmd_tgt1 = $2;
817*9801SAndrew.W.Wilson@sun.com $$->cmd_tgt2 = $4;
8185184Sek110237 if (parentscript) {
8195184Sek110237 parser_vars($$);
8205184Sek110237 }
821*9801SAndrew.W.Wilson@sun.com $$->cmd = parser_set_var;
8225184Sek110237 }
823*9801SAndrew.W.Wilson@sun.com | set_integer_command binary_op FSV_VAL_INT
824*9801SAndrew.W.Wilson@sun.com {
825*9801SAndrew.W.Wilson@sun.com if ($1->cmd == parser_set_integer) {
826*9801SAndrew.W.Wilson@sun.com switch ($2) {
827*9801SAndrew.W.Wilson@sun.com case FSK_PLUS:
828*9801SAndrew.W.Wilson@sun.com var_assign_integer($1->cmd_tgt1, $1->cmd_qty + $3);
829*9801SAndrew.W.Wilson@sun.com break;
830*9801SAndrew.W.Wilson@sun.com case FSK_MINUS:
831*9801SAndrew.W.Wilson@sun.com var_assign_integer($1->cmd_tgt1, $1->cmd_qty - $3);
832*9801SAndrew.W.Wilson@sun.com break;
833*9801SAndrew.W.Wilson@sun.com case FSK_MULTIPLY:
834*9801SAndrew.W.Wilson@sun.com var_assign_integer($1->cmd_tgt1, $1->cmd_qty * $3);
835*9801SAndrew.W.Wilson@sun.com break;
836*9801SAndrew.W.Wilson@sun.com case FSK_DIVIDE:
837*9801SAndrew.W.Wilson@sun.com var_assign_integer($1->cmd_tgt1, $1->cmd_qty / $3);
838*9801SAndrew.W.Wilson@sun.com break;
839*9801SAndrew.W.Wilson@sun.com }
840*9801SAndrew.W.Wilson@sun.com $$->cmd = NULL;
841*9801SAndrew.W.Wilson@sun.com } else {
842*9801SAndrew.W.Wilson@sun.com $1->cmd_qty = $3;
843*9801SAndrew.W.Wilson@sun.com $1->cmd_subtype = $2;
844*9801SAndrew.W.Wilson@sun.com $1->cmd = parser_set_var_op_int;
845*9801SAndrew.W.Wilson@sun.com }
846*9801SAndrew.W.Wilson@sun.com }
847*9801SAndrew.W.Wilson@sun.com | set_integer_command binary_op FSV_VARIABLE
848*9801SAndrew.W.Wilson@sun.com {
849*9801SAndrew.W.Wilson@sun.com $1->cmd_tgt3 = $3;
850*9801SAndrew.W.Wilson@sun.com $1->cmd_subtype = $2;
851*9801SAndrew.W.Wilson@sun.com if ($1->cmd == parser_set_integer) {
852*9801SAndrew.W.Wilson@sun.com $$->cmd = parser_set_int_op_var;
853*9801SAndrew.W.Wilson@sun.com } else {
854*9801SAndrew.W.Wilson@sun.com $1->cmd = parser_set_var_op_var;
855*9801SAndrew.W.Wilson@sun.com }
856*9801SAndrew.W.Wilson@sun.com };
857*9801SAndrew.W.Wilson@sun.com
858*9801SAndrew.W.Wilson@sun.com set_other_command: FSC_SET FSV_VARIABLE FSK_ASSIGN FSV_VAL_BOOLEAN
8596212Saw148015 {
8606212Saw148015 if (($$ = alloc_cmd()) == NULL)
8616212Saw148015 YYERROR;
8626212Saw148015 var_assign_boolean($2, $4);
8636212Saw148015 if (parentscript) {
8646212Saw148015 $$->cmd_tgt1 = $2;
8656212Saw148015 parser_vars($$);
8666212Saw148015 }
8676212Saw148015 $$->cmd = NULL;
8686212Saw148015 }
8695184Sek110237 | FSC_SET FSV_VARIABLE FSK_ASSIGN FSK_QUOTE FSV_WHITESTRING FSK_QUOTE
8705184Sek110237 {
8715184Sek110237 if (($$ = alloc_cmd()) == NULL)
8725184Sek110237 YYERROR;
8735184Sek110237 var_assign_string($2, $5);
8745184Sek110237 if (parentscript) {
8755184Sek110237 $$->cmd_tgt1 = $2;
8765184Sek110237 parser_vars($$);
8775184Sek110237 }
8785184Sek110237 $$->cmd = NULL;
8795184Sek110237 }| FSC_SET FSV_VARIABLE FSK_ASSIGN FSV_STRING
8805184Sek110237 {
8815184Sek110237 if (($$ = alloc_cmd()) == NULL)
8825184Sek110237 YYERROR;
8835184Sek110237 var_assign_string($2, $4);
8845184Sek110237 if (parentscript) {
8855184Sek110237 $$->cmd_tgt1 = $2;
8865184Sek110237 parser_vars($$);
8875184Sek110237 }
8885184Sek110237 $$->cmd = NULL;
8896084Saw148015 } | FSC_SET FSE_MODE FSC_QUIT FSA_TIMEOUT
8906084Saw148015 {
8916084Saw148015 filebench_shm->shm_rmode = FILEBENCH_MODE_TIMEOUT;
8926084Saw148015 if (($$ = alloc_cmd()) == NULL)
8936084Saw148015 YYERROR;
8946084Saw148015 $$->cmd = NULL;
8956084Saw148015 } | FSC_SET FSE_MODE FSC_QUIT FSA_ALLDONE
8966084Saw148015 {
8976084Saw148015 filebench_shm->shm_rmode = FILEBENCH_MODE_QALLDONE;
8986084Saw148015 if (($$ = alloc_cmd()) == NULL)
8996084Saw148015 YYERROR;
9006084Saw148015 $$->cmd = NULL;
9016084Saw148015 } | FSC_SET FSE_MODE FSC_QUIT FSA_FIRSTDONE
9026084Saw148015 {
9036084Saw148015 filebench_shm->shm_rmode = FILEBENCH_MODE_Q1STDONE;
9046084Saw148015 if (($$ = alloc_cmd()) == NULL)
9056084Saw148015 YYERROR;
9066084Saw148015 $$->cmd = NULL;
9079356SAndrew.W.Wilson@sun.com } | FSC_SET FSE_MODE FSC_NOUSESTATS
9089356SAndrew.W.Wilson@sun.com {
9099356SAndrew.W.Wilson@sun.com filebench_shm->shm_mmode |= FILEBENCH_MODE_NOUSAGE;
9109356SAndrew.W.Wilson@sun.com filebench_log(LOG_INFO, "disabling CPU usage statistics");
9119356SAndrew.W.Wilson@sun.com if (($$ = alloc_cmd()) == NULL)
9129356SAndrew.W.Wilson@sun.com YYERROR;
9139356SAndrew.W.Wilson@sun.com $$->cmd = NULL;
9149513SAndrew.W.Wilson@sun.com } | FSC_SET FSV_RANDVAR FSS_TYPE FSK_ASSIGN randvar_attr_typop
9156212Saw148015 {
9166212Saw148015 if (($$ = alloc_cmd()) == NULL)
9176212Saw148015 YYERROR;
9186212Saw148015 $$->cmd = &parser_randvar_set;
9196212Saw148015 $$->cmd_tgt1 = $2;
9206212Saw148015 $$->cmd_qty = FSS_TYPE;
9216212Saw148015 $$->cmd_attr_list = $5;
9226212Saw148015
9239513SAndrew.W.Wilson@sun.com } | FSC_SET FSV_RANDVAR FSS_SRC FSK_ASSIGN randvar_attr_srcop
9246212Saw148015 {
9256212Saw148015 if (($$ = alloc_cmd()) == NULL)
9266212Saw148015 YYERROR;
9276212Saw148015 $$->cmd = &parser_randvar_set;
9286212Saw148015 $$->cmd_tgt1 = $2;
9296212Saw148015 $$->cmd_qty = FSS_SRC;
9306212Saw148015 $$->cmd_attr_list = $5;
9316212Saw148015
9329513SAndrew.W.Wilson@sun.com } | FSC_SET FSV_RANDVAR randvar_attr_param FSK_ASSIGN attr_value
9336212Saw148015 {
9346212Saw148015 if (($$ = alloc_cmd()) == NULL)
9356212Saw148015 YYERROR;
9366212Saw148015 $$->cmd = &parser_randvar_set;
9376212Saw148015 $$->cmd_tgt1 = $2;
9386212Saw148015 $$->cmd_qty = $3;
9396212Saw148015 $$->cmd_attr_list = $5;
9406212Saw148015
9415184Sek110237 };
9425184Sek110237
9435184Sek110237 stats_command: FSC_STATS FSE_SNAP
9445184Sek110237 {
9455184Sek110237 if (($$ = alloc_cmd()) == NULL)
9465184Sek110237 YYERROR;
9475184Sek110237 $$->cmd = (void (*)(struct cmd *))&parser_statssnap;
9485184Sek110237 break;
9495184Sek110237
9505184Sek110237 }
9515184Sek110237 | FSC_STATS FSE_CLEAR
9525184Sek110237 {
9535184Sek110237 if (($$ = alloc_cmd()) == NULL)
9545184Sek110237 YYERROR;
9555184Sek110237 $$->cmd = (void (*)(struct cmd *))&stats_clear;
9565184Sek110237
9575184Sek110237 }
9585184Sek110237 | FSC_STATS FSE_DIRECTORY var_string_list
9595184Sek110237 {
9605184Sek110237 if (($$ = alloc_cmd()) == NULL)
9615184Sek110237 YYERROR;
9625184Sek110237 $$->cmd_param_list = $3;
9635184Sek110237 $$->cmd = (void (*)(struct cmd *))&parser_directory;
9645184Sek110237
9655184Sek110237 }
9665184Sek110237 | FSC_STATS FSE_COMMAND whitevar_string_list
9675184Sek110237 {
9685184Sek110237 if (($$ = alloc_cmd()) == NULL)
9695184Sek110237 YYERROR;
9705184Sek110237
9715184Sek110237 $$->cmd_param_list = $3;
9725184Sek110237 $$->cmd = parser_statscmd;
9735184Sek110237
9745184Sek110237 }| FSC_STATS FSE_DUMP whitevar_string_list
9755184Sek110237 {
9765184Sek110237 if (($$ = alloc_cmd()) == NULL)
9775184Sek110237 YYERROR;
9785184Sek110237
9795184Sek110237 $$->cmd_param_list = $3;
9805184Sek110237 $$->cmd = parser_statsdump;
9815184Sek110237 }| FSC_STATS FSE_XMLDUMP whitevar_string_list
9825184Sek110237 {
9835184Sek110237 if (($$ = alloc_cmd()) == NULL)
9845184Sek110237 YYERROR;
9855184Sek110237
9865184Sek110237 $$->cmd_param_list = $3;
9875184Sek110237 $$->cmd = parser_statsxmldump;
9887736SAndrew.W.Wilson@sun.com }| FSC_STATS FSE_MULTIDUMP whitevar_string_list
9897736SAndrew.W.Wilson@sun.com {
9907736SAndrew.W.Wilson@sun.com if (($$ = alloc_cmd()) == NULL)
9917736SAndrew.W.Wilson@sun.com YYERROR;
9927736SAndrew.W.Wilson@sun.com
9937736SAndrew.W.Wilson@sun.com $$->cmd_param_list = $3;
9947736SAndrew.W.Wilson@sun.com $$->cmd = parser_statsmultidump;
9955184Sek110237 };
9965184Sek110237
9975184Sek110237 quit_command: FSC_QUIT
9985184Sek110237 {
9995184Sek110237 if (($$ = alloc_cmd()) == NULL)
10005184Sek110237 YYERROR;
10015184Sek110237 $$->cmd = parser_filebench_shutdown;
10025184Sek110237 };
10035184Sek110237
10045184Sek110237 flowop_list: flowop_command
10055184Sek110237 {
10065184Sek110237 $$ = $1;
10075184Sek110237 }| flowop_list flowop_command
10085184Sek110237 {
10095184Sek110237 cmd_t *list = NULL;
10105184Sek110237 cmd_t *list_end = NULL;
10115184Sek110237
10125184Sek110237 /* Find end of list */
10135184Sek110237 for (list = $1; list != NULL;
10145184Sek110237 list = list->cmd_next)
10155184Sek110237 list_end = list;
10165184Sek110237
10175184Sek110237 list_end->cmd_next = $2;
10185184Sek110237
10195184Sek110237 filebench_log(LOG_DEBUG_IMPL,
10205184Sek110237 "flowop_list adding cmd %zx to list %zx", $2, $1);
10215184Sek110237
10225184Sek110237 $$ = $1;
10235184Sek110237 };
10245184Sek110237
10256212Saw148015 thread: FSE_THREAD pt_attr_ops FSK_OPENLST flowop_list FSK_CLOSELST
10265184Sek110237 {
10275184Sek110237 /*
10285184Sek110237 * Allocate a cmd node per thread, with a
10295184Sek110237 * list of flowops attached to the cmd_list
10305184Sek110237 */
10315184Sek110237 if (($$ = alloc_cmd()) == NULL)
10325184Sek110237 YYERROR;
10335184Sek110237 $$->cmd_list = $4;
10345184Sek110237 $$->cmd_attr_list = $2;
10355184Sek110237 };
10365184Sek110237
10375184Sek110237 thread_list: thread
10385184Sek110237 {
10395184Sek110237 $$ = $1;
10405184Sek110237 }| thread_list thread
10415184Sek110237 {
10425184Sek110237 cmd_t *list = NULL;
10435184Sek110237 cmd_t *list_end = NULL;
10445184Sek110237
10455184Sek110237 /* Find end of list */
10465184Sek110237 for (list = $1; list != NULL;
10475184Sek110237 list = list->cmd_next)
10485184Sek110237 list_end = list;
10495184Sek110237
10505184Sek110237 list_end->cmd_next = $2;
10515184Sek110237
10525184Sek110237 filebench_log(LOG_DEBUG_IMPL,
10535184Sek110237 "thread_list adding cmd %zx to list %zx", $2, $1);
10545184Sek110237
10555184Sek110237 $$ = $1;
10565184Sek110237 };
10575184Sek110237
10586212Saw148015 proc_define_command: FSC_DEFINE FSE_PROC pt_attr_ops FSK_OPENLST thread_list FSK_CLOSELST
10595184Sek110237 {
10605184Sek110237 if (($$ = alloc_cmd()) == NULL)
10615184Sek110237 YYERROR;
10625184Sek110237 $$->cmd = &parser_proc_define;
10635184Sek110237 $$->cmd_list = $5;
10645184Sek110237 $$->cmd_attr_list = $3;
10655184Sek110237
10666212Saw148015 }
10676212Saw148015 | proc_define_command pt_attr_ops
10686212Saw148015 {
10696212Saw148015 $1->cmd_attr_list = $2;
10706212Saw148015 };
10716212Saw148015
10726212Saw148015 files_define_command: FSC_DEFINE FSE_FILE
10735184Sek110237 {
10745184Sek110237 if (($$ = alloc_cmd()) == NULL)
10755184Sek110237 YYERROR;
10765184Sek110237 $$->cmd = &parser_file_define;
10775184Sek110237 }| FSC_DEFINE FSE_FILESET
10785184Sek110237 {
10795184Sek110237 if (($$ = alloc_cmd()) == NULL)
10805184Sek110237 YYERROR;
10815184Sek110237 $$->cmd = &parser_fileset_define;
10825184Sek110237 }
10836212Saw148015 | files_define_command files_attr_ops
10845184Sek110237 {
10855184Sek110237 $1->cmd_attr_list = $2;
10865184Sek110237 };
10875184Sek110237
10886212Saw148015 randvar_define_command: FSC_DEFINE FSE_RAND randvar_attr_ops
10896212Saw148015 {
10906212Saw148015 if (($$ = alloc_cmd()) == NULL)
10916212Saw148015 YYERROR;
10926212Saw148015 $$->cmd = &parser_randvar_define;
10936212Saw148015 $$->cmd_attr_list = $3;
10946212Saw148015 };
10956212Saw148015
10966550Saw148015 fo_define_command: FSC_DEFINE FSC_FLOWOP comp_attr_ops FSK_OPENLST flowop_list FSK_CLOSELST
10976550Saw148015 {
10986550Saw148015 if (($$ = alloc_cmd()) == NULL)
10996550Saw148015 YYERROR;
11006550Saw148015 $$->cmd = &parser_composite_flowop_define;
11016550Saw148015 $$->cmd_list = $5;
11026550Saw148015 $$->cmd_attr_list = $3;
11036550Saw148015 }
11046550Saw148015 | fo_define_command comp_attr_ops
11056550Saw148015 {
11066550Saw148015 $1->cmd_attr_list = $2;
11076550Saw148015 };
11086550Saw148015
11095184Sek110237 create_command: FSC_CREATE entity
11105184Sek110237 {
11115184Sek110237 if (($$ = alloc_cmd()) == NULL)
11125184Sek110237 YYERROR;
11135184Sek110237 switch ($2) {
11145184Sek110237 case FSE_PROC:
11155184Sek110237 $$->cmd = &parser_proc_create;
11165184Sek110237 break;
11175673Saw148015 case FSE_FILESET:
11185184Sek110237 case FSE_FILE:
11195184Sek110237 $$->cmd = &parser_fileset_create;
11205184Sek110237 break;
11215184Sek110237 default:
11225184Sek110237 filebench_log(LOG_ERROR, "unknown entity", $2);
11235184Sek110237 YYERROR;
11245184Sek110237 }
11255184Sek110237
11265184Sek110237 };
11275184Sek110237
11285184Sek110237 shutdown_command: FSC_SHUTDOWN entity
11295184Sek110237 {
11305184Sek110237 if (($$ = alloc_cmd()) == NULL)
11315184Sek110237 YYERROR;
11325184Sek110237 switch ($2) {
11335184Sek110237 case FSE_PROC:
11345184Sek110237 $$->cmd = &parser_proc_shutdown;
11355184Sek110237 break;
11369356SAndrew.W.Wilson@sun.com case FSE_FILE:
11379356SAndrew.W.Wilson@sun.com case FSE_FILESET:
11389356SAndrew.W.Wilson@sun.com $$->cmd = &parser_fileset_shutdown;
11399356SAndrew.W.Wilson@sun.com break;
11405184Sek110237 default:
11415184Sek110237 filebench_log(LOG_ERROR, "unknown entity", $2);
11425184Sek110237 YYERROR;
11435184Sek110237 }
11445184Sek110237
11455184Sek110237 };
11465184Sek110237
11479326SAndrew.W.Wilson@sun.com warmup_command: FSC_WARMUP FSV_VAL_INT
11489326SAndrew.W.Wilson@sun.com {
11499326SAndrew.W.Wilson@sun.com if (($$ = alloc_cmd()) == NULL)
11509326SAndrew.W.Wilson@sun.com YYERROR;
11519326SAndrew.W.Wilson@sun.com $$->cmd = parser_warmup;
11529326SAndrew.W.Wilson@sun.com $$->cmd_qty = $2;
11539326SAndrew.W.Wilson@sun.com }
11549326SAndrew.W.Wilson@sun.com | FSC_WARMUP FSV_VARIABLE
11559326SAndrew.W.Wilson@sun.com {
11569326SAndrew.W.Wilson@sun.com fbint_t *integer;
11579326SAndrew.W.Wilson@sun.com
11589326SAndrew.W.Wilson@sun.com if (($$ = alloc_cmd()) == NULL)
11599326SAndrew.W.Wilson@sun.com YYERROR;
11609326SAndrew.W.Wilson@sun.com $$->cmd = parser_warmup_variable;
11619326SAndrew.W.Wilson@sun.com $$->cmd_tgt1 = fb_stralloc($2);
11629326SAndrew.W.Wilson@sun.com };
11639326SAndrew.W.Wilson@sun.com
11645184Sek110237 sleep_command: FSC_SLEEP FSV_VAL_INT
11655184Sek110237 {
11665184Sek110237 if (($$ = alloc_cmd()) == NULL)
11675184Sek110237 YYERROR;
11685184Sek110237 $$->cmd = parser_sleep;
11695184Sek110237 $$->cmd_qty = $2;
11705184Sek110237 }
11715184Sek110237 | FSC_SLEEP FSV_VARIABLE
11725184Sek110237 {
11736212Saw148015 fbint_t *integer;
11745184Sek110237
11755184Sek110237 if (($$ = alloc_cmd()) == NULL)
11765184Sek110237 YYERROR;
11775184Sek110237 $$->cmd = parser_sleep_variable;
11785184Sek110237 $$->cmd_tgt1 = fb_stralloc($2);
11795184Sek110237 };
11805184Sek110237
11815184Sek110237 run_command: FSC_RUN FSV_VAL_INT
11825184Sek110237 {
11835184Sek110237 if (($$ = alloc_cmd()) == NULL)
11845184Sek110237 YYERROR;
11855184Sek110237 $$->cmd = parser_run;
11865184Sek110237 $$->cmd_qty = $2;
11875184Sek110237 }
11885184Sek110237 | FSC_RUN FSV_VARIABLE
11895184Sek110237 {
11906212Saw148015 fbint_t *integer;
11915184Sek110237
11925184Sek110237 if (($$ = alloc_cmd()) == NULL)
11935184Sek110237 YYERROR;
11945184Sek110237 $$->cmd = parser_run_variable;
11955184Sek110237 $$->cmd_tgt1 = fb_stralloc($2);
11965184Sek110237 }
11975184Sek110237 | FSC_RUN
11985184Sek110237 {
11996212Saw148015 fbint_t *integer;
12005184Sek110237
12015184Sek110237 if (($$ = alloc_cmd()) == NULL)
12025184Sek110237 YYERROR;
12035184Sek110237 $$->cmd = parser_run;
12045184Sek110237 $$->cmd_qty = 60UL;
12055184Sek110237 };
12065184Sek110237
12075184Sek110237 help_command: FSC_HELP
12085184Sek110237 {
12095184Sek110237 if (($$ = alloc_cmd()) == NULL)
12105184Sek110237 YYERROR;
12115184Sek110237 $$->cmd = parser_help;
12125184Sek110237 };
12135184Sek110237
12145184Sek110237 flowop_command: FSC_FLOWOP name
12155184Sek110237 {
12165184Sek110237 if (($$ = alloc_cmd()) == NULL)
12175184Sek110237 YYERROR;
12185184Sek110237 $$->cmd_name = fb_stralloc($2);
12195184Sek110237 }
12206212Saw148015 | flowop_command fo_attr_ops
12215184Sek110237 {
12225184Sek110237 $1->cmd_attr_list = $2;
12235184Sek110237 };
12245184Sek110237
12255184Sek110237 load_command: FSC_LOAD FSV_STRING
12265184Sek110237 {
12275184Sek110237 FILE *newfile;
12285184Sek110237 char loadfile[128];
12295184Sek110237
12305184Sek110237 if (($$ = alloc_cmd()) == NULL)
12315184Sek110237 YYERROR;
12325184Sek110237
12335184Sek110237 (void) strcpy(loadfile, $2);
12345184Sek110237 (void) strcat(loadfile, ".f");
12355184Sek110237
12365184Sek110237 if ((newfile = fopen(loadfile, "r")) == NULL) {
12379513SAndrew.W.Wilson@sun.com (void) strcpy(loadfile, fbbasepath);
12385184Sek110237 (void) strcat(loadfile, "/workloads/");
12395184Sek110237 (void) strcat(loadfile, $2);
12405184Sek110237 (void) strcat(loadfile, ".f");
12415184Sek110237 if ((newfile = fopen(loadfile, "r")) == NULL) {
12425184Sek110237 filebench_log(LOG_ERROR, "Cannot open %s", loadfile);
12435184Sek110237 YYERROR;
12445184Sek110237 }
12455184Sek110237 }
12465184Sek110237
12475184Sek110237 parentscript = yyin;
12485184Sek110237 yyin = newfile;
12495184Sek110237 yy_switchfileparent(yyin);
12505184Sek110237 };
12515184Sek110237
12526212Saw148015
12535184Sek110237 entity: FSE_PROC {$$ = FSE_PROC;}
12545184Sek110237 | FSE_THREAD {$$ = FSE_THREAD;}
12555184Sek110237 | FSE_FILESET {$$ = FSE_FILESET;}
12565184Sek110237 | FSE_FILE {$$ = FSE_FILE;};
12575184Sek110237
12585184Sek110237 value: FSV_VAL_INT { $$.i = $1;}
12595184Sek110237 | FSV_STRING { $$.s = $1;}
12605184Sek110237 | FSV_VAL_BOOLEAN { $$.b = $1;};
12615184Sek110237
12625184Sek110237 name: FSV_STRING;
12635184Sek110237
12646212Saw148015 /* attribute parsing for define file and define fileset */
12656212Saw148015 files_attr_ops: files_attr_op
12666212Saw148015 {
12676212Saw148015 $$ = $1;
12686212Saw148015 }
12696212Saw148015 | files_attr_ops FSK_SEPLST files_attr_op
12706212Saw148015 {
12716212Saw148015 attr_t *attr = NULL;
12726212Saw148015 attr_t *list_end = NULL;
12736212Saw148015
12746212Saw148015 for (attr = $1; attr != NULL;
12756212Saw148015 attr = attr->attr_next)
12766212Saw148015 list_end = attr; /* Find end of list */
12776212Saw148015
12786212Saw148015 list_end->attr_next = $3;
12796212Saw148015
12806212Saw148015 $$ = $1;
12816212Saw148015 };
12826212Saw148015
12836212Saw148015 files_attr_op: files_attr_name FSK_ASSIGN attr_list_value
12846212Saw148015 {
12856212Saw148015 $$ = $3;
12866212Saw148015 $$->attr_name = $1;
12876212Saw148015 }
12886212Saw148015 | files_attr_name
12896212Saw148015 {
12906212Saw148015 if (($$ = alloc_attr()) == NULL)
12916212Saw148015 YYERROR;
12926212Saw148015 $$->attr_name = $1;
12936212Saw148015 };
12946212Saw148015
12956212Saw148015 /* attribute parsing for random variables */
12966212Saw148015 randvar_attr_ops: randvar_attr_op
12975184Sek110237 {
12985184Sek110237 $$ = $1;
12995184Sek110237 }
13006212Saw148015 | randvar_attr_ops FSK_SEPLST randvar_attr_op
13016212Saw148015 {
13026212Saw148015 attr_t *attr = NULL;
13036212Saw148015 attr_t *list_end = NULL;
13046212Saw148015
13056212Saw148015 for (attr = $1; attr != NULL;
13066212Saw148015 attr = attr->attr_next)
13076212Saw148015 list_end = attr; /* Find end of list */
13086212Saw148015
13096212Saw148015 list_end->attr_next = $3;
13106212Saw148015
13116212Saw148015 $$ = $1;
13126212Saw148015 }
13136212Saw148015 | randvar_attr_ops FSK_SEPLST FSA_RANDTABLE FSK_ASSIGN FSK_OPENLST probtabentry_list FSK_CLOSELST
13146212Saw148015 {
13156212Saw148015 attr_t *attr = NULL;
13166212Saw148015 attr_t *list_end = NULL;
13176212Saw148015
13186212Saw148015 for (attr = $1; attr != NULL;
13196212Saw148015 attr = attr->attr_next)
13206212Saw148015 list_end = attr; /* Find end of list */
13216212Saw148015
13226212Saw148015
13236212Saw148015 if ((attr = alloc_attr()) == NULL)
13246212Saw148015 YYERROR;
13256212Saw148015
13266212Saw148015 attr->attr_name = FSA_RANDTABLE;
13276212Saw148015 attr->attr_obj = (void *)$6;
13286212Saw148015 list_end->attr_next = attr;
13296212Saw148015 $$ = $1;
13306212Saw148015 };
13316212Saw148015
13326212Saw148015 randvar_attr_op: randvar_attr_name FSK_ASSIGN attr_list_value
13336212Saw148015 {
13346212Saw148015 $$ = $3;
13356212Saw148015 $$->attr_name = $1;
13366212Saw148015 }
13376212Saw148015 | randvar_attr_name
13386212Saw148015 {
13396212Saw148015 if (($$ = alloc_attr()) == NULL)
13406212Saw148015 YYERROR;
13416212Saw148015 $$->attr_name = $1;
13426212Saw148015 }
13436212Saw148015 | FSA_TYPE FSK_ASSIGN randvar_attr_typop
13446212Saw148015 {
13456212Saw148015 $$ = $3;
13466212Saw148015 $$->attr_name = FSA_TYPE;
13476212Saw148015 }
13486212Saw148015 | FSA_RANDSRC FSK_ASSIGN randvar_attr_srcop
13496212Saw148015 {
13506212Saw148015 $$ = $3;
13516212Saw148015 $$->attr_name = FSA_RANDSRC;
13526212Saw148015 };
13536212Saw148015
13546212Saw148015 probtabentry: FSK_OPENLST var_int_val FSK_SEPLST var_int_val FSK_SEPLST var_int_val FSK_CLOSELST
13556212Saw148015 {
13566212Saw148015 if (($$ = alloc_probtabent()) == NULL)
13576212Saw148015 YYERROR;
13586212Saw148015 $$->pte_percent = $2;
13596212Saw148015 $$->pte_segmin = $4;
13606212Saw148015 $$->pte_segmax = $6;
13616212Saw148015 };
13626212Saw148015
13636212Saw148015 /* attribute parsing for prob density function table */
13646212Saw148015 probtabentry_list: probtabentry
13656212Saw148015 {
13666212Saw148015 $$ = $1;
13676212Saw148015 }
13686212Saw148015 | probtabentry_list FSK_SEPLST probtabentry
13696212Saw148015 {
13706212Saw148015 probtabent_t *pte = NULL;
13716212Saw148015 probtabent_t *ptelist_end = NULL;
13726212Saw148015
13736212Saw148015 for (pte = $1; pte != NULL;
13746212Saw148015 pte = pte->pte_next)
13756212Saw148015 ptelist_end = pte; /* Find end of prob table entry list */
13766212Saw148015
13776212Saw148015 ptelist_end->pte_next = $3;
13786212Saw148015
13796212Saw148015 $$ = $1;
13806212Saw148015 };
13816212Saw148015
13826212Saw148015 /* attribute parsing for define thread and process */
13836212Saw148015 pt_attr_ops: pt_attr_op
13846212Saw148015 {
13856212Saw148015 $$ = $1;
13866212Saw148015 }
13876212Saw148015 | pt_attr_ops FSK_SEPLST pt_attr_op
13886212Saw148015 {
13896212Saw148015 attr_t *attr = NULL;
13906212Saw148015 attr_t *list_end = NULL;
13916212Saw148015
13926212Saw148015 for (attr = $1; attr != NULL;
13936212Saw148015 attr = attr->attr_next)
13946212Saw148015 list_end = attr; /* Find end of list */
13956212Saw148015
13966212Saw148015 list_end->attr_next = $3;
13976212Saw148015
13986212Saw148015 $$ = $1;
13996212Saw148015 };
14006212Saw148015
14016212Saw148015 pt_attr_op: pt_attr_name FSK_ASSIGN attr_value
14026212Saw148015 {
14036212Saw148015 $$ = $3;
14046212Saw148015 $$->attr_name = $1;
14056212Saw148015 }
14066212Saw148015 | pt_attr_name
14076212Saw148015 {
14086212Saw148015 if (($$ = alloc_attr()) == NULL)
14096212Saw148015 YYERROR;
14106212Saw148015 $$->attr_name = $1;
14116212Saw148015 };
14126212Saw148015
14136212Saw148015 /* attribute parsing for flowops */
14146212Saw148015 fo_attr_ops: fo_attr_op
14156212Saw148015 {
14166212Saw148015 $$ = $1;
14176212Saw148015 }
14186212Saw148015 | fo_attr_ops FSK_SEPLST fo_attr_op
14195184Sek110237 {
14205184Sek110237 attr_t *attr = NULL;
14215184Sek110237 attr_t *list_end = NULL;
14225184Sek110237
14235184Sek110237 for (attr = $1; attr != NULL;
14245184Sek110237 attr = attr->attr_next)
14255184Sek110237 list_end = attr; /* Find end of list */
14265184Sek110237
14275184Sek110237 list_end->attr_next = $3;
14285184Sek110237
14295184Sek110237 $$ = $1;
14306550Saw148015 }
14316550Saw148015 | fo_attr_ops FSK_SEPLST comp_lvar_def
14326550Saw148015 {
14336550Saw148015 attr_t *attr = NULL;
14346550Saw148015 attr_t *list_end = NULL;
14356550Saw148015
14366550Saw148015 for (attr = $1; attr != NULL;
14376550Saw148015 attr = attr->attr_next)
14386550Saw148015 list_end = attr; /* Find end of list */
14396550Saw148015
14406550Saw148015 list_end->attr_next = $3;
14416550Saw148015
14426550Saw148015 $$ = $1;
14435184Sek110237 };
14445184Sek110237
14456212Saw148015 fo_attr_op: fo_attr_name FSK_ASSIGN attr_value
14465184Sek110237 {
14475184Sek110237 $$ = $3;
14485184Sek110237 $$->attr_name = $1;
14495184Sek110237 }
14506212Saw148015 | fo_attr_name
14515184Sek110237 {
14525184Sek110237 if (($$ = alloc_attr()) == NULL)
14535184Sek110237 YYERROR;
14545184Sek110237 $$->attr_name = $1;
14556212Saw148015 };
14566212Saw148015
14576212Saw148015 /* attribute parsing for Event Generator */
14586212Saw148015 ev_attr_ops: ev_attr_op
14596212Saw148015 {
14606212Saw148015 $$ = $1;
14615184Sek110237 }
14626212Saw148015 | ev_attr_ops FSK_SEPLST ev_attr_op
14636212Saw148015 {
14646212Saw148015 attr_t *attr = NULL;
14656212Saw148015 attr_t *list_end = NULL;
14666212Saw148015
14676212Saw148015 for (attr = $1; attr != NULL;
14686212Saw148015 attr = attr->attr_next)
14696212Saw148015 list_end = attr; /* Find end of list */
14706212Saw148015
14716212Saw148015 list_end->attr_next = $3;
14726212Saw148015
14736212Saw148015 $$ = $1;
14746212Saw148015 };
14756212Saw148015
14766212Saw148015 ev_attr_op: ev_attr_name FSK_ASSIGN attr_value
14776212Saw148015 {
14786212Saw148015 $$ = $3;
14796212Saw148015 $$->attr_name = $1;
14806212Saw148015 }
14816212Saw148015 | ev_attr_name
14826212Saw148015 {
14836212Saw148015 if (($$ = alloc_attr()) == NULL)
14846212Saw148015 YYERROR;
14856212Saw148015 $$->attr_name = $1;
14866212Saw148015 };
14876212Saw148015
14887736SAndrew.W.Wilson@sun.com /* attribute parsing for enable multiple client command */
14897736SAndrew.W.Wilson@sun.com enable_multi_ops: enable_multi_op
14907736SAndrew.W.Wilson@sun.com {
14917736SAndrew.W.Wilson@sun.com $$ = $1;
14927736SAndrew.W.Wilson@sun.com }
14937736SAndrew.W.Wilson@sun.com | enable_multi_ops FSK_SEPLST enable_multi_op
14947736SAndrew.W.Wilson@sun.com {
14957736SAndrew.W.Wilson@sun.com attr_t *attr = NULL;
14967736SAndrew.W.Wilson@sun.com attr_t *list_end = NULL;
14977736SAndrew.W.Wilson@sun.com
14987736SAndrew.W.Wilson@sun.com for (attr = $1; attr != NULL;
14997736SAndrew.W.Wilson@sun.com attr = attr->attr_next)
15007736SAndrew.W.Wilson@sun.com list_end = attr; /* Find end of list */
15017736SAndrew.W.Wilson@sun.com
15027736SAndrew.W.Wilson@sun.com list_end->attr_next = $3;
15037736SAndrew.W.Wilson@sun.com
15047736SAndrew.W.Wilson@sun.com $$ = $1;
15057736SAndrew.W.Wilson@sun.com };
15067736SAndrew.W.Wilson@sun.com
15077736SAndrew.W.Wilson@sun.com enable_multi_op: em_attr_name FSK_ASSIGN attr_value
15087736SAndrew.W.Wilson@sun.com {
15097736SAndrew.W.Wilson@sun.com $$ = $3;
15107736SAndrew.W.Wilson@sun.com $$->attr_name = $1;
15119326SAndrew.W.Wilson@sun.com };
15127736SAndrew.W.Wilson@sun.com
15137736SAndrew.W.Wilson@sun.com multisync_op: FSA_VALUE FSK_ASSIGN attr_value
15147736SAndrew.W.Wilson@sun.com {
15157736SAndrew.W.Wilson@sun.com $$ = $3;
15167736SAndrew.W.Wilson@sun.com $$->attr_name = FSA_VALUE;
15179326SAndrew.W.Wilson@sun.com };
15187736SAndrew.W.Wilson@sun.com
15199513SAndrew.W.Wilson@sun.com fscheck_attr_op: fscheck_attr_name FSK_ASSIGN FSV_STRING
15209513SAndrew.W.Wilson@sun.com {
15219513SAndrew.W.Wilson@sun.com if (($$ = alloc_attr()) == NULL)
15229513SAndrew.W.Wilson@sun.com YYERROR;
15239513SAndrew.W.Wilson@sun.com $$->attr_avd = avd_str_alloc($3);
15249513SAndrew.W.Wilson@sun.com $$->attr_name = $1;
15259513SAndrew.W.Wilson@sun.com };
15269513SAndrew.W.Wilson@sun.com
1527*9801SAndrew.W.Wilson@sun.com binary_op:
1528*9801SAndrew.W.Wilson@sun.com FSK_PLUS {$$ = FSK_PLUS;}
1529*9801SAndrew.W.Wilson@sun.com | FSK_MINUS {$$ = FSK_MINUS;}
1530*9801SAndrew.W.Wilson@sun.com | FSK_MULTIPLY {$$ = FSK_MULTIPLY;}
1531*9801SAndrew.W.Wilson@sun.com | FSK_DIVIDE {$$ = FSK_DIVIDE;};
1532*9801SAndrew.W.Wilson@sun.com
15336212Saw148015 files_attr_name: attrs_define_file
15346212Saw148015 |attrs_define_fileset;
15356212Saw148015
15366212Saw148015 pt_attr_name: attrs_define_thread
15376212Saw148015 |attrs_define_proc;
15386212Saw148015
15396212Saw148015 fo_attr_name: attrs_flowop;
15406212Saw148015
15416212Saw148015 ev_attr_name: attrs_eventgen;
15425184Sek110237
15435184Sek110237 attrs_define_proc:
15446212Saw148015 FSA_NICE { $$ = FSA_NICE;}
15456212Saw148015 | FSA_NAME { $$ = FSA_NAME;}
15466212Saw148015 | FSA_INSTANCES { $$ = FSA_INSTANCES;};
15475184Sek110237
15485184Sek110237 attrs_define_file:
15496212Saw148015 FSA_SIZE { $$ = FSA_SIZE;}
15506212Saw148015 | FSA_NAME { $$ = FSA_NAME;}
15515184Sek110237 | FSA_PATH { $$ = FSA_PATH;}
15529326SAndrew.W.Wilson@sun.com | FSA_READONLY { $$ = FSA_READONLY;}
15539326SAndrew.W.Wilson@sun.com | FSA_TRUSTTREE { $$ = FSA_TRUSTTREE;}
15545184Sek110237 | FSA_REUSE { $$ = FSA_REUSE;}
15555184Sek110237 | FSA_PREALLOC { $$ = FSA_PREALLOC;}
15565184Sek110237 | FSA_PARALLOC { $$ = FSA_PARALLOC;};
15575184Sek110237
15585184Sek110237 attrs_define_fileset:
15596212Saw148015 FSA_SIZE { $$ = FSA_SIZE;}
15606212Saw148015 | FSA_NAME { $$ = FSA_NAME;}
15615184Sek110237 | FSA_PATH { $$ = FSA_PATH;}
15625184Sek110237 | FSA_DIRWIDTH { $$ = FSA_DIRWIDTH;}
15636212Saw148015 | FSA_DIRDEPTHRV { $$ = FSA_DIRDEPTHRV;}
15645184Sek110237 | FSA_PREALLOC { $$ = FSA_PREALLOC;}
15658404SAndrew.W.Wilson@sun.com | FSA_PARALLOC { $$ = FSA_PARALLOC;}
15668404SAndrew.W.Wilson@sun.com | FSA_REUSE { $$ = FSA_REUSE;}
15679326SAndrew.W.Wilson@sun.com | FSA_READONLY { $$ = FSA_READONLY;}
15689326SAndrew.W.Wilson@sun.com | FSA_TRUSTTREE { $$ = FSA_TRUSTTREE;}
15695184Sek110237 | FSA_FILESIZEGAMMA { $$ = FSA_FILESIZEGAMMA;}
15705184Sek110237 | FSA_DIRGAMMA { $$ = FSA_DIRGAMMA;}
15715184Sek110237 | FSA_CACHED { $$ = FSA_CACHED;}
15729326SAndrew.W.Wilson@sun.com | FSA_ENTRIES { $$ = FSA_ENTRIES;}
15737946SAndrew.W.Wilson@sun.com | FSA_LEAFDIRS { $$ = FSA_LEAFDIRS;};
15745184Sek110237
15756212Saw148015 randvar_attr_name:
15766212Saw148015 FSA_NAME { $$ = FSA_NAME;}
15776212Saw148015 | FSA_RANDSEED { $$ = FSA_RANDSEED;}
15786212Saw148015 | FSA_RANDGAMMA { $$ = FSA_RANDGAMMA;}
15796212Saw148015 | FSA_RANDMEAN { $$ = FSA_RANDMEAN;}
15806212Saw148015 | FSA_RANDMIN { $$ = FSA_RANDMIN;}
15816212Saw148015 | FSA_RANDROUND { $$ = FSA_RANDROUND;};
15826212Saw148015
15836212Saw148015 randvar_attr_tsp:
15846212Saw148015 FSS_TYPE { $$ = FSS_TYPE;}
15856212Saw148015 | FSS_SRC { $$ = FSS_SRC;}
15866212Saw148015 | FSS_SEED { $$ = FSS_SEED;}
15876212Saw148015 | FSS_GAMMA { $$ = FSS_GAMMA;}
15886212Saw148015 | FSS_MEAN { $$ = FSS_MEAN;}
15896212Saw148015 | FSS_MIN { $$ = FSS_MIN;}
15906212Saw148015 | FSS_ROUND { $$ = FSS_ROUND;};
15916212Saw148015
15926212Saw148015
15936212Saw148015 randvar_attr_param:
15946212Saw148015 FSS_SEED { $$ = FSS_SEED;}
15956212Saw148015 | FSS_GAMMA { $$ = FSS_GAMMA;}
15966212Saw148015 | FSS_MEAN { $$ = FSS_MEAN;}
15976212Saw148015 | FSS_MIN { $$ = FSS_MIN;}
15986212Saw148015 | FSS_ROUND { $$ = FSS_ROUND;};
15996212Saw148015
16006212Saw148015 randvar_attr_typop: randtype_name
16016212Saw148015 {
16026212Saw148015 if (($$ = alloc_attr()) == NULL)
16036212Saw148015 YYERROR;
16046212Saw148015 $$->attr_avd = avd_int_alloc($1);
16056212Saw148015 };
16066212Saw148015
16076212Saw148015 randtype_name:
16086212Saw148015 FSV_RANDUNI { $$ = FSV_RANDUNI;}
16096212Saw148015 | FSV_RANDTAB { $$ = FSV_RANDTAB;}
16106212Saw148015 | FSA_RANDGAMMA { $$ = FSA_RANDGAMMA;};
16116212Saw148015
16126212Saw148015 randvar_attr_srcop: randsrc_name
16136212Saw148015 {
16146212Saw148015 if (($$ = alloc_attr()) == NULL)
16156212Saw148015 YYERROR;
16166212Saw148015 $$->attr_avd = avd_int_alloc($1);
16176212Saw148015 };
16186212Saw148015
16196212Saw148015 randsrc_name:
16206212Saw148015 FSV_URAND { $$ = FSV_URAND;}
16216212Saw148015 | FSV_RAND48 { $$ = FSV_RAND48;};
16226212Saw148015
16235184Sek110237 attrs_define_thread:
16246212Saw148015 FSA_PROCESS { $$ = FSA_PROCESS;}
16256212Saw148015 | FSA_NAME { $$ = FSA_NAME;}
16266212Saw148015 | FSA_MEMSIZE { $$ = FSA_MEMSIZE;}
16276212Saw148015 | FSA_USEISM { $$ = FSA_USEISM;}
16286212Saw148015 | FSA_INSTANCES { $$ = FSA_INSTANCES;};
16295184Sek110237
16305184Sek110237 attrs_flowop:
16316212Saw148015 FSA_WSS { $$ = FSA_WSS;}
16326212Saw148015 | FSA_FILE { $$ = FSA_FILE;}
16336212Saw148015 | FSA_NAME { $$ = FSA_NAME;}
16346212Saw148015 | FSA_RANDOM { $$ = FSA_RANDOM;}
16356212Saw148015 | FSA_FD { $$ = FSA_FD;}
16366212Saw148015 | FSA_SRCFD { $$ = FSA_SRCFD;}
16376212Saw148015 | FSA_ROTATEFD { $$ = FSA_ROTATEFD;}
16386212Saw148015 | FSA_DSYNC { $$ = FSA_DSYNC;}
16396212Saw148015 | FSA_DIRECTIO { $$ = FSA_DIRECTIO;}
16408404SAndrew.W.Wilson@sun.com | FSA_INDEXED { $$ = FSA_INDEXED;}
16416212Saw148015 | FSA_TARGET { $$ = FSA_TARGET;}
16426212Saw148015 | FSA_ITERS { $$ = FSA_ITERS;}
16436212Saw148015 | FSA_VALUE { $$ = FSA_VALUE;}
16446212Saw148015 | FSA_BLOCKING { $$ = FSA_BLOCKING;}
16456212Saw148015 | FSA_HIGHWATER { $$ = FSA_HIGHWATER;}
16466212Saw148015 | FSA_IOSIZE { $$ = FSA_IOSIZE;};
16475184Sek110237
16485184Sek110237 attrs_eventgen:
16496212Saw148015 FSA_RATE { $$ = FSA_RATE;};
16506212Saw148015
16517736SAndrew.W.Wilson@sun.com em_attr_name:
16529326SAndrew.W.Wilson@sun.com FSA_MASTER { $$ = FSA_MASTER;}
16537736SAndrew.W.Wilson@sun.com | FSA_CLIENT { $$ = FSA_CLIENT;};
16547736SAndrew.W.Wilson@sun.com
16559513SAndrew.W.Wilson@sun.com fscheck_attr_name:
16569513SAndrew.W.Wilson@sun.com FSA_PATH { $$ = FSA_PATH;}
16579513SAndrew.W.Wilson@sun.com | FSA_FSTYPE { $$ = FSA_FSTYPE;};
16589513SAndrew.W.Wilson@sun.com
16596550Saw148015 comp_attr_ops: comp_attr_op
16606550Saw148015 {
16616550Saw148015 $$ = $1;
16626550Saw148015 }
16636550Saw148015 | comp_attr_ops FSK_SEPLST comp_attr_op
16646550Saw148015 {
16656550Saw148015 attr_t *attr = NULL;
16666550Saw148015 attr_t *list_end = NULL;
16676550Saw148015
16686550Saw148015 for (attr = $1; attr != NULL;
16696550Saw148015 attr = attr->attr_next)
16706550Saw148015 list_end = attr; /* Find end of list */
16716550Saw148015
16726550Saw148015 list_end->attr_next = $3;
16736550Saw148015
16746550Saw148015 $$ = $1;
16756550Saw148015 }
16766550Saw148015 | comp_attr_ops FSK_SEPLST comp_lvar_def
16776550Saw148015 {
16786550Saw148015 attr_t *attr = NULL;
16796550Saw148015 attr_t *list_end = NULL;
16806550Saw148015
16816550Saw148015 for (attr = $1; attr != NULL;
16826550Saw148015 attr = attr->attr_next)
16836550Saw148015 list_end = attr; /* Find end of list */
16846550Saw148015
16856550Saw148015 list_end->attr_next = $3;
16866550Saw148015
16876550Saw148015 $$ = $1;
16886550Saw148015 };
16896550Saw148015
16906550Saw148015 comp_attr_op: attrs_define_comp FSK_ASSIGN attr_value
16916550Saw148015 {
16926550Saw148015 $$ = $3;
16936550Saw148015 $$->attr_name = $1;
16946550Saw148015 };
16956550Saw148015
16966550Saw148015 comp_lvar_def: FSV_VARIABLE FSK_ASSIGN FSV_VAL_BOOLEAN
16976550Saw148015 {
16986550Saw148015 if (($$ = alloc_lvar_attr(var_lvar_assign_boolean($1, $3))) == NULL)
16996550Saw148015 YYERROR;
17006550Saw148015 }
17016550Saw148015 | FSV_VARIABLE FSK_ASSIGN FSV_VAL_INT
17026550Saw148015 {
17036550Saw148015 if (($$ = alloc_lvar_attr(var_lvar_assign_integer($1, $3))) == NULL)
17046550Saw148015 YYERROR;
17056550Saw148015 }
17066550Saw148015 | FSV_VARIABLE FSK_ASSIGN FSK_QUOTE FSV_WHITESTRING FSK_QUOTE
17076550Saw148015 {
17086550Saw148015 if (($$ = alloc_lvar_attr(var_lvar_assign_string($1, $4))) == NULL)
17096550Saw148015 YYERROR;
17106550Saw148015 }
17116550Saw148015 | FSV_VARIABLE FSK_ASSIGN FSV_STRING
17126550Saw148015 {
17136550Saw148015 if (($$ = alloc_lvar_attr(var_lvar_assign_string($1, $3))) == NULL)
17146550Saw148015 YYERROR;
17156550Saw148015 }
17166550Saw148015 | FSV_VARIABLE FSK_ASSIGN FSV_VARIABLE
17176550Saw148015 {
17186550Saw148015 if (($$ = alloc_lvar_attr(var_lvar_assign_var($1, $3))) == NULL)
17196550Saw148015 YYERROR;
17206550Saw148015 }
17216550Saw148015 | FSV_VARIABLE
17226550Saw148015 {
17236550Saw148015 if (($$ = alloc_lvar_attr(var_lvar_alloc_local($1))) == NULL)
17246550Saw148015 YYERROR;
17256550Saw148015 };
17266550Saw148015
17276550Saw148015
17286550Saw148015 attrs_define_comp:
17296550Saw148015 FSA_NAME { $$ = FSA_NAME;}
17306550Saw148015 | FSA_ITERS { $$ = FSA_ITERS;};
17316550Saw148015
17326212Saw148015 attr_value: FSV_STRING
17336212Saw148015 {
17346212Saw148015 if (($$ = alloc_attr()) == NULL)
17356212Saw148015 YYERROR;
17366212Saw148015 $$->attr_avd = avd_str_alloc($1);
17376212Saw148015 } | FSV_VAL_INT {
17386212Saw148015 if (($$ = alloc_attr()) == NULL)
17396212Saw148015 YYERROR;
17406212Saw148015 $$->attr_avd = avd_int_alloc($1);
17416212Saw148015 } | FSV_VAL_BOOLEAN {
17426212Saw148015 if (($$ = alloc_attr()) == NULL)
17436212Saw148015 YYERROR;
17446212Saw148015 $$->attr_avd = avd_bool_alloc($1);
17456212Saw148015 } | FSV_VARIABLE {
17466212Saw148015 if (($$ = alloc_attr()) == NULL)
17476212Saw148015 YYERROR;
17486212Saw148015 $$->attr_avd = var_ref_attr($1);
17496212Saw148015 };
17506212Saw148015
17516212Saw148015 attr_list_value: var_string_list {
17525184Sek110237 if (($$ = alloc_attr()) == NULL)
17535184Sek110237 YYERROR;
17545184Sek110237 $$->attr_param_list = $1;
17558404SAndrew.W.Wilson@sun.com } | FSV_STRING {
17565184Sek110237 if (($$ = alloc_attr()) == NULL)
17575184Sek110237 YYERROR;
17586212Saw148015 $$->attr_avd = avd_str_alloc($1);
17595184Sek110237 } | FSV_VAL_INT {
17605184Sek110237 if (($$ = alloc_attr()) == NULL)
17615184Sek110237 YYERROR;
17626212Saw148015 $$->attr_avd = avd_int_alloc($1);
17636212Saw148015 } | FSV_VAL_BOOLEAN {
17646212Saw148015 if (($$ = alloc_attr()) == NULL)
17656212Saw148015 YYERROR;
17666212Saw148015 $$->attr_avd = avd_bool_alloc($1);
17675184Sek110237 } | FSV_VARIABLE {
17685184Sek110237 if (($$ = alloc_attr()) == NULL)
17695184Sek110237 YYERROR;
17706212Saw148015 $$->attr_avd = var_ref_attr($1);
17716212Saw148015 };
17726212Saw148015
17736212Saw148015 var_int_val: FSV_VAL_INT
17746212Saw148015 {
17756212Saw148015 $$ = avd_int_alloc($1);
17766212Saw148015 } | FSV_VARIABLE
17776212Saw148015 {
17786212Saw148015 $$ = var_ref_attr($1);
17795184Sek110237 };
17805184Sek110237
17815184Sek110237 %%
17825184Sek110237
17835184Sek110237 /*
17845184Sek110237 * The following 'c' routines implement the various commands defined in the
17855184Sek110237 * above yacc parser code. The yacc portion checks the syntax of the commands
17865184Sek110237 * found in a workload file, or typed on interactive command lines, parsing
17875184Sek110237 * the commands' parameters into lists. The lists are then passed in a cmd_t
17885184Sek110237 * struct for each command to its related routine in the following section
17895184Sek110237 * for actual execution. This section also includes a few utility routines
17905184Sek110237 * and the main entry point for the program.
17915184Sek110237 */
17925184Sek110237
17935184Sek110237 /*
17945184Sek110237 * Entry point for filebench. Processes command line arguements. The -f
17955184Sek110237 * option will read in a workload file (the full name and extension must
17965184Sek110237 * must be given). The -a, -s, -m and -i options are used by worker process
17975184Sek110237 * to receive their name, the base address of shared memory, its path, and
17985184Sek110237 * the process' instance number, respectively. This information is supplied
17995184Sek110237 * by the master process when it execs worker processes under the process
18005184Sek110237 * model of execution. If the worker process arguments are passed then main
18015184Sek110237 * will call the procflow_exec routine which creates worker threadflows and
18025184Sek110237 * flowops and executes the procflow's portion of the workload model until
18035184Sek110237 * completion. If worker process arguments are not passed to the process,
18045184Sek110237 * then it becomes the master process for a filebench run. It initializes
18055184Sek110237 * the various filebench components and either executes the supplied workload
18065184Sek110237 * file, or enters interactive mode.
18075184Sek110237 */
18085184Sek110237
18095184Sek110237 int
18105184Sek110237 main(int argc, char *argv[])
18115184Sek110237 {
18125184Sek110237 int opt;
18135184Sek110237 int docmd = FS_FALSE;
18145184Sek110237 int instance;
18155184Sek110237 char procname[128];
18165184Sek110237 caddr_t shmaddr;
18175184Sek110237 char dir[MAXPATHLEN];
18185184Sek110237 #ifdef HAVE_SETRLIMIT
18195184Sek110237 struct rlimit rlp;
18205184Sek110237 #endif
18215184Sek110237 #ifdef HAVE_LIBTECLA
18225184Sek110237 char *line;
18235184Sek110237 #else
18245184Sek110237 char line[1024];
18255184Sek110237 #endif
18265184Sek110237 char shmpathtmp[1024];
18275184Sek110237
18285184Sek110237 #ifdef HAVE_SETRLIMIT
18295184Sek110237 /* Set resource limits */
18305184Sek110237 (void) getrlimit(RLIMIT_NOFILE, &rlp);
18315184Sek110237 rlp.rlim_cur = rlp.rlim_max;
18325184Sek110237 setrlimit(RLIMIT_NOFILE, &rlp);
18335184Sek110237 #endif
18345184Sek110237
18355184Sek110237 yydebug = 0;
18365184Sek110237 execname = argv[0];
18375184Sek110237 *procname = 0;
18385184Sek110237 cwd = getcwd(dir, MAXPATHLEN);
18395184Sek110237
18405184Sek110237 while ((opt = getopt(argc, argv, cmd_options)) != (int)EOF) {
18415184Sek110237
18425184Sek110237 switch (opt) {
18435184Sek110237 case 'h':
18445184Sek110237 usage(2);
18455184Sek110237 break;
18465184Sek110237
18475184Sek110237 case 'p':
18485184Sek110237 noproc = 1;
18495184Sek110237 break;
18505184Sek110237
18515184Sek110237 case 'f':
18525184Sek110237 if (optarg == NULL)
18535184Sek110237 usage(1);
18545184Sek110237 if ((yyin = fopen(optarg, "r")) == NULL) {
18555184Sek110237 (void) fprintf(stderr,
18565184Sek110237 "Cannot open file %s", optarg);
18575184Sek110237 exit(1);
18585184Sek110237 }
18595184Sek110237 dofile = FS_TRUE;
18605184Sek110237 fscriptname = optarg;
18615184Sek110237
18625184Sek110237 break;
18635184Sek110237
18645184Sek110237 case 'a':
18655184Sek110237 if (optarg == NULL)
18665184Sek110237 usage(1);
18675184Sek110237 sscanf(optarg, "%s", &procname[0]);
18685184Sek110237 break;
18695184Sek110237
18705184Sek110237 case 's':
18715184Sek110237 if (optarg == NULL)
18725184Sek110237 usage(1);
18735184Sek110237 #if defined(_LP64) || (__WORDSIZE == 64)
18745184Sek110237 sscanf(optarg, "%llx", &shmaddr);
18755184Sek110237 #else
18765184Sek110237 sscanf(optarg, "%x", &shmaddr);
18775184Sek110237 #endif
18785184Sek110237 break;
18795184Sek110237
18805184Sek110237 case 'm':
18815184Sek110237 if (optarg == NULL)
18825184Sek110237 usage(1);
18835184Sek110237 sscanf(optarg, "%s", shmpathtmp);
18845184Sek110237 shmpath = shmpathtmp;
18855184Sek110237 break;
18865184Sek110237
18875184Sek110237 case 'i':
18885184Sek110237 if (optarg == NULL)
18895184Sek110237 usage(1);
18905184Sek110237 sscanf(optarg, "%d", &instance);
18915184Sek110237 break;
18925184Sek110237
18935184Sek110237 case '?':
18945184Sek110237 default:
18955184Sek110237 usage(1);
18965184Sek110237 break;
18975184Sek110237 }
18985184Sek110237 }
18995184Sek110237
19005184Sek110237 #ifdef USE_PROCESS_MODEL
19015184Sek110237 if (!(*procname))
19025184Sek110237 #endif
19035184Sek110237 printf("FileBench Version %s\n", FILEBENCH_VERSION);
19045184Sek110237 filebench_init();
19055184Sek110237
19066084Saw148015 /* get process pid for use with message logging */
19076084Saw148015 my_pid = getpid();
19086084Saw148015
19095184Sek110237 #ifdef USE_PROCESS_MODEL
19105184Sek110237 if (*procname) {
19116084Saw148015 /* A child FileBench instance */
19125184Sek110237 if (ipc_attach(shmaddr) < 0) {
19135184Sek110237 filebench_log(LOG_ERROR, "Cannot attach shm for %s",
19145184Sek110237 procname);
19155184Sek110237 exit(1);
19165184Sek110237 }
19175184Sek110237
19188615SAndrew.W.Wilson@sun.com /* get correct function pointer for each child process */
19198615SAndrew.W.Wilson@sun.com filebench_plugin_funcvecinit();
19208615SAndrew.W.Wilson@sun.com
19216212Saw148015 if (procflow_exec(procname, instance) < 0) {
19226212Saw148015 filebench_log(LOG_ERROR, "Cannot startup process %s",
19236212Saw148015 procname);
19245184Sek110237 exit(1);
19256212Saw148015 }
19266084Saw148015
19276084Saw148015 exit(0);
19285184Sek110237 }
19295184Sek110237 #endif
19305184Sek110237
19316084Saw148015 /* master (or only) process */
19325184Sek110237 ipc_init();
19335184Sek110237
19345184Sek110237 if (fscriptname)
19356391Saw148015 (void) strcpy(filebench_shm->shm_fscriptname, fscriptname);
19365184Sek110237
19378615SAndrew.W.Wilson@sun.com filebench_plugin_funcvecinit();
19385184Sek110237 flowop_init();
19395184Sek110237 stats_init();
19405184Sek110237 eventgen_init();
19415184Sek110237
19425184Sek110237 signal(SIGINT, parser_abort);
19435184Sek110237
19445184Sek110237 if (dofile)
19455184Sek110237 yyparse();
19465184Sek110237 else {
19475184Sek110237 #ifdef HAVE_LIBTECLA
19485184Sek110237 if ((gl = new_GetLine(MAX_LINE_LEN, MAX_CMD_HIST)) == NULL) {
19495184Sek110237 filebench_log(LOG_ERROR,
19505184Sek110237 "Failed to create GetLine object");
19515184Sek110237 filebench_shutdown(1);
19525184Sek110237 }
19535184Sek110237
19545184Sek110237 if (gl_customize_completion(gl, NULL, command_complete)) {
19555184Sek110237 filebench_log(LOG_ERROR,
19565184Sek110237 "Failed to register auto-completion function");
19575184Sek110237 filebench_shutdown(1);
19585184Sek110237 }
19595184Sek110237
19605184Sek110237 while (line = gl_get_line(gl, FILEBENCH_PROMPT, NULL, -1)) {
19615184Sek110237 arg_parse(line);
19625184Sek110237 yyparse();
19635184Sek110237 }
19645184Sek110237
19655184Sek110237 del_GetLine(gl);
19665184Sek110237 #else
19675184Sek110237 while (!feof(stdin)) {
19685184Sek110237 printf(FILEBENCH_PROMPT);
19695184Sek110237 fflush(stdout);
19705184Sek110237 if (fgets(line, sizeof (line), stdin) == NULL) {
19715184Sek110237 if (errno == EINTR)
19725184Sek110237 continue;
19735184Sek110237 else
19745184Sek110237 break;
19755184Sek110237 }
19765184Sek110237 arg_parse(line);
19775184Sek110237 yyparse();
19785184Sek110237 }
19795184Sek110237 printf("\n");
19805184Sek110237 #endif /* HAVE_LIBTECLA */
19815184Sek110237 }
19825184Sek110237
19835184Sek110237 parser_filebench_shutdown((cmd_t *)0);
19845184Sek110237
19855184Sek110237 return (0);
19865184Sek110237 }
19875184Sek110237
19885184Sek110237 /*
19895184Sek110237 * arg_parse() puts the parser into command parsing mode. Create a tmpfile
19905184Sek110237 * and instruct the parser to read instructions from this location by setting
19915184Sek110237 * yyin to the value returned by tmpfile. Write the command into the file.
19925184Sek110237 * Then seek back to to the start of the file so that the parser can read
19935184Sek110237 * the instructions.
19945184Sek110237 */
19955184Sek110237 static void
arg_parse(const char * command)19965184Sek110237 arg_parse(const char *command)
19975184Sek110237 {
19986750Sek110237 if ((yyin = tmpfile()) == NULL) {
19995184Sek110237 filebench_log(LOG_FATAL,
20006750Sek110237 "Exiting: Cannot create tmpfile: %s", strerror(errno));
20016750Sek110237 exit(1);
20026750Sek110237 }
20035184Sek110237
20045184Sek110237 if (fwrite(command, strlen(command), 1, yyin) != 1)
20055184Sek110237 filebench_log(LOG_FATAL,
20065184Sek110237 "Cannot write tmpfile: %s", strerror(errno));
20075184Sek110237
20085184Sek110237 if (fseek(yyin, 0, SEEK_SET) != 0)
20095184Sek110237 filebench_log(LOG_FATAL,
20105184Sek110237 "Cannot seek tmpfile: %s", strerror(errno));
20115184Sek110237 }
20125184Sek110237
20135184Sek110237 /*
20145184Sek110237 * Converts a list of var_strings or ordinary strings to a single ordinary
20155184Sek110237 * string. It returns a pointer to the string (in malloc'd memory) if found,
20165184Sek110237 * or NULL otherwise.
20175184Sek110237 */
20185184Sek110237 char *
parser_list2string(list_t * list)20195184Sek110237 parser_list2string(list_t *list)
20205184Sek110237 {
20215184Sek110237 list_t *l;
20225184Sek110237 char *string;
20235184Sek110237 char *tmp;
20246212Saw148015 fbint_t *integer;
20255184Sek110237 if ((string = malloc(MAXPATHLEN)) == NULL) {
20265184Sek110237 filebench_log(LOG_ERROR, "Failed to allocate memory");
20275184Sek110237 return (NULL);
20285184Sek110237 }
20295184Sek110237
20305184Sek110237 *string = 0;
20315184Sek110237
20328404SAndrew.W.Wilson@sun.com /* printf("parser_list2string: called\n"); */
20335184Sek110237 /* Format args */
20346212Saw148015 for (l = list; l != NULL; l = l->list_next) {
20356212Saw148015 char *lstr = avd_get_str(l->list_string);
20366212Saw148015
20375184Sek110237 filebench_log(LOG_DEBUG_SCRIPT,
20386212Saw148015 "converting string '%s'", lstr);
20396212Saw148015
20406212Saw148015 /* see if it is a random variable */
20416212Saw148015 if (l->list_integer) {
20426212Saw148015 fbint_t param_name;
20436212Saw148015
20446212Saw148015 tmp = NULL;
20456212Saw148015 param_name = avd_get_int(l->list_integer);
20466212Saw148015 switch (param_name) {
20476212Saw148015 case FSS_TYPE:
20486212Saw148015 tmp = var_randvar_to_string(lstr,
20496212Saw148015 RAND_PARAM_TYPE);
20506212Saw148015 break;
20516212Saw148015
20526212Saw148015 case FSS_SRC:
20536212Saw148015 tmp = var_randvar_to_string(lstr,
20546212Saw148015 RAND_PARAM_SRC);
20556212Saw148015 break;
20566212Saw148015
20576212Saw148015 case FSS_SEED:
20586212Saw148015 tmp = var_randvar_to_string(lstr,
20596212Saw148015 RAND_PARAM_SEED);
20606212Saw148015 break;
20616212Saw148015
20626212Saw148015 case FSS_MIN:
20636212Saw148015 tmp = var_randvar_to_string(lstr,
20646212Saw148015 RAND_PARAM_MIN);
20656212Saw148015 break;
20666212Saw148015
20676212Saw148015 case FSS_MEAN:
20686212Saw148015 tmp = var_randvar_to_string(lstr,
20696212Saw148015 RAND_PARAM_MEAN);
20706212Saw148015 break;
20716212Saw148015
20726212Saw148015 case FSS_GAMMA:
20736212Saw148015 tmp = var_randvar_to_string(lstr,
20746212Saw148015 RAND_PARAM_GAMMA);
20756212Saw148015 break;
20766212Saw148015
20776212Saw148015 case FSS_ROUND:
20786212Saw148015 tmp = var_randvar_to_string(lstr,
20796212Saw148015 RAND_PARAM_ROUND);
20806212Saw148015 break;
20816212Saw148015 }
20826212Saw148015
20836212Saw148015 if (tmp) {
20846212Saw148015 (void) strcat(string, tmp);
20856212Saw148015 free(tmp);
20866212Saw148015 } else {
20876212Saw148015 (void) strcat(string, lstr);
20886212Saw148015 }
20895184Sek110237 } else {
20906212Saw148015 /* perhaps a normal variable? */
20916212Saw148015 if ((tmp = var_to_string(lstr)) != NULL) {
20926212Saw148015 (void) strcat(string, tmp);
20936212Saw148015 free(tmp);
20946212Saw148015 } else {
20956212Saw148015 (void) strcat(string, lstr);
20966212Saw148015 }
20975184Sek110237 }
20985184Sek110237 }
20995184Sek110237 return (string);
21005184Sek110237 }
21015184Sek110237
21025184Sek110237 /*
21035184Sek110237 * If the list just contains a single string starting with '$', then find
21045184Sek110237 * or create the named var and return the var's var_string component.
21055184Sek110237 * Otherwise, convert the list to a string, and allocate a var_string
21065184Sek110237 * containing a copy of that string. On failure either returns NULL
21075184Sek110237 * or shuts down the run.
21085184Sek110237 */
21096212Saw148015 avd_t
parser_list2varstring(list_t * list)21105184Sek110237 parser_list2varstring(list_t *list)
21115184Sek110237 {
21126212Saw148015 char *lstr = avd_get_str(list->list_string);
21136212Saw148015
21148404SAndrew.W.Wilson@sun.com /* printf("parser_list2varstring: Called\n"); */
21155184Sek110237 /* Special case - variable name */
21166212Saw148015 if ((list->list_next == NULL) && (*lstr == '$'))
21176212Saw148015 return (var_ref_attr(lstr));
21186212Saw148015
21196212Saw148015 return (avd_str_alloc(parser_list2string(list)));
21205184Sek110237 }
21215184Sek110237
21225184Sek110237 /*
21235184Sek110237 * Looks for the var named in list_string of the first element of the
21246212Saw148015 * supplied list. If found, returns the var_val portion of the var in
21256212Saw148015 * an attribute value descriptor. If the var is not found, cannot be
21266212Saw148015 * allocated, the supplied list is NULL, or the list_string filed is
21276212Saw148015 * empty, returns NULL.
21285184Sek110237 */
21296212Saw148015 avd_t
parser_list2avd(list_t * list)21306212Saw148015 parser_list2avd(list_t *list)
21315184Sek110237 {
21326212Saw148015 avd_t avd;
21336212Saw148015 char *lstr;
21346212Saw148015
21356212Saw148015 if (list && ((lstr = avd_get_str(list->list_string)) != NULL)) {
21366212Saw148015 avd = var_ref_attr(lstr);
21376212Saw148015 return (avd);
21385184Sek110237 }
21395184Sek110237
21405184Sek110237 return (NULL);
21415184Sek110237 }
21425184Sek110237
21435184Sek110237 /*
21445184Sek110237 * Sets the event generator rate from the attribute supplied with the
21455184Sek110237 * command. If the attribute doesn't exist the routine does nothing.
21465184Sek110237 */
21475184Sek110237 static void
parser_eventgen(cmd_t * cmd)21485184Sek110237 parser_eventgen(cmd_t *cmd)
21495184Sek110237 {
21505184Sek110237 attr_t *attr;
21515184Sek110237
21525184Sek110237 /* Get the rate from attribute */
21535184Sek110237 if (attr = get_attr_integer(cmd, FSA_RATE)) {
21546212Saw148015 if (attr->attr_avd) {
21557946SAndrew.W.Wilson@sun.com eventgen_setrate(attr->attr_avd);
21565184Sek110237 }
21575184Sek110237 }
21585184Sek110237 }
21595184Sek110237
21605184Sek110237 /*
21615184Sek110237 * Assigns the designated integer variable successive values from the
21625184Sek110237 * supplied comma seperated integer list. After each successive integer
21635184Sek110237 * assignment, it executes the bracket enclosed list of commands. For
21645184Sek110237 * example, repeated runs of a workload with increasing io sizes can
21655184Sek110237 * be done using the following command line:
21665184Sek110237 * foreach $iosize in 2k, 4k, 8k {run 60}
21675184Sek110237 */
21685184Sek110237 static void
parser_foreach_integer(cmd_t * cmd)21695184Sek110237 parser_foreach_integer(cmd_t *cmd)
21705184Sek110237 {
21715184Sek110237 list_t *list = cmd->cmd_param_list;
21725184Sek110237 cmd_t *inner_cmd;
21735184Sek110237
21745184Sek110237 for (; list != NULL; list = list->list_next) {
21756212Saw148015 fbint_t list_int = avd_get_int(list->list_integer);
21766212Saw148015
21776212Saw148015 var_assign_integer(cmd->cmd_tgt1, list_int);
21786286Saw148015 filebench_log(LOG_VERBOSE, "Iterating %s=%llu",
21796286Saw148015 cmd->cmd_tgt1, (u_longlong_t)list_int);
21805184Sek110237 for (inner_cmd = cmd->cmd_list; inner_cmd != NULL;
21815184Sek110237 inner_cmd = inner_cmd->cmd_next) {
21825184Sek110237 inner_cmd->cmd(inner_cmd);
21835184Sek110237 }
21845184Sek110237 }
21855184Sek110237 }
21865184Sek110237
21875184Sek110237 /*
21885184Sek110237 * Similar to parser_foreach_integer(), except takes a list of strings after
21895184Sek110237 * the "in" token. For example, to run twice using a different directory,
21905184Sek110237 * perhaps using a different filesystem, the following command line
21915184Sek110237 * could be used:
21925184Sek110237 * foreach $dir in "/ufs_top/fbt", "/zfs_top/fbt" {run 60)
21935184Sek110237 */
21945184Sek110237 static void
parser_foreach_string(cmd_t * cmd)21955184Sek110237 parser_foreach_string(cmd_t *cmd)
21965184Sek110237 {
21975184Sek110237 list_t *list = cmd->cmd_param_list;
21985184Sek110237
21995184Sek110237 for (; list != NULL; list = list->list_next) {
22006212Saw148015 cmd_t *inner_cmd;
22016212Saw148015 char *lstr = avd_get_str(list->list_string);
22026212Saw148015 var_assign_string(cmd->cmd_tgt1, lstr);
22035184Sek110237 filebench_log(LOG_VERBOSE, "Iterating %s=%s",
22046212Saw148015 cmd->cmd_tgt1, lstr);
22055184Sek110237 for (inner_cmd = cmd->cmd_list; inner_cmd != NULL;
22065184Sek110237 inner_cmd = inner_cmd->cmd_next) {
22075184Sek110237 inner_cmd->cmd(inner_cmd);
22085184Sek110237 }
22095184Sek110237 }
22105184Sek110237 }
22115184Sek110237
22125184Sek110237 /*
22135673Saw148015 * Lists the fileset name, path name and average size for all defined
22145673Saw148015 * filesets.
22155184Sek110237 */
22165184Sek110237 static void
parser_list(cmd_t * cmd)22175184Sek110237 parser_list(cmd_t *cmd)
22185184Sek110237 {
22195673Saw148015 (void) fileset_iter(fileset_print);
22205184Sek110237 }
22215184Sek110237
22225184Sek110237 /*
22236212Saw148015 * Lists the flowop name and instance number for all flowops.
22246212Saw148015 */
22256212Saw148015 static void
parser_flowop_list(cmd_t * cmd)22266212Saw148015 parser_flowop_list(cmd_t *cmd)
22276212Saw148015 {
22286212Saw148015 flowop_printall();
22296212Saw148015 }
22306212Saw148015
22316212Saw148015 /*
22325184Sek110237 * Calls procflow_define() to allocate "instances" number of procflow(s)
22335184Sek110237 * (processes) with the supplied name. The default number of instances is
22345184Sek110237 * one. An optional priority level attribute can be supplied and is stored in
22355184Sek110237 * pf_nice. Finally the routine loops through the list of inner commands, if
22365184Sek110237 * any, which are defines for threadflows, and passes them one at a time to
22375184Sek110237 * parser_thread_define() to allocate threadflow entities for the process(es).
22385184Sek110237 */
22395184Sek110237 static void
parser_proc_define(cmd_t * cmd)22405184Sek110237 parser_proc_define(cmd_t *cmd)
22415184Sek110237 {
22425184Sek110237 procflow_t *procflow, template;
22435184Sek110237 char *name;
22445184Sek110237 attr_t *attr;
22456212Saw148015 avd_t var_instances;
22466212Saw148015 fbint_t instances;
22475184Sek110237 cmd_t *inner_cmd;
22485184Sek110237
22495184Sek110237 /* Get the name of the process */
22505184Sek110237 if (attr = get_attr(cmd, FSA_NAME)) {
22516212Saw148015 name = avd_get_str(attr->attr_avd);
22525184Sek110237 } else {
22535184Sek110237 filebench_log(LOG_ERROR,
22545184Sek110237 "define proc: proc specifies no name");
22555184Sek110237 filebench_shutdown(1);
22565184Sek110237 }
22575184Sek110237
22585184Sek110237 /* Get the memory size from attribute */
22595184Sek110237 if (attr = get_attr_integer(cmd, FSA_INSTANCES)) {
22606212Saw148015 if (AVD_IS_RANDOM(attr->attr_avd)) {
22616212Saw148015 filebench_log(LOG_ERROR,
22626212Saw148015 "proc_define: Instances attr cannot be random");
22636212Saw148015 filebench_shutdown(1);
22646212Saw148015 }
22656212Saw148015 var_instances = attr->attr_avd;
22666212Saw148015 instances = avd_get_int(var_instances);
22675184Sek110237 filebench_log(LOG_DEBUG_IMPL,
22686286Saw148015 "Setting instances = %llu", (u_longlong_t)instances);
22696212Saw148015 } else {
22706212Saw148015 filebench_log(LOG_DEBUG_IMPL,
22716212Saw148015 "Defaulting to instances = 1");
22726212Saw148015 var_instances = avd_int_alloc(1);
22736212Saw148015 instances = 1;
22745184Sek110237 }
22755184Sek110237
22766212Saw148015 if ((procflow = procflow_define(name, NULL, var_instances)) == NULL) {
22775184Sek110237 filebench_log(LOG_ERROR,
22785184Sek110237 "Failed to instantiate %d %s process(es)\n",
22795184Sek110237 instances, name);
22805184Sek110237 filebench_shutdown(1);
22815184Sek110237 }
22825184Sek110237
22835184Sek110237 /* Get the pri from attribute */
22845184Sek110237 if (attr = get_attr_integer(cmd, FSA_NICE)) {
22856212Saw148015 if (AVD_IS_RANDOM(attr->attr_avd)) {
22866212Saw148015 filebench_log(LOG_ERROR,
22876212Saw148015 "proc_define: priority cannot be random");
22886212Saw148015 filebench_shutdown(1);
22896212Saw148015 }
22906286Saw148015 filebench_log(LOG_DEBUG_IMPL, "Setting pri = %llu",
22916286Saw148015 (u_longlong_t)avd_get_int(attr->attr_avd));
22926212Saw148015 procflow->pf_nice = attr->attr_avd;
22935184Sek110237 } else
22946212Saw148015 procflow->pf_nice = avd_int_alloc(0);
22955184Sek110237
22965184Sek110237
22975184Sek110237 /* Create the list of threads for this process */
22985184Sek110237 for (inner_cmd = cmd->cmd_list; inner_cmd != NULL;
22995184Sek110237 inner_cmd = inner_cmd->cmd_next) {
23006212Saw148015 parser_thread_define(inner_cmd, procflow, instances);
23015184Sek110237 }
23025184Sek110237 }
23035184Sek110237
23045184Sek110237 /*
23055184Sek110237 * Calls threadflow_define() to allocate "instances" number of threadflow(s)
23065184Sek110237 * (threads) with the supplied name. The default number of instances is
23075184Sek110237 * one. Two other optional attributes may be supplied, one to set the memory
23085184Sek110237 * size, stored in tf_memsize, and to select the use of Interprocess Shared
23095184Sek110237 * Memory, which sets the THREADFLOW_USEISM flag in tf_attrs. Finally
23105184Sek110237 * the routine loops through the list of inner commands, if any, which are
23115184Sek110237 * defines for flowops, and passes them one at a time to
23125184Sek110237 * parser_flowop_define() to allocate flowop entities for the threadflows.
23135184Sek110237 */
23145184Sek110237 static void
parser_thread_define(cmd_t * cmd,procflow_t * procflow,int procinstances)23155184Sek110237 parser_thread_define(cmd_t *cmd, procflow_t *procflow, int procinstances)
23165184Sek110237 {
23175184Sek110237 threadflow_t *threadflow, template;
23185184Sek110237 attr_t *attr;
23196212Saw148015 avd_t instances;
23205184Sek110237 cmd_t *inner_cmd;
23215184Sek110237 char *name;
23225184Sek110237
23235184Sek110237 memset(&template, 0, sizeof (threadflow_t));
23245184Sek110237
23255184Sek110237 /* Get the name of the thread */
23265184Sek110237 if (attr = get_attr(cmd, FSA_NAME)) {
23276212Saw148015 name = avd_get_str(attr->attr_avd);
23285184Sek110237 } else {
23295184Sek110237 filebench_log(LOG_ERROR,
23305184Sek110237 "define thread: thread in process %s specifies no name",
23315184Sek110237 procflow->pf_name);
23325184Sek110237 filebench_shutdown(1);
23335184Sek110237 }
23345184Sek110237
23355184Sek110237 /* Get the number of instances from attribute */
23365184Sek110237 if (attr = get_attr_integer(cmd, FSA_INSTANCES)) {
23376212Saw148015 if (AVD_IS_RANDOM(attr->attr_avd)) {
23386212Saw148015 filebench_log(LOG_ERROR,
23396212Saw148015 "define thread: Instances attr cannot be random");
23406212Saw148015 filebench_shutdown(1);
23416212Saw148015 }
23425184Sek110237 filebench_log(LOG_DEBUG_IMPL,
23436286Saw148015 "define thread: Setting instances = %llu",
23446286Saw148015 (u_longlong_t)avd_get_int(attr->attr_avd));
23456212Saw148015 instances = attr->attr_avd;
23466212Saw148015 } else
23476212Saw148015 instances = avd_int_alloc(1);
23485184Sek110237
23495184Sek110237 /* Get the memory size from attribute */
23505184Sek110237 if (attr = get_attr_integer(cmd, FSA_MEMSIZE)) {
23516212Saw148015 if (AVD_IS_RANDOM(attr->attr_avd)) {
23526212Saw148015 filebench_log(LOG_ERROR,
23536212Saw148015 "define thread: Memory size cannot be random");
23546212Saw148015 filebench_shutdown(1);
23556212Saw148015 }
23565184Sek110237 filebench_log(LOG_DEBUG_IMPL,
23576286Saw148015 "define thread: Setting memsize = %llu",
23586286Saw148015 (u_longlong_t)avd_get_int(attr->attr_avd));
23596212Saw148015 template.tf_memsize = attr->attr_avd;
23605184Sek110237 } else
23616212Saw148015 template.tf_memsize = avd_int_alloc(0);
23625184Sek110237
23635184Sek110237 if ((threadflow = threadflow_define(procflow, name,
23645184Sek110237 &template, instances)) == NULL) {
23655184Sek110237 filebench_log(LOG_ERROR,
23665184Sek110237 "define thread: Failed to instantiate thread\n");
23675184Sek110237 filebench_shutdown(1);
23685184Sek110237 }
23695184Sek110237
23705184Sek110237 /* Use ISM Memory? */
23715184Sek110237 if (attr = get_attr(cmd, FSA_USEISM)) {
23725184Sek110237 threadflow->tf_attrs |= THREADFLOW_USEISM;
23735184Sek110237 }
23745184Sek110237
23755184Sek110237 /* Create the list of flowops */
23765184Sek110237 for (inner_cmd = cmd->cmd_list; inner_cmd != NULL;
23775184Sek110237 inner_cmd = inner_cmd->cmd_next) {
23786212Saw148015 parser_flowop_define(inner_cmd, threadflow,
23796550Saw148015 &threadflow->tf_thrd_fops, FLOW_MASTER);
23805184Sek110237 }
23815184Sek110237 }
23825184Sek110237
23835184Sek110237 /*
23848404SAndrew.W.Wilson@sun.com * Fills in the attributes for a newly allocated flowop
23856212Saw148015 */
23866212Saw148015 static void
parser_flowop_get_attrs(cmd_t * cmd,flowop_t * flowop)23876212Saw148015 parser_flowop_get_attrs(cmd_t *cmd, flowop_t *flowop)
23886212Saw148015 {
23896212Saw148015 attr_t *attr;
23906212Saw148015
23916212Saw148015 /* Get the filename from attribute */
23926212Saw148015 if (attr = get_attr(cmd, FSA_FILE)) {
23936212Saw148015 flowop->fo_filename = attr->attr_avd;
23946212Saw148015 if (flowop->fo_filename == NULL) {
23956212Saw148015 filebench_log(LOG_ERROR,
23966212Saw148015 "define flowop: no filename specfied");
23976212Saw148015 filebench_shutdown(1);
23986212Saw148015 }
23999326SAndrew.W.Wilson@sun.com } else {
24009326SAndrew.W.Wilson@sun.com /* no filename attribute specified */
24019326SAndrew.W.Wilson@sun.com flowop->fo_filename = NULL;
24026212Saw148015 }
24036212Saw148015
24046212Saw148015 /* Get the iosize of the op */
24056212Saw148015 if (attr = get_attr_integer(cmd, FSA_IOSIZE))
24066212Saw148015 flowop->fo_iosize = attr->attr_avd;
24076212Saw148015 else
24086212Saw148015 flowop->fo_iosize = avd_int_alloc(0);
24096212Saw148015
24106212Saw148015 /* Get the working set size of the op */
24116212Saw148015 if (attr = get_attr_integer(cmd, FSA_WSS))
24126212Saw148015 flowop->fo_wss = attr->attr_avd;
24136212Saw148015 else
24146212Saw148015 flowop->fo_wss = avd_int_alloc(0);
24156212Saw148015
24166212Saw148015 /* Random I/O? */
24176212Saw148015 if (attr = get_attr_bool(cmd, FSA_RANDOM))
24186212Saw148015 flowop->fo_random = attr->attr_avd;
24196212Saw148015 else
24206212Saw148015 flowop->fo_random = avd_bool_alloc(FALSE);
24216212Saw148015
24226212Saw148015 /* Sync I/O? */
24236212Saw148015 if (attr = get_attr_bool(cmd, FSA_DSYNC))
24246212Saw148015 flowop->fo_dsync = attr->attr_avd;
24256212Saw148015 else
24266212Saw148015 flowop->fo_dsync = avd_bool_alloc(FALSE);
24276212Saw148015
24286212Saw148015 /* Target, for wakeup etc */
24296212Saw148015 if (attr = get_attr(cmd, FSA_TARGET))
24306212Saw148015 (void) strcpy(flowop->fo_targetname,
24316212Saw148015 avd_get_str(attr->attr_avd));
24326212Saw148015
24336212Saw148015 /* Value */
24346212Saw148015 if (attr = get_attr_integer(cmd, FSA_VALUE))
24356212Saw148015 flowop->fo_value = attr->attr_avd;
24366212Saw148015 else
24376212Saw148015 flowop->fo_value = avd_int_alloc(0);
24386212Saw148015
24396212Saw148015 /* FD */
24409326SAndrew.W.Wilson@sun.com if (attr = get_attr_integer(cmd, FSA_FD)) {
24416212Saw148015 flowop->fo_fdnumber = avd_get_int(attr->attr_avd);
24429326SAndrew.W.Wilson@sun.com if (flowop->fo_filename != NULL)
24439326SAndrew.W.Wilson@sun.com filebench_log(LOG_DEBUG_SCRIPT, "It is not "
24449326SAndrew.W.Wilson@sun.com "advisable to supply both an fd number "
24459326SAndrew.W.Wilson@sun.com "and a fileset name in most cases");
24469326SAndrew.W.Wilson@sun.com }
24476212Saw148015
24486212Saw148015 /* Rotatefd? */
24496212Saw148015 if (attr = get_attr_bool(cmd, FSA_ROTATEFD))
24506212Saw148015 flowop->fo_rotatefd = attr->attr_avd;
24516212Saw148015 else
24526212Saw148015 flowop->fo_rotatefd = avd_bool_alloc(FALSE);
24536212Saw148015
24546212Saw148015 /* SRC FD, for copies etc... */
24556212Saw148015 if (attr = get_attr_integer(cmd, FSA_SRCFD))
24566212Saw148015 flowop->fo_srcfdnumber = avd_get_int(attr->attr_avd);
24576212Saw148015
24586212Saw148015 /* Blocking operation? */
24596212Saw148015 if (attr = get_attr_bool(cmd, FSA_BLOCKING))
24606212Saw148015 flowop->fo_blocking = attr->attr_avd;
24616212Saw148015 else
24626212Saw148015 flowop->fo_blocking = avd_bool_alloc(FALSE);
24636212Saw148015
24646212Saw148015 /* Direct I/O Operation */
24656212Saw148015 if (attr = get_attr_bool(cmd, FSA_DIRECTIO))
24666212Saw148015 flowop->fo_directio = attr->attr_avd;
24676212Saw148015 else
24686212Saw148015 flowop->fo_directio = avd_bool_alloc(FALSE);
24696212Saw148015
24706212Saw148015 /* Highwater mark */
24716212Saw148015 if (attr = get_attr_integer(cmd, FSA_HIGHWATER)) {
24726212Saw148015 flowop->fo_highwater = attr->attr_avd;
24736212Saw148015 if (AVD_IS_RANDOM(attr->attr_avd)) {
24746212Saw148015 filebench_log(LOG_ERROR,
24756212Saw148015 "define flowop: Highwater attr cannot be random");
24766212Saw148015 filebench_shutdown(1);
24776212Saw148015 }
24786212Saw148015 } else {
24796212Saw148015 flowop->fo_highwater = avd_int_alloc(1);
24806212Saw148015 }
24818404SAndrew.W.Wilson@sun.com
24828404SAndrew.W.Wilson@sun.com /* find file or leaf directory by index number */
24838404SAndrew.W.Wilson@sun.com if (attr = get_attr_integer(cmd, FSA_INDEXED))
24848404SAndrew.W.Wilson@sun.com flowop->fo_fileindex = attr->attr_avd;
24858404SAndrew.W.Wilson@sun.com else
24868404SAndrew.W.Wilson@sun.com flowop->fo_fileindex = NULL;
24876212Saw148015 }
24886212Saw148015
24896550Saw148015 /*
24906550Saw148015 * defines the FLOW_MASTER flowops within a FLOW_MASTER instance of
24916550Saw148015 * a composit flowop. Default attributes from the FLOW_INNER_DEF instances
24926550Saw148015 * of the composit flowop's inner flowops are used if set. Otherwise
24936550Saw148015 * default attributes from the FLOW_MASTER instance of the composit flowop
24946550Saw148015 * are used, which may include defaults from the original FLOW_DEFINITION
24956550Saw148015 * of the composit flowop.
24966550Saw148015 */
24976550Saw148015 static void
parser_inner_flowop_define(threadflow_t * thread,flowop_t * comp0_flow,flowop_t * comp_mstr_flow)24986550Saw148015 parser_inner_flowop_define(threadflow_t *thread, flowop_t *comp0_flow,
24996550Saw148015 flowop_t *comp_mstr_flow)
25006550Saw148015 {
25016550Saw148015 flowop_t *inner_flowtype, *inner_flowop;
25026550Saw148015
25036550Saw148015 /* follow flowop list, creating composit names */
25046550Saw148015 inner_flowtype = comp0_flow->fo_comp_fops;
25056550Saw148015 comp_mstr_flow->fo_comp_fops = NULL;
25066550Saw148015
25076550Saw148015 while (inner_flowtype) {
25086550Saw148015 char fullname[MAXPATHLEN];
25096550Saw148015
25106550Saw148015 /* create composite_name.name for new flowop */
25116613Sek110237 snprintf(fullname, MAXPATHLEN, "%s.%s",
25126613Sek110237 comp_mstr_flow->fo_name, inner_flowtype->fo_name);
25136550Saw148015
25146550Saw148015 if ((inner_flowop = flowop_define(thread, fullname,
25156550Saw148015 inner_flowtype, &comp_mstr_flow->fo_comp_fops,
25166550Saw148015 FLOW_MASTER, 0)) == NULL) {
25176550Saw148015 filebench_log(LOG_ERROR,
25186550Saw148015 "define flowop: Failed to instantiate flowop %s\n",
25196550Saw148015 fullname);
25206550Saw148015 filebench_shutdown(1);
25216550Saw148015 }
25226550Saw148015
25236550Saw148015 /* if applicable, update filename attribute */
25246550Saw148015 if (inner_flowop->fo_filename) {
25256550Saw148015 char *name;
25266550Saw148015
25276550Saw148015 /* fix up avd_t */
25286550Saw148015 avd_update(&inner_flowop->fo_filename,
25296550Saw148015 comp_mstr_flow->fo_lvar_list);
25306550Saw148015
25316550Saw148015 /* see if ready to get the file or fileset */
25326550Saw148015 name = avd_get_str(inner_flowop->fo_filename);
25336550Saw148015 if (name) {
25346550Saw148015
25356550Saw148015 inner_flowop->fo_fileset = fileset_find(name);
25366550Saw148015
25376550Saw148015 if (inner_flowop->fo_fileset == NULL) {
25386550Saw148015 filebench_log(LOG_ERROR,
25396550Saw148015 "inr flowop %s: file %s not found",
25406550Saw148015 inner_flowop->fo_name, name);
25416550Saw148015 filebench_shutdown(1);
25426550Saw148015 }
25436550Saw148015 }
25446550Saw148015 }
25456550Saw148015
25466550Saw148015 /* update attributes from local variables */
25476550Saw148015 avd_update(&inner_flowop->fo_iters,
25486550Saw148015 comp_mstr_flow->fo_lvar_list);
25496550Saw148015
25506550Saw148015 /* if the inner flowop is a composit flowop, recurse */
25516550Saw148015 if (inner_flowtype->fo_type == FLOW_TYPE_COMPOSITE) {
25526550Saw148015 var_t *newlvar, *proto_lvars, *lvar_ptr;
25536550Saw148015
25546550Saw148015 proto_lvars = inner_flowop->fo_lvar_list;
25556550Saw148015 inner_flowop->fo_lvar_list = 0;
25566550Saw148015
25576550Saw148015 for (lvar_ptr = inner_flowtype->fo_lvar_list; lvar_ptr;
25586550Saw148015 lvar_ptr = lvar_ptr->var_next) {
25596550Saw148015
25606550Saw148015 if ((newlvar = var_lvar_alloc_local(
25616550Saw148015 lvar_ptr->var_name)) != NULL) {
25626550Saw148015
25636550Saw148015 add_lvar_to_list(newlvar,
25646550Saw148015 &inner_flowop->fo_lvar_list);
25656550Saw148015
25666550Saw148015 var_update_comp_lvars(newlvar,
25676550Saw148015 proto_lvars,
25686550Saw148015 comp_mstr_flow->fo_lvar_list);
25696550Saw148015 }
25706550Saw148015 }
25716550Saw148015
25726550Saw148015 parser_inner_flowop_define(thread,
25736550Saw148015 inner_flowtype,
25746550Saw148015 inner_flowop);
25756550Saw148015
25766550Saw148015 inner_flowtype = inner_flowtype->fo_exec_next;
25776550Saw148015 continue;
25786550Saw148015 }
25796550Saw148015
25806550Saw148015 avd_update(&inner_flowop->fo_iosize,
25816550Saw148015 comp_mstr_flow->fo_lvar_list);
25826550Saw148015 avd_update(&inner_flowop->fo_wss,
25836550Saw148015 comp_mstr_flow->fo_lvar_list);
25846550Saw148015 avd_update(&inner_flowop->fo_iters,
25856550Saw148015 comp_mstr_flow->fo_lvar_list);
25866550Saw148015 avd_update(&inner_flowop->fo_value,
25876550Saw148015 comp_mstr_flow->fo_lvar_list);
25886550Saw148015 avd_update(&inner_flowop->fo_random,
25896550Saw148015 comp_mstr_flow->fo_lvar_list);
25906550Saw148015 avd_update(&inner_flowop->fo_dsync,
25916550Saw148015 comp_mstr_flow->fo_lvar_list);
25926550Saw148015 avd_update(&inner_flowop->fo_rotatefd,
25936550Saw148015 comp_mstr_flow->fo_lvar_list);
25946550Saw148015 avd_update(&inner_flowop->fo_blocking,
25956550Saw148015 comp_mstr_flow->fo_lvar_list);
25966550Saw148015 avd_update(&inner_flowop->fo_directio,
25976550Saw148015 comp_mstr_flow->fo_lvar_list);
25986550Saw148015 avd_update(&inner_flowop->fo_highwater,
25996550Saw148015 comp_mstr_flow->fo_lvar_list);
26006550Saw148015
26016550Saw148015 inner_flowtype = inner_flowtype->fo_exec_next;
26026550Saw148015 }
26036550Saw148015 }
26046212Saw148015
26056212Saw148015 /*
26065184Sek110237 * Calls flowop_define() to allocate a flowop with the supplied name.
26075184Sek110237 * The allocated flowop inherits attributes from a base flowop of the
26085184Sek110237 * same type. If the new flowop has a file or fileset attribute specified,
26095184Sek110237 * it must specify a defined fileobj or fileset or an error will be logged.
26105184Sek110237 * The new flowop may also have the following attributes set by
26115184Sek110237 * the program:
26125184Sek110237 * - file size (fo_iosize)
26135184Sek110237 * - working set size (fo_wss)
26145184Sek110237 * - do random io (fo_random)
26155184Sek110237 * - do synchronous io (fo_dsync)
26165184Sek110237 * - perform each operation multiple times before advancing (fo_iter)
26175184Sek110237 * - target name (fo_targetname)
26185184Sek110237 * - An integer value (fo_value)
26195184Sek110237 * - a file descriptor (fo_fd)
26205184Sek110237 * - specify to rotate file descriptors (fo_rotatefd)
26215184Sek110237 * - a source fd (fo_srcfdnumber)
26225184Sek110237 * - specify a blocking operation (fo_blocking)
26235184Sek110237 * - specify a highwater mark (fo_highwater)
26245184Sek110237 *
26255184Sek110237 * After all the supplied attributes are stored in their respective locations
26265184Sek110237 * in the flowop object, the flowop's init function is called. No errors are
26275184Sek110237 * returned, but the filebench run will be terminated if the flowtype is not
26285184Sek110237 * specified, a name for the new flowop is not supplied, the flowop_define
26295184Sek110237 * call fails, or a file or fileset name is supplied but the corresponding
26305184Sek110237 * fileobj or fileset cannot be located.
26315184Sek110237 */
26325184Sek110237 static void
parser_flowop_define(cmd_t * cmd,threadflow_t * thread,flowop_t ** flowoplist_hdp,int category)26336212Saw148015 parser_flowop_define(cmd_t *cmd, threadflow_t *thread,
26346212Saw148015 flowop_t **flowoplist_hdp, int category)
26355184Sek110237 {
26365184Sek110237 flowop_t *flowop, *flowop_type;
26375184Sek110237 char *type = (char *)cmd->cmd_name;
26385184Sek110237 char *name;
26395184Sek110237 attr_t *attr;
26405184Sek110237
26415184Sek110237 /* Get the inherited flowop */
26425184Sek110237 flowop_type = flowop_find(type);
26435184Sek110237 if (flowop_type == NULL) {
26445184Sek110237 filebench_log(LOG_ERROR,
26455184Sek110237 "define flowop: flowop type %s not found",
26465184Sek110237 type);
26475184Sek110237 filebench_shutdown(1);
26485184Sek110237 }
26495184Sek110237
26505184Sek110237 /* Get the name of the flowop */
26515184Sek110237 if (attr = get_attr(cmd, FSA_NAME)) {
26526212Saw148015 name = avd_get_str(attr->attr_avd);
26535184Sek110237 } else {
26545184Sek110237 filebench_log(LOG_ERROR,
26555184Sek110237 "define flowop: flowop %s specifies no name",
26565184Sek110237 flowop_type->fo_name);
26575184Sek110237 filebench_shutdown(1);
26585184Sek110237 }
26595184Sek110237
26605184Sek110237 if ((flowop = flowop_define(thread, name,
26616550Saw148015 flowop_type, flowoplist_hdp, category, 0)) == NULL) {
26625184Sek110237 filebench_log(LOG_ERROR,
26635184Sek110237 "define flowop: Failed to instantiate flowop %s\n",
26645184Sek110237 cmd->cmd_name);
26655184Sek110237 filebench_shutdown(1);
26665184Sek110237 }
26675184Sek110237
26685184Sek110237 /* Iterations */
26695184Sek110237 if (attr = get_attr_integer(cmd, FSA_ITERS))
26706212Saw148015 flowop->fo_iters = attr->attr_avd;
26715184Sek110237 else
26726212Saw148015 flowop->fo_iters = avd_int_alloc(1);
26736212Saw148015
26746550Saw148015
26756550Saw148015 /* if this is a use of a composit flowop, create inner FLOW MASTERS */
26766550Saw148015 if (flowop_type->fo_type == FLOW_TYPE_COMPOSITE) {
26776550Saw148015 get_attr_lvars(cmd, flowop);
26786550Saw148015 if (category == FLOW_MASTER)
26796550Saw148015 parser_inner_flowop_define(thread,
26806550Saw148015 flowop_type, flowop);
26816550Saw148015 }
26826550Saw148015 else {
26836550Saw148015 parser_flowop_get_attrs(cmd, flowop);
26846550Saw148015 }
26855184Sek110237 }
26865184Sek110237
26876550Saw148015 static void
parser_composite_flowop_define(cmd_t * cmd)26886550Saw148015 parser_composite_flowop_define(cmd_t *cmd)
26896550Saw148015 {
26906550Saw148015 flowop_t *flowop;
26916550Saw148015 cmd_t *inner_cmd;
26926550Saw148015 char *name;
26936550Saw148015 attr_t *attr;
26946550Saw148015
26956550Saw148015 /* Get the name of the flowop */
26966550Saw148015 if (attr = get_attr(cmd, FSA_NAME)) {
26976550Saw148015 name = avd_get_str(attr->attr_avd);
26986550Saw148015 } else {
26996550Saw148015 filebench_log(LOG_ERROR,
27006550Saw148015 "define flowop: Composit flowop specifies no name");
27016550Saw148015
27026550Saw148015 filebench_shutdown(1);
27036550Saw148015 }
27046550Saw148015
27056550Saw148015 if ((flowop = flowop_new_composite_define(name)) == NULL) {
27066550Saw148015 filebench_log(LOG_ERROR,
27076550Saw148015 "define flowop: Failed to instantiate flowop %s\n",
27086550Saw148015 cmd->cmd_name);
27096550Saw148015 filebench_shutdown(1);
27106550Saw148015 }
27116550Saw148015
27126550Saw148015 /* place any local var_t variables on the flowop's local list */
27136550Saw148015 get_attr_lvars(cmd, flowop);
27146550Saw148015
27156550Saw148015 /* Iterations */
27166550Saw148015 if (attr = get_attr_integer(cmd, FSA_ITERS))
27176550Saw148015 flowop->fo_iters = attr->attr_avd;
27186550Saw148015 else
27196550Saw148015 flowop->fo_iters = avd_int_alloc(1);
27206550Saw148015
27216550Saw148015 /* define inner flowops */
27226550Saw148015 for (inner_cmd = cmd->cmd_list; inner_cmd != NULL;
27236550Saw148015 inner_cmd = inner_cmd->cmd_next) {
27246550Saw148015 parser_flowop_define(inner_cmd, NULL,
27256550Saw148015 &flowop->fo_comp_fops, FLOW_INNER_DEF);
27266550Saw148015 }
27276550Saw148015 }
27286550Saw148015
27296550Saw148015
27305184Sek110237 /*
27315184Sek110237 * Calls fileset_define() to allocate a fileset with the supplied name and
27326212Saw148015 * initializes the fileset's pathname attribute, and optionally the
27336212Saw148015 * fileset_cached, fileset_reuse, fileset_prealloc and fileset_size attributes.
27345673Saw148015 *
27355184Sek110237 */
27365673Saw148015 static fileset_t *
parser_fileset_define_common(cmd_t * cmd)27375673Saw148015 parser_fileset_define_common(cmd_t *cmd)
27385184Sek110237 {
27395184Sek110237 fileset_t *fileset;
27406212Saw148015 avd_t name;
27415184Sek110237 attr_t *attr;
27426212Saw148015 avd_t pathname;
27435184Sek110237
27448615SAndrew.W.Wilson@sun.com /*
27458615SAndrew.W.Wilson@sun.com * Make sure all plugin flowops are initialized.
27468615SAndrew.W.Wilson@sun.com * Defaults to local fs for now
27478615SAndrew.W.Wilson@sun.com */
27488615SAndrew.W.Wilson@sun.com flowop_plugin_flowinit();
27498615SAndrew.W.Wilson@sun.com
27505184Sek110237 /* Get the name of the file */
27518404SAndrew.W.Wilson@sun.com if (attr = get_attr_fileset(cmd, FSA_NAME)) {
27526212Saw148015 name = attr->attr_avd;
27535184Sek110237 } else {
27545184Sek110237 filebench_log(LOG_ERROR,
27555673Saw148015 "define fileset: file or fileset specifies no name");
27565673Saw148015 return (NULL);
27575184Sek110237 }
27585184Sek110237
27595184Sek110237 if ((fileset = fileset_define(name)) == NULL) {
27605184Sek110237 filebench_log(LOG_ERROR,
27615184Sek110237 "define file: failed to instantiate file %s\n",
27626212Saw148015 avd_get_str(name));
27635673Saw148015 return (NULL);
27645184Sek110237 }
27655184Sek110237
27665184Sek110237 /* Get the pathname from attribute */
27675184Sek110237 if ((attr = get_attr(cmd, FSA_PATH)) == NULL) {
27685184Sek110237 filebench_log(LOG_ERROR, "define file: no pathname specified");
27695673Saw148015 return (NULL);
27705184Sek110237 }
27715184Sek110237
27725184Sek110237 /* Expand variables in pathname */
27735673Saw148015 if ((pathname = parser_list2varstring(attr->attr_param_list))
27745673Saw148015 == NULL) {
27755184Sek110237 filebench_log(LOG_ERROR, "Cannot interpret path");
27765673Saw148015 return (NULL);
27775184Sek110237 }
27785184Sek110237
27795184Sek110237 fileset->fs_path = pathname;
27805184Sek110237
27817736SAndrew.W.Wilson@sun.com /* How much should we preallocate? */
27827736SAndrew.W.Wilson@sun.com if ((attr = get_attr_integer(cmd, FSA_PREALLOC)) &&
27837736SAndrew.W.Wilson@sun.com attr->attr_avd) {
27847736SAndrew.W.Wilson@sun.com if (AVD_IS_RANDOM(attr->attr_avd)) {
27857736SAndrew.W.Wilson@sun.com filebench_log(LOG_ERROR,
27867736SAndrew.W.Wilson@sun.com "define fileset: Prealloc attr cannot be random");
27877736SAndrew.W.Wilson@sun.com filebench_shutdown(1);
27887736SAndrew.W.Wilson@sun.com }
27897736SAndrew.W.Wilson@sun.com fileset->fs_preallocpercent = attr->attr_avd;
27907736SAndrew.W.Wilson@sun.com } else if (attr && !attr->attr_avd) {
27917736SAndrew.W.Wilson@sun.com fileset->fs_preallocpercent = avd_int_alloc(100);
27927736SAndrew.W.Wilson@sun.com } else {
27937736SAndrew.W.Wilson@sun.com fileset->fs_preallocpercent = avd_int_alloc(0);
27947736SAndrew.W.Wilson@sun.com }
27957736SAndrew.W.Wilson@sun.com
27967736SAndrew.W.Wilson@sun.com /* Should we preallocate? */
27977736SAndrew.W.Wilson@sun.com if (attr = get_attr_bool(cmd, FSA_PREALLOC))
27987736SAndrew.W.Wilson@sun.com fileset->fs_prealloc = attr->attr_avd;
27997736SAndrew.W.Wilson@sun.com else
28007736SAndrew.W.Wilson@sun.com fileset->fs_prealloc = avd_bool_alloc(FALSE);
28017736SAndrew.W.Wilson@sun.com
28025673Saw148015 /* Should we prealloc in parallel? */
28036212Saw148015 if (attr = get_attr_bool(cmd, FSA_PARALLOC))
28046212Saw148015 fileset->fs_paralloc = attr->attr_avd;
28056212Saw148015 else
28066212Saw148015 fileset->fs_paralloc = avd_bool_alloc(FALSE);
28075673Saw148015
28089326SAndrew.W.Wilson@sun.com /* Should we allow writes to the file? */
28099326SAndrew.W.Wilson@sun.com if (attr = get_attr_bool(cmd, FSA_READONLY))
28109326SAndrew.W.Wilson@sun.com fileset->fs_readonly = attr->attr_avd;
28119326SAndrew.W.Wilson@sun.com else
28129326SAndrew.W.Wilson@sun.com fileset->fs_readonly = avd_bool_alloc(FALSE);
28139326SAndrew.W.Wilson@sun.com
28145673Saw148015 /* Should we reuse the existing file? */
28157736SAndrew.W.Wilson@sun.com if (attr = get_attr_bool(cmd, FSA_REUSE))
28166212Saw148015 fileset->fs_reuse = attr->attr_avd;
28177736SAndrew.W.Wilson@sun.com else
28186212Saw148015 fileset->fs_reuse = avd_bool_alloc(FALSE);
28195673Saw148015
28209326SAndrew.W.Wilson@sun.com /* Should we check for files actual existance? */
28219326SAndrew.W.Wilson@sun.com if (attr = get_attr_bool(cmd, FSA_TRUSTTREE))
28229326SAndrew.W.Wilson@sun.com fileset->fs_trust_tree = attr->attr_avd;
28239326SAndrew.W.Wilson@sun.com else
28249326SAndrew.W.Wilson@sun.com fileset->fs_trust_tree = avd_bool_alloc(FALSE);
28259326SAndrew.W.Wilson@sun.com
28265184Sek110237 /* Should we leave in cache? */
28277736SAndrew.W.Wilson@sun.com if (attr = get_attr_bool(cmd, FSA_CACHED))
28286212Saw148015 fileset->fs_cached = attr->attr_avd;
28297736SAndrew.W.Wilson@sun.com else
28306212Saw148015 fileset->fs_cached = avd_bool_alloc(FALSE);
28315184Sek110237
28325673Saw148015 /* Get the mean or absolute size of the file */
28337736SAndrew.W.Wilson@sun.com if (attr = get_attr_integer(cmd, FSA_SIZE))
28346212Saw148015 fileset->fs_size = attr->attr_avd;
28357736SAndrew.W.Wilson@sun.com else
28366212Saw148015 fileset->fs_size = avd_int_alloc(0);
28375673Saw148015
28385673Saw148015 return (fileset);
28395673Saw148015 }
28405673Saw148015
28415673Saw148015 /*
28425673Saw148015 * Calls parser_fileset_define_common() to allocate a fileset with
28437736SAndrew.W.Wilson@sun.com * one entry and optionally the fileset_prealloc. sets the fileset_entries,
28447736SAndrew.W.Wilson@sun.com * fileset_dirwidth, fileset_dirgamma, and fileset_sizegamma attributes
28455673Saw148015 * to appropriate values for emulating the old "fileobj" entity
28465673Saw148015 */
28475673Saw148015 static void
parser_file_define(cmd_t * cmd)28485673Saw148015 parser_file_define(cmd_t *cmd)
28495673Saw148015 {
28505673Saw148015 fileset_t *fileset;
28515673Saw148015 attr_t *attr;
28525673Saw148015
28535673Saw148015 if ((fileset = parser_fileset_define_common(cmd)) == NULL) {
28545673Saw148015 filebench_log(LOG_ERROR,
28555673Saw148015 "define file: failed to instantiate file");
28565673Saw148015 filebench_shutdown(1);
28575673Saw148015 return;
28585673Saw148015 }
28595673Saw148015
28605673Saw148015 /* fileset is emulating a single file */
28615673Saw148015 fileset->fs_attrs = FILESET_IS_FILE;
28625673Saw148015
28635673Saw148015 /* Set the size of the fileset to 1 */
28646212Saw148015 fileset->fs_entries = avd_int_alloc(1);
28655673Saw148015
28665673Saw148015 /* Set the mean dir width to more than 1 */
28676212Saw148015 fileset->fs_dirwidth = avd_int_alloc(10);
28685673Saw148015
28695673Saw148015 /* Set the dir and size gammas to 0 */
28706212Saw148015 fileset->fs_dirgamma = avd_int_alloc(0);
28716212Saw148015 fileset->fs_sizegamma = avd_int_alloc(0);
28725673Saw148015 }
28735673Saw148015
28745673Saw148015 /*
28755673Saw148015 * Calls parser_fileset_define_common() to allocate a fileset with the
28766212Saw148015 * supplied name and initializes the fileset's fileset_preallocpercent,
28776212Saw148015 * fileset_prealloc, fileset_entries, fileset_dirwidth, fileset_dirgamma,
28786212Saw148015 * and fileset_sizegamma attributes.
28795673Saw148015 */
28805673Saw148015 static void
parser_fileset_define(cmd_t * cmd)28815673Saw148015 parser_fileset_define(cmd_t *cmd)
28825673Saw148015 {
28835673Saw148015 fileset_t *fileset;
28845673Saw148015 attr_t *attr;
28855673Saw148015
28865673Saw148015 if ((fileset = parser_fileset_define_common(cmd)) == NULL) {
28875673Saw148015 filebench_log(LOG_ERROR,
28885673Saw148015 "define fileset: failed to instantiate fileset");
28895673Saw148015 filebench_shutdown(1);
28905673Saw148015 return;
28915673Saw148015 }
28925673Saw148015 /* Get the number of files in the fileset */
28935184Sek110237 if (attr = get_attr_integer(cmd, FSA_ENTRIES)) {
28946212Saw148015 fileset->fs_entries = attr->attr_avd;
28955184Sek110237 } else {
28966212Saw148015 fileset->fs_entries = avd_int_alloc(0);
28975184Sek110237 }
28985184Sek110237
28997946SAndrew.W.Wilson@sun.com /* Get the number of leafdirs in the fileset */
29007946SAndrew.W.Wilson@sun.com if (attr = get_attr_integer(cmd, FSA_LEAFDIRS)) {
29017946SAndrew.W.Wilson@sun.com fileset->fs_leafdirs = attr->attr_avd;
29027946SAndrew.W.Wilson@sun.com } else {
29037946SAndrew.W.Wilson@sun.com fileset->fs_leafdirs = avd_int_alloc(0);
29047946SAndrew.W.Wilson@sun.com }
29057946SAndrew.W.Wilson@sun.com
29067946SAndrew.W.Wilson@sun.com if ((avd_get_int(fileset->fs_entries) == 0) &&
29077946SAndrew.W.Wilson@sun.com (avd_get_int(fileset->fs_leafdirs) == 0)) {
29087946SAndrew.W.Wilson@sun.com filebench_log(LOG_ERROR, "Fileset has no files or leafdirs");
29097946SAndrew.W.Wilson@sun.com }
29107946SAndrew.W.Wilson@sun.com
29115184Sek110237 /* Get the mean dir width of the fileset */
29125184Sek110237 if (attr = get_attr_integer(cmd, FSA_DIRWIDTH)) {
29136212Saw148015 fileset->fs_dirwidth = attr->attr_avd;
29145184Sek110237 } else {
29155184Sek110237 filebench_log(LOG_ERROR, "Fileset has zero directory width");
29166212Saw148015 fileset->fs_dirwidth = avd_int_alloc(0);
29175184Sek110237 }
29185184Sek110237
29196212Saw148015 /* Get the random variable for dir depth, if supplied */
29206212Saw148015 if (attr = get_attr_integer(cmd, FSA_DIRDEPTHRV)) {
29216212Saw148015 if (!AVD_IS_RANDOM(attr->attr_avd)) {
29226212Saw148015 filebench_log(LOG_ERROR,
29236212Saw148015 "Define fileset: dirdepthrv must be random var");
29246212Saw148015 filebench_shutdown(1);
29256212Saw148015 }
29266212Saw148015 fileset->fs_dirdepthrv = attr->attr_avd;
29276212Saw148015 } else {
29286212Saw148015 fileset->fs_dirdepthrv = NULL;
29296212Saw148015 }
29306212Saw148015
29316212Saw148015 /* Get the gamma value for dir depth distributions */
29325184Sek110237 if (attr = get_attr_integer(cmd, FSA_DIRGAMMA)) {
29336212Saw148015 if (AVD_IS_RANDOM(attr->attr_avd)) {
29346212Saw148015 filebench_log(LOG_ERROR,
29356212Saw148015 "Define fileset: dirgamma attr cannot be random");
29366212Saw148015 filebench_shutdown(1);
29376212Saw148015 }
29386212Saw148015 fileset->fs_dirgamma = attr->attr_avd;
29395184Sek110237 } else
29406212Saw148015 fileset->fs_dirgamma = avd_int_alloc(1500);
29415184Sek110237
29425184Sek110237 /* Get the gamma value for dir width distributions */
29435184Sek110237 if (attr = get_attr_integer(cmd, FSA_FILESIZEGAMMA)) {
29446212Saw148015 if (AVD_IS_RANDOM(attr->attr_avd)) {
29456212Saw148015 filebench_log(LOG_ERROR,
29466212Saw148015 "Define fileset: filesizegamma cannot be random");
29476212Saw148015 filebench_shutdown(1);
29486212Saw148015 }
29496212Saw148015 fileset->fs_sizegamma = attr->attr_avd;
29505184Sek110237 } else
29516212Saw148015 fileset->fs_sizegamma = avd_int_alloc(1500);
29525184Sek110237 }
29535184Sek110237
29545184Sek110237 /*
29555184Sek110237 * Creates and starts all defined procflow processes. The call to
29565184Sek110237 * procflow_init() results in creation of the requested number of
29575184Sek110237 * process instances for each previously defined procflow. The
29585184Sek110237 * child processes exec() a new instance of filebench, passing it
29595184Sek110237 * the instance number and address of the shared memory region.
29605184Sek110237 * The child processes will then create their threads and flowops.
29615184Sek110237 * The routine then unlocks the run_lock to allow all the processes'
29625184Sek110237 * threads to start and waits for all of them to begin execution.
29635184Sek110237 * Finally, it records the start time and resets the event generation
29645184Sek110237 * system.
29655184Sek110237 */
29665184Sek110237 static void
parser_proc_create(cmd_t * cmd)29675184Sek110237 parser_proc_create(cmd_t *cmd)
29685184Sek110237 {
29696084Saw148015 filebench_shm->shm_1st_err = 0;
29709326SAndrew.W.Wilson@sun.com filebench_shm->shm_f_abort = FILEBENCH_OK;
29719326SAndrew.W.Wilson@sun.com
29725184Sek110237 if (procflow_init() != 0) {
29735184Sek110237 filebench_log(LOG_ERROR, "Failed to create processes\n");
29745184Sek110237 filebench_shutdown(1);
29755184Sek110237 }
29765184Sek110237
29775184Sek110237 /* Release the read lock, allowing threads to start */
29786391Saw148015 (void) pthread_rwlock_unlock(&filebench_shm->shm_run_lock);
29795184Sek110237
29805184Sek110237 /* Wait for all threads to start */
29815184Sek110237 if (procflow_allstarted() != 0) {
29825184Sek110237 filebench_log(LOG_ERROR, "Could not start run");
29835184Sek110237 return;
29845184Sek110237 }
29855184Sek110237
29865184Sek110237
29875184Sek110237 if (filebench_shm->shm_required &&
29885184Sek110237 (ipc_ismcreate(filebench_shm->shm_required) < 0)) {
29895184Sek110237 filebench_log(LOG_ERROR, "Could not allocate shared memory");
29905184Sek110237 return;
29915184Sek110237 }
29925184Sek110237
29936305Saw148015 filebench_shm->shm_starttime = gethrtime();
29945184Sek110237 eventgen_reset();
29955184Sek110237 }
29965184Sek110237
29975184Sek110237 /*
29985673Saw148015 * Calls fileset_createset() to populate all files and filesets and
29995673Saw148015 * create all associated, initially existant, files and subdirectories.
30005184Sek110237 * If errors are encountered, calls filebench_shutdown()
30015184Sek110237 * to exit filebench.
30025184Sek110237 */
30035184Sek110237 static void
parser_fileset_create(cmd_t * cmd)30045184Sek110237 parser_fileset_create(cmd_t *cmd)
30055184Sek110237 {
30065673Saw148015 if (!filecreate_done) {
30075673Saw148015 filecreate_done = 1;
30086212Saw148015
30096212Saw148015 /* initialize the random number system first */
30106212Saw148015 randdist_init();
30116212Saw148015
30126212Saw148015 /* create all the filesets */
30135673Saw148015 if (fileset_createset(NULL) != 0) {
30145673Saw148015 filebench_log(LOG_ERROR, "Failed to create filesets");
30155673Saw148015 filebench_shutdown(1);
30165673Saw148015 }
30175673Saw148015 } else {
30185673Saw148015 filebench_log(LOG_INFO,
30195673Saw148015 "Attempting to create fileset more than once, ignoring");
30205184Sek110237 }
30215673Saw148015
30225184Sek110237 }
30235184Sek110237
30245184Sek110237 /*
30259356SAndrew.W.Wilson@sun.com * Deletes the files and directories that represent files and filesets on the
30269356SAndrew.W.Wilson@sun.com * storage medium.
30279356SAndrew.W.Wilson@sun.com */
30289356SAndrew.W.Wilson@sun.com static void
parser_fileset_shutdown(cmd_t * cmd)30299356SAndrew.W.Wilson@sun.com parser_fileset_shutdown(cmd_t *cmd)
30309356SAndrew.W.Wilson@sun.com {
30319356SAndrew.W.Wilson@sun.com filebench_log(LOG_INFO, "Shutting down filesets");
30329356SAndrew.W.Wilson@sun.com fileset_delete_all_filesets();
30339356SAndrew.W.Wilson@sun.com }
30349356SAndrew.W.Wilson@sun.com
30359356SAndrew.W.Wilson@sun.com /*
30365184Sek110237 * Shuts down all processes and their associated threads. When finished
30375184Sek110237 * it deletes interprocess shared memory and resets the event generator.
30385184Sek110237 * It does not exit the filebench program though.
30395184Sek110237 */
30405184Sek110237 static void
parser_proc_shutdown(cmd_t * cmd)30415184Sek110237 parser_proc_shutdown(cmd_t *cmd)
30425184Sek110237 {
30435184Sek110237 filebench_log(LOG_INFO, "Shutting down processes");
30445673Saw148015 filecreate_done = 0;
30455184Sek110237 procflow_shutdown();
30465184Sek110237 if (filebench_shm->shm_required)
30475184Sek110237 ipc_ismdelete();
30485184Sek110237 eventgen_reset();
30495184Sek110237 }
30505184Sek110237
30515184Sek110237 /*
30525184Sek110237 * Ends filebench run after first destoring any interprocess
30535184Sek110237 * shared memory. The call to filebench_shutdown()
30545184Sek110237 * also causes filebench to exit.
30555184Sek110237 */
30565184Sek110237 static void
parser_filebench_shutdown(cmd_t * cmd)30575184Sek110237 parser_filebench_shutdown(cmd_t *cmd)
30585184Sek110237 {
30596391Saw148015 int f_abort = filebench_shm->shm_f_abort;
30606391Saw148015
30616750Sek110237 ipc_fini();
30626391Saw148015
30636391Saw148015 if (f_abort == FILEBENCH_ABORT_ERROR)
30646391Saw148015 filebench_shutdown(1);
30656391Saw148015 else
30666391Saw148015 filebench_shutdown(0);
30675184Sek110237 }
30685184Sek110237
30695184Sek110237 /*
30706084Saw148015 * This is Used for timing runs.Pauses the master thread in one second
30716084Saw148015 * intervals until the supplied ptime runs out or the f_abort flag
30726084Saw148015 * is raised. If given a time of zero or less, or the mode is stop on
30736084Saw148015 * lack of resources, it will pause until f_abort is raised.
30745184Sek110237 */
30759326SAndrew.W.Wilson@sun.com static int
parser_pause(int ptime)30766084Saw148015 parser_pause(int ptime)
30775184Sek110237 {
30786084Saw148015 int timeslept = 0;
30796084Saw148015
30806084Saw148015 if ((filebench_shm->shm_rmode == FILEBENCH_MODE_TIMEOUT) &&
30816084Saw148015 (ptime > 0)) {
30826084Saw148015 while (timeslept < ptime) {
30836084Saw148015 (void) sleep(1);
30846084Saw148015 timeslept++;
30856391Saw148015 if (filebench_shm->shm_f_abort)
30866084Saw148015 break;
30876084Saw148015 }
30886084Saw148015 } else {
30896084Saw148015 /* initial runtime of 0 means run till abort */
30906084Saw148015 /* CONSTCOND */
30916084Saw148015 while (1) {
30926084Saw148015 (void) sleep(1);
30936084Saw148015 timeslept++;
30946391Saw148015 if (filebench_shm->shm_f_abort)
30956084Saw148015 break;
30966084Saw148015 }
30975184Sek110237 }
30989326SAndrew.W.Wilson@sun.com return (timeslept);
30995184Sek110237 }
31005184Sek110237
31015184Sek110237 /*
31025184Sek110237 * Do a file bench run. Calls routines to create file sets, files, and
31035184Sek110237 * processes. It resets the statistics counters, then sleeps for the runtime
31045184Sek110237 * passed as an argument to it on the command line in 1 second increments.
31055184Sek110237 * When it is finished sleeping, it collects a snapshot of the statistics
31065184Sek110237 * and ends the run.
31075184Sek110237 */
31085184Sek110237 static void
parser_run(cmd_t * cmd)31095184Sek110237 parser_run(cmd_t *cmd)
31105184Sek110237 {
31115184Sek110237 int runtime;
31129326SAndrew.W.Wilson@sun.com int timeslept;
31135184Sek110237
31145184Sek110237 runtime = cmd->cmd_qty;
31156084Saw148015
31165184Sek110237 parser_fileset_create(cmd);
31175184Sek110237 parser_proc_create(cmd);
31185184Sek110237
31195184Sek110237 /* check for startup errors */
31206391Saw148015 if (filebench_shm->shm_f_abort)
31215184Sek110237 return;
31225184Sek110237
31235184Sek110237 filebench_log(LOG_INFO, "Running...");
31245184Sek110237 stats_clear();
31256084Saw148015
31269326SAndrew.W.Wilson@sun.com timeslept = parser_pause(runtime);
31279326SAndrew.W.Wilson@sun.com
31289326SAndrew.W.Wilson@sun.com filebench_log(LOG_INFO, "Run took %d seconds...", timeslept);
31295184Sek110237 parser_statssnap(cmd);
31305184Sek110237 parser_proc_shutdown(cmd);
31315184Sek110237 }
31325184Sek110237
31335184Sek110237 /*
31345184Sek110237 * Similar to parser_run, but gets the sleep time from a variable
31355184Sek110237 * whose name is supplied as an argument to the command.
31365184Sek110237 */
31375184Sek110237 static void
parser_run_variable(cmd_t * cmd)31385184Sek110237 parser_run_variable(cmd_t *cmd)
31395184Sek110237 {
31406212Saw148015 avd_t integer = var_ref_attr(cmd->cmd_tgt1);
31415184Sek110237 int runtime;
31429326SAndrew.W.Wilson@sun.com int timeslept;
31435184Sek110237
31445184Sek110237 if (integer == NULL) {
31455184Sek110237 filebench_log(LOG_ERROR, "Unknown variable %s",
31465184Sek110237 cmd->cmd_tgt1);
31475184Sek110237 return;
31485184Sek110237 }
31495184Sek110237
31506212Saw148015 runtime = avd_get_int(integer);
31515184Sek110237
31525184Sek110237 /* check for startup errors */
31536391Saw148015 if (filebench_shm->shm_f_abort)
31545184Sek110237 return;
31555184Sek110237
31565184Sek110237 filebench_log(LOG_INFO, "Running...");
31575184Sek110237 stats_clear();
31586084Saw148015
31599326SAndrew.W.Wilson@sun.com timeslept = parser_pause(runtime);
31609326SAndrew.W.Wilson@sun.com
31619326SAndrew.W.Wilson@sun.com filebench_log(LOG_INFO, "Run took %d seconds...", timeslept);
31625184Sek110237 parser_statssnap(cmd);
31636084Saw148015 parser_proc_shutdown(cmd);
31645184Sek110237 }
31655184Sek110237
31665184Sek110237 char *usagestr = NULL;
31675184Sek110237
31685184Sek110237 /*
31695184Sek110237 * Prints usage string if defined, else just a message requesting load of a
31705184Sek110237 * personality.
31715184Sek110237 */
31725184Sek110237 static void
parser_help(cmd_t * cmd)31735184Sek110237 parser_help(cmd_t *cmd)
31745184Sek110237 {
31755184Sek110237 if (usagestr) {
31765184Sek110237 filebench_log(LOG_INFO, "%s", usagestr);
31775184Sek110237 } else {
31785184Sek110237 filebench_log(LOG_INFO,
31795184Sek110237 "load <personality> (ls "
31809513SAndrew.W.Wilson@sun.com "%s/workloads for list)", fbbasepath);
31815184Sek110237 }
31825184Sek110237 }
31835184Sek110237
31845184Sek110237 char *varstr = NULL;
31855184Sek110237
31865184Sek110237 /*
31875184Sek110237 * Prints the string of all var definitions, if there is one.
31885184Sek110237 */
31895184Sek110237 static void
parser_printvars(cmd_t * cmd)31905184Sek110237 parser_printvars(cmd_t *cmd)
31915184Sek110237 {
31925184Sek110237 char *str, *c;
31935184Sek110237
31945184Sek110237 if (varstr) {
31955184Sek110237 str = strdup(varstr);
31965184Sek110237 for (c = str; *c != '\0'; c++) {
31975184Sek110237 if ((char)*c == '$')
31985184Sek110237 *c = ' ';
31995184Sek110237 }
32005184Sek110237 filebench_log(LOG_INFO, "%s", str);
32015184Sek110237 free(str);
32025184Sek110237 }
32035184Sek110237 }
32045184Sek110237
32055184Sek110237 /*
32067736SAndrew.W.Wilson@sun.com * Establishes multi-client synchronization socket with synch server.
32077736SAndrew.W.Wilson@sun.com */
32087736SAndrew.W.Wilson@sun.com static void
parser_enable_mc(cmd_t * cmd)32097736SAndrew.W.Wilson@sun.com parser_enable_mc(cmd_t *cmd)
32107736SAndrew.W.Wilson@sun.com {
32117736SAndrew.W.Wilson@sun.com attr_t *attr;
32127736SAndrew.W.Wilson@sun.com char *master;
32137736SAndrew.W.Wilson@sun.com char *client;
32147736SAndrew.W.Wilson@sun.com
32157736SAndrew.W.Wilson@sun.com if (attr= get_attr(cmd, FSA_MASTER)) {
32167736SAndrew.W.Wilson@sun.com master = avd_get_str(attr->attr_avd);
32177736SAndrew.W.Wilson@sun.com } else {
32187736SAndrew.W.Wilson@sun.com filebench_log(LOG_ERROR,
32197736SAndrew.W.Wilson@sun.com "enable multi: no master specified");
32207736SAndrew.W.Wilson@sun.com return;
32217736SAndrew.W.Wilson@sun.com }
32227736SAndrew.W.Wilson@sun.com
32237736SAndrew.W.Wilson@sun.com if (attr= get_attr(cmd, FSA_CLIENT)) {
32247736SAndrew.W.Wilson@sun.com client = avd_get_str(attr->attr_avd);
32257736SAndrew.W.Wilson@sun.com } else {
32267736SAndrew.W.Wilson@sun.com filebench_log(LOG_ERROR,
32277736SAndrew.W.Wilson@sun.com "enable multi: no client specified");
32287736SAndrew.W.Wilson@sun.com return;
32297736SAndrew.W.Wilson@sun.com }
32307736SAndrew.W.Wilson@sun.com
32317736SAndrew.W.Wilson@sun.com mc_sync_open_sock(master, 8001, client);
32327736SAndrew.W.Wilson@sun.com }
32337736SAndrew.W.Wilson@sun.com
32347736SAndrew.W.Wilson@sun.com /*
32357736SAndrew.W.Wilson@sun.com * Exchanges multi-client synchronization message with synch server.
32367736SAndrew.W.Wilson@sun.com */
32377736SAndrew.W.Wilson@sun.com static void
parser_domultisync(cmd_t * cmd)32387736SAndrew.W.Wilson@sun.com parser_domultisync(cmd_t *cmd)
32397736SAndrew.W.Wilson@sun.com {
32407736SAndrew.W.Wilson@sun.com attr_t *attr;
32417736SAndrew.W.Wilson@sun.com fbint_t value;
32427736SAndrew.W.Wilson@sun.com
32437736SAndrew.W.Wilson@sun.com if (attr = get_attr(cmd, FSA_VALUE))
32447736SAndrew.W.Wilson@sun.com value = avd_get_int(attr->attr_avd);
32457736SAndrew.W.Wilson@sun.com else
32467736SAndrew.W.Wilson@sun.com value = 1;
32477736SAndrew.W.Wilson@sun.com
32487736SAndrew.W.Wilson@sun.com mc_sync_synchronize((int)value);
32497736SAndrew.W.Wilson@sun.com }
32507736SAndrew.W.Wilson@sun.com
32517736SAndrew.W.Wilson@sun.com /*
32525184Sek110237 * Used by the SET command to add a var and default value string to the
32535184Sek110237 * varstr string. It allocates a new, larger varstr string, copies the
32545184Sek110237 * old contents of varstr into it, then adds the new var string on the end.
32555184Sek110237 */
32565184Sek110237 static void
parser_vars(cmd_t * cmd)32575184Sek110237 parser_vars(cmd_t *cmd)
32585184Sek110237 {
32595184Sek110237 char *string = cmd->cmd_tgt1;
32605184Sek110237 char *newvars;
32615184Sek110237
32625184Sek110237 if (string == NULL)
32635184Sek110237 return;
32645184Sek110237
32655184Sek110237 if (dofile)
32665184Sek110237 return;
32675184Sek110237
32685184Sek110237 if (varstr == NULL) {
32695184Sek110237 newvars = malloc(strlen(string) + 2);
32705184Sek110237 *newvars = 0;
32715184Sek110237 } else {
32725184Sek110237 newvars = malloc(strlen(varstr) + strlen(string) + 2);
32735184Sek110237 (void) strcpy(newvars, varstr);
32745184Sek110237 }
32755184Sek110237 (void) strcat(newvars, string);
32765184Sek110237 (void) strcat(newvars, " ");
32775184Sek110237
32785184Sek110237 if (varstr)
32795184Sek110237 free(varstr);
32805184Sek110237
32815184Sek110237 varstr = newvars;
32825184Sek110237 }
32835184Sek110237
32845184Sek110237 /*
32856212Saw148015 * used by the set command to set the integer part of a regular
32866212Saw148015 * variable, or the appropriate field of a random variable
32876212Saw148015 */
32886212Saw148015 static void
parser_set_integer(cmd_t * cmd)3289*9801SAndrew.W.Wilson@sun.com parser_set_integer(cmd_t *cmd)
32906212Saw148015 {
3291*9801SAndrew.W.Wilson@sun.com var_assign_integer(cmd->cmd_tgt1, cmd->cmd_qty);
32926212Saw148015 }
32936212Saw148015
32946212Saw148015 /*
32956212Saw148015 * used by the set command to set the integer part of a regular
32966212Saw148015 * variable from another variable, or the appropriate field of a
32976212Saw148015 * random variable from another variable
32986212Saw148015 */
32996212Saw148015 static void
parser_set_var(cmd_t * cmd)3300*9801SAndrew.W.Wilson@sun.com parser_set_var(cmd_t *cmd)
3301*9801SAndrew.W.Wilson@sun.com {
3302*9801SAndrew.W.Wilson@sun.com var_assign_var(cmd->cmd_tgt1, cmd->cmd_tgt2);
3303*9801SAndrew.W.Wilson@sun.com }
3304*9801SAndrew.W.Wilson@sun.com
3305*9801SAndrew.W.Wilson@sun.com /*
3306*9801SAndrew.W.Wilson@sun.com * Used by the set command to set up for a binary operation of a
3307*9801SAndrew.W.Wilson@sun.com * variable from a var, with an integer
3308*9801SAndrew.W.Wilson@sun.com */
3309*9801SAndrew.W.Wilson@sun.com static void
parser_set_var_op_int(cmd_t * cmd)3310*9801SAndrew.W.Wilson@sun.com parser_set_var_op_int(cmd_t *cmd)
3311*9801SAndrew.W.Wilson@sun.com {
3312*9801SAndrew.W.Wilson@sun.com printf("parser_set_var_op_int: Called\n");
3313*9801SAndrew.W.Wilson@sun.com switch (cmd->cmd_subtype) {
3314*9801SAndrew.W.Wilson@sun.com case FSK_PLUS:
3315*9801SAndrew.W.Wilson@sun.com var_assign_op_var_int(cmd->cmd_tgt1, VAR_IND_INT_SUM_IV,
3316*9801SAndrew.W.Wilson@sun.com cmd->cmd_tgt2, cmd->cmd_qty);
3317*9801SAndrew.W.Wilson@sun.com break;
3318*9801SAndrew.W.Wilson@sun.com
3319*9801SAndrew.W.Wilson@sun.com case FSK_MINUS:
3320*9801SAndrew.W.Wilson@sun.com var_assign_op_var_int(cmd->cmd_tgt1, VAR_IND_IV_DIF_INT,
3321*9801SAndrew.W.Wilson@sun.com cmd->cmd_tgt2, cmd->cmd_qty);
3322*9801SAndrew.W.Wilson@sun.com break;
3323*9801SAndrew.W.Wilson@sun.com
3324*9801SAndrew.W.Wilson@sun.com case FSK_MULTIPLY:
3325*9801SAndrew.W.Wilson@sun.com var_assign_op_var_int(cmd->cmd_tgt1, VAR_IND_INT_MUL_IV,
3326*9801SAndrew.W.Wilson@sun.com cmd->cmd_tgt2, cmd->cmd_qty);
3327*9801SAndrew.W.Wilson@sun.com break;
3328*9801SAndrew.W.Wilson@sun.com
3329*9801SAndrew.W.Wilson@sun.com case FSK_DIVIDE:
3330*9801SAndrew.W.Wilson@sun.com var_assign_op_var_int(cmd->cmd_tgt1, VAR_IND_IV_DIV_INT,
3331*9801SAndrew.W.Wilson@sun.com cmd->cmd_tgt2, cmd->cmd_qty);
3332*9801SAndrew.W.Wilson@sun.com break;
3333*9801SAndrew.W.Wilson@sun.com }
3334*9801SAndrew.W.Wilson@sun.com }
3335*9801SAndrew.W.Wilson@sun.com
3336*9801SAndrew.W.Wilson@sun.com /*
3337*9801SAndrew.W.Wilson@sun.com * Used by the set command to set up for a binary operation of an
3338*9801SAndrew.W.Wilson@sun.com * integer with a variable from a var
3339*9801SAndrew.W.Wilson@sun.com */
3340*9801SAndrew.W.Wilson@sun.com static void
parser_set_int_op_var(cmd_t * cmd)3341*9801SAndrew.W.Wilson@sun.com parser_set_int_op_var(cmd_t *cmd)
33426212Saw148015 {
3343*9801SAndrew.W.Wilson@sun.com switch (cmd->cmd_subtype) {
3344*9801SAndrew.W.Wilson@sun.com case FSK_PLUS:
3345*9801SAndrew.W.Wilson@sun.com var_assign_op_var_int(cmd->cmd_tgt1, VAR_IND_INT_SUM_IV,
3346*9801SAndrew.W.Wilson@sun.com cmd->cmd_tgt3, cmd->cmd_qty);
3347*9801SAndrew.W.Wilson@sun.com break;
3348*9801SAndrew.W.Wilson@sun.com
3349*9801SAndrew.W.Wilson@sun.com case FSK_MINUS:
3350*9801SAndrew.W.Wilson@sun.com var_assign_op_var_int(cmd->cmd_tgt1, VAR_IND_INT_DIF_IV,
3351*9801SAndrew.W.Wilson@sun.com cmd->cmd_tgt3, cmd->cmd_qty);
3352*9801SAndrew.W.Wilson@sun.com break;
3353*9801SAndrew.W.Wilson@sun.com
3354*9801SAndrew.W.Wilson@sun.com case FSK_MULTIPLY:
3355*9801SAndrew.W.Wilson@sun.com var_assign_op_var_int(cmd->cmd_tgt1, VAR_IND_INT_MUL_IV,
3356*9801SAndrew.W.Wilson@sun.com cmd->cmd_tgt3, cmd->cmd_qty);
3357*9801SAndrew.W.Wilson@sun.com break;
3358*9801SAndrew.W.Wilson@sun.com
3359*9801SAndrew.W.Wilson@sun.com case FSK_DIVIDE:
3360*9801SAndrew.W.Wilson@sun.com var_assign_op_var_int(cmd->cmd_tgt1, VAR_IND_INT_DIV_IV,
3361*9801SAndrew.W.Wilson@sun.com cmd->cmd_tgt3, cmd->cmd_qty);
3362*9801SAndrew.W.Wilson@sun.com break;
3363*9801SAndrew.W.Wilson@sun.com }
3364*9801SAndrew.W.Wilson@sun.com }
3365*9801SAndrew.W.Wilson@sun.com
3366*9801SAndrew.W.Wilson@sun.com /*
3367*9801SAndrew.W.Wilson@sun.com * Used by the set command to set up for a binary operation of two
3368*9801SAndrew.W.Wilson@sun.com * variables from other vars.
3369*9801SAndrew.W.Wilson@sun.com */
3370*9801SAndrew.W.Wilson@sun.com static void
parser_set_var_op_var(cmd_t * cmd)3371*9801SAndrew.W.Wilson@sun.com parser_set_var_op_var(cmd_t *cmd)
3372*9801SAndrew.W.Wilson@sun.com {
3373*9801SAndrew.W.Wilson@sun.com switch (cmd->cmd_subtype) {
3374*9801SAndrew.W.Wilson@sun.com case FSK_PLUS:
3375*9801SAndrew.W.Wilson@sun.com var_assign_op_var_var(cmd->cmd_tgt1, VAR_IND_IV_SUM_IV,
3376*9801SAndrew.W.Wilson@sun.com cmd->cmd_tgt2, cmd->cmd_tgt3);
3377*9801SAndrew.W.Wilson@sun.com break;
3378*9801SAndrew.W.Wilson@sun.com
3379*9801SAndrew.W.Wilson@sun.com case FSK_MINUS:
3380*9801SAndrew.W.Wilson@sun.com var_assign_op_var_var(cmd->cmd_tgt1, VAR_IND_IV_DIF_IV,
3381*9801SAndrew.W.Wilson@sun.com cmd->cmd_tgt2, cmd->cmd_tgt3);
3382*9801SAndrew.W.Wilson@sun.com break;
3383*9801SAndrew.W.Wilson@sun.com
3384*9801SAndrew.W.Wilson@sun.com case FSK_MULTIPLY:
3385*9801SAndrew.W.Wilson@sun.com var_assign_op_var_var(cmd->cmd_tgt1, VAR_IND_IV_MUL_IV,
3386*9801SAndrew.W.Wilson@sun.com cmd->cmd_tgt2, cmd->cmd_tgt3);
3387*9801SAndrew.W.Wilson@sun.com break;
3388*9801SAndrew.W.Wilson@sun.com
3389*9801SAndrew.W.Wilson@sun.com case FSK_DIVIDE:
3390*9801SAndrew.W.Wilson@sun.com var_assign_op_var_var(cmd->cmd_tgt1, VAR_IND_IV_DIV_IV,
3391*9801SAndrew.W.Wilson@sun.com cmd->cmd_tgt2, cmd->cmd_tgt3);
3392*9801SAndrew.W.Wilson@sun.com break;
3393*9801SAndrew.W.Wilson@sun.com }
33946212Saw148015 }
33956212Saw148015
33966212Saw148015
33976212Saw148015 /*
33989326SAndrew.W.Wilson@sun.com * Sleeps for cmd->cmd_qty seconds, one second at a time.
33999326SAndrew.W.Wilson@sun.com */
34009326SAndrew.W.Wilson@sun.com static void
parser_warmup(cmd_t * cmd)34019326SAndrew.W.Wilson@sun.com parser_warmup(cmd_t *cmd)
34029326SAndrew.W.Wilson@sun.com {
34039326SAndrew.W.Wilson@sun.com int sleeptime;
34049326SAndrew.W.Wilson@sun.com
34059326SAndrew.W.Wilson@sun.com /* check for startup errors */
34069326SAndrew.W.Wilson@sun.com if (filebench_shm->shm_f_abort)
34079326SAndrew.W.Wilson@sun.com return;
34089326SAndrew.W.Wilson@sun.com
34099326SAndrew.W.Wilson@sun.com sleeptime = cmd->cmd_qty;
34109326SAndrew.W.Wilson@sun.com filebench_log(LOG_INFO, "Warming up...");
34119326SAndrew.W.Wilson@sun.com
34129326SAndrew.W.Wilson@sun.com (void) parser_pause(sleeptime);
34139326SAndrew.W.Wilson@sun.com }
34149326SAndrew.W.Wilson@sun.com
34159326SAndrew.W.Wilson@sun.com /*
34165184Sek110237 * Same as parser_sleep, except the sleep time is obtained from a variable
34175184Sek110237 * whose name is passed to it as an argument on the command line.
34185184Sek110237 */
34195184Sek110237 static void
parser_warmup_variable(cmd_t * cmd)34209326SAndrew.W.Wilson@sun.com parser_warmup_variable(cmd_t *cmd)
34215184Sek110237 {
34226212Saw148015 avd_t integer = var_ref_attr(cmd->cmd_tgt1);
34235184Sek110237 int sleeptime;
34245184Sek110237
34255184Sek110237 if (integer == NULL) {
34265184Sek110237 filebench_log(LOG_ERROR, "Unknown variable %s",
34275184Sek110237 cmd->cmd_tgt1);
34285184Sek110237 return;
34295184Sek110237 }
34305184Sek110237
34316212Saw148015 sleeptime = avd_get_int(integer);
34325184Sek110237
34335184Sek110237 /* check for startup errors */
34346391Saw148015 if (filebench_shm->shm_f_abort)
34355184Sek110237 return;
34365184Sek110237
34379326SAndrew.W.Wilson@sun.com filebench_log(LOG_INFO, "Warming up...");
34389326SAndrew.W.Wilson@sun.com
34399326SAndrew.W.Wilson@sun.com (void) parser_pause(sleeptime);
34409326SAndrew.W.Wilson@sun.com }
34419326SAndrew.W.Wilson@sun.com
34429326SAndrew.W.Wilson@sun.com /*
34439326SAndrew.W.Wilson@sun.com * Sleeps for cmd->cmd_qty seconds, one second at a time.
34449326SAndrew.W.Wilson@sun.com */
34459326SAndrew.W.Wilson@sun.com static void
parser_sleep(cmd_t * cmd)34469326SAndrew.W.Wilson@sun.com parser_sleep(cmd_t *cmd)
34479326SAndrew.W.Wilson@sun.com {
34489326SAndrew.W.Wilson@sun.com int sleeptime;
34499326SAndrew.W.Wilson@sun.com int timeslept;
34509326SAndrew.W.Wilson@sun.com
34519326SAndrew.W.Wilson@sun.com /* check for startup errors */
34529326SAndrew.W.Wilson@sun.com if (filebench_shm->shm_f_abort)
34539326SAndrew.W.Wilson@sun.com return;
34549326SAndrew.W.Wilson@sun.com
34559326SAndrew.W.Wilson@sun.com sleeptime = cmd->cmd_qty;
34565184Sek110237 filebench_log(LOG_INFO, "Running...");
34576084Saw148015
34589326SAndrew.W.Wilson@sun.com timeslept = parser_pause(sleeptime);
34599326SAndrew.W.Wilson@sun.com
34609326SAndrew.W.Wilson@sun.com filebench_log(LOG_INFO, "Run took %d seconds...", timeslept);
34619326SAndrew.W.Wilson@sun.com }
34629326SAndrew.W.Wilson@sun.com
34639326SAndrew.W.Wilson@sun.com /*
34649326SAndrew.W.Wilson@sun.com * Same as parser_sleep, except the sleep time is obtained from a variable
34659326SAndrew.W.Wilson@sun.com * whose name is passed to it as an argument on the command line.
34669326SAndrew.W.Wilson@sun.com */
34679326SAndrew.W.Wilson@sun.com static void
parser_sleep_variable(cmd_t * cmd)34689326SAndrew.W.Wilson@sun.com parser_sleep_variable(cmd_t *cmd)
34699326SAndrew.W.Wilson@sun.com {
34709326SAndrew.W.Wilson@sun.com avd_t integer = var_ref_attr(cmd->cmd_tgt1);
34719326SAndrew.W.Wilson@sun.com int sleeptime;
34729326SAndrew.W.Wilson@sun.com int timeslept;
34739326SAndrew.W.Wilson@sun.com
34749326SAndrew.W.Wilson@sun.com if (integer == NULL) {
34759326SAndrew.W.Wilson@sun.com filebench_log(LOG_ERROR, "Unknown variable %s",
34769326SAndrew.W.Wilson@sun.com cmd->cmd_tgt1);
34779326SAndrew.W.Wilson@sun.com return;
34789326SAndrew.W.Wilson@sun.com }
34799326SAndrew.W.Wilson@sun.com
34809326SAndrew.W.Wilson@sun.com sleeptime = avd_get_int(integer);
34819326SAndrew.W.Wilson@sun.com
34829326SAndrew.W.Wilson@sun.com /* check for startup errors */
34839326SAndrew.W.Wilson@sun.com if (filebench_shm->shm_f_abort)
34849326SAndrew.W.Wilson@sun.com return;
34859326SAndrew.W.Wilson@sun.com
34869326SAndrew.W.Wilson@sun.com filebench_log(LOG_INFO, "Running...");
34879326SAndrew.W.Wilson@sun.com
34889326SAndrew.W.Wilson@sun.com timeslept = parser_pause(sleeptime);
34899326SAndrew.W.Wilson@sun.com
34909326SAndrew.W.Wilson@sun.com filebench_log(LOG_INFO, "Run took %d seconds...", timeslept);
34915184Sek110237 }
34925184Sek110237
34935184Sek110237 /*
34945184Sek110237 * Parser log prints the values of a list of variables to the log file.
34955184Sek110237 * The list of variables is placed on the command line, separated
34965184Sek110237 * by comas and the entire list is enclosed in quotes.
34975184Sek110237 * For example, if $dir contains "/export/home/tmp" and $filesize = 1048576,
34985184Sek110237 * then typing: log "$dir, $filesize" prints: log /export/home/tmp, 1048576
34995184Sek110237 */
35005184Sek110237 static void
parser_log(cmd_t * cmd)35015184Sek110237 parser_log(cmd_t *cmd)
35025184Sek110237 {
35035184Sek110237 char *string;
35045184Sek110237
35055184Sek110237 if (cmd->cmd_param_list == NULL)
35065184Sek110237 return;
35075184Sek110237
35085184Sek110237 string = parser_list2string(cmd->cmd_param_list);
35095184Sek110237
35105184Sek110237 if (string == NULL)
35115184Sek110237 return;
35125184Sek110237
35135184Sek110237 filebench_log(LOG_VERBOSE, "log %s", string);
35145184Sek110237 filebench_log(LOG_LOG, "%s", string);
35155184Sek110237 }
35165184Sek110237
35175184Sek110237 /*
35185184Sek110237 * Implements the stats directory command. changes the directory for
35195184Sek110237 * dumping statistics to supplied directory path. For example:
35205184Sek110237 * stats directory /tmp
35215184Sek110237 * changes the stats directory to "/tmp".
35225184Sek110237 */
35235184Sek110237 static void
parser_directory(cmd_t * cmd)35245184Sek110237 parser_directory(cmd_t *cmd)
35255184Sek110237 {
35265184Sek110237 char newdir[MAXPATHLEN];
35275184Sek110237 char *dir;
35285184Sek110237
35295184Sek110237 if ((dir = parser_list2string(cmd->cmd_param_list)) == NULL) {
35305184Sek110237 filebench_log(LOG_ERROR, "Cannot interpret directory");
35315184Sek110237 return;
35325184Sek110237 }
35335184Sek110237
35345184Sek110237 *newdir = 0;
35355184Sek110237 /* Change dir relative to cwd if path not fully qualified */
35365184Sek110237 if (*dir != '/') {
35375184Sek110237 (void) strcat(newdir, cwd);
35385184Sek110237 (void) strcat(newdir, "/");
35395184Sek110237 }
35405184Sek110237 (void) strcat(newdir, dir);
35415184Sek110237 (void) mkdir(newdir, 0755);
35425184Sek110237 filebench_log(LOG_VERBOSE, "Change dir to %s", newdir);
35435184Sek110237 chdir(newdir);
35445184Sek110237 free(dir);
35455184Sek110237 }
35465184Sek110237
35475184Sek110237 #define PIPE_PARENT 1
35485184Sek110237 #define PIPE_CHILD 0
35495184Sek110237
35505184Sek110237 /*
35515184Sek110237 * Runs the quoted unix command as a background process. Intended for
35525184Sek110237 * running statistics gathering utilities such as mpstat while the filebench
35535184Sek110237 * workload is running. Also records the pid's of the background processes
35545184Sek110237 * so that parser_statssnap() can terminate them when the run completes.
35555184Sek110237 */
35565184Sek110237 static void
parser_statscmd(cmd_t * cmd)35575184Sek110237 parser_statscmd(cmd_t *cmd)
35585184Sek110237 {
35595184Sek110237 char *string;
35605184Sek110237 pid_t pid;
35615184Sek110237 pidlist_t *pidlistent;
35625184Sek110237 int pipe_fd[2];
35635184Sek110237 int newstdout;
35645184Sek110237
35655184Sek110237 if (cmd->cmd_param_list == NULL)
35665184Sek110237 return;
35675184Sek110237
35685184Sek110237 string = parser_list2string(cmd->cmd_param_list);
35695184Sek110237
35705184Sek110237 if (string == NULL)
35715184Sek110237 return;
35725184Sek110237
35735184Sek110237 if ((pipe(pipe_fd)) < 0) {
35745184Sek110237 filebench_log(LOG_ERROR, "statscmd pipe failed");
35755184Sek110237 return;
35765184Sek110237 }
35775184Sek110237
35785184Sek110237 #ifdef HAVE_FORK1
35795184Sek110237 if ((pid = fork1()) < 0) {
35805184Sek110237 filebench_log(LOG_ERROR, "statscmd fork failed");
35815184Sek110237 return;
35825184Sek110237 }
35835184Sek110237 #elif HAVE_FORK
35845184Sek110237 if ((pid = fork()) < 0) {
35855184Sek110237 filebench_log(LOG_ERROR, "statscmd fork failed");
35865184Sek110237 return;
35875184Sek110237 }
35885184Sek110237 #else
35895184Sek110237 Crash! - Need code to deal with no fork1!
35905184Sek110237 #endif /* HAVE_FORK1 */
35915184Sek110237
35925184Sek110237 if (pid == 0) {
35935184Sek110237
35945184Sek110237 setsid();
35955184Sek110237
35965184Sek110237 filebench_log(LOG_VERBOSE,
35975184Sek110237 "Backgrounding %s", string);
35985184Sek110237 /*
35995184Sek110237 * Child
36005184Sek110237 * - close stdout
36015184Sek110237 * - dup to create new stdout
36025184Sek110237 * - close pipe fds
36035184Sek110237 */
36045184Sek110237 (void) close(1);
36055184Sek110237
36065184Sek110237 if ((newstdout = dup(pipe_fd[PIPE_CHILD])) < 0) {
36075184Sek110237 filebench_log(LOG_ERROR,
36085184Sek110237 "statscmd dup failed: %s",
36095184Sek110237 strerror(errno));
36105184Sek110237 }
36115184Sek110237
36125184Sek110237 (void) close(pipe_fd[PIPE_PARENT]);
36135184Sek110237 (void) close(pipe_fd[PIPE_CHILD]);
36145184Sek110237
36155184Sek110237 if (system(string) < 0) {
36165184Sek110237 filebench_log(LOG_ERROR,
36175184Sek110237 "statscmd exec failed: %s",
36185184Sek110237 strerror(errno));
36195184Sek110237 }
36205184Sek110237 /* Failed! */
36215184Sek110237 exit(1);
36225184Sek110237
36235184Sek110237 } else {
36245184Sek110237
36255184Sek110237 /* Record pid in pidlist for subsequent reaping by stats snap */
36265184Sek110237 if ((pidlistent = (pidlist_t *)malloc(sizeof (pidlist_t)))
36275184Sek110237 == NULL) {
36285184Sek110237 filebench_log(LOG_ERROR, "pidlistent malloc failed");
36295184Sek110237 return;
36305184Sek110237 }
36315184Sek110237
36325184Sek110237 pidlistent->pl_pid = pid;
36335184Sek110237 pidlistent->pl_fd = pipe_fd[PIPE_PARENT];
36345184Sek110237 (void) close(pipe_fd[PIPE_CHILD]);
36355184Sek110237
36365184Sek110237 /* Add fileobj to global list */
36375184Sek110237 if (pidlist == NULL) {
36385184Sek110237 pidlist = pidlistent;
36395184Sek110237 pidlistent->pl_next = NULL;
36405184Sek110237 } else {
36415184Sek110237 pidlistent->pl_next = pidlist;
36425184Sek110237 pidlist = pidlistent;
36435184Sek110237 }
36445184Sek110237 }
36455184Sek110237 }
36465184Sek110237
36475184Sek110237 /*
36485184Sek110237 * Launches a shell to run the unix command supplied in the argument.
36495184Sek110237 * The command should be enclosed in quotes, as in:
36505184Sek110237 * system "rm xyz"
36515184Sek110237 * which would run the "rm" utility to delete the file "xyz".
36525184Sek110237 */
36535184Sek110237 static void
parser_system(cmd_t * cmd)36545184Sek110237 parser_system(cmd_t *cmd)
36555184Sek110237 {
36565184Sek110237 char *string;
36575184Sek110237
36585184Sek110237 if (cmd->cmd_param_list == NULL)
36595184Sek110237 return;
36605184Sek110237
36615184Sek110237 string = parser_list2string(cmd->cmd_param_list);
36625184Sek110237
36635184Sek110237 if (string == NULL)
36645184Sek110237 return;
36655184Sek110237
36665184Sek110237 filebench_log(LOG_VERBOSE,
36675184Sek110237 "Running '%s'", string);
36685184Sek110237
36695184Sek110237 if (system(string) < 0) {
36705184Sek110237 filebench_log(LOG_ERROR,
36715184Sek110237 "system exec failed: %s",
36725184Sek110237 strerror(errno));
36739513SAndrew.W.Wilson@sun.com filebench_shutdown(1);
36745184Sek110237 }
36755184Sek110237 free(string);
36765184Sek110237 }
36775184Sek110237
36785184Sek110237 /*
36795184Sek110237 * Echos string supplied with command to the log.
36805184Sek110237 */
36815184Sek110237 static void
parser_echo(cmd_t * cmd)36825184Sek110237 parser_echo(cmd_t *cmd)
36835184Sek110237 {
36845184Sek110237 char *string;
36855184Sek110237
36865184Sek110237 if (cmd->cmd_param_list == NULL)
36875184Sek110237 return;
36885184Sek110237
36895184Sek110237 string = parser_list2string(cmd->cmd_param_list);
36905184Sek110237
36915184Sek110237 if (string == NULL)
36925184Sek110237 return;
36935184Sek110237
36945184Sek110237 filebench_log(LOG_INFO, "%s", string);
36955184Sek110237 }
36965184Sek110237
36976750Sek110237 /*
36989513SAndrew.W.Wilson@sun.com * Checks to see if the specified data directory exists and it's mounted file
36999513SAndrew.W.Wilson@sun.com * system is the correct type.
37009513SAndrew.W.Wilson@sun.com */
37019513SAndrew.W.Wilson@sun.com static void
parser_fscheck(cmd_t * cmd)37029513SAndrew.W.Wilson@sun.com parser_fscheck(cmd_t *cmd)
37039513SAndrew.W.Wilson@sun.com {
37049513SAndrew.W.Wilson@sun.com int fstype_idx;
37059513SAndrew.W.Wilson@sun.com char *pathname = NULL;
37069513SAndrew.W.Wilson@sun.com char *filesys = "tmpfs";
37079513SAndrew.W.Wilson@sun.com char string[MAXPATHLEN];
37089513SAndrew.W.Wilson@sun.com struct statvfs64 statbuf;
37099513SAndrew.W.Wilson@sun.com attr_t *attr;
37109513SAndrew.W.Wilson@sun.com
37119513SAndrew.W.Wilson@sun.com if (cmd->cmd_attr_list == NULL)
37129513SAndrew.W.Wilson@sun.com return;
37139513SAndrew.W.Wilson@sun.com
37149513SAndrew.W.Wilson@sun.com for (attr = cmd->cmd_attr_list; attr; attr = attr->attr_next) {
37159513SAndrew.W.Wilson@sun.com
37169513SAndrew.W.Wilson@sun.com switch(attr->attr_name) {
37179513SAndrew.W.Wilson@sun.com case FSA_PATH:
37189513SAndrew.W.Wilson@sun.com pathname = avd_get_str(attr->attr_avd);
37199513SAndrew.W.Wilson@sun.com break;
37209513SAndrew.W.Wilson@sun.com case FSA_FSTYPE:
37219513SAndrew.W.Wilson@sun.com filesys = avd_get_str(attr->attr_avd);
37229513SAndrew.W.Wilson@sun.com break;
37239513SAndrew.W.Wilson@sun.com }
37249513SAndrew.W.Wilson@sun.com }
37259513SAndrew.W.Wilson@sun.com
37269513SAndrew.W.Wilson@sun.com if (pathname == NULL)
37279513SAndrew.W.Wilson@sun.com return;
37289513SAndrew.W.Wilson@sun.com
37299513SAndrew.W.Wilson@sun.com if (statvfs64(pathname, &statbuf) < 0) {
37309513SAndrew.W.Wilson@sun.com filebench_log(LOG_ERROR,
37319513SAndrew.W.Wilson@sun.com "%s error with supplied data path name: %s; exiting",
37329513SAndrew.W.Wilson@sun.com strerror(errno), pathname);
37339513SAndrew.W.Wilson@sun.com filebench_shutdown(1);
37349513SAndrew.W.Wilson@sun.com return;
37359513SAndrew.W.Wilson@sun.com }
37369513SAndrew.W.Wilson@sun.com
37379513SAndrew.W.Wilson@sun.com if (strncmp(filesys, statbuf.f_basetype, FSTYPSZ) != 0) {
37389513SAndrew.W.Wilson@sun.com filebench_log(LOG_ERROR,
37399513SAndrew.W.Wilson@sun.com "File System is of type %s, NOT %s as indicated",
37409513SAndrew.W.Wilson@sun.com statbuf.f_basetype, filesys);
37419513SAndrew.W.Wilson@sun.com filebench_shutdown(1);
37429513SAndrew.W.Wilson@sun.com return;
37439513SAndrew.W.Wilson@sun.com }
37449513SAndrew.W.Wilson@sun.com }
37459513SAndrew.W.Wilson@sun.com
37469513SAndrew.W.Wilson@sun.com /*
37479513SAndrew.W.Wilson@sun.com * Checks to see if any filesets need to have their caches flushed, and
37489513SAndrew.W.Wilson@sun.com * if so invokes the fs_flush script.
37499513SAndrew.W.Wilson@sun.com */
37509513SAndrew.W.Wilson@sun.com static void
parser_fsflush(cmd_t * cmd)37519513SAndrew.W.Wilson@sun.com parser_fsflush(cmd_t *cmd)
37529513SAndrew.W.Wilson@sun.com {
37539513SAndrew.W.Wilson@sun.com fileset_t *fileset;
37549513SAndrew.W.Wilson@sun.com char **fspathlist;
37559513SAndrew.W.Wilson@sun.com char *pathname = NULL;
37569513SAndrew.W.Wilson@sun.com char *filesys = NULL;
37579513SAndrew.W.Wilson@sun.com char string[MAXPATHLEN];
37589513SAndrew.W.Wilson@sun.com attr_t *attr;
37599513SAndrew.W.Wilson@sun.com int fsidx;
37609513SAndrew.W.Wilson@sun.com
37619513SAndrew.W.Wilson@sun.com if ((attr = cmd->cmd_attr_list) == NULL)
37629513SAndrew.W.Wilson@sun.com return;
37639513SAndrew.W.Wilson@sun.com
37649513SAndrew.W.Wilson@sun.com /* Get supplied file system type */
37659513SAndrew.W.Wilson@sun.com if (attr->attr_name == FSA_FSTYPE)
37669513SAndrew.W.Wilson@sun.com filesys = avd_get_str(attr->attr_avd);
37679513SAndrew.W.Wilson@sun.com
37689513SAndrew.W.Wilson@sun.com if (filesys == NULL) {
37699513SAndrew.W.Wilson@sun.com filebench_log(LOG_ERROR,
37709513SAndrew.W.Wilson@sun.com "FSFLUSH command lacks file system type");
37719513SAndrew.W.Wilson@sun.com return;
37729513SAndrew.W.Wilson@sun.com }
37739513SAndrew.W.Wilson@sun.com
37749513SAndrew.W.Wilson@sun.com /* Check all filesets for any that remain cached and count them*/
37759513SAndrew.W.Wilson@sun.com fsidx = 0;
37769513SAndrew.W.Wilson@sun.com for (fileset = filebench_shm->shm_filesetlist; fileset != NULL;
37779513SAndrew.W.Wilson@sun.com fileset = fileset->fs_next) {
37789513SAndrew.W.Wilson@sun.com
37799513SAndrew.W.Wilson@sun.com if (avd_get_bool(fileset->fs_cached))
37809513SAndrew.W.Wilson@sun.com return;
37819513SAndrew.W.Wilson@sun.com
37829513SAndrew.W.Wilson@sun.com fsidx++;
37839513SAndrew.W.Wilson@sun.com }
37849513SAndrew.W.Wilson@sun.com
37859513SAndrew.W.Wilson@sun.com /* allocated space for fileset path pointers */
37869513SAndrew.W.Wilson@sun.com fspathlist = (char **)malloc(fsidx * sizeof(char *));
37879513SAndrew.W.Wilson@sun.com
37889513SAndrew.W.Wilson@sun.com /* If flushing still required, flush all filesets */
37899513SAndrew.W.Wilson@sun.com fsidx = 0;
37909513SAndrew.W.Wilson@sun.com for (fileset = filebench_shm->shm_filesetlist; fileset != NULL;
37919513SAndrew.W.Wilson@sun.com fileset = fileset->fs_next) {
37929513SAndrew.W.Wilson@sun.com int idx;
37939513SAndrew.W.Wilson@sun.com
37949513SAndrew.W.Wilson@sun.com if ((pathname = avd_get_str(fileset->fs_path)) == NULL)
37959513SAndrew.W.Wilson@sun.com return;
37969513SAndrew.W.Wilson@sun.com
37979513SAndrew.W.Wilson@sun.com for (idx = 0; idx < fsidx; idx++) {
37989513SAndrew.W.Wilson@sun.com if (strcmp(pathname, fspathlist[idx]) == 0)
37999513SAndrew.W.Wilson@sun.com break;
38009513SAndrew.W.Wilson@sun.com }
38019513SAndrew.W.Wilson@sun.com
38029513SAndrew.W.Wilson@sun.com if (fsidx == idx) {
38039513SAndrew.W.Wilson@sun.com
38049513SAndrew.W.Wilson@sun.com /* found a new path */
38059513SAndrew.W.Wilson@sun.com fspathlist[fsidx++] = pathname;
38069513SAndrew.W.Wilson@sun.com
38079513SAndrew.W.Wilson@sun.com /* now flush it */
38089513SAndrew.W.Wilson@sun.com snprintf(string, MAXPATHLEN,
38099513SAndrew.W.Wilson@sun.com "%s/scripts/fs_flush %s %s", fbbasepath,
38109513SAndrew.W.Wilson@sun.com filesys, pathname);
38119513SAndrew.W.Wilson@sun.com
38129513SAndrew.W.Wilson@sun.com if (system(string) < 0) {
38139513SAndrew.W.Wilson@sun.com filebench_log(LOG_ERROR,
38149513SAndrew.W.Wilson@sun.com "exec of fs_flush script failed: %s",
38159513SAndrew.W.Wilson@sun.com strerror(errno));
38169513SAndrew.W.Wilson@sun.com filebench_shutdown(1);
38179513SAndrew.W.Wilson@sun.com }
38189513SAndrew.W.Wilson@sun.com }
38199513SAndrew.W.Wilson@sun.com }
38209513SAndrew.W.Wilson@sun.com }
38219513SAndrew.W.Wilson@sun.com
38229513SAndrew.W.Wilson@sun.com /*
38236750Sek110237 * Prints out the version of FileBench.
38246750Sek110237 */
38256750Sek110237 static void
parser_version(cmd_t * cmd)38266750Sek110237 parser_version(cmd_t *cmd)
38276750Sek110237 {
38286750Sek110237 filebench_log(LOG_INFO, "FileBench Version: %s", FILEBENCH_VERSION);
38296750Sek110237 }
38305184Sek110237
38315184Sek110237 /*
38325184Sek110237 * Adds the string supplied as the argument to the usage command
38335184Sek110237 * to the end of the string printed by the help command.
38345184Sek110237 */
38355184Sek110237 static void
parser_usage(cmd_t * cmd)38365184Sek110237 parser_usage(cmd_t *cmd)
38375184Sek110237 {
38385184Sek110237 char *string;
38395184Sek110237 char *newusage;
38405184Sek110237
38415184Sek110237 if (cmd->cmd_param_list == NULL)
38425184Sek110237 return;
38435184Sek110237
38445184Sek110237 string = parser_list2string(cmd->cmd_param_list);
38455184Sek110237
38465184Sek110237 if (string == NULL)
38475184Sek110237 return;
38485184Sek110237
38495184Sek110237 if (dofile)
38505184Sek110237 return;
38515184Sek110237
38525184Sek110237 if (usagestr == NULL) {
38535184Sek110237 newusage = malloc(strlen(string) + 2);
38545184Sek110237 *newusage = 0;
38555184Sek110237 } else {
38565184Sek110237 newusage = malloc(strlen(usagestr) + strlen(string) + 2);
38575184Sek110237 (void) strcpy(newusage, usagestr);
38585184Sek110237 }
38595184Sek110237 (void) strcat(newusage, "\n");
38605184Sek110237 (void) strcat(newusage, string);
38615184Sek110237
38625184Sek110237 if (usagestr)
38635184Sek110237 free(usagestr);
38645184Sek110237
38655184Sek110237 usagestr = newusage;
38665184Sek110237
38675184Sek110237 filebench_log(LOG_INFO, "%s", string);
38685184Sek110237 }
38695184Sek110237
38705184Sek110237 /*
38715184Sek110237 * Updates the global dump filename with the filename supplied
38725184Sek110237 * as the command's argument. Then dumps the statistics of each
38735184Sek110237 * worker flowop into the dump file, followed by a summary of
38745184Sek110237 * overall totals.
38755184Sek110237 */
38765184Sek110237 static void
parser_statsdump(cmd_t * cmd)38775184Sek110237 parser_statsdump(cmd_t *cmd)
38785184Sek110237 {
38795184Sek110237 char *string;
38805184Sek110237
38815184Sek110237 if (cmd->cmd_param_list == NULL)
38825184Sek110237 return;
38835184Sek110237
38845184Sek110237 string = parser_list2string(cmd->cmd_param_list);
38855184Sek110237
38865184Sek110237 if (string == NULL)
38875184Sek110237 return;
38885184Sek110237
38895184Sek110237 filebench_log(LOG_VERBOSE,
38905184Sek110237 "Stats dump to file '%s'", string);
38915184Sek110237
38925184Sek110237 stats_dump(string);
38935184Sek110237
38945184Sek110237 free(string);
38955184Sek110237 }
38965184Sek110237
38975184Sek110237 /*
38987736SAndrew.W.Wilson@sun.com * Same as statsdump, but outputs in a computer friendly format.
38997736SAndrew.W.Wilson@sun.com */
39007736SAndrew.W.Wilson@sun.com static void
parser_statsmultidump(cmd_t * cmd)39017736SAndrew.W.Wilson@sun.com parser_statsmultidump(cmd_t *cmd)
39027736SAndrew.W.Wilson@sun.com {
39037736SAndrew.W.Wilson@sun.com char *string;
39047736SAndrew.W.Wilson@sun.com
39057736SAndrew.W.Wilson@sun.com if (cmd->cmd_param_list == NULL)
39067736SAndrew.W.Wilson@sun.com return;
39077736SAndrew.W.Wilson@sun.com
39087736SAndrew.W.Wilson@sun.com string = parser_list2string(cmd->cmd_param_list);
39097736SAndrew.W.Wilson@sun.com
39107736SAndrew.W.Wilson@sun.com if (string == NULL)
39117736SAndrew.W.Wilson@sun.com return;
39127736SAndrew.W.Wilson@sun.com
39137736SAndrew.W.Wilson@sun.com filebench_log(LOG_VERBOSE,
39147736SAndrew.W.Wilson@sun.com "Stats dump to file '%s'", string);
39157736SAndrew.W.Wilson@sun.com
39167736SAndrew.W.Wilson@sun.com stats_multidump(string);
39177736SAndrew.W.Wilson@sun.com
39187736SAndrew.W.Wilson@sun.com free(string);
39197736SAndrew.W.Wilson@sun.com }
39207736SAndrew.W.Wilson@sun.com
39217736SAndrew.W.Wilson@sun.com /*
39225184Sek110237 * Same as parser_statsdump, but in xml format.
39235184Sek110237 */
39245184Sek110237 static void
parser_statsxmldump(cmd_t * cmd)39255184Sek110237 parser_statsxmldump(cmd_t *cmd)
39265184Sek110237 {
39275184Sek110237 char *string;
39285184Sek110237
39295184Sek110237 if (cmd->cmd_param_list == NULL)
39305184Sek110237 return;
39315184Sek110237
39325184Sek110237 string = parser_list2string(cmd->cmd_param_list);
39335184Sek110237
39345184Sek110237 if (string == NULL)
39355184Sek110237 return;
39365184Sek110237
39375184Sek110237 filebench_log(LOG_VERBOSE,
39385184Sek110237 "Stats dump to file '%s'", string);
39395184Sek110237
39405184Sek110237 stats_xmldump(string);
39415184Sek110237
39425184Sek110237 free(string);
39435184Sek110237 }
39445184Sek110237
39455184Sek110237 /*
39465184Sek110237 * Kills off background statistics collection processes, then takes a snapshot
39475184Sek110237 * of the filebench run's collected statistics using stats_snap() from
39485184Sek110237 * stats.c.
39495184Sek110237 */
39505184Sek110237 static void
parser_statssnap(cmd_t * cmd)39515184Sek110237 parser_statssnap(cmd_t *cmd)
39525184Sek110237 {
39535184Sek110237 pidlist_t *pidlistent;
39545184Sek110237 int stat;
39555184Sek110237 pid_t pid;
39565184Sek110237
39575184Sek110237 for (pidlistent = pidlist; pidlistent != NULL;
39585184Sek110237 pidlistent = pidlistent->pl_next) {
39595184Sek110237 filebench_log(LOG_VERBOSE, "Killing session %d for pid %d",
39605184Sek110237 getsid(pidlistent->pl_pid),
39615184Sek110237 pidlistent->pl_pid);
39625184Sek110237 if (pidlistent->pl_fd)
39635184Sek110237 (void) close(pidlistent->pl_fd);
39645184Sek110237 #ifdef HAVE_SIGSEND
39655184Sek110237 sigsend(P_SID, getsid(pidlistent->pl_pid), SIGTERM);
39665184Sek110237 #else
39675184Sek110237 (void) kill(-1, SIGTERM);
39685184Sek110237 #endif
39695184Sek110237
39705184Sek110237 /* Close pipe */
39715184Sek110237 if (pidlistent->pl_fd)
39725184Sek110237 (void) close(pidlistent->pl_fd);
39735184Sek110237
39745184Sek110237 /* Wait for cmd and all its children */
39755184Sek110237 while ((pid = waitpid(pidlistent->pl_pid * -1, &stat, 0)) > 0)
39765184Sek110237 filebench_log(LOG_DEBUG_IMPL,
39776286Saw148015 "Waited for pid %d", (int)pid);
39785184Sek110237 }
39795184Sek110237
39805184Sek110237 for (pidlistent = pidlist; pidlistent != NULL;
39815184Sek110237 pidlistent = pidlistent->pl_next) {
39825184Sek110237 free(pidlistent);
39835184Sek110237 }
39845184Sek110237
39855184Sek110237 pidlist = NULL;
39865184Sek110237 stats_snap();
39875184Sek110237 }
39885184Sek110237
39895184Sek110237 /*
39905184Sek110237 * Shutdown filebench.
39915184Sek110237 */
39925184Sek110237 static void
parser_abort(int arg)39935184Sek110237 parser_abort(int arg)
39945184Sek110237 {
39955184Sek110237 (void) sigignore(SIGINT);
39965184Sek110237 filebench_log(LOG_INFO, "Aborting...");
39975184Sek110237 filebench_shutdown(1);
39985184Sek110237 }
39995184Sek110237
40005184Sek110237 /*
40016212Saw148015 * define a random variable and initialize the distribution parameters
40026212Saw148015 */
40036212Saw148015 static void
parser_randvar_define(cmd_t * cmd)40046212Saw148015 parser_randvar_define(cmd_t *cmd)
40056212Saw148015 {
40066212Saw148015 var_t *var;
40076212Saw148015 randdist_t *rndp;
40086212Saw148015 attr_t *attr;
40096212Saw148015 char *name;
40106212Saw148015
40116212Saw148015 /* Get the name for the random variable */
40126212Saw148015 if (attr = get_attr(cmd, FSA_NAME)) {
40136212Saw148015 name = avd_get_str(attr->attr_avd);
40146212Saw148015 } else {
40156212Saw148015 filebench_log(LOG_ERROR,
40166212Saw148015 "define randvar: no name specified");
40176212Saw148015 return;
40186212Saw148015 }
40196212Saw148015
40206212Saw148015 if ((var = var_define_randvar(name)) == NULL) {
40216212Saw148015 filebench_log(LOG_ERROR,
40226212Saw148015 "define randvar: failed for random variable %s",
40236212Saw148015 name);
40246212Saw148015 return;
40256212Saw148015 }
40266212Saw148015
40276212Saw148015 rndp = var->var_val.randptr;
40286212Saw148015 rndp->rnd_type = 0;
40296212Saw148015
40306212Saw148015 /* Get the source of the random numbers */
40316212Saw148015 if (attr = get_attr_integer(cmd, FSA_RANDSRC)) {
40326212Saw148015 int randsrc = (int)avd_get_int(attr->attr_avd);
40336212Saw148015
40346212Saw148015 switch (randsrc) {
40356212Saw148015 case FSV_URAND:
40366212Saw148015 rndp->rnd_type |= RAND_SRC_URANDOM;
40376212Saw148015 break;
40386212Saw148015 case FSV_RAND48:
40396212Saw148015 rndp->rnd_type |= RAND_SRC_GENERATOR;
40406212Saw148015 break;
40416212Saw148015 }
40426212Saw148015 } else {
40436212Saw148015 /* default to rand48 random number generator */
40446212Saw148015 rndp->rnd_type |= RAND_SRC_GENERATOR;
40456212Saw148015 }
40466212Saw148015
40476212Saw148015 /* Get the min value of the random distribution */
40486212Saw148015 if (attr = get_attr_integer(cmd, FSA_RANDMIN))
40496212Saw148015 rndp->rnd_min = attr->attr_avd;
40506212Saw148015 else
40516212Saw148015 rndp->rnd_min = avd_int_alloc(0);
40526212Saw148015
40536212Saw148015 /* Get the roundoff value for the random distribution */
40546212Saw148015 if (attr = get_attr_integer(cmd, FSA_RANDROUND))
40556212Saw148015 rndp->rnd_round = attr->attr_avd;
40566212Saw148015 else
40576212Saw148015 rndp->rnd_round = avd_int_alloc(0);
40586212Saw148015
40596212Saw148015 /* Get a tablular probablility distribution if there is one */
40606212Saw148015 if (attr = get_attr(cmd, FSA_RANDTABLE)) {
40616212Saw148015 rndp->rnd_probtabs = (probtabent_t *)(attr->attr_obj);
40626212Saw148015 rndp->rnd_type |= RAND_TYPE_TABLE;
40636212Saw148015
40646212Saw148015 /* no need for the rest of the attributes */
40656212Saw148015 return;
40666212Saw148015 } else {
40676212Saw148015 rndp->rnd_probtabs = NULL;
40686212Saw148015 }
40696212Saw148015
40706212Saw148015 /* Get the type for the random variable */
40716212Saw148015 if (attr = get_attr(cmd, FSA_TYPE)) {
40726212Saw148015 int disttype = (int)avd_get_int(attr->attr_avd);
40736212Saw148015
40746212Saw148015 switch (disttype) {
40756212Saw148015 case FSV_RANDUNI:
40766212Saw148015 rndp->rnd_type |= RAND_TYPE_UNIFORM;
40776212Saw148015 break;
40786212Saw148015 case FSA_RANDGAMMA:
40796212Saw148015 rndp->rnd_type |= RAND_TYPE_GAMMA;
40806212Saw148015 break;
40816212Saw148015 case FSV_RANDTAB:
40826212Saw148015 filebench_log(LOG_ERROR,
40836212Saw148015 "Table distribution type without prob table");
40846212Saw148015 break;
40856212Saw148015 }
40866212Saw148015 } else {
40876212Saw148015 /* default to gamma distribution type */
40886212Saw148015 rndp->rnd_type |= RAND_TYPE_GAMMA;
40896212Saw148015 }
40906212Saw148015
40916212Saw148015 /* Get the seed for the random variable */
40926212Saw148015 if (attr = get_attr_integer(cmd, FSA_RANDSEED))
40936212Saw148015 rndp->rnd_seed = attr->attr_avd;
40946212Saw148015 else
40956212Saw148015 rndp->rnd_seed = avd_int_alloc(0);
40966212Saw148015
40976212Saw148015 /* Get the gamma value of the random distribution */
40986212Saw148015 if (attr = get_attr_integer(cmd, FSA_RANDGAMMA))
40996212Saw148015 rndp->rnd_gamma = attr->attr_avd;
41006212Saw148015 else
41016212Saw148015 rndp->rnd_gamma = avd_int_alloc(1500);
41028404SAndrew.W.Wilson@sun.com
41038404SAndrew.W.Wilson@sun.com /* Get the mean value of the random distribution */
41048404SAndrew.W.Wilson@sun.com if (attr = get_attr_integer(cmd, FSA_RANDMEAN)) {
41058404SAndrew.W.Wilson@sun.com rndp->rnd_mean = attr->attr_avd;
41068404SAndrew.W.Wilson@sun.com } else if ((rndp->rnd_type & RAND_TYPE_MASK) == RAND_TYPE_GAMMA) {
41078404SAndrew.W.Wilson@sun.com rndp->rnd_mean = NULL;
41088404SAndrew.W.Wilson@sun.com } else {
41098404SAndrew.W.Wilson@sun.com rndp->rnd_mean = avd_int_alloc(0);
41108404SAndrew.W.Wilson@sun.com }
41116212Saw148015 }
41126212Saw148015
41136212Saw148015 /*
41146212Saw148015 * Set a specified random distribution parameter in a random variable.
41156212Saw148015 */
41166212Saw148015 static void
parser_randvar_set(cmd_t * cmd)41176212Saw148015 parser_randvar_set(cmd_t *cmd)
41186212Saw148015 {
41196212Saw148015 var_t *src_var, *randvar;
41206212Saw148015 randdist_t *rndp;
41216212Saw148015 avd_t value;
41226212Saw148015
41236212Saw148015 if ((randvar = var_find_randvar(cmd->cmd_tgt1)) == NULL) {
41246212Saw148015 filebench_log(LOG_ERROR,
41256212Saw148015 "set randvar: failed",
41266212Saw148015 cmd->cmd_tgt1);
41276212Saw148015 return;
41286212Saw148015 }
41296212Saw148015
41306212Saw148015 rndp = randvar->var_val.randptr;
41316212Saw148015 value = cmd->cmd_attr_list->attr_avd;
41326212Saw148015
41336212Saw148015 switch (cmd->cmd_qty) {
41346212Saw148015 case FSS_TYPE:
41356212Saw148015 {
41366212Saw148015 int disttype = (int)avd_get_int(value);
41376212Saw148015
41386212Saw148015 rndp->rnd_type &= (~RAND_TYPE_MASK);
41396212Saw148015
41406212Saw148015 switch (disttype) {
41416212Saw148015 case FSV_RANDUNI:
41426212Saw148015 rndp->rnd_type |= RAND_TYPE_UNIFORM;
41436212Saw148015 break;
41446212Saw148015 case FSA_RANDGAMMA:
41456212Saw148015 rndp->rnd_type |= RAND_TYPE_GAMMA;
41466212Saw148015 break;
41476212Saw148015 case FSV_RANDTAB:
41486212Saw148015 rndp->rnd_type |= RAND_TYPE_TABLE;
41496212Saw148015 break;
41506212Saw148015 }
41516212Saw148015 break;
41526212Saw148015 }
41536212Saw148015
41546212Saw148015 case FSS_SRC:
41556212Saw148015 {
41566212Saw148015 int randsrc = (int)avd_get_int(value);
41576212Saw148015
41586212Saw148015 rndp->rnd_type &=
41596212Saw148015 (~(RAND_SRC_URANDOM | RAND_SRC_GENERATOR));
41606212Saw148015
41616212Saw148015 switch (randsrc) {
41626212Saw148015 case FSV_URAND:
41636212Saw148015 rndp->rnd_type |= RAND_SRC_URANDOM;
41646212Saw148015 break;
41656212Saw148015 case FSV_RAND48:
41666212Saw148015 rndp->rnd_type |= RAND_SRC_GENERATOR;
41676212Saw148015 break;
41686212Saw148015 }
41696212Saw148015 break;
41706212Saw148015 }
41716212Saw148015
41726212Saw148015 case FSS_SEED:
41736212Saw148015 rndp->rnd_seed = value;
41746212Saw148015 break;
41756212Saw148015
41766212Saw148015 case FSS_GAMMA:
41776212Saw148015 rndp->rnd_gamma = value;
41786212Saw148015 break;
41796212Saw148015
41806212Saw148015 case FSS_MEAN:
41816212Saw148015 rndp->rnd_mean = value;
41826212Saw148015 break;
41836212Saw148015
41846212Saw148015 case FSS_MIN:
41856212Saw148015 rndp->rnd_min = value;
41866212Saw148015 break;
41876212Saw148015
41886212Saw148015 case FSS_ROUND:
41896212Saw148015 rndp->rnd_round = value;
41906212Saw148015 break;
41916212Saw148015
41926212Saw148015 default:
41936212Saw148015 filebench_log(LOG_ERROR, "setrandvar: undefined attribute");
41946212Saw148015 }
41956212Saw148015 }
41966212Saw148015
41976212Saw148015 /*
41985184Sek110237 * alloc_cmd() allocates the required resources for a cmd_t. On failure, a
41995184Sek110237 * filebench_log is issued and NULL is returned.
42005184Sek110237 */
42015184Sek110237 static cmd_t *
alloc_cmd(void)42025184Sek110237 alloc_cmd(void)
42035184Sek110237 {
42045184Sek110237 cmd_t *cmd;
42055184Sek110237
42065184Sek110237 if ((cmd = malloc(sizeof (cmd_t))) == NULL) {
42075184Sek110237 filebench_log(LOG_ERROR, "Alloc cmd failed");
42085184Sek110237 return (NULL);
42095184Sek110237 }
42105184Sek110237
42115184Sek110237 (void) memset(cmd, 0, sizeof (cmd_t));
42125184Sek110237
42135184Sek110237 return (cmd);
42145184Sek110237 }
42155184Sek110237
42165184Sek110237 /*
42175184Sek110237 * Frees the resources of a cmd_t and then the cmd_t "cmd" itself.
42185184Sek110237 */
42195184Sek110237 static void
free_cmd(cmd_t * cmd)42205184Sek110237 free_cmd(cmd_t *cmd)
42215184Sek110237 {
42225184Sek110237 free((void *)cmd->cmd_tgt1);
42235184Sek110237 free((void *)cmd->cmd_tgt2);
42245184Sek110237 free(cmd);
42255184Sek110237 }
42265184Sek110237
42275184Sek110237 /*
42285184Sek110237 * Allocates an attr_t structure and zeros it. Returns NULL on failure, or
42295184Sek110237 * a pointer to the attr_t.
42305184Sek110237 */
42315184Sek110237 static attr_t *
alloc_attr(void)42326550Saw148015 alloc_attr(void)
42335184Sek110237 {
42345184Sek110237 attr_t *attr;
42355184Sek110237
42365184Sek110237 if ((attr = malloc(sizeof (attr_t))) == NULL) {
42375184Sek110237 return (NULL);
42385184Sek110237 }
42395184Sek110237
42405184Sek110237 (void) memset(attr, 0, sizeof (attr_t));
42415184Sek110237 return (attr);
42425184Sek110237 }
42435184Sek110237
42445184Sek110237 /*
42456212Saw148015 * Allocates a probtabent_t structure and zeros it. Returns NULL on failure, or
42466212Saw148015 * a pointer to the probtabent_t.
42476212Saw148015 */
42486212Saw148015 static probtabent_t *
alloc_probtabent(void)42496212Saw148015 alloc_probtabent(void)
42506212Saw148015 {
42516212Saw148015 probtabent_t *rte;
42526212Saw148015
42536212Saw148015 if ((rte = malloc(sizeof (probtabent_t))) == NULL) {
42546212Saw148015 return (NULL);
42556212Saw148015 }
42566212Saw148015
42576212Saw148015 (void) memset(rte, 0, sizeof (probtabent_t));
42586212Saw148015 return (rte);
42596212Saw148015 }
42606212Saw148015
42616212Saw148015 /*
42626550Saw148015 * Allocates an attr_t structure and puts the supplied var_t into
42636550Saw148015 * its attr_avd location, and sets its name to FSA_LVAR_ASSIGN
42646550Saw148015 */
42656550Saw148015 static attr_t *
alloc_lvar_attr(var_t * var)42666550Saw148015 alloc_lvar_attr(var_t *var)
42676550Saw148015 {
42686550Saw148015 attr_t *attr;
42696550Saw148015
42706550Saw148015 if ((attr = alloc_attr()) == NULL)
42716550Saw148015 return (NULL);
42726550Saw148015
42736550Saw148015 attr->attr_name = FSA_LVAR_ASSIGN;
42746550Saw148015 attr->attr_avd = (avd_t)var;
42756550Saw148015
42766550Saw148015 return (attr);
42776550Saw148015 }
42786550Saw148015
42798404SAndrew.W.Wilson@sun.com
42808404SAndrew.W.Wilson@sun.com /*
42818404SAndrew.W.Wilson@sun.com * Searches the attribute list for the command for the named attribute type.
42828404SAndrew.W.Wilson@sun.com * The attribute list is created by the parser from the list of attributes
42838404SAndrew.W.Wilson@sun.com * supplied with certain commands, such as the define and flowop commands.
42848404SAndrew.W.Wilson@sun.com * Returns a pointer to the attribute structure if the named attribute is
42858404SAndrew.W.Wilson@sun.com * found, otherwise returns NULL. If the attribute includes a parameter list,
42868404SAndrew.W.Wilson@sun.com * the list is converted to a string and stored in the attr_avd field of
42878404SAndrew.W.Wilson@sun.com * the returned attr_t struct.
42888404SAndrew.W.Wilson@sun.com */
42898404SAndrew.W.Wilson@sun.com static attr_t *
get_attr_fileset(cmd_t * cmd,int64_t name)42908404SAndrew.W.Wilson@sun.com get_attr_fileset(cmd_t *cmd, int64_t name)
42918404SAndrew.W.Wilson@sun.com {
42928404SAndrew.W.Wilson@sun.com attr_t *attr;
42938404SAndrew.W.Wilson@sun.com attr_t *rtn = NULL;
42948404SAndrew.W.Wilson@sun.com char *string;
42958404SAndrew.W.Wilson@sun.com
42968404SAndrew.W.Wilson@sun.com for (attr = cmd->cmd_attr_list; attr != NULL;
42978404SAndrew.W.Wilson@sun.com attr = attr->attr_next) {
42988404SAndrew.W.Wilson@sun.com filebench_log(LOG_DEBUG_IMPL,
42998404SAndrew.W.Wilson@sun.com "attr %d = %d %llx?",
43008404SAndrew.W.Wilson@sun.com attr->attr_name,
43018404SAndrew.W.Wilson@sun.com name,
43028404SAndrew.W.Wilson@sun.com attr->attr_avd);
43038404SAndrew.W.Wilson@sun.com
43048404SAndrew.W.Wilson@sun.com if (attr->attr_name == name)
43058404SAndrew.W.Wilson@sun.com rtn = attr;
43068404SAndrew.W.Wilson@sun.com }
43078404SAndrew.W.Wilson@sun.com
43088404SAndrew.W.Wilson@sun.com if (rtn == NULL)
43098404SAndrew.W.Wilson@sun.com return (NULL);
43108404SAndrew.W.Wilson@sun.com
43118404SAndrew.W.Wilson@sun.com if (rtn->attr_param_list) {
43128404SAndrew.W.Wilson@sun.com filebench_log(LOG_DEBUG_SCRIPT, "attr is param list");
43138404SAndrew.W.Wilson@sun.com rtn->attr_avd = parser_list2varstring(rtn->attr_param_list);
43148404SAndrew.W.Wilson@sun.com }
43158404SAndrew.W.Wilson@sun.com
43168404SAndrew.W.Wilson@sun.com return (rtn);
43178404SAndrew.W.Wilson@sun.com }
43188404SAndrew.W.Wilson@sun.com
43198404SAndrew.W.Wilson@sun.com
43206550Saw148015 /*
43215184Sek110237 * Searches the attribute list for the command for the named attribute type.
43225184Sek110237 * The attribute list is created by the parser from the list of attributes
43235184Sek110237 * supplied with certain commands, such as the define and flowop commands.
43245184Sek110237 * Returns a pointer to the attribute structure if the named attribute is
43255184Sek110237 * found, otherwise returns NULL. If the attribute includes a parameter list,
43266212Saw148015 * the list is converted to a string and stored in the attr_avd field of
43275184Sek110237 * the returned attr_t struct.
43285184Sek110237 */
43295184Sek110237 static attr_t *
get_attr(cmd_t * cmd,int64_t name)43305184Sek110237 get_attr(cmd_t *cmd, int64_t name)
43315184Sek110237 {
43325184Sek110237 attr_t *attr;
43335184Sek110237 attr_t *rtn = NULL;
43345184Sek110237 char *string;
43355184Sek110237
43365184Sek110237 for (attr = cmd->cmd_attr_list; attr != NULL;
43375184Sek110237 attr = attr->attr_next) {
43385184Sek110237 filebench_log(LOG_DEBUG_IMPL,
43395184Sek110237 "attr %d = %d %llx?",
43405184Sek110237 attr->attr_name,
43415184Sek110237 name,
43426212Saw148015 attr->attr_avd);
43435184Sek110237
43445184Sek110237 if (attr->attr_name == name)
43455184Sek110237 rtn = attr;
43465184Sek110237 }
43475184Sek110237
43485184Sek110237 if (rtn == NULL)
43495184Sek110237 return (NULL);
43505184Sek110237
43515184Sek110237 if (rtn->attr_param_list) {
43525184Sek110237 filebench_log(LOG_DEBUG_SCRIPT, "attr is param list");
43535184Sek110237 string = parser_list2string(rtn->attr_param_list);
43545184Sek110237 if (string != NULL) {
43556212Saw148015 rtn->attr_avd = avd_str_alloc(string);
43565184Sek110237 filebench_log(LOG_DEBUG_SCRIPT,
43575184Sek110237 "attr string %s", string);
43585184Sek110237 }
43595184Sek110237 }
43605184Sek110237
43615184Sek110237 return (rtn);
43625184Sek110237 }
43635184Sek110237
43645184Sek110237 /*
43655184Sek110237 * Similar to get_attr, but converts the parameter string supplied with the
43666212Saw148015 * named attribute to an integer and stores the integer in the attr_avd
43675184Sek110237 * portion of the returned attr_t struct.
43685184Sek110237 */
43695184Sek110237 static attr_t *
get_attr_integer(cmd_t * cmd,int64_t name)43705184Sek110237 get_attr_integer(cmd_t *cmd, int64_t name)
43715184Sek110237 {
43725184Sek110237 attr_t *attr;
43735184Sek110237 attr_t *rtn = NULL;
43745184Sek110237
43755184Sek110237 for (attr = cmd->cmd_attr_list; attr != NULL;
43765184Sek110237 attr = attr->attr_next) {
43775184Sek110237 if (attr->attr_name == name)
43785184Sek110237 rtn = attr;
43795184Sek110237 }
43805184Sek110237
43815184Sek110237 if (rtn == NULL)
43825184Sek110237 return (NULL);
43835184Sek110237
43846212Saw148015 if (rtn->attr_param_list)
43856212Saw148015 rtn->attr_avd = parser_list2avd(rtn->attr_param_list);
43865184Sek110237
43875184Sek110237 return (rtn);
43885184Sek110237 }
43895184Sek110237
43905184Sek110237 /*
43915184Sek110237 * Similar to get_attr, but converts the parameter string supplied with the
43926212Saw148015 * named attribute to an integer and stores the integer in the attr_avd
43935184Sek110237 * portion of the returned attr_t struct. If no parameter string is supplied
43945184Sek110237 * then it defaults to TRUE (1).
43955184Sek110237 */
43965184Sek110237 static attr_t *
get_attr_bool(cmd_t * cmd,int64_t name)43975184Sek110237 get_attr_bool(cmd_t *cmd, int64_t name)
43985184Sek110237 {
43995184Sek110237 attr_t *attr;
44005184Sek110237 attr_t *rtn = NULL;
44015184Sek110237
44025184Sek110237 for (attr = cmd->cmd_attr_list; attr != NULL;
44035184Sek110237 attr = attr->attr_next) {
44045184Sek110237 if (attr->attr_name == name)
44055184Sek110237 rtn = attr;
44065184Sek110237 }
44075184Sek110237
44085184Sek110237 if (rtn == NULL)
44095184Sek110237 return (NULL);
44105184Sek110237
44115184Sek110237 if (rtn->attr_param_list) {
44126212Saw148015 rtn->attr_avd = parser_list2avd(rtn->attr_param_list);
44136212Saw148015
44146212Saw148015 } else if (rtn->attr_avd == NULL) {
44156212Saw148015 rtn->attr_avd = avd_bool_alloc(TRUE);
44166212Saw148015 }
44176212Saw148015
44186212Saw148015 /* boolean attributes cannot point to random variables */
44196212Saw148015 if (AVD_IS_RANDOM(rtn->attr_avd)) {
44206212Saw148015 filebench_log(LOG_ERROR,
44216212Saw148015 "define flowop: Boolean attr %s cannot be random", name);
44226212Saw148015 filebench_shutdown(1);
44236212Saw148015 return (NULL);
44245184Sek110237 }
44255184Sek110237
44265184Sek110237 return (rtn);
44275184Sek110237 }
44285184Sek110237
44295184Sek110237 /*
44306550Saw148015 * removes the newly allocated local var from the shared local var
44316550Saw148015 * list, then puts it at the head of the private local var list
44326550Saw148015 * supplied as the second argument.
44336550Saw148015 */
44346550Saw148015 static void
add_lvar_to_list(var_t * newlvar,var_t ** lvar_list)44356550Saw148015 add_lvar_to_list(var_t *newlvar, var_t **lvar_list)
44366550Saw148015 {
44376550Saw148015 var_t *prev;
44386550Saw148015
44396550Saw148015 /* remove from shared local list, if there */
44406550Saw148015 if (newlvar == filebench_shm->shm_var_loc_list) {
44416550Saw148015 /* on top of list, just grap */
44426550Saw148015 filebench_shm->shm_var_loc_list = newlvar->var_next;
44436550Saw148015 } else {
44446550Saw148015 /* find newvar on list and remove */
44456550Saw148015 for (prev = filebench_shm->shm_var_loc_list; prev;
44466550Saw148015 prev = prev->var_next) {
44476550Saw148015 if (prev->var_next == newlvar)
44486550Saw148015 prev->var_next = newlvar->var_next;
44496550Saw148015 }
44506550Saw148015 }
44516550Saw148015 newlvar->var_next = NULL;
44526550Saw148015
44536550Saw148015 /* add to flowop private local list at head */
44546550Saw148015 newlvar->var_next = *lvar_list;
44556550Saw148015 *lvar_list = newlvar;
44566550Saw148015 }
44576550Saw148015
44586550Saw148015 /*
44596550Saw148015 * Searches the attribute list for the command for any allocated local
44606550Saw148015 * variables. The attribute list is created by the parser from the list of
44616550Saw148015 * attributes supplied with certain commands, such as the define and flowop
44626550Saw148015 * commands. Places all found local vars onto the flowop's local variable
44636550Saw148015 * list.
44646550Saw148015 */
44656550Saw148015 static void
get_attr_lvars(cmd_t * cmd,flowop_t * flowop)44666550Saw148015 get_attr_lvars(cmd_t *cmd, flowop_t *flowop)
44676550Saw148015 {
44686550Saw148015 attr_t *attr;
44696550Saw148015 var_t *list_tail, *orig_lvar_list;
44706550Saw148015
44716550Saw148015 /* save the local var list */
44726550Saw148015 orig_lvar_list = flowop->fo_lvar_list;
44736550Saw148015
44746550Saw148015 for (attr = cmd->cmd_attr_list; attr != NULL;
44756550Saw148015 attr = attr->attr_next) {
44766550Saw148015
44776550Saw148015 if (attr->attr_name == FSA_LVAR_ASSIGN) {
44786550Saw148015 var_t *newvar, *prev;
44796550Saw148015
44806550Saw148015 if ((newvar = (var_t *)attr->attr_avd) == NULL)
44816550Saw148015 continue;
44826550Saw148015
44836550Saw148015 add_lvar_to_list(newvar, &flowop->fo_lvar_list);
44846550Saw148015 var_update_comp_lvars(newvar, orig_lvar_list, NULL);
44856550Saw148015 }
44866550Saw148015 }
44876550Saw148015 }
44886550Saw148015
44896550Saw148015 /*
44905184Sek110237 * Allocates memory for a list_t structure, initializes it to zero, and
44915184Sek110237 * returns a pointer to it. On failure, returns NULL.
44925184Sek110237 */
44935184Sek110237 static list_t *
alloc_list()44945184Sek110237 alloc_list()
44955184Sek110237 {
44965184Sek110237 list_t *list;
44975184Sek110237
44985184Sek110237 if ((list = malloc(sizeof (list_t))) == NULL) {
44995184Sek110237 return (NULL);
45005184Sek110237 }
45015184Sek110237
45025184Sek110237 (void) memset(list, 0, sizeof (list_t));
45035184Sek110237 return (list);
45045184Sek110237 }
45055184Sek110237
45065184Sek110237
45075184Sek110237 #define USAGE1 \
45085184Sek110237 "Usage:\n" \
45096613Sek110237 "go_filebench: interpret f script and generate file workload\n" \
45105184Sek110237 "Options:\n" \
45115184Sek110237 " [-h] Display verbose help\n" \
45125184Sek110237 " [-p] Disable opening /proc to set uacct to enable truss\n"
45135184Sek110237
45145184Sek110237 #define PARSER_CMDS \
45155184Sek110237 "create [files|filesets|processes]\n" \
45165184Sek110237 "stats [clear|snap]\n" \
45175184Sek110237 "stats command \"shell command $var1,$var2...\"\n" \
45185184Sek110237 "stats directory <directory>\n" \
45195184Sek110237 "sleep <sleep-value>\n" \
45205184Sek110237 "quit\n\n" \
45215184Sek110237 "Variables:\n" \
45225184Sek110237 "set $var = value\n" \
45235184Sek110237 " $var - regular variables\n" \
45245184Sek110237 " ${var} - internal special variables\n" \
45255184Sek110237 " $(var) - environment variables\n\n"
45265184Sek110237
45275184Sek110237 #define PARSER_EXAMPLE \
45285184Sek110237 "Example:\n\n" \
45296613Sek110237 "#!" FILEBENCHDIR "/bin/go_filebench -f\n" \
45305184Sek110237 "\n" \
45315184Sek110237 "define file name=bigfile,path=bigfile,size=1g,prealloc,reuse\n" \
45325184Sek110237 "define process name=randomizer\n" \
45335184Sek110237 "{\n" \
45345184Sek110237 " thread random-thread procname=randomizer\n" \
45355184Sek110237 " {\n" \
45365184Sek110237 " flowop read name=random-read,filename=bigfile,iosize=16k,random\n" \
45375184Sek110237 " }\n" \
45385184Sek110237 "}\n" \
45395184Sek110237 "create files\n" \
45405184Sek110237 "create processes\n" \
45415184Sek110237 "stats clear\n" \
45425184Sek110237 "sleep 30\n" \
45435184Sek110237 "stats snap\n"
45445184Sek110237
45455184Sek110237 /*
45465184Sek110237 * usage() display brief or verbose help for the filebench(1) command.
45475184Sek110237 */
45485184Sek110237 static void
usage(int help)45495184Sek110237 usage(int help)
45505184Sek110237 {
45515184Sek110237 if (help >= 1)
45525184Sek110237 (void) fprintf(stderr, USAGE1, cmdname);
45535184Sek110237 if (help >= 2) {
45545184Sek110237
45555184Sek110237 (void) fprintf(stderr,
45565184Sek110237 "\n'f' language definition:\n\n");
45575184Sek110237 fileset_usage();
45585184Sek110237 procflow_usage();
45595184Sek110237 threadflow_usage();
45605184Sek110237 flowoplib_usage();
45615184Sek110237 eventgen_usage();
45625184Sek110237 (void) fprintf(stderr, PARSER_CMDS);
45635184Sek110237 (void) fprintf(stderr, PARSER_EXAMPLE);
45645184Sek110237 }
45655184Sek110237 exit(E_USAGE);
45665184Sek110237 }
45675184Sek110237
45685184Sek110237 int
yywrap()45695184Sek110237 yywrap()
45705184Sek110237 {
45715184Sek110237 char buf[1024];
45725184Sek110237
45735184Sek110237 if (parentscript) {
45745184Sek110237 yyin = parentscript;
45755184Sek110237 yy_switchfilescript(yyin);
45765184Sek110237 parentscript = NULL;
45775184Sek110237 return (0);
45785184Sek110237 } else
45795184Sek110237 return (1);
45805184Sek110237 }
4581