[PVFS2-CVS]
commit by neill in pvfs2/src/client/sysint: sys-remove.sm
sys-rename.sm
CVS commit program
cvs at parl.clemson.edu
Tue Mar 9 15:40:54 EST 2004
Update of /projects/cvsroot/pvfs2/src/client/sysint
In directory parlweb:/tmp/cvs-serv26988/src/client/sysint
Modified Files:
sys-remove.sm sys-rename.sm
Log Message:
- more cleanups and error handling
Index: sys-remove.sm
===================================================================
RCS file: /projects/cvsroot/pvfs2/src/client/sysint/sys-remove.sm,v
diff -p -u -r1.50 -r1.51
--- sys-remove.sm 8 Mar 2004 21:30:28 -0000 1.50
+++ sys-remove.sm 9 Mar 2004 20:40:53 -0000 1.51
@@ -26,52 +26,52 @@ enum
MSGPAIR_RETURN_SUCCESS
};
-/* state function prototypes */
-static int remove_init(PINT_client_sm *sm_p,
- job_status_s *js_p);
-
-static int remove_getattr_setup_msgpair(PINT_client_sm *sm_p,
- job_status_s *js_p);
-static int remove_getattr_failure(PINT_client_sm *sm_p,
- job_status_s *js_p);
-static int remove_check_dir_contents_setup_msgpair(PINT_client_sm *sm_p,
- job_status_s *js_p);
-static int remove_check_dir_contents_failure(PINT_client_sm *sm_p,
- job_status_s *js_p);
-static int remove_datafile_remove_setup_msgpair(PINT_client_sm *sm_p,
- job_status_s *js_p);
-static int remove_datafile_remove_failure(PINT_client_sm *sm_p,
- job_status_s *js_p);
-static int remove_rmdirent_setup_msgpair(PINT_client_sm *sm_p,
- job_status_s *js_p);
-static int remove_rmdirent_failure(PINT_client_sm *sm_p,
- job_status_s *js_p);
-static int remove_object_remove_setup_msgpair(PINT_client_sm *sm_p,
- job_status_s *js_p);
-static int remove_object_remove_failure(PINT_client_sm *sm_p,
- job_status_s *js_p);
-static int remove_crdirent_setup_msgpair(PINT_client_sm *sm_p,
- job_status_s *js_p);
-static int remove_crdirent_failure(PINT_client_sm *sm_p,
- job_status_s *js_p);
-static int remove_cleanup(PINT_client_sm *sm_p,
- job_status_s *js_p);
+static int remove_init(
+ PINT_client_sm *sm_p, job_status_s *js_p);
+static int remove_getattr_setup_msgpair(
+ PINT_client_sm *sm_p, job_status_s *js_p);
+static int remove_getattr_failure(
+ PINT_client_sm *sm_p, job_status_s *js_p);
+static int remove_check_dir_contents_setup_msgpair(
+ PINT_client_sm *sm_p, job_status_s *js_p);
+static int remove_check_dir_contents_failure(
+ PINT_client_sm *sm_p, job_status_s *js_p);
+static int remove_datafile_remove_setup_msgpair(
+ PINT_client_sm *sm_p, job_status_s *js_p);
+static int remove_datafile_remove_failure(
+ PINT_client_sm *sm_p, job_status_s *js_p);
+static int remove_rmdirent_setup_msgpair(
+ PINT_client_sm *sm_p, job_status_s *js_p);
+static int remove_rmdirent_failure(
+ PINT_client_sm *sm_p, job_status_s *js_p);
+static int remove_object_remove_setup_msgpair(
+ PINT_client_sm *sm_p, job_status_s *js_p);
+static int remove_object_remove_failure(
+ PINT_client_sm *sm_p, job_status_s *js_p);
+static int remove_crdirent_setup_msgpair(
+ PINT_client_sm *sm_p, job_status_s *js_p);
+static int remove_crdirent_failure(
+ PINT_client_sm *sm_p, job_status_s *js_p);
+static int remove_cleanup(
+ PINT_client_sm *sm_p, job_status_s *js_p);
/* completion function prototypes */
-static int remove_getattr_comp_fn(void *v_p,
- struct PVFS_server_resp *resp_p,
- int i);
-
+static int remove_getattr_comp_fn(
+ void *v_p,
+ struct PVFS_server_resp *resp_p,
+ int i);
static int remove_check_dir_contents_comp_fn(
- void *v_p, struct PVFS_server_resp *resp_p, int i);
-
-static int remove_rmdirent_comp_fn(void *v_p,
- struct PVFS_server_resp *resp_p,
- int i);
-
-static int remove_crdirent_comp_fn(void *v_p,
- struct PVFS_server_resp *resp_p,
- int i);
+ void *v_p,
+ struct PVFS_server_resp *resp_p,
+ int i);
+static int remove_rmdirent_comp_fn(
+ void *v_p,
+ struct PVFS_server_resp *resp_p,
+ int i);
+static int remove_crdirent_comp_fn(
+ void *v_p,
+ struct PVFS_server_resp *resp_p,
+ int i);
%%
@@ -286,10 +286,9 @@ int PVFS_sys_remove(char *object_name,
gossip_debug(GOSSIP_CLIENT_DEBUG, "PVFS_sys_remove calling "
"PINT_client_state_machine_post()\n");
- /* do something to kick off processing */
ret = PINT_client_state_machine_post(sm_p, PVFS_SYS_REMOVE);
- while (!sm_p->op_complete && ret == 0)
+ while (!sm_p->op_complete && (ret == 0))
{
gossip_debug(GOSSIP_CLIENT_DEBUG, "PVFS_sys_remove calling "
"PINT_client_state_machine_test()\n");
@@ -335,7 +334,6 @@ static int remove_getattr_setup_msgpair(
gossip_debug(GOSSIP_CLIENT_DEBUG,
"remove state: getattr_setup_msgpair\n");
-
js_p->error_code = 0;
assert(sm_p->u.remove.object_ref.fs_id != 0);
@@ -389,9 +387,6 @@ static int remove_getattr_comp_fn(void *
assert(resp_p->op == PVFS_SERV_GETATTR);
- /* 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;
@@ -434,9 +429,7 @@ static int remove_getattr_comp_fn(void *
case PVFS_TYPE_SYMLINK:
return 0;
case PVFS_TYPE_DATAFILE:
- /* fall through */
case PVFS_TYPE_DIRDATA:
- /* fall through */
default:
gossip_err("error: remove_getattr_comp_fn: unhandled "
"object type\n");
@@ -649,8 +642,6 @@ static int remove_datafile_remove_setup_
* NOTE: it's easier to clean up from a metafile with no datafiles
* than the other way around! so we remove datafiles first.
*/
-
- /* clear error field in job */
js_p->error_code = 0;
gossip_debug(GOSSIP_CLIENT_DEBUG,
@@ -756,9 +747,7 @@ static int remove_cleanup(PINT_client_sm
sm_p->u.remove.datafile_handles = NULL;
}
- /* mark operation as complete */
sm_p->op_complete = 1;
-
return 0;
}
@@ -766,20 +755,6 @@ static int remove_getattr_failure(PINT_c
job_status_s *js_p)
{
gossip_debug(GOSSIP_CLIENT_DEBUG, "remove state: getattr_failure\n");
-
- /* TODO: unpost operations that are still in progress, once we can. */
-
- /* ISSUE: can't tell which thing completed (with an error).
- *
- * SOLUTION: add job_id to the job_status structure, keep up with
- * them in the PINT_client_sm structure so we can tell the
- * difference.
- */
-
- /* Q: CAN WE HANDLE ALL THE SEND/RECV PAIRS FAILURE CASES WITH ONE
- * STATE?
- */
-
return 1;
}
Index: sys-rename.sm
===================================================================
RCS file: /projects/cvsroot/pvfs2/src/client/sysint/sys-rename.sm,v
diff -p -u -r1.7 -r1.8
--- sys-rename.sm 30 Jan 2004 20:12:10 -0000 1.7
+++ sys-rename.sm 9 Mar 2004 20:40:54 -0000 1.8
@@ -20,27 +20,26 @@
extern job_context_id pint_client_sm_context;
-/* state function prototypes */
-static int rename_init(PINT_client_sm *sm_p,
- job_status_s *js_p);
-static int rename_lookups_setup_msgpair_array(PINT_client_sm *sm_p,
- job_status_s *js_p);
-static int rename_lookups_failure(PINT_client_sm *sm_p,
- job_status_s *js_p);
-static int rename_get_attrs_setup_msgpair_array(PINT_client_sm *sm_p,
- job_status_s *js_p);
-static int rename_get_attrs_failure(PINT_client_sm *sm_p,
- job_status_s *js_p);
-static int rename_crdirent_setup_msgpair(PINT_client_sm *sm_p,
- job_status_s *js_p);
-static int rename_crdirent_failure(PINT_client_sm *sm_p,
- job_status_s *js_p);
-static int rename_rmdirent_setup_msgpair(PINT_client_sm *sm_p,
- job_status_s *js_p);
-static int rename_rmdirent_failure(PINT_client_sm *sm_p,
- job_status_s *js_p);
-static int rename_cleanup(PINT_client_sm *sm_p,
- job_status_s *js_p);
+static int rename_init(
+ PINT_client_sm *sm_p, job_status_s *js_p);
+static int rename_lookups_setup_msgpair_array(
+ PINT_client_sm *sm_p, job_status_s *js_p);
+static int rename_lookups_failure(
+ PINT_client_sm *sm_p, job_status_s *js_p);
+static int rename_get_attrs_setup_msgpair_array(
+ PINT_client_sm *sm_p, job_status_s *js_p);
+static int rename_get_attrs_failure(
+ PINT_client_sm *sm_p, job_status_s *js_p);
+static int rename_crdirent_setup_msgpair(
+ PINT_client_sm *sm_p, job_status_s *js_p);
+static int rename_crdirent_failure(
+ PINT_client_sm *sm_p, job_status_s *js_p);
+static int rename_rmdirent_setup_msgpair(
+ PINT_client_sm *sm_p, job_status_s *js_p);
+static int rename_rmdirent_failure(
+ PINT_client_sm *sm_p, job_status_s *js_p);
+static int rename_cleanup(
+ PINT_client_sm *sm_p, job_status_s *js_p);
/* completion function prototypes */
static int rename_lookups_comp_fn(
@@ -77,80 +76,94 @@ machine pvfs2_client_rename_sm(init,
rename_rmdirent_failure,
cleanup)
{
- state init {
- run rename_init;
- default => rename_lookups_setup_msgpair_array;
+ state init
+ {
+ run rename_init;
+ default => rename_lookups_setup_msgpair_array;
}
- state rename_lookups_setup_msgpair_array {
+ state rename_lookups_setup_msgpair_array
+ {
run rename_lookups_setup_msgpair_array;
success => rename_lookups_xfer_msgpair_array;
default => rename_lookups_failure;
}
- state rename_lookups_xfer_msgpair_array {
- jump pvfs2_client_msgpairarray_sm;
+ state rename_lookups_xfer_msgpair_array
+ {
+ jump pvfs2_client_msgpairarray_sm;
success => rename_get_attrs_setup_msgpair_array;
default => rename_lookups_failure;
}
- state rename_lookups_failure {
- run rename_lookups_failure;
- default => cleanup;
+ state rename_lookups_failure
+ {
+ run rename_lookups_failure;
+ default => cleanup;
}
- state rename_get_attrs_setup_msgpair_array {
+ state rename_get_attrs_setup_msgpair_array
+ {
run rename_get_attrs_setup_msgpair_array;
success => rename_get_attrs_xfer_msgpair_array;
default => rename_get_attrs_failure;
}
- state rename_get_attrs_xfer_msgpair_array {
- jump pvfs2_client_msgpairarray_sm;
+ state rename_get_attrs_xfer_msgpair_array
+ {
+ jump pvfs2_client_msgpairarray_sm;
success => rename_crdirent_setup_msgpair;
default => rename_lookups_failure;
}
- state rename_get_attrs_failure {
- run rename_get_attrs_failure;
- default => cleanup;
+ state rename_get_attrs_failure
+ {
+ run rename_get_attrs_failure;
+ default => cleanup;
}
- state rename_crdirent_setup_msgpair {
- run rename_crdirent_setup_msgpair;
- success => rename_crdirent_xfer_msgpair;
+ state rename_crdirent_setup_msgpair
+ {
+ run rename_crdirent_setup_msgpair;
+ success => rename_crdirent_xfer_msgpair;
default => rename_crdirent_failure;
}
- state rename_crdirent_xfer_msgpair {
- jump pvfs2_client_msgpair_sm;
+ state rename_crdirent_xfer_msgpair
+ {
+ jump pvfs2_client_msgpair_sm;
success => rename_rmdirent_setup_msgpair;
- default => rename_crdirent_failure;
+ default => rename_crdirent_failure;
}
- state rename_crdirent_failure {
- run rename_crdirent_failure;
- default => cleanup;
+ state rename_crdirent_failure
+ {
+ run rename_crdirent_failure;
+ default => cleanup;
}
- state rename_rmdirent_setup_msgpair {
- run rename_rmdirent_setup_msgpair;
- success => rename_rmdirent_xfer_msgpair;
+ state rename_rmdirent_setup_msgpair
+ {
+ run rename_rmdirent_setup_msgpair;
+ success => rename_rmdirent_xfer_msgpair;
default => rename_rmdirent_failure;
}
- state rename_rmdirent_xfer_msgpair {
- jump pvfs2_client_msgpair_sm;
+ state rename_rmdirent_xfer_msgpair
+ {
+ jump pvfs2_client_msgpair_sm;
success => cleanup;
- default => rename_rmdirent_failure;
+ default => rename_rmdirent_failure;
}
- state rename_rmdirent_failure {
- run rename_rmdirent_failure;
- default => rename_rmdirent_setup_msgpair;
+ state rename_rmdirent_failure
+ {
+ run rename_rmdirent_failure;
+ default => rename_rmdirent_setup_msgpair;
}
- state cleanup {
+ state cleanup
+ {
run rename_cleanup;
default => terminate;
}
@@ -177,9 +190,6 @@ int PVFS_sys_rename(
gossip_debug(GOSSIP_CLIENT_DEBUG, "PVFS_sys_rename entered\n");
- /* parameter checking goes here. assume everything from the user
- * is ok past this point.
- */
if ((old_entry == NULL) || (new_entry == NULL))
{
return ret;
@@ -233,22 +243,18 @@ int PVFS_sys_rename(
ret = PINT_client_state_machine_post(sm_p, PVFS_SYS_RENAME);
assert(ret == 0);
- /* 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_sys_rename calling "
"PINT_client_state_machine_test()\n");
ret = PINT_client_state_machine_test();
}
-
assert(ret == 0);
gossip_debug(GOSSIP_CLIENT_DEBUG, "PVFS_sys_rename completed\n");
- /* save our return value */
error = sm_p->error_code;
- /* clean up after ourselves */
free(sm_p);
return error;
}
@@ -262,8 +268,6 @@ static int rename_init(PINT_client_sm *s
assert(js_p->error_code == 0);
- /* do the request scheduler thing, if necessary */
-
return 1;
}
@@ -279,9 +283,6 @@ static int rename_lookups_comp_fn(
assert(resp_p->op == PVFS_SERV_LOOKUP_PATH);
assert((index > -1) && (index < 2));
- /* if we get an error, just return immediately, don't try to
- * actually fill anything in.
- */
if (resp_p->status != 0)
{
if (index == 1)
@@ -348,9 +349,6 @@ static int rename_get_attrs_comp_fn(
assert(resp_p->op == PVFS_SERV_GETATTR);
- /* 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;
@@ -387,15 +385,10 @@ static int rename_crdirent_comp_fn(void
struct PVFS_server_resp *resp_p,
int index)
{
-/* PINT_client_sm *sm_p = (PINT_client_sm *) v_p; */
-
gossip_debug(GOSSIP_CLIENT_DEBUG, "rename_crdirent_comp_fn\n");
assert(resp_p->op == PVFS_SERV_CRDIRENT);
- /* 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;
@@ -413,9 +406,6 @@ static int rename_rmdirent_comp_fn(void
assert(resp_p->op == PVFS_SERV_RMDIRENT);
- /* 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;
@@ -434,12 +424,11 @@ static int rename_rmdirent_comp_fn(void
static int rename_lookups_setup_msgpair_array(PINT_client_sm *sm_p,
job_status_s *js_p)
{
- int i = 0;
+ int ret = -PVFS_EINVAL, i = 0;
gossip_debug(GOSSIP_CLIENT_DEBUG, "rename state: "
"rename_lookups_setup_msgpair_array\n");
- /* clear error field in job */
js_p->error_code = 0;
/* allocate msgarray and set msgarray_count */
@@ -473,12 +462,14 @@ static int rename_lookups_setup_msgpair_
msg_p->handle = sm_p->u.rename.parent_refns[i].handle;
msg_p->comp_fn = rename_lookups_comp_fn;
- if (PINT_bucket_map_to_server(&msg_p->svr_addr,
- msg_p->handle,
- msg_p->fs_id) < 0)
+ ret = PINT_bucket_map_to_server(&msg_p->svr_addr,
+ msg_p->handle,
+ msg_p->fs_id);
+ if (ret)
{
- gossip_err("Failed to get meta server %d information\n",i);
- return -PVFS_EINVAL;
+ gossip_err("Failed to map meta server address\n");
+ js_p->error_code = ret;
+ break;
}
}
return 1;
@@ -490,7 +481,7 @@ static int rename_lookups_failure(PINT_c
gossip_debug(GOSSIP_CLIENT_DEBUG,
"rename state: rename_lookups_failure\n");
- /* free the allocated lookup msgs */
+ assert(sm_p->msgarray);
free(sm_p->msgarray);
return 1;
}
@@ -498,18 +489,11 @@ static int rename_lookups_failure(PINT_c
static int rename_get_attrs_setup_msgpair_array(
PINT_client_sm *sm_p, job_status_s *js_p)
{
- int i = 0;
+ int ret = -PVFS_EINVAL, i = 0;
gossip_debug(GOSSIP_CLIENT_DEBUG, "rename state: "
"rename_get_attrs_setup_msgpair_array\n");
- /*
- the idea here is to issue a getattr request for
- the 'old' entry and the 'new' parent directory
- in parallel
- */
-
- /* clear error field in job */
js_p->error_code = 0;
/* free the previously allocated lookup msgs */
@@ -525,7 +509,11 @@ static int rename_get_attrs_setup_msgpai
return -PVFS_ENOMEM;
}
- /* prepare to post the getattr send/recv pairs */
+ /*
+ prepare to post the getattr send/recv pairs. the idea here is
+ to issue a getattr request for the 'old' entry and the 'new'
+ parent directory in parallel
+ */
for(i = 0; i < 2; i++)
{
PINT_client_sm_msgpair_state *msg_p = &sm_p->msgarray[i];
@@ -558,12 +546,14 @@ static int rename_get_attrs_setup_msgpai
msg_p->handle = current_handle;
msg_p->comp_fn = rename_get_attrs_comp_fn;
- if (PINT_bucket_map_to_server(&msg_p->svr_addr,
- msg_p->handle,
- msg_p->fs_id) < 0)
+ ret = PINT_bucket_map_to_server(&msg_p->svr_addr,
+ msg_p->handle,
+ msg_p->fs_id);
+ if (ret)
{
- gossip_err("Failed to get meta server %d information\n",i);
- return -PVFS_EINVAL;
+ gossip_err("Failed to map meta server address\n");
+ js_p->error_code = ret;
+ break;
}
}
return 1;
@@ -575,6 +565,7 @@ static int rename_get_attrs_failure(
gossip_debug(GOSSIP_CLIENT_DEBUG, "rename state: "
"rename_get_attrs_failure\n");
+ assert(sm_p->msgarray);
free(sm_p->msgarray);
if (js_p->error_code == -PVFS_EPERM)
@@ -593,17 +584,17 @@ static int rename_get_attrs_failure(
static int rename_crdirent_setup_msgpair(PINT_client_sm *sm_p,
job_status_s *js_p)
{
+ int ret = -PVFS_EINVAL;
PINT_client_sm_msgpair_state *msg_p = NULL;
gossip_debug(GOSSIP_CLIENT_DEBUG, "rename state: "
"rename_crdirent_setup_msgpair\n");
- /* clear error field in job */
js_p->error_code = 0;
gossip_debug(GOSSIP_CLIENT_DEBUG," rename: posting crdirent req\n");
- /* free the allocated getattr msgs */
+ assert(sm_p->msgarray);
free(sm_p->msgarray);
msg_p = &sm_p->msgpair;
@@ -627,12 +618,13 @@ static int rename_crdirent_setup_msgpair
msg_p->handle = sm_p->u.rename.parent_refns[1].handle;
msg_p->comp_fn = rename_crdirent_comp_fn;
- if (PINT_bucket_map_to_server(&msg_p->svr_addr,
- msg_p->handle,
- msg_p->fs_id) < 0)
+ ret = PINT_bucket_map_to_server(&msg_p->svr_addr,
+ msg_p->handle,
+ msg_p->fs_id);
+ if (ret)
{
- gossip_err("Failed to get meta server information\n");
- assert(0);
+ gossip_err("Failed to map meta server address\n");
+ js_p->error_code = ret;
}
return 1;
}
@@ -653,12 +645,12 @@ static int rename_crdirent_failure(PINT_
static int rename_rmdirent_setup_msgpair(PINT_client_sm *sm_p,
job_status_s *js_p)
{
+ int ret = -PVFS_EINVAL;
PINT_client_sm_msgpair_state *msg_p = NULL;
gossip_debug(GOSSIP_CLIENT_DEBUG, "rename state: "
"rename_rmdirent_setup_msgpair\n");
- /* clear error field in job */
js_p->error_code = 0;
gossip_debug(GOSSIP_CLIENT_DEBUG," rename: posting rmdirent req\n");
@@ -690,12 +682,13 @@ static int rename_rmdirent_setup_msgpair
msg_p->handle = sm_p->u.rename.parent_refns[0].handle;
msg_p->comp_fn = rename_rmdirent_comp_fn;
- if (PINT_bucket_map_to_server(&msg_p->svr_addr,
- msg_p->handle,
- msg_p->fs_id) < 0)
+ ret = PINT_bucket_map_to_server(&msg_p->svr_addr,
+ msg_p->handle,
+ msg_p->fs_id);
+ if (ret)
{
- gossip_err("Failed to get meta server information\n");
- assert(0);
+ gossip_err("Failed to map meta server address\n");
+ js_p->error_code = ret;
}
return 1;
}
@@ -734,9 +727,7 @@ static int rename_cleanup(PINT_client_sm
sm_p->error_code = js_p->error_code;
- /* mark operation as complete */
sm_p->op_complete = 1;
-
return 0;
}
More information about the PVFS2-CVS
mailing list