Skip to content

Commit

Permalink
Refactoring flowop types initialization.
Browse files Browse the repository at this point in the history
  • Loading branch information
sectorsize512 committed Oct 4, 2015
1 parent b0e0a5e commit 293c372
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 76 deletions.
21 changes: 7 additions & 14 deletions fb_localfs.c
Expand Up @@ -128,8 +128,9 @@ static flowop_proto_t fb_lfsflow_funcs[] = {
#endif /* HAVE_AIO */

/*
* Initialize this processes I/O functions vector to point to
* the vector of local file system I/O functions
* Initialize file system functions vector to point to the vector of local file
* system functions. This function will be called for the master process and
* every created worker process.
*/
void
fb_lfs_funcvecinit(void)
Expand All @@ -138,22 +139,14 @@ fb_lfs_funcvecinit(void)
}

/*
* Initialize those flowops whose implementation is file system
* specific.
* Initialize those flowops which implementation is file system specific. It is
* called only once in the master process.
*/
void
fb_lfs_flowinit(void)
fb_lfs_newflowops(void)
{
int nops;

/*
* re-initialize the I/O functions vector while we are at
* it as it may have been redefined since the process was
* created, at least if this is the master processes
*/
fb_lfs_funcvecinit();

#ifdef HAVE_AIO
int nops;
nops = sizeof (fb_lfsflow_funcs) / sizeof (flowop_proto_t);
flowop_add_from_proto(fb_lfsflow_funcs, nops);
#endif /* HAVE_AIO */
Expand Down
39 changes: 14 additions & 25 deletions flowop.c
Expand Up @@ -667,44 +667,33 @@ flowop_start(threadflow_t *threadflow)
pthread_exit(&threadflow->tf_abort);
}

void flowoplib_flowinit(void);
void fb_lfs_flowinit(void);

/*
* For master mode we add flowops from the generic library, flowops that are
* file system specific, and adjust the vector of functions used by the
* generic library. For worker mode we only need to adjust the vector.
*/
void
flowop_init(void)
flowop_init(int ismaster)
{
(void) pthread_mutex_init(&controlstats_lock,
ipc_mutexattr(IPC_MUTEX_NORMAL));
flowoplib_flowinit();
}

static int plugin_flowinit_done = FALSE;

/*
* Initialize any "plug-in" flowops. Called when the first "create fileset"
* command is encountered.
*/
void
flowop_plugin_flowinit(void)
{
if (plugin_flowinit_done)
return;

plugin_flowinit_done = TRUE;
if (ismaster) {
(void) pthread_mutex_init(&controlstats_lock,
ipc_mutexattr(IPC_MUTEX_NORMAL));
flowoplib_flowinit();
}

switch (filebench_shm->shm_filesys_type) {
case LOCAL_FS_PLUG:
fb_lfs_flowinit();
if (ismaster)
fb_lfs_newflowops();
fb_lfs_funcvecinit();
break;

case NFS3_PLUG:
case NFS4_PLUG:
case CIFS_PLUG:
break;
}
}


/*
* Delete the designated flowop from the thread's flowop list.
*/
Expand Down
9 changes: 7 additions & 2 deletions flowop.h
Expand Up @@ -132,10 +132,9 @@ typedef struct flowop_proto {
extern struct flowstats controlstats;
extern pthread_mutex_t controlstats_lock;

void flowop_init(void);
void flowop_plugin_flowinit(void);
flowop_t *flowop_define(threadflow_t *, char *name, flowop_t *inherit,
flowop_t **flowoplist_hdp, int instance, int type);

flowop_t *flowop_find(char *name);
flowop_t *flowop_find_one(char *name, int instance);
flowop_t *flowop_find_from_list(char *name, flowop_t *list);
Expand All @@ -151,4 +150,10 @@ void flowop_destruct_all_flows(threadflow_t *threadflow);
flowop_t *flowop_new_composite_define(char *name);
void flowop_printall(void);

void flowop_init(int ismaster);

/* Local file system specific */
void fb_lfs_funcvecinit();
void fb_lfs_newflowops();

#endif /* _FB_FLOWOP_H */
2 changes: 2 additions & 0 deletions ipc.c
Expand Up @@ -374,6 +374,8 @@ void ipc_init(void)
filebench_shm->shm_dump_fd = -1;
filebench_shm->shm_eventgen_hz = 0;
filebench_shm->shm_id = -1;

filebench_shm->shm_filesys_type = LOCAL_FS_PLUG;
}

void
Expand Down
27 changes: 0 additions & 27 deletions misc.c
Expand Up @@ -441,30 +441,3 @@ script_var(var_t *var)

return (var);
}

void fb_lfs_funcvecinit(void);

/*
* Initialize any "plug-in" I/O function vectors. Called by each
* filebench process that is forked, as the vector is relative to
* its image.
*/
void
filebench_plugin_funcvecinit(void)
{

switch (filebench_shm->shm_filesys_type) {
case LOCAL_FS_PLUG:
fb_lfs_funcvecinit();
break;

case NFS3_PLUG:
case NFS4_PLUG:
case CIFS_PLUG:
break;
default:
filebench_log(LOG_ERROR,
"filebench_plugin_funcvecinit: unknown file system");
break;
}
}
10 changes: 2 additions & 8 deletions parser_gram.y
Expand Up @@ -1445,7 +1445,7 @@ worker_mode(struct fbparams *fbparams)
}

/* get correct function pointer for each working process */
filebench_plugin_funcvecinit();
flowop_init(0);

/* load custom variable libraries and revalidate handles */
ret = init_cvar_libraries();
Expand Down Expand Up @@ -1582,7 +1582,7 @@ master_mode(struct fbparams *fbparams) {
(void)strcpy(filebench_shm->shm_fscriptname,
fbparams->fscriptname);

flowop_init();
flowop_init(1);
eventgen_init();

/* Initialize custom variables. */
Expand Down Expand Up @@ -2322,12 +2322,6 @@ parser_fileset_define_common(cmd_t *cmd)
avd_t name;
avd_t path;

/*
* Make sure all plugin flowops are initialized.
* Defaults to local fs for now.
*/
flowop_plugin_flowinit();

attr = get_attr(cmd, FSA_NAME);
if (attr)
name = attr->attr_avd;
Expand Down

0 comments on commit 293c372

Please sign in to comment.