static int flowop_create_runtime_flowops(threadflow_t *threadflow, flowop_t **ops_list_ptr) { flowop_t *flowop = *ops_list_ptr; char *name; while (flowop) { flowop_t *newflowop; if (flowop == *ops_list_ptr) *ops_list_ptr = NULL; newflowop = flowop_define_common(threadflow, flowop->fo_name, flowop, ops_list_ptr, 1, 0); if (newflowop == NULL) return (FILEBENCH_ERROR); /* check for fo_filename attribute, and resolve if present */ if (flowop->fo_filename) { 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); } } /* check for fo_possetname attribute, and resolve if present */ if (flowop->fo_possetname) { name = avd_get_str(flowop->fo_possetname); newflowop->fo_posset = posset_find(name); if (newflowop->fo_posset == NULL) { filebench_log(LOG_ERROR, "flowop %s: posset %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_exec_next; } return (FILEBENCH_OK); }
struct posset * posset_find(char *name) { struct posset *ps; (void)ipc_mutex_lock(&filebench_shm->shm_posset_lock); ps = filebench_shm->shm_possetlist; while (ps) { if (!strcmp(avd_get_str(ps->ps_name), name)) break; ps = ps->ps_next; } (void)ipc_mutex_unlock(&filebench_shm->shm_posset_lock); return ps; }
struct posset * posset_alloc(avd_t name, avd_t type, avd_t seed, avd_t max, avd_t entries) { struct posset *ps; int ret; ps = (struct posset *)ipc_malloc(FILEBENCH_POSSET); if (!ps) { filebench_log(LOG_ERROR, "posset_alloc: " "can't malloc posset in IPC region"); return NULL; } /* we do not support any possets except "rnd" at the moment */ if (!strcmp(avd_get_str(type), "rnd")) { ps->ps_type = avd_int_alloc(POSSET_TYPE_RND); } else if (!strcmp(avd_get_str(type), "collection")) { ps->ps_type = avd_int_alloc(POSSET_TYPE_COLLECTION); } else { filebench_log(LOG_ERROR, "posset_alloc: wrong posset type"); ipc_free(FILEBENCH_POSSET, (char *)ps); return NULL; } ps->ps_name = name; ps->ps_rnd_seed = seed; ps->ps_rnd_max = max; ps->ps_entries = entries; if (avd_get_int(ps->ps_entries) > POSSET_MAX_ENTRIES) { filebench_log(LOG_ERROR, "posset_alloc: the number of posset " "entries is too high"); ipc_free(FILEBENCH_POSSET, (char *)ps); return NULL; } /* depending on the posset type generate (or load) positions */ switch (avd_get_int(ps->ps_type)) { case(POSSET_TYPE_RND): ret = posset_rnd_fill(ps); break; case(POSSET_TYPE_COLLECTION): ret = posset_collection_fill(ps); break; default: filebench_log(LOG_ERROR, "posset_alloc: wrong posset type"); ipc_free(FILEBENCH_POSSET, (char *)ps); return NULL; } if (ret < 0) { filebench_log(LOG_ERROR, "posset_alloc: could not fill posset"); ipc_free(FILEBENCH_POSSET, (char *)ps); return NULL; } /* add posset to the global list */ (void)ipc_mutex_lock(&filebench_shm->shm_posset_lock); if (filebench_shm->shm_possetlist == NULL) { filebench_shm->shm_possetlist = ps; ps->ps_next = NULL; } else { ps->ps_next = filebench_shm->shm_possetlist; filebench_shm->shm_possetlist = ps; } (void)ipc_mutex_unlock(&filebench_shm->shm_posset_lock); return ps; }