summaryrefslogtreecommitdiff
path: root/usr/src
diff options
context:
space:
mode:
Diffstat (limited to 'usr/src')
-rw-r--r--usr/src/cmd/filebench/common/auto_comp.c10
-rw-r--r--usr/src/cmd/filebench/common/eventgen.c36
-rw-r--r--usr/src/cmd/filebench/common/eventgen.h1
-rw-r--r--usr/src/cmd/filebench/common/filebench.h2
-rw-r--r--usr/src/cmd/filebench/common/fileset.c37
-rw-r--r--usr/src/cmd/filebench/common/flowop.c105
-rw-r--r--usr/src/cmd/filebench/common/flowop_library.c218
-rw-r--r--usr/src/cmd/filebench/common/ipc.c60
-rw-r--r--usr/src/cmd/filebench/common/ipc.h57
-rw-r--r--usr/src/cmd/filebench/common/misc.c63
-rw-r--r--usr/src/cmd/filebench/common/parser_gram.y43
-rw-r--r--usr/src/cmd/filebench/common/procflow.c89
-rw-r--r--usr/src/cmd/filebench/common/stats.c38
-rw-r--r--usr/src/cmd/filebench/common/threadflow.c36
-rw-r--r--usr/src/cmd/filebench/common/vars.c13
-rw-r--r--usr/src/cmd/filebench/workloads/filemicro_delete.f4
16 files changed, 442 insertions, 370 deletions
diff --git a/usr/src/cmd/filebench/common/auto_comp.c b/usr/src/cmd/filebench/common/auto_comp.c
index 1c0a0b9074..81a5d24a98 100644
--- a/usr/src/cmd/filebench/common/auto_comp.c
+++ b/usr/src/cmd/filebench/common/auto_comp.c
@@ -19,7 +19,7 @@
* CDDL HEADER END
*/
/*
- * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
@@ -524,12 +524,13 @@ get_next_tokval(ac_iter_t *iterp)
}
/*
- * Bind the iterator to filebench_shm->var_list
+ * Bind the iterator to filebench_shm->shm_var_list
*/
+/* ARGSUSED */
static void
varname_bind(ac_iter_t *iterp, void *listp, void * nlistpp)
{
- iterp->listp = filebench_shm->var_list;
+ iterp->listp = filebench_shm->shm_var_list;
iterp->nlistpp = nlistpp;
}
@@ -599,6 +600,7 @@ get_next_rvarname(ac_iter_t *iterp)
* and contains up-to-date workload file names. The function calls
* search_loadfiles() to update the cache before the binding.
*/
+/* ARGSUSED */
static void
loadfile_bind(ac_iter_t *iterp, void *listp, void * nlistpp)
{
@@ -711,6 +713,7 @@ search_loadfiles(ac_fname_cache_t *fnamecache)
* parameters are passed from libtecla library. line points to user input
* buffer, and word_end is the index of the last character of user input.
*/
+/* ARGSUSED */
static void
parse_user_input(const char *line, int word_end, ac_inputline_t *input)
{
@@ -993,6 +996,7 @@ match_string(WordCompletion *cpl, const char *line, int word_end,
* string in user input in sequence until either the last string
* is reached and completed or the the matching fails.
*/
+/* ARGSUSED */
CPL_MATCH_FN(command_complete)
{
ac_inputline_t inputline;
diff --git a/usr/src/cmd/filebench/common/eventgen.c b/usr/src/cmd/filebench/common/eventgen.c
index f83c379293..f8e4dc7b66 100644
--- a/usr/src/cmd/filebench/common/eventgen.c
+++ b/usr/src/cmd/filebench/common/eventgen.c
@@ -61,9 +61,9 @@ eventgen_usage(void)
* Once eventgen_hz has been set by eventgen_setrate(),
* the routine sends eventgen_hz events per second until
* the program terminates. Events are posted by incrementing
- * filebench_shm->eventgen_q by the number of generated
+ * filebench_shm->shm_eventgen_q by the number of generated
* events then signalling the condition variable
- * filebench_shm->eventgen_cv to indicate to event consumers
+ * filebench_shm->shm_eventgen_cv to indicate to event consumers
* that more events are available.
*
* Eventgen_thread attempts to sleep for 10 event periods,
@@ -85,38 +85,42 @@ eventgen_thread(void)
hrtime_t delta;
int count;
- if (filebench_shm->eventgen_hz == 0) {
+ if (filebench_shm->shm_eventgen_hz == 0) {
(void) sleep(1);
continue;
}
/* Sleep for 10xperiod */
sleeptime.tv_sec = 0;
- sleeptime.tv_nsec = 1000000000UL / filebench_shm->eventgen_hz;
+ sleeptime.tv_nsec = FB_SEC2NSEC /
+ filebench_shm->shm_eventgen_hz;
+
sleeptime.tv_nsec *= 10;
if (sleeptime.tv_nsec < 1000UL)
sleeptime.tv_nsec = 1000UL;
- sleeptime.tv_sec = sleeptime.tv_nsec / 1000000000UL;
+
+ sleeptime.tv_sec = sleeptime.tv_nsec / FB_SEC2NSEC;
if (sleeptime.tv_sec > 0)
- sleeptime.tv_nsec -= (sleeptime.tv_sec * 1000000000UL);
+ sleeptime.tv_nsec -= (sleeptime.tv_sec * FB_SEC2NSEC);
+
(void) nanosleep(&sleeptime, NULL);
delta = gethrtime() - last;
last = gethrtime();
- count = (filebench_shm->eventgen_hz * delta) / 1000000000;
+ count = (filebench_shm->shm_eventgen_hz * delta) / FB_SEC2NSEC;
filebench_log(LOG_DEBUG_SCRIPT,
"delta %llums count %d",
(u_longlong_t)(delta / 1000000), count);
/* Send 'count' events */
- (void) ipc_mutex_lock(&filebench_shm->eventgen_lock);
+ (void) ipc_mutex_lock(&filebench_shm->shm_eventgen_lock);
/* Keep the producer with a max of 5 second depth */
- if (filebench_shm->eventgen_q <
- (5 * filebench_shm->eventgen_hz))
- filebench_shm->eventgen_q += count;
+ if (filebench_shm->shm_eventgen_q <
+ (5 * filebench_shm->shm_eventgen_hz))
+ filebench_shm->shm_eventgen_q += count;
- (void) pthread_cond_signal(&filebench_shm->eventgen_cv);
+ (void) pthread_cond_signal(&filebench_shm->shm_eventgen_cv);
- (void) ipc_mutex_unlock(&filebench_shm->eventgen_lock);
+ (void) ipc_mutex_unlock(&filebench_shm->shm_eventgen_lock);
}
}
@@ -150,7 +154,7 @@ eventgen_init(void)
var_t *
eventgen_ratevar(var_t *var)
{
- VAR_SET_INT(var, filebench_shm->eventgen_hz);
+ VAR_SET_INT(var, filebench_shm->shm_eventgen_hz);
return (var);
}
@@ -161,7 +165,7 @@ eventgen_ratevar(var_t *var)
void
eventgen_setrate(fbint_t rate)
{
- filebench_shm->eventgen_hz = (int)rate;
+ filebench_shm->shm_eventgen_hz = (int)rate;
}
/*
@@ -170,5 +174,5 @@ eventgen_setrate(fbint_t rate)
void
eventgen_reset(void)
{
- filebench_shm->eventgen_q = 0;
+ filebench_shm->shm_eventgen_q = 0;
}
diff --git a/usr/src/cmd/filebench/common/eventgen.h b/usr/src/cmd/filebench/common/eventgen.h
index 51d80f9aed..2f50fcac82 100644
--- a/usr/src/cmd/filebench/common/eventgen.h
+++ b/usr/src/cmd/filebench/common/eventgen.h
@@ -35,6 +35,7 @@
extern "C" {
#endif
+#define FB_SEC2NSEC 1000000000UL
void eventgen_init(void);
void eventgen_setrate(fbint_t rate);
var_t *eventgen_ratevar(var_t *var);
diff --git a/usr/src/cmd/filebench/common/filebench.h b/usr/src/cmd/filebench/common/filebench.h
index 28d8198b1c..5386425303 100644
--- a/usr/src/cmd/filebench/common/filebench.h
+++ b/usr/src/cmd/filebench/common/filebench.h
@@ -109,7 +109,7 @@ void filebench_shutdown(int error);
#define MIN(x, y) ((x) < (y) ? (x) : (y))
#endif
-#define FILEBENCH_VERSION "1.2.3"
+#define FILEBENCH_VERSION "1.2.4"
#define FILEBENCHDIR "/usr/benchmarks/filebench"
#define FILEBENCH_PROMPT "filebench> "
#define MAX_LINE_LEN 1024
diff --git a/usr/src/cmd/filebench/common/fileset.c b/usr/src/cmd/filebench/common/fileset.c
index 2a2819a287..284aef19ec 100644
--- a/usr/src/cmd/filebench/common/fileset.c
+++ b/usr/src/cmd/filebench/common/fileset.c
@@ -469,6 +469,8 @@ fileset_openfile(fileset_t *fileset,
* (FSE_EXISTS) state files are selected, while
* FILESET_PICKNOEXIST insures that only non extant
* (not FSE_EXISTS) state files are selected.
+ * Note that the selected fileset entry (file) is returned
+ * with its fse_lock field locked.
*/
filesetentry_t *
fileset_pick(fileset_t *fileset, int flags, int tid)
@@ -476,7 +478,7 @@ fileset_pick(fileset_t *fileset, int flags, int tid)
filesetentry_t *entry = NULL;
filesetentry_t *first = NULL;
- (void) ipc_mutex_lock(&filebench_shm->fileset_lock);
+ (void) ipc_mutex_lock(&filebench_shm->shm_fileset_lock);
while (entry == NULL) {
@@ -552,12 +554,12 @@ fileset_pick(fileset_t *fileset, int flags, int tid)
}
}
- (void) ipc_mutex_unlock(&filebench_shm->fileset_lock);
+ (void) ipc_mutex_unlock(&filebench_shm->shm_fileset_lock);
filebench_log(LOG_DEBUG_SCRIPT, "Picked file %s", entry->fse_path);
return (entry);
empty:
- (void) ipc_mutex_unlock(&filebench_shm->fileset_lock);
+ (void) ipc_mutex_unlock(&filebench_shm->shm_fileset_lock);
return (NULL);
}
@@ -1022,21 +1024,21 @@ fileset_define(avd_t name)
filebench_log(LOG_DEBUG_IMPL,
"Defining file %s", avd_get_str(name));
- (void) ipc_mutex_lock(&filebench_shm->fileset_lock);
+ (void) ipc_mutex_lock(&filebench_shm->shm_fileset_lock);
fileset->fs_dirgamma = avd_int_alloc(1500);
fileset->fs_sizegamma = avd_int_alloc(1500);
/* Add fileset to global list */
- if (filebench_shm->filesetlist == NULL) {
- filebench_shm->filesetlist = fileset;
+ if (filebench_shm->shm_filesetlist == NULL) {
+ filebench_shm->shm_filesetlist = fileset;
fileset->fs_next = NULL;
} else {
- fileset->fs_next = filebench_shm->filesetlist;
- filebench_shm->filesetlist = fileset;
+ fileset->fs_next = filebench_shm->shm_filesetlist;
+ filebench_shm->shm_filesetlist = fileset;
}
- (void) ipc_mutex_unlock(&filebench_shm->fileset_lock);
+ (void) ipc_mutex_unlock(&filebench_shm->shm_fileset_lock);
fileset->fs_name = name;
@@ -1091,7 +1093,7 @@ fileset_createset(fileset_t *fileset)
filebench_log(LOG_INFO,
"Creating/pre-allocating files and filesets");
- list = filebench_shm->filesetlist;
+ list = filebench_shm->shm_filesetlist;
while (list) {
/* check for raw files */
if (fileset_checkraw(list)) {
@@ -1133,18 +1135,19 @@ fileset_createset(fileset_t *fileset)
fileset_t *
fileset_find(char *name)
{
- fileset_t *fileset = filebench_shm->filesetlist;
+ fileset_t *fileset = filebench_shm->shm_filesetlist;
- (void) ipc_mutex_lock(&filebench_shm->fileset_lock);
+ (void) ipc_mutex_lock(&filebench_shm->shm_fileset_lock);
while (fileset) {
if (strcmp(name, avd_get_str(fileset->fs_name)) == 0) {
- (void) ipc_mutex_unlock(&filebench_shm->fileset_lock);
+ (void) ipc_mutex_unlock(
+ &filebench_shm->shm_fileset_lock);
return (fileset);
}
fileset = fileset->fs_next;
}
- (void) ipc_mutex_unlock(&filebench_shm->fileset_lock);
+ (void) ipc_mutex_unlock(&filebench_shm->shm_fileset_lock);
return (NULL);
}
@@ -1159,10 +1162,10 @@ fileset_find(char *name)
void
fileset_iter(int (*cmd)(fileset_t *fileset, int first))
{
- fileset_t *fileset = filebench_shm->filesetlist;
+ fileset_t *fileset = filebench_shm->shm_filesetlist;
int count = 0;
- (void) ipc_mutex_lock(&filebench_shm->fileset_lock);
+ (void) ipc_mutex_lock(&filebench_shm->shm_fileset_lock);
while (fileset) {
cmd(fileset, count == 0);
@@ -1170,7 +1173,7 @@ fileset_iter(int (*cmd)(fileset_t *fileset, int first))
count++;
}
- (void) ipc_mutex_unlock(&filebench_shm->fileset_lock);
+ (void) ipc_mutex_unlock(&filebench_shm->shm_fileset_lock);
}
/*
diff --git a/usr/src/cmd/filebench/common/flowop.c b/usr/src/cmd/filebench/common/flowop.c
index 1b86a0c8a4..1394152dd2 100644
--- a/usr/src/cmd/filebench/common/flowop.c
+++ b/usr/src/cmd/filebench/common/flowop.c
@@ -78,7 +78,7 @@ flowop_printlist(flowop_t *list)
void
flowop_printall(void)
{
- flowop_t *flowop = filebench_shm->flowoplist;
+ flowop_t *flowop = filebench_shm->shm_flowoplist;
while (flowop) {
filebench_log(LOG_VERBOSE, "flowop-list %s-%d",
@@ -300,7 +300,7 @@ flowop_start(threadflow_t *threadflow)
flowop->fo_stats.fs_stime = gethrtime();
/* Hold the flowop find lock as reader to prevent lookups */
- (void) pthread_rwlock_rdlock(&filebench_shm->flowop_find_lock);
+ (void) pthread_rwlock_rdlock(&filebench_shm->shm_flowop_find_lock);
/*
* Block until all processes have started, acting like
@@ -312,11 +312,11 @@ flowop_start(threadflow_t *threadflow)
* run_lock, allowing each waiting thread to lock
* and then immediately unlock it, then begin running.
*/
- (void) pthread_rwlock_wrlock(&filebench_shm->run_lock);
- (void) pthread_rwlock_unlock(&filebench_shm->run_lock);
+ (void) pthread_rwlock_wrlock(&filebench_shm->shm_run_lock);
+ (void) pthread_rwlock_unlock(&filebench_shm->shm_run_lock);
/* Create the runtime flowops from those defined by the script */
- (void) ipc_mutex_lock(&filebench_shm->flowop_lock);
+ (void) ipc_mutex_lock(&filebench_shm->shm_flowop_lock);
while (flowop) {
flowop_t *newflowop;
@@ -326,16 +326,32 @@ flowop_start(threadflow_t *threadflow)
flowop, 1, 0);
if (newflowop == NULL)
return;
+
+ /* check for fo_filename attribute, and resolve if present */
+ if (flowop->fo_filename) {
+ char *name;
+
+ name = avd_get_str(flowop->fo_filename);
+ newflowop->fo_fileset = fileset_find(name);
+
+ if (newflowop->fo_fileset == NULL) {
+ filebench_log(LOG_ERROR,
+ "flowop %s: file %s not found",
+ newflowop->fo_name, name);
+ filebench_shutdown(1);
+ }
+ }
+
if (flowop_initflow(newflowop) < 0) {
filebench_log(LOG_ERROR, "Flowop init of %s failed",
newflowop->fo_name);
}
flowop = flowop->fo_threadnext;
}
- (void) ipc_mutex_unlock(&filebench_shm->flowop_lock);
+ (void) ipc_mutex_unlock(&filebench_shm->shm_flowop_lock);
/* Release the find lock as reader to allow lookups */
- (void) pthread_rwlock_unlock(&filebench_shm->flowop_find_lock);
+ (void) pthread_rwlock_unlock(&filebench_shm->shm_flowop_find_lock);
/* Set to the start of the new flowop list */
flowop = threadflow->tf_ops;
@@ -369,18 +385,20 @@ flowop_start(threadflow_t *threadflow)
int i, count;
/* Abort if asked */
- if (threadflow->tf_abort || filebench_shm->f_abort)
+ if (threadflow->tf_abort || filebench_shm->shm_f_abort)
break;
/* Be quiet while stats are gathered */
- if (filebench_shm->bequiet) {
+ if (filebench_shm->shm_bequiet) {
(void) sleep(1);
continue;
}
/* Take it easy until everyone is ready to go */
- if (!filebench_shm->shm_running)
+ if (!filebench_shm->shm_running) {
(void) sleep(1);
+ continue;
+ }
if (flowop == NULL) {
filebench_log(LOG_ERROR, "flowop_read null flowop");
@@ -413,7 +431,8 @@ flowop_start(threadflow_t *threadflow)
flowop->fo_instance);
(void) ipc_mutex_lock(&threadflow->tf_lock);
threadflow->tf_abort = 1;
- filebench_shm->f_abort = FILEBENCH_ABORT_ERROR;
+ filebench_shm->shm_f_abort =
+ FILEBENCH_ABORT_ERROR;
(void) ipc_mutex_unlock(&threadflow->tf_lock);
break;
}
@@ -428,7 +447,7 @@ flowop_start(threadflow_t *threadflow)
threadflow->tf_abort = FILEBENCH_DONE;
if (filebench_shm->shm_rmode ==
FILEBENCH_MODE_Q1STDONE) {
- filebench_shm->f_abort =
+ filebench_shm->shm_f_abort =
FILEBENCH_ABORT_RSRC;
} else if (filebench_shm->shm_rmode !=
FILEBENCH_MODE_QALLDONE) {
@@ -441,7 +460,7 @@ flowop_start(threadflow_t *threadflow)
"($nfiles), or switch modes.",
flowop->fo_name,
flowop->fo_instance);
- filebench_shm->f_abort =
+ filebench_shm->shm_f_abort =
FILEBENCH_ABORT_ERROR;
}
(void) ipc_mutex_unlock(&threadflow->tf_lock);
@@ -455,10 +474,26 @@ flowop_start(threadflow_t *threadflow)
if (ret == FILEBENCH_DONE) {
(void) ipc_mutex_lock(&threadflow->tf_lock);
threadflow->tf_abort = FILEBENCH_DONE;
- filebench_shm->f_abort = FILEBENCH_ABORT_DONE;
+ filebench_shm->shm_f_abort =
+ FILEBENCH_ABORT_DONE;
(void) ipc_mutex_unlock(&threadflow->tf_lock);
break;
}
+
+ /*
+ * If we get here and the return is something other
+ * than FILEBENCH_OK, it means a spurious code
+ * was returned, so treat as major error. This
+ * probably indicates a bug in the flowop.
+ */
+ if (ret != FILEBENCH_OK) {
+ filebench_log(LOG_ERROR,
+ "Flowop %s unexpected return value = %d\n",
+ flowop->fo_name, ret);
+ filebench_shm->shm_f_abort =
+ FILEBENCH_ABORT_ERROR;
+ break;
+ }
}
/* advance to next flowop */
@@ -539,11 +574,11 @@ flowop_delete(flowop_t **flowoplist, flowop_t *flowop)
#endif
/* Delete from global list */
- entry = filebench_shm->flowoplist;
+ entry = filebench_shm->shm_flowoplist;
- if (flowop == filebench_shm->flowoplist) {
+ if (flowop == filebench_shm->shm_flowoplist) {
/* First on list */
- filebench_shm->flowoplist = flowop->fo_next;
+ filebench_shm->shm_flowoplist = flowop->fo_next;
found = 1;
} else {
while (entry->fo_next) {
@@ -594,7 +629,7 @@ flowop_delete_all(flowop_t **flowoplist)
flowop = *flowoplist;
- (void) ipc_mutex_lock(&filebench_shm->flowop_lock);
+ (void) ipc_mutex_lock(&filebench_shm->shm_flowop_lock);
while (flowop) {
if (flowop->fo_instance &&
@@ -606,7 +641,7 @@ flowop_delete_all(flowop_t **flowoplist)
flowop = flowop->fo_threadnext;
}
- (void) ipc_mutex_unlock(&filebench_shm->flowop_lock);
+ (void) ipc_mutex_unlock(&filebench_shm->shm_flowop_lock);
}
/*
@@ -622,7 +657,7 @@ flowop_delete_all(flowop_t **flowoplist)
* it returns a pointer to the allocated and initialized flowop,
* otherwise NULL.
*
- * filebench_shm->flowop_lock must be held by caller.
+ * filebench_shm->shm_flowop_lock must be held by caller.
*/
static flowop_t *
flowop_define_common(threadflow_t *threadflow, char *name, flowop_t *inherit,
@@ -651,12 +686,10 @@ flowop_define_common(threadflow_t *threadflow, char *name, flowop_t *inherit,
(void) ipc_mutex_lock(&flowop->fo_lock);
flowop->fo_next = NULL;
flowop->fo_threadnext = NULL;
- flowop->fo_fd = -1;
filebench_log(LOG_DEBUG_IMPL,
"flowop %s-%d calling init", name, instance);
} else {
(void) memset(flowop, 0, sizeof (flowop_t));
- flowop->fo_fd = -1;
flowop->fo_iters = avd_int_alloc(1);
flowop->fo_type = type;
(void) pthread_mutex_init(&flowop->fo_lock, ipc_mutexattr());
@@ -667,12 +700,12 @@ flowop_define_common(threadflow_t *threadflow, char *name, flowop_t *inherit,
flowop->fo_thread = threadflow;
/* Add flowop to global list */
- if (filebench_shm->flowoplist == NULL) {
- filebench_shm->flowoplist = flowop;
+ if (filebench_shm->shm_flowoplist == NULL) {
+ filebench_shm->shm_flowoplist = flowop;
flowop->fo_next = NULL;
} else {
- flowop->fo_next = filebench_shm->flowoplist;
- filebench_shm->flowoplist = flowop;
+ flowop->fo_next = filebench_shm->shm_flowoplist;
+ filebench_shm->shm_flowoplist = flowop;
}
(void) strcpy(flowop->fo_name, name);
@@ -710,10 +743,10 @@ flowop_define(threadflow_t *threadflow, char *name, flowop_t *inherit,
{
flowop_t *flowop;
- (void) ipc_mutex_lock(&filebench_shm->flowop_lock);
+ (void) ipc_mutex_lock(&filebench_shm->shm_flowop_lock);
flowop = flowop_define_common(threadflow, name,
inherit, instance, type);
- (void) ipc_mutex_unlock(&filebench_shm->flowop_lock);
+ (void) ipc_mutex_unlock(&filebench_shm->shm_flowop_lock);
if (flowop == NULL)
return (NULL);
@@ -736,8 +769,8 @@ static void
flowop_find_barrier(void)
{
/* Block on wrlock to ensure find waits for all creates */
- (void) pthread_rwlock_wrlock(&filebench_shm->flowop_find_lock);
- (void) pthread_rwlock_unlock(&filebench_shm->flowop_find_lock);
+ (void) pthread_rwlock_wrlock(&filebench_shm->shm_flowop_find_lock);
+ (void) pthread_rwlock_unlock(&filebench_shm->shm_flowop_find_lock);
}
/*
@@ -752,9 +785,9 @@ flowop_find(char *name)
flowop_find_barrier();
- (void) ipc_mutex_lock(&filebench_shm->flowop_lock);
+ (void) ipc_mutex_lock(&filebench_shm->shm_flowop_lock);
- flowop = filebench_shm->flowoplist;
+ flowop = filebench_shm->shm_flowoplist;
while (flowop) {
if (strcmp(name, flowop->fo_name) == 0) {
@@ -771,7 +804,7 @@ flowop_find(char *name)
flowop = flowop->fo_next;
}
- (void) ipc_mutex_unlock(&filebench_shm->flowop_lock);
+ (void) ipc_mutex_unlock(&filebench_shm->shm_flowop_lock);
return (result);
@@ -788,9 +821,9 @@ flowop_find_one(char *name, int instance)
flowop_find_barrier();
- (void) ipc_mutex_lock(&filebench_shm->flowop_lock);
+ (void) ipc_mutex_lock(&filebench_shm->shm_flowop_lock);
- test_flowop = filebench_shm->flowoplist;
+ test_flowop = filebench_shm->shm_flowoplist;
while (test_flowop) {
if ((strcmp(name, test_flowop->fo_name) == 0) &&
@@ -800,7 +833,7 @@ flowop_find_one(char *name, int instance)
test_flowop = test_flowop->fo_next;
}
- (void) ipc_mutex_unlock(&filebench_shm->flowop_lock);
+ (void) ipc_mutex_unlock(&filebench_shm->shm_flowop_lock);
return (test_flowop);
}
diff --git a/usr/src/cmd/filebench/common/flowop_library.c b/usr/src/cmd/filebench/common/flowop_library.c
index 3dc5adf2c7..e13692b569 100644
--- a/usr/src/cmd/filebench/common/flowop_library.c
+++ b/usr/src/cmd/filebench/common/flowop_library.c
@@ -321,14 +321,20 @@ static int
flowoplib_fdnum(threadflow_t *threadflow, flowop_t *flowop)
{
fbint_t entries;
+ int fdnumber = flowop->fo_fdnumber;
/* If the script sets the fd explicitly */
- if (flowop->fo_fdnumber > 0)
- return (flowop->fo_fdnumber);
+ if (fdnumber > 0)
+ return (fdnumber);
/* If the flowop defaults to persistent fd */
if (!avd_get_bool(flowop->fo_rotatefd))
- return (flowop->fo_fdnumber);
+ return (fdnumber);
+
+ if (flowop->fo_fileset == NULL) {
+ filebench_log(LOG_ERROR, "flowop NULL file");
+ return (FILEBENCH_ERROR);
+ }
entries = flowop->fo_fileset->fs_constentries;
@@ -988,7 +994,7 @@ static int
flowoplib_eventlimit(threadflow_t *threadflow, flowop_t *flowop)
{
/* Immediately bail if not set/enabled */
- if (filebench_shm->eventgen_hz == 0)
+ if (filebench_shm->shm_eventgen_hz == 0)
return (FILEBENCH_OK);
if (flowop->fo_initted == 0) {
@@ -998,16 +1004,17 @@ flowoplib_eventlimit(threadflow_t *threadflow, flowop_t *flowop)
}
flowop_beginop(threadflow, flowop);
- while (filebench_shm->eventgen_hz) {
- (void) ipc_mutex_lock(&filebench_shm->eventgen_lock);
- if (filebench_shm->eventgen_q > 0) {
- filebench_shm->eventgen_q--;
- (void) ipc_mutex_unlock(&filebench_shm->eventgen_lock);
+ while (filebench_shm->shm_eventgen_hz) {
+ (void) ipc_mutex_lock(&filebench_shm->shm_eventgen_lock);
+ if (filebench_shm->shm_eventgen_q > 0) {
+ filebench_shm->shm_eventgen_q--;
+ (void) ipc_mutex_unlock(
+ &filebench_shm->shm_eventgen_lock);
break;
}
- (void) pthread_cond_wait(&filebench_shm->eventgen_cv,
- &filebench_shm->eventgen_lock);
- (void) ipc_mutex_unlock(&filebench_shm->eventgen_lock);
+ (void) pthread_cond_wait(&filebench_shm->shm_eventgen_cv,
+ &filebench_shm->shm_eventgen_lock);
+ (void) ipc_mutex_unlock(&filebench_shm->shm_eventgen_lock);
}
flowop_endop(threadflow, flowop, 0);
return (FILEBENCH_OK);
@@ -1027,7 +1034,7 @@ flowoplib_iopslimit(threadflow_t *threadflow, flowop_t *flowop)
uint64_t events;
/* Immediately bail if not set/enabled */
- if (filebench_shm->eventgen_hz == 0)
+ if (filebench_shm->shm_eventgen_hz == 0)
return (FILEBENCH_OK);
if (flowop->fo_initted == 0) {
@@ -1061,18 +1068,19 @@ flowoplib_iopslimit(threadflow_t *threadflow, flowop_t *flowop)
events = iops;
flowop_beginop(threadflow, flowop);
- while (filebench_shm->eventgen_hz) {
+ while (filebench_shm->shm_eventgen_hz) {
- (void) ipc_mutex_lock(&filebench_shm->eventgen_lock);
- if (filebench_shm->eventgen_q >= events) {
- filebench_shm->eventgen_q -= events;
- (void) ipc_mutex_unlock(&filebench_shm->eventgen_lock);
+ (void) ipc_mutex_lock(&filebench_shm->shm_eventgen_lock);
+ if (filebench_shm->shm_eventgen_q >= events) {
+ filebench_shm->shm_eventgen_q -= events;
+ (void) ipc_mutex_unlock(
+ &filebench_shm->shm_eventgen_lock);
flowop->fo_tputbucket += events;
break;
}
- (void) pthread_cond_wait(&filebench_shm->eventgen_cv,
- &filebench_shm->eventgen_lock);
- (void) ipc_mutex_unlock(&filebench_shm->eventgen_lock);
+ (void) pthread_cond_wait(&filebench_shm->shm_eventgen_cv,
+ &filebench_shm->shm_eventgen_lock);
+ (void) ipc_mutex_unlock(&filebench_shm->shm_eventgen_lock);
}
flowop_endop(threadflow, flowop, 0);
@@ -1093,7 +1101,7 @@ flowoplib_opslimit(threadflow_t *threadflow, flowop_t *flowop)
uint64_t events;
/* Immediately bail if not set/enabled */
- if (filebench_shm->eventgen_hz == 0)
+ if (filebench_shm->shm_eventgen_hz == 0)
return (FILEBENCH_OK);
if (flowop->fo_initted == 0) {
@@ -1126,17 +1134,18 @@ flowoplib_opslimit(threadflow_t *threadflow, flowop_t *flowop)
events = ops;
flowop_beginop(threadflow, flowop);
- while (filebench_shm->eventgen_hz) {
- (void) ipc_mutex_lock(&filebench_shm->eventgen_lock);
- if (filebench_shm->eventgen_q >= events) {
- filebench_shm->eventgen_q -= events;
- (void) ipc_mutex_unlock(&filebench_shm->eventgen_lock);
+ while (filebench_shm->shm_eventgen_hz) {
+ (void) ipc_mutex_lock(&filebench_shm->shm_eventgen_lock);
+ if (filebench_shm->shm_eventgen_q >= events) {
+ filebench_shm->shm_eventgen_q -= events;
+ (void) ipc_mutex_unlock(
+ &filebench_shm->shm_eventgen_lock);
flowop->fo_tputbucket += events;
break;
}
- (void) pthread_cond_wait(&filebench_shm->eventgen_cv,
- &filebench_shm->eventgen_lock);
- (void) ipc_mutex_unlock(&filebench_shm->eventgen_lock);
+ (void) pthread_cond_wait(&filebench_shm->shm_eventgen_cv,
+ &filebench_shm->shm_eventgen_lock);
+ (void) ipc_mutex_unlock(&filebench_shm->shm_eventgen_lock);
}
flowop_endop(threadflow, flowop, 0);
@@ -1159,7 +1168,7 @@ flowoplib_bwlimit(threadflow_t *threadflow, flowop_t *flowop)
uint64_t events;
/* Immediately bail if not set/enabled */
- if (filebench_shm->eventgen_hz == 0)
+ if (filebench_shm->shm_eventgen_hz == 0)
return (FILEBENCH_OK);
if (flowop->fo_initted == 0) {
@@ -1196,17 +1205,18 @@ flowoplib_bwlimit(threadflow_t *threadflow, flowop_t *flowop)
(u_longlong_t)bytes, (u_longlong_t)events);
flowop_beginop(threadflow, flowop);
- while (filebench_shm->eventgen_hz) {
- (void) ipc_mutex_lock(&filebench_shm->eventgen_lock);
- if (filebench_shm->eventgen_q >= events) {
- filebench_shm->eventgen_q -= events;
- (void) ipc_mutex_unlock(&filebench_shm->eventgen_lock);
+ while (filebench_shm->shm_eventgen_hz) {
+ (void) ipc_mutex_lock(&filebench_shm->shm_eventgen_lock);
+ if (filebench_shm->shm_eventgen_q >= events) {
+ filebench_shm->shm_eventgen_q -= events;
+ (void) ipc_mutex_unlock(
+ &filebench_shm->shm_eventgen_lock);
flowop->fo_tputbucket += (events * MB);
break;
}
- (void) pthread_cond_wait(&filebench_shm->eventgen_cv,
- &filebench_shm->eventgen_lock);
- (void) ipc_mutex_unlock(&filebench_shm->eventgen_lock);
+ (void) pthread_cond_wait(&filebench_shm->shm_eventgen_cv,
+ &filebench_shm->shm_eventgen_lock);
+ (void) ipc_mutex_unlock(&filebench_shm->shm_eventgen_lock);
}
flowop_endop(threadflow, flowop, 0);
@@ -1295,7 +1305,7 @@ flowoplib_semblock_init(flowop_t *flowop)
{
#ifdef HAVE_SYSV_SEM
- int semid;
+ int sys_semid;
struct sembuf sbuf[2];
int highwater;
@@ -1307,16 +1317,7 @@ flowoplib_semblock_init(flowop_t *flowop)
filebench_log(LOG_DEBUG_IMPL, "flow %s-%d semblock init semid=%x",
flowop->fo_name, flowop->fo_instance, flowop->fo_semid_lw);
- /*
- * Raise the number of the hw queue, causing the posting side to
- * block if queue is > 2 x blocking value
- */
- if ((semid = semget(filebench_shm->semkey, FILEBENCH_NSEMS, 0)) == -1) {
- filebench_log(LOG_ERROR, "semblock init lookup %x failed: %s",
- filebench_shm->semkey,
- strerror(errno));
- return (FILEBENCH_ERROR);
- }
+ sys_semid = filebench_shm->shm_sys_semid;
if ((highwater = flowop->fo_semid_hw) == 0)
highwater = flowop->fo_constvalue; /* use constant value */
@@ -1326,7 +1327,7 @@ flowoplib_semblock_init(flowop_t *flowop)
sbuf[0].sem_num = (short)highwater;
sbuf[0].sem_op = avd_get_int(flowop->fo_highwater);
sbuf[0].sem_flg = 0;
- if ((semop(semid, &sbuf[0], 1) == -1) && errno) {
+ if ((semop(sys_semid, &sbuf[0], 1) == -1) && errno) {
filebench_log(LOG_ERROR, "semblock init post failed: %s (%d,"
"%d)", strerror(errno), sbuf[0].sem_num, sbuf[0].sem_op);
return (FILEBENCH_ERROR);
@@ -1356,6 +1357,8 @@ flowoplib_semblock_destruct(flowop_t *flowop)
#ifdef HAVE_SYSV_SEM
ipc_semidfree(flowop->fo_semid_lw);
ipc_semidfree(flowop->fo_semid_hw);
+ (void) semctl(filebench_shm->shm_sys_semid, 0, IPC_RMID);
+ filebench_shm->shm_sys_semid = -1;
#else
sem_destroy(&flowop->fo_sem);
#endif /* HAVE_SYSV_SEM */
@@ -1374,19 +1377,14 @@ flowoplib_semblock(threadflow_t *threadflow, flowop_t *flowop)
#ifdef HAVE_SYSV_SEM
struct sembuf sbuf[2];
int value = avd_get_int(flowop->fo_value);
- int semid;
+ int sys_semid;
struct timespec timeout;
- if ((semid = semget(filebench_shm->semkey, FILEBENCH_NSEMS, 0)) == -1) {
- filebench_log(LOG_ERROR, "lookup semop %x failed: %s",
- filebench_shm->semkey,
- strerror(errno));
- return (FILEBENCH_ERROR);
- }
+ sys_semid = filebench_shm->shm_sys_semid;
filebench_log(LOG_DEBUG_IMPL,
"flow %s-%d sem blocking on id %x num %x value %d",
- flowop->fo_name, flowop->fo_instance, semid,
+ flowop->fo_name, flowop->fo_instance, sys_semid,
flowop->fo_semid_hw, value);
/* Post, decrement the increment the hw queue */
@@ -1405,11 +1403,11 @@ flowoplib_semblock(threadflow_t *threadflow, flowop_t *flowop)
flowop_beginop(threadflow, flowop);
#ifdef HAVE_SEMTIMEDOP
- (void) semtimedop(semid, &sbuf[0], 1, &timeout);
- (void) semtimedop(semid, &sbuf[1], 1, &timeout);
+ (void) semtimedop(sys_semid, &sbuf[0], 1, &timeout);
+ (void) semtimedop(sys_semid, &sbuf[1], 1, &timeout);
#else
- (void) semop(semid, &sbuf[0], 1);
- (void) semop(semid, &sbuf[1], 1);
+ (void) semop(sys_semid, &sbuf[0], 1);
+ (void) semop(sys_semid, &sbuf[1], 1);
#endif /* HAVE_SEMTIMEDOP */
if (avd_get_bool(flowop->fo_blocking))
@@ -1499,7 +1497,7 @@ flowoplib_sempost(threadflow_t *threadflow, flowop_t *flowop)
while (target) {
#ifdef HAVE_SYSV_SEM
struct sembuf sbuf[2];
- int semid;
+ int sys_semid;
int blocking;
#else
int i;
@@ -1520,15 +1518,7 @@ flowoplib_sempost(threadflow_t *threadflow, flowop_t *flowop)
target->fo_instance,
target->fo_semid_lw);
- if ((semid = semget(filebench_shm->semkey,
- FILEBENCH_NSEMS, 0)) == -1) {
- filebench_log(LOG_ERROR,
- "lookup semop %x failed: %s",
- filebench_shm->semkey,
- strerror(errno));
- return (FILEBENCH_ERROR);
- }
-
+ sys_semid = filebench_shm->shm_sys_semid;
sbuf[0].sem_num = target->fo_semid_lw;
sbuf[0].sem_op = (short)value;
sbuf[0].sem_flg = 0;
@@ -1544,10 +1534,10 @@ flowoplib_sempost(threadflow_t *threadflow, flowop_t *flowop)
blocking = 0;
#ifdef HAVE_SEMTIMEDOP
- if ((semtimedop(semid, &sbuf[0], blocking + 1,
+ if ((semtimedop(sys_semid, &sbuf[0], blocking + 1,
&timeout) == -1) && (errno && (errno != EAGAIN))) {
#else
- if ((semop(semid, &sbuf[0], blocking + 1) == -1) &&
+ if ((semop(sys_semid, &sbuf[0], blocking + 1) == -1) &&
(errno && (errno != EAGAIN))) {
#endif /* HAVE_SEMTIMEDOP */
filebench_log(LOG_ERROR, "semop post failed: %s",
@@ -1641,6 +1631,11 @@ flowoplib_openfile_common(threadflow_t *threadflow, flowop_t *flowop, int fd)
char *fileset_name;
int tid = 0;
+ if (flowop->fo_fileset == NULL) {
+ filebench_log(LOG_ERROR, "flowop NULL file");
+ return (FILEBENCH_ERROR);
+ }
+
if ((fileset_name =
avd_get_str(flowop->fo_fileset->fs_name)) == NULL) {
filebench_log(LOG_ERROR,
@@ -1662,11 +1657,6 @@ flowoplib_openfile_common(threadflow_t *threadflow, flowop_t *flowop, int fd)
return (FILEBENCH_ERROR);
}
- if (flowop->fo_fileset == NULL) {
- filebench_log(LOG_ERROR, "flowop NULL file");
- return (FILEBENCH_ERROR);
- }
-
#ifdef HAVE_RAW_SUPPORT
if (flowop->fo_fileset->fs_attrs & FILESET_IS_RAW_DEV) {
int open_attrs = 0;
@@ -1807,8 +1797,10 @@ flowoplib_createfile(threadflow_t *threadflow, flowop_t *flowop)
}
/*
- * Emulates delete of a file. Picks an arbitrary filesetentry
- * whose file exists and uses unlink() to delete it. Clears
+ * Emulates delete of a file. If a valid fd is provided, it uses the
+ * filesetentry stored at that fd location to select the file to be
+ * deleted, otherwise it picks an arbitrary filesetentry
+ * whose file exists. It then uses unlink() to delete it and Clears
* the FSE_EXISTS flag for the filesetentry. Returns FILEBENCH_ERROR if the
* flowop has no associated fileset. Returns FILEBENCH_NORSC if an appropriate
* filesetentry cannot be found, and FILEBENCH_OK on success.
@@ -1820,17 +1812,38 @@ flowoplib_deletefile(threadflow_t *threadflow, flowop_t *flowop)
fileset_t *fileset;
char path[MAXPATHLEN];
char *pathtmp;
+ int fd = flowop->fo_fdnumber;
- if (flowop->fo_fileset == NULL) {
+ /* if fd specified, use it to access file */
+ if ((fd > 0) && ((file = threadflow->tf_fse[fd]) != NULL)) {
+
+ /* check whether file still open */
+ if (threadflow->tf_fd[fd] > 0) {
+ filebench_log(LOG_DEBUG_SCRIPT,
+ "flowop %s deleting still open file at fd = %d",
+ flowop->fo_name, fd);
+ }
+
+ /* indicate that the file will be deleted */
+ threadflow->tf_fse[fd] = NULL;
+
+ /* if here, we still have a valid file pointer */
+ fileset = file->fse_fileset;
+ } else {
+ /* Otherwise, pick arbitrary file */
+ file = NULL;
+ fileset = flowop->fo_fileset;
+ }
+
+
+ if (fileset == NULL) {
filebench_log(LOG_ERROR, "flowop NULL file");
return (FILEBENCH_ERROR);
}
- fileset = flowop->fo_fileset;
-
#ifdef HAVE_RAW_SUPPORT
/* can't be used with raw devices */
- if (flowop->fo_fileset->fs_attrs & FILESET_IS_RAW_DEV) {
+ if (fileset->fs_attrs & FILESET_IS_RAW_DEV) {
filebench_log(LOG_ERROR,
"flowop %s attempted a deletefile on RAW device",
flowop->fo_name);
@@ -1838,11 +1851,15 @@ flowoplib_deletefile(threadflow_t *threadflow, flowop_t *flowop)
}
#endif /* HAVE_RAW_SUPPORT */
- if ((file = fileset_pick(flowop->fo_fileset,
- FILESET_PICKEXISTS, 0)) == NULL) {
- filebench_log(LOG_DEBUG_SCRIPT, "flowop %s failed to pick file",
- flowop->fo_name);
- return (FILEBENCH_NORSC);
+ if (file == NULL) {
+ if ((file = fileset_pick(fileset, FILESET_PICKEXISTS, 0))
+ == NULL) {
+ filebench_log(LOG_DEBUG_SCRIPT,
+ "flowop %s failed to pick file", flowop->fo_name);
+ return (FILEBENCH_NORSC);
+ }
+ } else {
+ (void) ipc_mutex_lock(&file->fse_lock);
}
*path = 0;
@@ -1967,7 +1984,6 @@ flowoplib_closefile(threadflow_t *threadflow, flowop_t *flowop)
file = threadflow->tf_fse[fd];
threadflow->tf_fd[fd] = 0;
- threadflow->tf_fse[fd] = NULL;
filebench_log(LOG_DEBUG_SCRIPT, "closed file %s", file->fse_path);
@@ -1989,16 +2005,14 @@ flowoplib_statfile(threadflow_t *threadflow, flowop_t *flowop)
char path[MAXPATHLEN];
char *pathtmp;
- if (flowop->fo_fileset == NULL) {
+ if ((fileset = flowop->fo_fileset) == NULL) {
filebench_log(LOG_ERROR, "flowop NULL file");
return (FILEBENCH_ERROR);
}
- fileset = flowop->fo_fileset;
-
- if ((file = fileset_pick(flowop->fo_fileset,
- FILESET_PICKEXISTS, 0)) == NULL) {
- filebench_log(LOG_DEBUG_SCRIPT, "flowop %s failed to pick file",
+ if ((file = fileset_pick(fileset, FILESET_PICKEXISTS, 0)) == NULL) {
+ filebench_log(LOG_DEBUG_SCRIPT,
+ "flowop %s failed to pick file",
flowop->fo_name);
return (FILEBENCH_NORSC);
}
@@ -2043,7 +2057,6 @@ flowoplib_readwholefile(threadflow_t *threadflow, flowop_t *flowop)
{
caddr_t iobuf;
off64_t bytes = 0;
- int fd = flowop->fo_fdnumber;
int filedesc;
uint64_t wss;
fbint_t iosize;
@@ -2084,8 +2097,8 @@ flowoplib_readwholefile(threadflow_t *threadflow, flowop_t *flowop)
if (ret < 0) {
filebench_log(LOG_ERROR,
- "Failed to read fd %d: %s",
- fd, strerror(errno));
+ "readwhole fail Failed to read whole file: %s",
+ strerror(errno));
return (FILEBENCH_ERROR);
}
@@ -2143,8 +2156,7 @@ flowoplib_write(threadflow_t *threadflow, flowop_t *flowop)
flowop_endop(threadflow, flowop, iosize);
} else {
flowop_beginop(threadflow, flowop);
- if (write(filedesc, iobuf,
- iosize) == -1) {
+ if (write(filedesc, iobuf, iosize) == -1) {
filebench_log(LOG_ERROR,
"write failed, io buffer %zd: %s",
iobuf, strerror(errno));
diff --git a/usr/src/cmd/filebench/common/ipc.c b/usr/src/cmd/filebench/common/ipc.c
index ee92f7b020..e7593787b8 100644
--- a/usr/src/cmd/filebench/common/ipc.c
+++ b/usr/src/cmd/filebench/common/ipc.c
@@ -234,20 +234,23 @@ char *shmpath = NULL;
void
ipc_seminit(void)
{
- key_t key = filebench_shm->semkey;
+ key_t key = filebench_shm->shm_semkey;
+ int sys_semid;
/* Already done? */
- if (filebench_shm->seminit)
+ if (filebench_shm->shm_sys_semid >= 0)
return;
- if ((semget(key, FILEBENCH_NSEMS, IPC_CREAT |
+ if ((sys_semid = semget(key, FILEBENCH_NSEMS, IPC_CREAT |
S_IRUSR | S_IWUSR)) == -1) {
filebench_log(LOG_ERROR,
"could not create sysv semaphore set "
"(need to increase sems?): %s",
strerror(errno));
- exit(1);
+ filebench_shutdown(1);
}
+
+ filebench_shm->shm_sys_semid = sys_semid;
}
/*
@@ -273,7 +276,7 @@ ipc_init(void)
caddr_t c1;
caddr_t c2;
#ifdef HAVE_SEM_RMID
- int semid;
+ int sys_semid;
#endif
#ifdef HAVE_MKSTEMP
@@ -321,33 +324,37 @@ ipc_init(void)
c2 = (caddr_t)&filebench_shm->shm_marker;
(void) memset(filebench_shm, 0, c2 - c1);
- filebench_shm->epoch = gethrtime();
- filebench_shm->debug_level = LOG_VERBOSE;
+ filebench_shm->shm_epoch = gethrtime();
+ filebench_shm->shm_debug_level = LOG_VERBOSE;
filebench_shm->shm_rmode = FILEBENCH_MODE_TIMEOUT;
filebench_shm->shm_string_ptr = &filebench_shm->shm_strings[0];
filebench_shm->shm_ptr = (char *)filebench_shm->shm_addr;
filebench_shm->shm_path_ptr = &filebench_shm->shm_filesetpaths[0];
/* Setup mutexes for object lists */
- (void) pthread_mutex_init(&filebench_shm->fileset_lock,
+ (void) pthread_mutex_init(&filebench_shm->shm_fileset_lock,
ipc_mutexattr());
- (void) pthread_mutex_init(&filebench_shm->procflow_lock,
+ (void) pthread_mutex_init(&filebench_shm->shm_procflow_lock,
ipc_mutexattr());
- (void) pthread_mutex_init(&filebench_shm->threadflow_lock,
+ (void) pthread_mutex_init(&filebench_shm->shm_threadflow_lock,
ipc_mutexattr());
- (void) pthread_mutex_init(&filebench_shm->flowop_lock, ipc_mutexattr());
- (void) pthread_mutex_init(&filebench_shm->msg_lock, ipc_mutexattr());
- (void) pthread_mutex_init(&filebench_shm->eventgen_lock,
+ (void) pthread_mutex_init(&filebench_shm->shm_flowop_lock,
+ ipc_mutexattr());
+ (void) pthread_mutex_init(&filebench_shm->shm_msg_lock,
+ ipc_mutexattr());
+ (void) pthread_mutex_init(&filebench_shm->shm_eventgen_lock,
ipc_mutexattr());
(void) pthread_mutex_init(&filebench_shm->shm_malloc_lock,
ipc_mutexattr());
(void) pthread_mutex_init(&filebench_shm->shm_ism_lock,
ipc_mutexattr());
- (void) pthread_cond_init(&filebench_shm->eventgen_cv, ipc_condattr());
- (void) pthread_rwlock_init(&filebench_shm->flowop_find_lock,
+ (void) pthread_cond_init(&filebench_shm->shm_eventgen_cv,
+ ipc_condattr());
+ (void) pthread_rwlock_init(&filebench_shm->shm_flowop_find_lock,
+ ipc_rwlockattr());
+ (void) pthread_rwlock_init(&filebench_shm->shm_run_lock,
ipc_rwlockattr());
- (void) pthread_rwlock_init(&filebench_shm->run_lock, ipc_rwlockattr());
- (void) pthread_rwlock_rdlock(&filebench_shm->run_lock);
+ (void) pthread_rwlock_rdlock(&filebench_shm->shm_run_lock);
(void) ipc_mutex_lock(&filebench_shm->shm_ism_lock);
@@ -359,14 +366,15 @@ ipc_init(void)
}
#ifdef HAVE_SEM_RMID
- if ((semid = semget(key, 0, 0)) != -1)
- (void) semctl(semid, 0, IPC_RMID);
+ if ((sys_semid = semget(key, 0, 0)) != -1)
+ (void) semctl(sys_semid, 0, IPC_RMID);
#endif
- filebench_shm->semkey = key;
- filebench_shm->log_fd = -1;
- filebench_shm->dump_fd = -1;
- filebench_shm->eventgen_hz = 0;
+ filebench_shm->shm_semkey = key;
+ filebench_shm->shm_sys_semid = -1;
+ filebench_shm->shm_log_fd = -1;
+ filebench_shm->shm_dump_fd = -1;
+ filebench_shm->shm_eventgen_hz = 0;
filebench_shm->shm_id = -1;
free(buf);
@@ -660,14 +668,14 @@ ipc_semidalloc(void)
{
int semid;
- for (semid = 0; filebench_shm->semids[semid] == 1; semid++)
+ for (semid = 0; filebench_shm->shm_semids[semid] == 1; semid++)
;
if (semid == FILEBENCH_NSEMS) {
filebench_log(LOG_ERROR,
"Out of semaphores, increase system tunable limit");
filebench_shutdown(1);
}
- filebench_shm->semids[semid] = 1;
+ filebench_shm->shm_semids[semid] = 1;
return (semid);
}
@@ -678,7 +686,7 @@ ipc_semidalloc(void)
void
ipc_semidfree(int semid)
{
- filebench_shm->semids[semid] = 0;
+ filebench_shm->shm_semids[semid] = 0;
}
/*
diff --git a/usr/src/cmd/filebench/common/ipc.h b/usr/src/cmd/filebench/common/ipc.h
index eb90b9b891..e60416f3ee 100644
--- a/usr/src/cmd/filebench/common/ipc.h
+++ b/usr/src/cmd/filebench/common/ipc.h
@@ -80,51 +80,51 @@ extern "C" {
#define FILEBENCH_MODE_QALLDONE 0x2
typedef struct filebench_shm {
- pthread_mutex_t fileset_lock;
- pthread_mutex_t procflow_lock;
- pthread_mutex_t threadflow_lock;
- pthread_mutex_t flowop_lock;
- pthread_mutex_t msg_lock;
+ pthread_mutex_t shm_fileset_lock;
+ pthread_mutex_t shm_procflow_lock;
+ pthread_mutex_t shm_threadflow_lock;
+ pthread_mutex_t shm_flowop_lock;
+ pthread_mutex_t shm_msg_lock;
pthread_mutex_t shm_malloc_lock;
pthread_mutex_t shm_ism_lock;
- pthread_rwlock_t run_lock;
- pthread_rwlock_t flowop_find_lock;
+ pthread_rwlock_t shm_run_lock;
+ pthread_rwlock_t shm_flowop_find_lock;
char *shm_string_ptr;
char *shm_path_ptr;
- fileset_t *filesetlist;
- flowop_t *flowoplist;
- procflow_t *proclist;
- var_t *var_list;
- var_t *var_dyn_list;
+ fileset_t *shm_filesetlist;
+ flowop_t *shm_flowoplist;
+ procflow_t *shm_proclist;
+ var_t *shm_var_list;
+ var_t *shm_var_dyn_list;
randdist_t *shm_rand_list;
- int debug_level;
- hrtime_t epoch;
+ int shm_debug_level;
+ hrtime_t shm_epoch;
hrtime_t shm_starttime;
- int bequiet;
- key_t semkey;
- int seminit;
- int semid_seq;
- int utid;
- int log_fd;
- int dump_fd;
- char dump_filename[MAXPATHLEN];
- pthread_mutex_t eventgen_lock;
- pthread_cond_t eventgen_cv;
- int eventgen_hz;
- uint64_t eventgen_q;
- char fscriptname[1024];
+ int shm_bequiet;
+ key_t shm_semkey;
+ int shm_sys_semid;
+ int shm_utid;
+ int shm_log_fd;
+ int shm_dump_fd;
+ char shm_dump_filename[MAXPATHLEN];
+ pthread_mutex_t shm_eventgen_lock;
+ pthread_cond_t shm_eventgen_cv;
+ int shm_eventgen_hz;
+ uint64_t shm_eventgen_q;
+ char shm_fscriptname[1024];
int shm_id;
size_t shm_required;
size_t shm_allocated;
caddr_t shm_addr;
char *shm_ptr;
int shm_running;
- int f_abort;
+ int shm_f_abort;
int shm_rmode;
int shm_1st_err;
int shm_bitmap[FILEBENCH_TYPES][FILEBENCH_MAXBITMAP];
int shm_lastbitmapindex[FILEBENCH_TYPES];
+ char shm_semids[FILEBENCH_NSEMS];
int shm_marker;
@@ -138,7 +138,6 @@ typedef struct filebench_shm {
randdist_t shm_randdist[FILEBENCH_NRANDDISTS];
struct avd shm_avd_ptrs[FILEBENCH_NVARS * 2];
char shm_strings[FILEBENCH_STRINGMEMORY];
- char semids[FILEBENCH_NSEMS];
} filebench_shm_t;
extern char *shmpath;
diff --git a/usr/src/cmd/filebench/common/misc.c b/usr/src/cmd/filebench/common/misc.c
index bc0887e904..8d834f4cc4 100644
--- a/usr/src/cmd/filebench/common/misc.c
+++ b/usr/src/cmd/filebench/common/misc.c
@@ -174,7 +174,7 @@ extern int lex_lineno;
* and will open it on the first invocation. Other levels
* print to the stdout device, with the amount of information
* dependent on the error level and the current error level
- * setting in filebench_shm->debug_level.
+ * setting in filebench_shm->shm_debug_level.
*/
void filebench_log
__V((int level, const char *fmt, ...))
@@ -189,11 +189,11 @@ __V((int level, const char *fmt, ...))
/* open logfile if not already open and writing to it */
if ((level == LOG_LOG) &&
- (filebench_shm->log_fd < 0)) {
+ (filebench_shm->shm_log_fd < 0)) {
char path[MAXPATHLEN];
char *s;
- (void) strcpy(path, filebench_shm->fscriptname);
+ (void) strcpy(path, filebench_shm->shm_fscriptname);
if ((s = strstr(path, ".f")))
*s = 0;
else
@@ -201,7 +201,7 @@ __V((int level, const char *fmt, ...))
(void) strcat(path, ".csv");
- filebench_shm->log_fd =
+ filebench_shm->shm_log_fd =
open(path, O_RDWR | O_CREAT | O_TRUNC, 0666);
}
@@ -210,7 +210,7 @@ __V((int level, const char *fmt, ...))
* it gets reported to stdout
*/
if ((level == LOG_LOG) &&
- (filebench_shm->log_fd < 0)) {
+ (filebench_shm->shm_log_fd < 0)) {
(void) snprintf(line, sizeof (line), "Open logfile failed: %s",
strerror(errno));
level = LOG_ERROR;
@@ -218,19 +218,19 @@ __V((int level, const char *fmt, ...))
/* open dumpfile if not already open and writing to it */
if ((level == LOG_DUMP) &&
- (*filebench_shm->dump_filename == 0))
+ (*filebench_shm->shm_dump_filename == 0))
return;
if ((level == LOG_DUMP) &&
- (filebench_shm->dump_fd < 0)) {
+ (filebench_shm->shm_dump_fd < 0)) {
- filebench_shm->dump_fd =
- open(filebench_shm->dump_filename,
+ filebench_shm->shm_dump_fd =
+ open(filebench_shm->shm_dump_filename,
O_RDWR | O_CREAT | O_TRUNC, 0666);
}
if ((level == LOG_DUMP) &&
- (filebench_shm->dump_fd < 0)) {
+ (filebench_shm->shm_dump_fd < 0)) {
(void) snprintf(line, sizeof (line), "Open logfile failed: %s",
strerror(errno));
level = LOG_ERROR;
@@ -251,7 +251,7 @@ __V((int level, const char *fmt, ...))
/* Only log greater than debug setting */
if ((level != LOG_DUMP) && (level != LOG_LOG) &&
- (level > filebench_shm->debug_level))
+ (level > filebench_shm->shm_debug_level))
return;
now = gethrtime();
@@ -276,27 +276,29 @@ fatal:
}
/* Serialize messages to log */
- (void) ipc_mutex_lock(&filebench_shm->msg_lock);
+ (void) ipc_mutex_lock(&filebench_shm->shm_msg_lock);
if (level == LOG_LOG) {
- if (filebench_shm->log_fd > 0) {
+ if (filebench_shm->shm_log_fd > 0) {
(void) snprintf(buf, sizeof (buf), "%s\n", line);
- (void) write(filebench_shm->log_fd, buf, strlen(buf));
- (void) fsync(filebench_shm->log_fd);
- (void) ipc_mutex_unlock(&filebench_shm->msg_lock);
+ (void) write(filebench_shm->shm_log_fd, buf,
+ strlen(buf));
+ (void) fsync(filebench_shm->shm_log_fd);
+ (void) ipc_mutex_unlock(&filebench_shm->shm_msg_lock);
return;
}
} else if (level == LOG_DUMP) {
- if (filebench_shm->dump_fd != -1) {
+ if (filebench_shm->shm_dump_fd != -1) {
(void) snprintf(buf, sizeof (buf), "%s\n", line);
- (void) write(filebench_shm->dump_fd, buf, strlen(buf));
- (void) fsync(filebench_shm->dump_fd);
- (void) ipc_mutex_unlock(&filebench_shm->msg_lock);
+ (void) write(filebench_shm->shm_dump_fd, buf,
+ strlen(buf));
+ (void) fsync(filebench_shm->shm_dump_fd);
+ (void) ipc_mutex_unlock(&filebench_shm->shm_msg_lock);
return;
}
- } else if (filebench_shm->debug_level > LOG_INFO) {
+ } else if (filebench_shm->shm_debug_level > LOG_INFO) {
if (level < LOG_INFO)
(void) fprintf(stderr, "%5d: ", (int)my_pid);
else
@@ -305,7 +307,7 @@ fatal:
if (level < LOG_INFO) {
(void) fprintf(stderr, "%4.3f: %s",
- (now - filebench_shm->epoch) / FSECS,
+ (now - filebench_shm->shm_epoch) / FSECS,
line);
if (my_procflow == NULL)
@@ -315,13 +317,13 @@ fatal:
(void) fflush(stderr);
} else {
(void) fprintf(stdout, "%4.3f: %s",
- (now - filebench_shm->epoch) / FSECS,
+ (now - filebench_shm->shm_epoch) / FSECS,
line);
(void) fprintf(stdout, "\n");
(void) fflush(stdout);
}
- (void) ipc_mutex_unlock(&filebench_shm->msg_lock);
+ (void) ipc_mutex_unlock(&filebench_shm->shm_msg_lock);
}
/*
@@ -331,11 +333,18 @@ fatal:
*/
void
filebench_shutdown(int error) {
- filebench_log(LOG_DEBUG_IMPL, "Shutdown");
- (void) unlink("/tmp/filebench_shm");
+
+ if (error) {
+ filebench_log(LOG_DEBUG_IMPL, "Shutdown on error");
+ filebench_shm->shm_f_abort = FILEBENCH_ABORT_ERROR;
+ } else {
+ filebench_log(LOG_DEBUG_IMPL, "Shutdown");
+ }
+
if (filebench_shm->shm_running)
procflow_shutdown();
- filebench_shm->f_abort = 1;
+
+ (void) unlink("/tmp/filebench_shm");
ipc_ismdelete();
exit(error);
}
diff --git a/usr/src/cmd/filebench/common/parser_gram.y b/usr/src/cmd/filebench/common/parser_gram.y
index 3c12884c2d..cbfe0bae52 100644
--- a/usr/src/cmd/filebench/common/parser_gram.y
+++ b/usr/src/cmd/filebench/common/parser_gram.y
@@ -701,8 +701,8 @@ debug_command: FSC_DEBUG FSV_VAL_INT
if (($$ = alloc_cmd()) == NULL)
YYERROR;
$$->cmd = NULL;
- filebench_shm->debug_level = $2;
- if (filebench_shm->debug_level > 9)
+ filebench_shm->shm_debug_level = $2;
+ if (filebench_shm->shm_debug_level > 9)
yydebug = 1;
};
@@ -1608,7 +1608,7 @@ main(int argc, char *argv[])
ipc_init();
if (fscriptname)
- (void) strcpy(filebench_shm->fscriptname, fscriptname);
+ (void) strcpy(filebench_shm->shm_fscriptname, fscriptname);
flowop_init();
stats_init();
@@ -2073,21 +2073,6 @@ parser_flowop_get_attrs(cmd_t *cmd, flowop_t *flowop)
"define flowop: no filename specfied");
filebench_shutdown(1);
}
-
- if ((flowop->fo_filename->avd_type == AVD_VAL_STR) ||
- (flowop->fo_filename->avd_type == AVD_VARVAL_STR)) {
- char *name;
-
- name = avd_get_str(flowop->fo_filename);
- flowop->fo_fileset = fileset_find(name);
-
- if (flowop->fo_fileset == NULL) {
- filebench_log(LOG_ERROR,
- "flowop %s: file %s not found",
- flowop->fo_name, name);
- filebench_shutdown(1);
- }
- }
}
/* Get the iosize of the op */
@@ -2467,7 +2452,7 @@ parser_proc_create(cmd_t *cmd)
}
/* Release the read lock, allowing threads to start */
- (void) pthread_rwlock_unlock(&filebench_shm->run_lock);
+ (void) pthread_rwlock_unlock(&filebench_shm->shm_run_lock);
/* Wait for all threads to start */
if (procflow_allstarted() != 0) {
@@ -2537,8 +2522,14 @@ parser_proc_shutdown(cmd_t *cmd)
static void
parser_filebench_shutdown(cmd_t *cmd)
{
+ int f_abort = filebench_shm->shm_f_abort;
+
ipc_cleanup();
- filebench_shutdown(0);
+
+ if (f_abort == FILEBENCH_ABORT_ERROR)
+ filebench_shutdown(1);
+ else
+ filebench_shutdown(0);
}
/*
@@ -2557,7 +2548,7 @@ parser_pause(int ptime)
while (timeslept < ptime) {
(void) sleep(1);
timeslept++;
- if (filebench_shm->f_abort)
+ if (filebench_shm->shm_f_abort)
break;
}
} else {
@@ -2566,7 +2557,7 @@ parser_pause(int ptime)
while (1) {
(void) sleep(1);
timeslept++;
- if (filebench_shm->f_abort)
+ if (filebench_shm->shm_f_abort)
break;
}
}
@@ -2592,7 +2583,7 @@ parser_run(cmd_t *cmd)
parser_proc_create(cmd);
/* check for startup errors */
- if (filebench_shm->f_abort)
+ if (filebench_shm->shm_f_abort)
return;
filebench_log(LOG_INFO, "Running...");
@@ -2623,7 +2614,7 @@ parser_run_variable(cmd_t *cmd)
runtime = avd_get_int(integer);
/* check for startup errors */
- if (filebench_shm->f_abort)
+ if (filebench_shm->shm_f_abort)
return;
filebench_log(LOG_INFO, "Running...");
@@ -2719,7 +2710,7 @@ parser_sleep(cmd_t *cmd)
int sleeptime;
/* check for startup errors */
- if (filebench_shm->f_abort)
+ if (filebench_shm->shm_f_abort)
return;
sleeptime = cmd->cmd_qty;
@@ -2769,7 +2760,7 @@ parser_sleep_variable(cmd_t *cmd)
sleeptime = avd_get_int(integer);
/* check for startup errors */
- if (filebench_shm->f_abort)
+ if (filebench_shm->shm_f_abort)
return;
filebench_log(LOG_INFO, "Running...");
diff --git a/usr/src/cmd/filebench/common/procflow.c b/usr/src/cmd/filebench/common/procflow.c
index 02d92059ab..37cd222fd7 100644
--- a/usr/src/cmd/filebench/common/procflow.c
+++ b/usr/src/cmd/filebench/common/procflow.c
@@ -191,7 +191,7 @@ procflow_createproc(procflow_t *procflow)
/*
* Find a procflow of name "name" and instance "instance" on the
- * master procflow list, filebench_shm->proclist. Locks the list
+ * master procflow list, filebench_shm->shm_proclist. Locks the list
* and scans through it searching for a procflow with matching
* name and instance number. If found returns a pointer to the
* procflow, otherwise returns NULL.
@@ -199,12 +199,12 @@ procflow_createproc(procflow_t *procflow)
static procflow_t *
procflow_find(char *name, int instance)
{
- procflow_t *procflow = filebench_shm->proclist;
+ procflow_t *procflow = filebench_shm->shm_proclist;
filebench_log(LOG_DEBUG_IMPL, "Find: (%s-%d) proclist = %zx",
name, instance, procflow);
- (void) ipc_mutex_lock(&filebench_shm->procflow_lock);
+ (void) ipc_mutex_lock(&filebench_shm->shm_procflow_lock);
while (procflow) {
filebench_log(LOG_DEBUG_IMPL, "Find: (%s-%d) == (%s-%d)",
@@ -214,14 +214,15 @@ procflow_find(char *name, int instance)
if ((strcmp(name, procflow->pf_name) == 0) &&
(instance == procflow->pf_instance)) {
- (void) ipc_mutex_unlock(&filebench_shm->procflow_lock);
+ (void) ipc_mutex_unlock(
+ &filebench_shm->shm_procflow_lock);
return (procflow);
}
procflow = procflow->pf_next;
}
- (void) ipc_mutex_unlock(&filebench_shm->procflow_lock);
+ (void) ipc_mutex_unlock(&filebench_shm->shm_procflow_lock);
return (NULL);
}
@@ -229,7 +230,7 @@ procflow_find(char *name, int instance)
static int
procflow_create_all_procs(void)
{
- procflow_t *procflow = filebench_shm->proclist;
+ procflow_t *procflow = filebench_shm->shm_proclist;
int ret = 0;
while (procflow) {
@@ -245,7 +246,7 @@ procflow_create_all_procs(void)
/* Create processes */
newproc =
- procflow_define_common(&filebench_shm->proclist,
+ procflow_define_common(&filebench_shm->shm_proclist,
procflow->pf_name, procflow, i + 1);
if (newproc == NULL)
ret = -1;
@@ -330,9 +331,9 @@ procflow_exec(char *name, int instance)
}
procflow->pf_running = 0;
- (void) ipc_mutex_lock(&filebench_shm->procflow_lock);
+ (void) ipc_mutex_lock(&filebench_shm->shm_procflow_lock);
filebench_shm->shm_running --;
- (void) ipc_mutex_unlock(&filebench_shm->procflow_lock);
+ (void) ipc_mutex_unlock(&filebench_shm->shm_procflow_lock);
return (ret);
}
@@ -348,7 +349,7 @@ procflow_exec(char *name, int instance)
static void *
procflow_createnwait(void *nothing)
{
- (void) ipc_mutex_lock(&filebench_shm->procflow_lock);
+ (void) ipc_mutex_lock(&filebench_shm->shm_procflow_lock);
if (procflow_create_all_procs() == 0)
cnw_wait = CNW_DONE;
@@ -358,7 +359,7 @@ procflow_createnwait(void *nothing)
if (pthread_cond_signal(&procflow_procs_created) != 0)
exit(1);
- (void) ipc_mutex_unlock(&filebench_shm->procflow_lock);
+ (void) ipc_mutex_unlock(&filebench_shm->shm_procflow_lock);
/* CONSTCOND */
while (1) {
@@ -369,7 +370,7 @@ procflow_createnwait(void *nothing)
pthread_exit(0);
/* if normal shutdown in progress, just quit */
- if (filebench_shm->f_abort)
+ if (filebench_shm->shm_f_abort)
pthread_exit(0);
if (status.si_code == CLD_EXITED) {
@@ -390,7 +391,7 @@ procflow_createnwait(void *nothing)
/* nothing running, exit */
if (filebench_shm->shm_running == 0) {
- filebench_shm->f_abort = FILEBENCH_ABORT_RSRC;
+ filebench_shm->shm_f_abort = FILEBENCH_ABORT_RSRC;
pthread_exit(0);
}
}
@@ -409,7 +410,7 @@ procflow_createnwait(void *nothing)
int
procflow_init(void)
{
- procflow_t *procflow = filebench_shm->proclist;
+ procflow_t *procflow = filebench_shm->shm_proclist;
pthread_t tid;
int ret = 0;
@@ -425,22 +426,22 @@ procflow_init(void)
if ((pthread_create(&tid, NULL, procflow_createnwait, NULL)) != 0)
return (ret);
- (void) ipc_mutex_lock(&filebench_shm->procflow_lock);
+ (void) ipc_mutex_lock(&filebench_shm->shm_procflow_lock);
if ((ret = pthread_cond_wait(&procflow_procs_created,
- &filebench_shm->procflow_lock)) != 0)
+ &filebench_shm->shm_procflow_lock)) != 0)
return (ret);
if (cnw_wait == CNW_ERROR)
ret = -1;
#else /* USE_PROCESS_MODEL */
- (void) ipc_mutex_lock(&filebench_shm->procflow_lock);
+ (void) ipc_mutex_lock(&filebench_shm->shm_procflow_lock);
ret = procflow_create_all_procs();
#endif /* USE_PROCESS_MODEL */
- (void) ipc_mutex_unlock(&filebench_shm->procflow_lock);
+ (void) ipc_mutex_unlock(&filebench_shm->shm_procflow_lock);
return (ret);
}
@@ -467,7 +468,7 @@ procflow_wait(pid_t pid)
* Deletes the designated procflow and all its threadflows except
* for FLOW_MASTER ones. Waits 10 seconds if the procflow is still
* running, then kills the associated process. Finally it frees the
- * procflow entity. filebench_shm->procflow_lock must be held on entry.
+ * procflow entity. filebench_shm->shm_procflow_lock must be held on entry.
*
* If the designated procflow is not found on the list it returns -1 and
* the procflow is not deleted. Otherwise it returns 0.
@@ -493,9 +494,11 @@ procflow_delete(procflow_t *procflow, int wait_cnt)
procflow->pf_pid);
if (wait_cnt) {
- (void) ipc_mutex_unlock(&filebench_shm->procflow_lock);
+ (void) ipc_mutex_unlock(
+ &filebench_shm->shm_procflow_lock);
(void) sleep(1);
- (void) ipc_mutex_lock(&filebench_shm->procflow_lock);
+ (void) ipc_mutex_lock(
+ &filebench_shm->shm_procflow_lock);
wait_cnt--;
continue;
}
@@ -514,12 +517,12 @@ procflow_delete(procflow_t *procflow, int wait_cnt)
procflow_wait(procflow->pf_pid);
#endif
/* remove entry from proclist */
- entry = filebench_shm->proclist;
+ entry = filebench_shm->shm_proclist;
/* unlink procflow entity from proclist */
if (entry == procflow) {
/* at head of list */
- filebench_shm->proclist = procflow->pf_next;
+ filebench_shm->shm_proclist = procflow->pf_next;
} else {
/* search list for procflow */
while (entry && entry->pf_next != procflow)
@@ -546,17 +549,17 @@ procflow_delete(procflow_t *procflow, int wait_cnt)
* anyway after logging the fact. Once pf_running is set
* to 1 for a given procflow or the timeout is reached,
* threadflow_allstarted() is called to start the threads.
- * Returns 0 (OK), unless filebench_shm->f_abort is signaled,
+ * Returns 0 (OK), unless filebench_shm->shm_f_abort is signaled,
* in which case it returns -1.
*/
int
procflow_allstarted()
{
- procflow_t *procflow = filebench_shm->proclist;
+ procflow_t *procflow = filebench_shm->shm_proclist;
int running_procs = 0;
int ret = 0;
- (void) ipc_mutex_lock(&filebench_shm->procflow_lock);
+ (void) ipc_mutex_lock(&filebench_shm->shm_procflow_lock);
(void) sleep(1);
@@ -571,8 +574,9 @@ procflow_allstarted()
waits = 10;
while (waits && procflow->pf_running == 0) {
- (void) ipc_mutex_unlock(&filebench_shm->procflow_lock);
- if (filebench_shm->f_abort == 1)
+ (void) ipc_mutex_unlock(
+ &filebench_shm->shm_procflow_lock);
+ if (filebench_shm->shm_f_abort == 1)
return (-1);
if (waits < 3)
@@ -584,7 +588,8 @@ procflow_allstarted()
(void) sleep(3);
waits--;
- (void) ipc_mutex_lock(&filebench_shm->procflow_lock);
+ (void) ipc_mutex_lock(
+ &filebench_shm->shm_procflow_lock);
}
if (waits == 0)
@@ -600,7 +605,7 @@ procflow_allstarted()
}
filebench_shm->shm_running = running_procs;
- (void) ipc_mutex_unlock(&filebench_shm->procflow_lock);
+ (void) ipc_mutex_unlock(&filebench_shm->shm_procflow_lock);
return (ret);
@@ -617,12 +622,12 @@ procflow_allstarted()
void
procflow_shutdown(void)
{
- procflow_t *procflow = filebench_shm->proclist;
+ procflow_t *procflow = filebench_shm->shm_proclist;
int wait_cnt;
- (void) ipc_mutex_lock(&filebench_shm->procflow_lock);
+ (void) ipc_mutex_lock(&filebench_shm->shm_procflow_lock);
filebench_shm->shm_running = 0;
- filebench_shm->f_abort = 1;
+ filebench_shm->shm_f_abort = 1;
wait_cnt = SHUTDOWN_WAIT_SECONDS;
while (procflow) {
@@ -642,9 +647,9 @@ procflow_shutdown(void)
wait_cnt--;
}
- filebench_shm->f_abort = 0;
+ filebench_shm->shm_f_abort = 0;
- (void) ipc_mutex_unlock(&filebench_shm->procflow_lock);
+ (void) ipc_mutex_unlock(&filebench_shm->shm_procflow_lock);
}
@@ -657,7 +662,7 @@ procflow_shutdown(void)
* procflow, or NULL if a name isn't supplied or the procflow
* entity cannot be allocated.
*
- * The calling routine must hold the filebench_shm->procflow_lock.
+ * The calling routine must hold the filebench_shm->shm_procflow_lock.
*/
static procflow_t *
procflow_define_common(procflow_t **list, char *name,
@@ -684,7 +689,7 @@ procflow_define_common(procflow_t **list, char *name,
filebench_log(LOG_DEBUG_IMPL, "defining process %s-%d", name, instance);
filebench_log(LOG_DEBUG_IMPL, "process %s-%d proclist %zx",
- name, instance, filebench_shm->proclist);
+ name, instance, filebench_shm->shm_proclist);
/* Add procflow to list, lock is being held already */
if (*list == NULL) {
*list = procflow;
@@ -694,14 +699,14 @@ procflow_define_common(procflow_t **list, char *name,
*list = procflow;
}
filebench_log(LOG_DEBUG_IMPL, "process %s-%d proclist %zx",
- name, instance, filebench_shm->proclist);
+ name, instance, filebench_shm->shm_proclist);
return (procflow);
}
/*
* Create an in-memory process object as described by the syntax.
- * Acquires the filebench_shm->procflow_lock and calls
+ * Acquires the filebench_shm->shm_procflow_lock and calls
* procflow_define_common() to create and initialize a
* FLOW_MASTER procflow entity from the optional "inherit"
* procflow with the given name and configured for "instances"
@@ -713,13 +718,13 @@ procflow_define(char *name, procflow_t *inherit, avd_t instances)
{
procflow_t *procflow;
- (void) ipc_mutex_lock(&filebench_shm->procflow_lock);
+ (void) ipc_mutex_lock(&filebench_shm->shm_procflow_lock);
- procflow = procflow_define_common(&filebench_shm->proclist,
+ procflow = procflow_define_common(&filebench_shm->shm_proclist,
name, inherit, FLOW_MASTER);
procflow->pf_instances = instances;
- (void) ipc_mutex_unlock(&filebench_shm->procflow_lock);
+ (void) ipc_mutex_unlock(&filebench_shm->shm_procflow_lock);
return (procflow);
}
diff --git a/usr/src/cmd/filebench/common/stats.c b/usr/src/cmd/filebench/common/stats.c
index fca191dbd2..bc1cdf1f8e 100644
--- a/usr/src/cmd/filebench/common/stats.c
+++ b/usr/src/cmd/filebench/common/stats.c
@@ -434,7 +434,7 @@ stats_snap(void)
}
/* don't print out if run ended in error */
- if (filebench_shm->f_abort == FILEBENCH_ABORT_ERROR) {
+ if (filebench_shm->shm_f_abort == FILEBENCH_ABORT_ERROR) {
filebench_log(LOG_ERROR,
"NO VALID RESULTS! FileBench run terminated prematurely");
return;
@@ -446,9 +446,9 @@ stats_snap(void)
(globalstats->fs_etime - globalstats->fs_stime) / 1000000000);
/* Freeze statistics during update */
- filebench_shm->bequiet = 1;
+ filebench_shm->shm_bequiet = 1;
- flowop = filebench_shm->flowoplist;
+ flowop = filebench_shm->shm_flowoplist;
while (flowop) {
flowop_t *flowop_master;
@@ -513,7 +513,7 @@ stats_snap(void)
(cputime - gl_stats_ohead()) : 0;
- flowop = filebench_shm->flowoplist;
+ flowop = filebench_shm->shm_flowoplist;
str = malloc(1048576);
*str = NULL;
(void) strcpy(str, "Per-Operation Breakdown\n");
@@ -568,7 +568,7 @@ stats_snap(void)
((iostat->fs_rcount + iostat->fs_wcount) * 1000000.0) : 0);
- filebench_shm->bequiet = 0;
+ filebench_shm->shm_bequiet = 0;
}
/*
@@ -582,21 +582,21 @@ stats_dump(char *filename)
flowop_t *flowop;
/* don't dump stats if run ended in error */
- if (filebench_shm->f_abort == FILEBENCH_ABORT_ERROR)
+ if (filebench_shm->shm_f_abort == FILEBENCH_ABORT_ERROR)
return;
- (void) strcpy(filebench_shm->dump_filename, filename);
+ (void) strcpy(filebench_shm->shm_dump_filename, filename);
filebench_log(LOG_INFO, "in statsdump %s", filename);
- if (filebench_shm->dump_fd > 0) {
- (void) close(filebench_shm->dump_fd);
- filebench_shm->dump_fd = -1;
+ if (filebench_shm->shm_dump_fd > 0) {
+ (void) close(filebench_shm->shm_dump_fd);
+ filebench_shm->shm_dump_fd = -1;
}
filebench_log(LOG_DUMP, "Flowop totals:");
- flowop = filebench_shm->flowoplist;
+ flowop = filebench_shm->shm_flowoplist;
while (flowop) {
if (flowop->fo_instance != FLOW_MASTER) {
@@ -658,21 +658,21 @@ stats_xmldump(char *filename)
flowop_t *flowop;
/* don't dump stats if run ended in error */
- if (filebench_shm->f_abort == FILEBENCH_ABORT_ERROR)
+ if (filebench_shm->shm_f_abort == FILEBENCH_ABORT_ERROR)
return;
- (void) strcpy(filebench_shm->dump_filename, filename);
+ (void) strcpy(filebench_shm->shm_dump_filename, filename);
- if (filebench_shm->dump_fd > 0) {
- (void) close(filebench_shm->dump_fd);
- filebench_shm->dump_fd = -1;
+ if (filebench_shm->shm_dump_fd > 0) {
+ (void) close(filebench_shm->shm_dump_fd);
+ filebench_shm->shm_dump_fd = -1;
}
filebench_log(LOG_DUMP, "<stat_doc name=\"Filebench Workload\">");
filebench_log(LOG_DUMP, "<stat_group name=\"Flowop totals\">");
filebench_log(LOG_DUMP, "<cell_list>");
- flowop = filebench_shm->flowoplist;
+ flowop = filebench_shm->shm_flowoplist;
while (flowop) {
if (flowop->fo_instance != FLOW_MASTER) {
flowop = flowop->fo_next;
@@ -707,7 +707,7 @@ stats_xmldump(char *filename)
filebench_log(LOG_DUMP, "</dim>");
filebench_log(LOG_DUMP, "<dim>");
- flowop = filebench_shm->flowoplist;
+ flowop = filebench_shm->shm_flowoplist;
while (flowop) {
if (flowop->fo_instance != FLOW_MASTER) {
flowop = flowop->fo_next;
@@ -782,7 +782,7 @@ stats_clear(void)
(void) memset(globalstats, 0, FLOW_TYPES * sizeof (flowstat_t));
- flowop = filebench_shm->flowoplist;
+ flowop = filebench_shm->shm_flowoplist;
while (flowop) {
filebench_log(LOG_DEBUG_IMPL, "Clearing stats for %s-%d",
diff --git a/usr/src/cmd/filebench/common/threadflow.c b/usr/src/cmd/filebench/common/threadflow.c
index 041241de27..6c99e339d9 100644
--- a/usr/src/cmd/filebench/common/threadflow.c
+++ b/usr/src/cmd/filebench/common/threadflow.c
@@ -158,7 +158,7 @@ threadflow_init(procflow_t *procflow)
threadflow_t *threadflow = procflow->pf_threads;
int ret = 0;
- (void) ipc_mutex_lock(&filebench_shm->threadflow_lock);
+ (void) ipc_mutex_lock(&filebench_shm->shm_threadflow_lock);
(void) signal(SIGUSR1, threadflow_cancel);
@@ -197,7 +197,7 @@ threadflow_init(procflow_t *procflow)
threadflow = procflow->pf_threads;
- (void) ipc_mutex_unlock(&filebench_shm->threadflow_lock);
+ (void) ipc_mutex_unlock(&filebench_shm->shm_threadflow_lock);
while (threadflow) {
/* wait for all threads to finish */
@@ -313,7 +313,7 @@ threadflow_delete_all(threadflow_t **threadlist, int wait_cnt)
{
threadflow_t *threadflow = *threadlist;
- (void) ipc_mutex_lock(&filebench_shm->threadflow_lock);
+ (void) ipc_mutex_lock(&filebench_shm->shm_threadflow_lock);
filebench_log(LOG_DEBUG_IMPL, "Deleting all threads");
@@ -330,7 +330,7 @@ threadflow_delete_all(threadflow_t **threadlist, int wait_cnt)
wait_cnt--;
}
- (void) ipc_mutex_unlock(&filebench_shm->threadflow_lock);
+ (void) ipc_mutex_unlock(&filebench_shm->shm_threadflow_lock);
}
/*
@@ -343,7 +343,7 @@ threadflow_delete_all(threadflow_t **threadlist, int wait_cnt)
void
threadflow_allstarted(pid_t pid, threadflow_t *threadflow)
{
- (void) ipc_mutex_lock(&filebench_shm->threadflow_lock);
+ (void) ipc_mutex_lock(&filebench_shm->shm_threadflow_lock);
while (threadflow) {
int waits;
@@ -360,9 +360,10 @@ threadflow_allstarted(pid_t pid, threadflow_t *threadflow)
threadflow->tf_instance);
waits = 10;
- while (waits && threadflow->tf_running == 0) {
+ while (waits && (threadflow->tf_running == 0) &&
+ (filebench_shm->shm_f_abort == 0)) {
(void) ipc_mutex_unlock(
- &filebench_shm->threadflow_lock);
+ &filebench_shm->shm_threadflow_lock);
if (waits < 3)
filebench_log(LOG_INFO,
"Waiting for pid %d thread %s-%d",
@@ -371,14 +372,15 @@ threadflow_allstarted(pid_t pid, threadflow_t *threadflow)
threadflow->tf_instance);
(void) sleep(1);
- (void) ipc_mutex_lock(&filebench_shm->threadflow_lock);
+ (void) ipc_mutex_lock(
+ &filebench_shm->shm_threadflow_lock);
waits--;
}
threadflow = threadflow->tf_next;
}
- (void) ipc_mutex_unlock(&filebench_shm->threadflow_lock);
+ (void) ipc_mutex_unlock(&filebench_shm->shm_threadflow_lock);
}
/*
@@ -392,7 +394,7 @@ threadflow_allstarted(pid_t pid, threadflow_t *threadflow)
* returned Otherwise a pointer to the newly allocated threadflow
* is returned.
*
- * The filebench_shm->threadflow_lock must be held by the caller.
+ * The filebench_shm->shm_threadflow_lock must be held by the caller.
*/
static threadflow_t *
threadflow_define_common(procflow_t *procflow, char *name,
@@ -414,7 +416,7 @@ threadflow_define_common(procflow_t *procflow, char *name,
else
(void) memset(threadflow, 0, sizeof (threadflow_t));
- threadflow->tf_utid = ++filebench_shm->utid;
+ threadflow->tf_utid = ++filebench_shm->shm_utid;
threadflow->tf_instance = instance;
(void) strcpy(threadflow->tf_name, name);
@@ -437,7 +439,7 @@ threadflow_define_common(procflow_t *procflow, char *name,
/*
* Create an in memory FLOW_MASTER thread object as described
- * by the syntax. Acquire the filebench_shm->threadflow_lock and
+ * by the syntax. Acquire the filebench_shm->shm_threadflow_lock and
* call threadflow_define_common() to create a threadflow entity.
* Set the number of instances to create at runtime,
* tf_instances, to "instances". Return the threadflow pointer
@@ -449,7 +451,7 @@ threadflow_define(procflow_t *procflow, char *name,
{
threadflow_t *threadflow;
- (void) ipc_mutex_lock(&filebench_shm->threadflow_lock);
+ (void) ipc_mutex_lock(&filebench_shm->shm_threadflow_lock);
if ((threadflow = threadflow_define_common(procflow, name,
inherit, FLOW_MASTER)) == NULL)
@@ -457,7 +459,7 @@ threadflow_define(procflow_t *procflow, char *name,
threadflow->tf_instances = instances;
- (void) ipc_mutex_unlock(&filebench_shm->threadflow_lock);
+ (void) ipc_mutex_unlock(&filebench_shm->shm_threadflow_lock);
return (threadflow);
}
@@ -473,20 +475,20 @@ threadflow_find(threadflow_t *threadlist, char *name)
{
threadflow_t *threadflow = threadlist;
- (void) ipc_mutex_lock(&filebench_shm->threadflow_lock);
+ (void) ipc_mutex_lock(&filebench_shm->shm_threadflow_lock);
while (threadflow) {
if (strcmp(name, threadflow->tf_name) == 0) {
(void) ipc_mutex_unlock(
- &filebench_shm->threadflow_lock);
+ &filebench_shm->shm_threadflow_lock);
return (threadflow);
}
threadflow = threadflow->tf_next;
}
- (void) ipc_mutex_unlock(&filebench_shm->threadflow_lock);
+ (void) ipc_mutex_unlock(&filebench_shm->shm_threadflow_lock);
return (NULL);
diff --git a/usr/src/cmd/filebench/common/vars.c b/usr/src/cmd/filebench/common/vars.c
index f3c26e562c..38fad4d540 100644
--- a/usr/src/cmd/filebench/common/vars.c
+++ b/usr/src/cmd/filebench/common/vars.c
@@ -528,15 +528,15 @@ var_alloc_cmn(char *name, int var_type)
switch (var_type & VAR_TYPE_MASK) {
case VAR_TYPE_RANDOM:
case VAR_TYPE_GLOBAL:
- var_listp = &filebench_shm->var_list;
+ var_listp = &filebench_shm->shm_var_list;
break;
case VAR_TYPE_DYNAMIC:
- var_listp = &filebench_shm->var_dyn_list;
+ var_listp = &filebench_shm->shm_var_dyn_list;
break;
default:
- var_listp = &filebench_shm->var_list;
+ var_listp = &filebench_shm->shm_var_list;
break;
}
@@ -585,7 +585,8 @@ var_find(char *name)
{
var_t *var;
- for (var = filebench_shm->var_list; var != NULL; var = var->var_next) {
+ for (var = filebench_shm->shm_var_list; var != NULL;
+ var = var->var_next) {
if (strcmp(var->var_name, name) == 0)
return (var);
}
@@ -1208,14 +1209,14 @@ static var_t *
var_find_dynamic(char *name)
{
var_t *var = NULL;
- var_t *v = filebench_shm->var_dyn_list;
+ var_t *v = filebench_shm->shm_var_dyn_list;
var_t *rtn;
/*
* Lookup a reference to the var handle for this
* special var
*/
- for (v = filebench_shm->var_dyn_list; v != NULL; v = v->var_next) {
+ for (v = filebench_shm->shm_var_dyn_list; v != NULL; v = v->var_next) {
if (strcmp(v->var_name, name) == 0) {
var = v;
break;
diff --git a/usr/src/cmd/filebench/workloads/filemicro_delete.f b/usr/src/cmd/filebench/workloads/filemicro_delete.f
index 7fff4287c2..c9cceabf11 100644
--- a/usr/src/cmd/filebench/workloads/filemicro_delete.f
+++ b/usr/src/cmd/filebench/workloads/filemicro_delete.f
@@ -44,13 +44,13 @@ define process name=filedelete,instances=1
{
thread name=filedeletethread,memsize=10m,instances=$nthreads
{
- flowop deletefile name=deletefile1,filesetname=bigfileset,fd=1
+ flowop deletefile name=deletefile1,filesetname=bigfileset
flowop opslimit name=limit
flowop finishoncount name=finish,value=$count
}
}
-echo "FileMicro-Delete Version 2.2 personality successfully loaded"
+echo "FileMicro-Delete Version 2.3 personality successfully loaded"
usage "Usage: set \$dir=<dir>"
usage " set \$count=<value> defaults to $count"
usage " set \$filesize=<size> defaults to $filesize"