summaryrefslogtreecommitdiff
path: root/usr/src/cmd/filebench/common/fileset.c
diff options
context:
space:
mode:
authoraw148015 <none@none>2008-05-23 10:59:13 -0700
committeraw148015 <none@none>2008-05-23 10:59:13 -0700
commitda396009ff06eab8fbdbeb4290e565bb8486d9d3 (patch)
treee2a2402863fff03ff9b8bb402c8469eb68266ea6 /usr/src/cmd/filebench/common/fileset.c
parentee60c47b212c3bbaab93900abaf5b7921bb3cb3d (diff)
downloadillumos-joyent-da396009ff06eab8fbdbeb4290e565bb8486d9d3.tar.gz
6680475 Request for per flowop byte limit
6698807 Filebench Shutdown still takes too long with multiple threads 6702350 Filebench Hangs while shutting down on x86 when running oltp.f
Diffstat (limited to 'usr/src/cmd/filebench/common/fileset.c')
-rw-r--r--usr/src/cmd/filebench/common/fileset.c62
1 files changed, 61 insertions, 1 deletions
diff --git a/usr/src/cmd/filebench/common/fileset.c b/usr/src/cmd/filebench/common/fileset.c
index 57d97ad2e6..d402c49431 100644
--- a/usr/src/cmd/filebench/common/fileset.c
+++ b/usr/src/cmd/filebench/common/fileset.c
@@ -47,6 +47,13 @@
* is rooted in a directory specified by fileset_path, and once the populated
* fileset has been created, has a tree of directories and files
* corresponding to the fileset's filesetentry tree.
+ *
+ * This routine is called from fileset_createset(), which is in turn
+ * called from parser_gram.y: parser_create_fileset() when a
+ * "create fileset" or "run" command is encountered.
+ * When the "create fileset" command is used, it is generally paired with
+ * a "create processes" command, and must appear first, in order to
+ * instantiate all the files in the fileset before trying to use them.
*/
static int fileset_checkraw(fileset_t *fileset);
@@ -298,6 +305,12 @@ fileset_alloc_file(filesetentry_t *entry)
entry->fse_size);
entry->fse_flags |= FSE_EXISTS;
+ (void) ipc_mutex_lock(
+ &entry->fse_fileset->fs_num_files_lock);
+ entry->fse_fileset->fs_num_act_files++;
+ (void) ipc_mutex_unlock(
+ &entry->fse_fileset->fs_num_files_lock);
+
(void) close(fd);
return (0);
@@ -317,6 +330,13 @@ fileset_alloc_file(filesetentry_t *entry)
entry->fse_size);
entry->fse_flags |= FSE_EXISTS;
+
+ (void) ipc_mutex_lock(
+ &entry->fse_fileset->fs_num_files_lock);
+ entry->fse_fileset->fs_num_act_files++;
+ (void) ipc_mutex_unlock(
+ &entry->fse_fileset->fs_num_files_lock);
+
(void) close(fd);
return (0);
}
@@ -337,6 +357,10 @@ fileset_alloc_file(filesetentry_t *entry)
entry->fse_flags |= FSE_EXISTS;
+ (void) ipc_mutex_lock(&entry->fse_fileset->fs_num_files_lock);
+ entry->fse_fileset->fs_num_act_files++;
+ (void) ipc_mutex_unlock(&entry->fse_fileset->fs_num_files_lock);
+
for (seek = 0; seek < entry->fse_size; ) {
off64_t wsize;
int ret = 0;
@@ -431,9 +455,14 @@ fileset_openfile(fileset_t *fileset,
return (-1);
}
- if (flag & O_CREAT)
+ if (flag & O_CREAT) {
entry->fse_flags |= FSE_EXISTS;
+ (void) ipc_mutex_lock(&fileset->fs_num_files_lock);
+ fileset->fs_num_act_files++;
+ (void) ipc_mutex_unlock(&fileset->fs_num_files_lock);
+ }
+
if (attrs & FLOW_ATTR_DSYNC) {
#ifdef sun
open_attrs |= O_DSYNC;
@@ -486,6 +515,25 @@ fileset_pick(fileset_t *fileset, int flags, int tid)
(void) ipc_mutex_lock(&filebench_shm->shm_fileset_lock);
+ /* see if asking for impossible */
+ (void) ipc_mutex_lock(&fileset->fs_num_files_lock);
+ if (flags & FILESET_PICKEXISTS) {
+ if (fileset->fs_num_act_files == 0) {
+ (void) ipc_mutex_unlock(&fileset->fs_num_files_lock);
+ (void) ipc_mutex_unlock(
+ &filebench_shm->shm_fileset_lock);
+ return (NULL);
+ }
+ } else if (flags & FILESET_PICKNOEXIST) {
+ if (fileset->fs_num_act_files == fileset->fs_realfiles) {
+ (void) ipc_mutex_unlock(&fileset->fs_num_files_lock);
+ (void) ipc_mutex_unlock(
+ &filebench_shm->shm_fileset_lock);
+ return (NULL);
+ }
+ }
+ (void) ipc_mutex_unlock(&fileset->fs_num_files_lock);
+
while (entry == NULL) {
if ((flags & FILESET_PICKDIR) && (flags & FILESET_PICKRESET)) {
@@ -609,6 +657,9 @@ fileset_create(fileset_t *fileset)
return (-1);
}
+ /* declare all files currently non existant (single threaded code) */
+ fileset->fs_num_act_files = 0;
+
#ifdef HAVE_RAW_SUPPORT
/* treat raw device as special case */
if (fileset->fs_attrs & FILESET_IS_RAW_DEV)
@@ -1002,6 +1053,7 @@ exists:
fileset->fs_meandepth,
(u_longlong_t)(fileset->fs_bytes / 1024UL / 1024UL));
}
+
return (0);
}
@@ -1010,6 +1062,10 @@ exists:
* fileset_sizegamma default values, and sets the fileset name to the
* supplied name string. Puts the allocated fileset on the
* master fileset list and returns a pointer to it.
+ *
+ * This routine implements the 'define fileset' calls found in a .f
+ * workload, such as in the following example:
+ * define fileset name=drew4ever, entries=$nfiles
*/
fileset_t *
fileset_define(avd_t name)
@@ -1028,6 +1084,10 @@ fileset_define(avd_t name)
filebench_log(LOG_DEBUG_IMPL,
"Defining file %s", avd_get_str(name));
+ /* initialize fs_num_act_files lock */
+ (void) pthread_mutex_init(&fileset->fs_num_files_lock,
+ ipc_mutexattr());
+
(void) ipc_mutex_lock(&filebench_shm->shm_fileset_lock);
fileset->fs_dirgamma = avd_int_alloc(1500);