[PVFS2-CVS]
commit by neill in pvfs2/src/client/sysint: client-state-machine.h
mgmt-get-dfile-array.sm
CVS commit program
cvs at parl.clemson.edu
Wed Mar 10 14:16:44 EST 2004
Update of /projects/cvsroot/pvfs2/src/client/sysint
In directory parlweb:/tmp/cvs-serv31492/src/client/sysint
Modified Files:
client-state-machine.h mgmt-get-dfile-array.sm
Log Message:
- simplify and cleanup mgmt-get-dfile-array sm
Index: client-state-machine.h
===================================================================
RCS file: /projects/cvsroot/pvfs2/src/client/sysint/client-state-machine.h,v
diff -p -u -r1.84 -r1.85
--- client-state-machine.h 10 Mar 2004 17:21:21 -0000 1.84
+++ client-state-machine.h 10 Mar 2004 19:16:44 -0000 1.85
@@ -285,8 +285,7 @@ struct PINT_client_mgmt_iterate_handles_
struct PINT_client_mgmt_get_dfile_array_sm
{
- PVFS_pinode_reference pinode_refn;
- PVFS_handle* dfile_array;
+ PVFS_handle *dfile_array;
int dfile_count;
};
Index: mgmt-get-dfile-array.sm
===================================================================
RCS file: /projects/cvsroot/pvfs2/src/client/sysint/mgmt-get-dfile-array.sm,v
diff -p -u -r1.9 -r1.10
--- mgmt-get-dfile-array.sm 30 Jan 2004 20:12:10 -0000 1.9
+++ mgmt-get-dfile-array.sm 10 Mar 2004 19:16:44 -0000 1.10
@@ -9,6 +9,7 @@
#include "client-state-machine.h"
#include "state-machine-fns.h"
+#include "shared-state-methods.h"
#include "pvfs2-debug.h"
#include "job.h"
#include "gossip.h"
@@ -19,49 +20,40 @@
extern job_context_id pint_client_sm_context;
-/* values greater than zero are usable here */
-/* TODO: this is a hack, duplicated in msgpair.sm, sort out later... */
-enum
-{
- MSGPAIR_RETURN_SUCCESS = 2
-};
-
-/* state function prototypes */
-static int mgmt_get_dfile_array_getattr_setup_msgpair(
- PINT_client_sm * sm_p,
- job_status_s * js_p);
-
static int mgmt_get_dfile_array_cleanup(
- PINT_client_sm * sm_p,
- job_status_s * js_p);
-
-/* completion function prototypes */
-static int getattr_comp_fn(
- void *v_p,
- struct PVFS_server_resp *resp_p,
- int i);
+ PINT_client_sm * sm_p, job_status_s * js_p);
%%
machine pvfs2_client_mgmt_get_dfile_array_sm(getattr_setup_msgpair,
getattr_xfer_msgpair,
+ getattr_failure,
cleanup)
{
state getattr_setup_msgpair
{
- run mgmt_get_dfile_array_getattr_setup_msgpair;
- success => getattr_xfer_msgpair;
- default => cleanup;
+ run PINT_sm_common_object_getattr_setup_msgpair;
+ success => getattr_xfer_msgpair;
+ default => getattr_failure;
}
+
state getattr_xfer_msgpair
{
- jump pvfs2_client_getattr_acache_sm;
- default => cleanup;
+ jump pvfs2_client_getattr_acache_sm;
+ success => cleanup;
+ default => getattr_failure;
}
+
+ state getattr_failure
+ {
+ run PINT_sm_common_object_getattr_failure;
+ default => cleanup;
+ }
+
state cleanup
{
- run mgmt_get_dfile_array_cleanup;
- default => terminate;
+ run mgmt_get_dfile_array_cleanup;
+ default => terminate;
}
}
@@ -73,60 +65,59 @@ int PVFS_mgmt_get_dfile_array(
PVFS_handle * dfile_array,
int dfile_count)
{
- int ret;
- PINT_client_sm *sm_p;
+ int ret = -PVFS_EINVAL;
+ PINT_client_sm *sm_p = NULL;
- gossip_debug(GOSSIP_CLIENT_DEBUG, "PVFS_mgmt_get_dfile_array entered\n");
+ gossip_debug(GOSSIP_CLIENT_DEBUG,
+ "PVFS_mgmt_get_dfile_array entered\n");
- /* do parameter checking here, then assume things are ok below.
- * assert()s are still ok of course :).
- */
if (!dfile_array)
- return -PVFS_EINVAL;
+ {
+ return ret;
+ }
- sm_p = (PINT_client_sm *) malloc(sizeof(*sm_p));
- if (sm_p == NULL)
+ sm_p = (PINT_client_sm *)malloc(sizeof(*sm_p));
+ if (!sm_p)
+ {
return -PVFS_ENOMEM;
-
+ }
memset(sm_p, 0, sizeof(*sm_p));
sm_p->cred_p = &credentials;
- sm_p->u.get_dfile_array.pinode_refn = pinode_refn;
+ sm_p->object_ref = pinode_refn;
sm_p->u.get_dfile_array.dfile_array = dfile_array;
sm_p->u.get_dfile_array.dfile_count = dfile_count;
- gossip_debug(GOSSIP_CLIENT_DEBUG,
- "PVFS_mgmt_get_dfile_array calling PINT_client_state_machine_post()\n");
+ gossip_debug(GOSSIP_CLIENT_DEBUG, "PVFS_mgmt_get_dfile_array calling "
+ "PINT_client_state_machine_post()\n");
- /* do something to kick off processing */
ret = PINT_client_state_machine_post(sm_p, PVFS_MGMT_GET_DFILE_ARRAY);
- if(ret < 0)
+ if (ret < 0)
{
gossip_lerr("Error: PINT_client_state_machine_post() failure.\n");
free(sm_p);
return(ret);
}
- /* while !done call progress function */
- while (!sm_p->op_complete && ret == 0)
+ while (!sm_p->op_complete && (ret == 0))
{
- gossip_debug(GOSSIP_CLIENT_DEBUG,
- "PVFS_mgmt_get_dfile_array calling PINT_client_state_machine_test()\n");
+ gossip_debug(GOSSIP_CLIENT_DEBUG, "PVFS_mgmt_get_dfile_array "
+ "calling PINT_client_state_machine_test()\n");
ret = PINT_client_state_machine_test();
}
- if(ret < 0)
+
+ if (ret < 0)
{
gossip_lerr("Error: PINT_client_state_machine_test() failure.\n");
free(sm_p);
return(ret);
}
- gossip_debug(GOSSIP_CLIENT_DEBUG, "PVFS_mgmt_get_dfile_array completed\n");
+ gossip_debug(GOSSIP_CLIENT_DEBUG,
+ "PVFS_mgmt_get_dfile_array completed\n");
- /* save our return value */
ret = sm_p->error_code;
- /* clean up after ourselves */
free(sm_p);
return (ret);
}
@@ -134,128 +125,42 @@ int PVFS_mgmt_get_dfile_array(
/****************************************************************/
-/* mgmt_get_dfile_array_getattr_setup_msgpair()
- *
- */
-static int mgmt_get_dfile_array_getattr_setup_msgpair(
+static int mgmt_get_dfile_array_cleanup(
PINT_client_sm * sm_p,
job_status_s * js_p)
{
- int ret = -1;
+ PVFS_object_attr *attr = NULL;
gossip_debug(GOSSIP_CLIENT_DEBUG,
- "mgmt_get_dfile_array state: getattr_setup_msgpair\n");
+ "mgmt_get_dfile_array state: cleanup\n");
- /* parameter range checks */
- assert(sm_p->u.get_dfile_array.pinode_refn.handle != PVFS_HANDLE_NULL);
- /* TODO: do we have some defined value to check for here? */
- assert(sm_p->u.get_dfile_array.pinode_refn.fs_id != 0);
-
- /* fill in getattr request */
- PINT_SERVREQ_GETATTR_FILL(sm_p->msgpair.req,
- *sm_p->cred_p,
- sm_p->u.get_dfile_array.pinode_refn.fs_id,
- sm_p->u.get_dfile_array.pinode_refn.handle,
- PVFS_ATTR_COMMON_ALL | PVFS_ATTR_META_DFILES);
-
- /* fill in msgpair structure components */
- sm_p->msgpair.fs_id = sm_p->u.get_dfile_array.pinode_refn.fs_id;
- sm_p->msgpair.handle = sm_p->u.get_dfile_array.pinode_refn.handle;
- sm_p->msgpair.comp_fn = getattr_comp_fn;
- ret = PINT_bucket_map_to_server(&sm_p->msgpair.svr_addr,
- sm_p->msgpair.handle, sm_p->msgpair.fs_id);
- if (ret < 0)
- {
- gossip_err("Error: failure mapping to server.\n");
- js_p->error_code = ret;
- return(1);
- }
-
- js_p->error_code = 0;
- return(1);
-}
-
-/* getattr_comp_fn()
- *
- * Called to copy data from getattr response into the
- * mgmt_get_dfile_array-specific portion of the PINT_client_sm structure,
- * so we can use the data after returning to this state
- * machine.
- *
- * Return value is returned in job status, so it affects the
- * resulting state coming back from the nested state machine.
- */
-static int getattr_comp_fn(
- void *v_p,
- struct PVFS_server_resp *resp_p,
- int index)
-{
- PINT_client_sm *sm_p = (PINT_client_sm *) v_p;
- PVFS_object_attr* r_attr_p;
-
- assert(resp_p->op == PVFS_SERV_GETATTR); /* sanity check */
-
- /* if we get an error, just return immediately, don't try to
- * actually fill anything in.
- */
- if (resp_p->status != 0)
- {
- return resp_p->status;
- }
-
- r_attr_p = (sm_p->acache_hit ?
- &sm_p->pinode->attr :
- &resp_p->u.getattr.attr);
-
- /* make sure the caller asked about the right type of object */
- if(r_attr_p->objtype != PVFS_TYPE_METAFILE)
- {
- return (-PVFS_EINVAL);
- }
-
- /* sanity checks */
- assert(r_attr_p->mask & PVFS_ATTR_META_DFILES);
- assert(r_attr_p->u.meta.dfile_count > 0);
+ sm_p->error_code = js_p->error_code;
- /* make sure the caller provided a large enough array */
- if(r_attr_p->u.meta.dfile_count >
- sm_p->u.get_dfile_array.dfile_count)
+ if (sm_p->error_code == 0)
{
- return (-PVFS_EMSGSIZE);
+ attr = (sm_p->acache_hit ?
+ &sm_p->pinode->attr :
+ &sm_p->acache_attr);
+
+ assert(attr);
+ assert(attr->objtype == PVFS_TYPE_METAFILE);
+ assert(attr->mask & PVFS_ATTR_META_DFILES);
+ assert(attr->u.meta.dfile_count > 0);
+
+ /* copy out going parameters */
+ sm_p->u.get_dfile_array.dfile_count =
+ attr->u.meta.dfile_count;
+ memcpy(sm_p->u.get_dfile_array.dfile_array,
+ attr->u.meta.dfile_array,
+ (attr->u.meta.dfile_count * sizeof(PVFS_handle)));
}
- /* copy out dfile count and array */
- sm_p->u.get_dfile_array.dfile_count =
- r_attr_p->u.meta.dfile_count;
- memcpy(sm_p->u.get_dfile_array.dfile_array,
- r_attr_p->u.meta.dfile_array,
- (r_attr_p->u.meta.dfile_count * sizeof(PVFS_handle)));
-
- return (0);
-}
-
-/* mgmt_get_dfile_array_cleanup()
- */
-static int mgmt_get_dfile_array_cleanup(
- PINT_client_sm * sm_p,
- job_status_s * js_p)
-{
- gossip_debug(GOSSIP_CLIENT_DEBUG, "mgmt_get_dfile_array state: cleanup\n");
-
- /* store enough information in the sm structure that the caller
- * can tell what happened.
- */
- sm_p->error_code = js_p->error_code;
-
- /* if we acache entry, release it */
if (sm_p->acache_hit)
{
PINT_acache_release(sm_p->pinode);
}
- /* mark operation as complete */
sm_p->op_complete = 1;
-
return 0;
}
More information about the PVFS2-CVS
mailing list