[Pvfs2-cvs] commit by pcarns in pvfs2-1/src/server: batch-create.sm
CVS commit program
cvs at parl.clemson.edu
Tue Feb 26 20:27:13 EST 2008
Update of /projects/cvsroot/pvfs2-1/src/server
In directory parlweb1:/tmp/cvs-serv11568/src/server
Modified Files:
Tag: small-file-branch
batch-create.sm
Log Message:
convert batch create to use new trove/job function, fix a bug in the
implementation. This speeds up the batch create considerably.
Index: batch-create.sm
===================================================================
RCS file: /projects/cvsroot/pvfs2-1/src/server/Attic/batch-create.sm,v
diff -p -u -r1.1.2.4 -r1.1.2.5
--- batch-create.sm 21 Feb 2008 02:10:20 -0000 1.1.2.4
+++ batch-create.sm 27 Feb 2008 01:27:13 -0000 1.1.2.5
@@ -13,8 +13,6 @@
#include "gossip.h"
#include "pvfs2-internal.h"
-#define ALL_DONE 100
-
%%
machine pvfs2_batch_create_sm
@@ -22,13 +20,6 @@ machine pvfs2_batch_create_sm
state prelude
{
jump pvfs2_prelude_sm;
- success => create_prepare;
- default => final_response;
- }
-
- state create_prepare
- {
- run batch_create_create_prepare;
success => create;
default => final_response;
}
@@ -36,33 +27,6 @@ machine pvfs2_batch_create_sm
state create
{
run batch_create_create;
- default => create_looper;
- }
-
- state create_looper
- {
- run batch_create_create_looper;
- success => create;
- ALL_DONE => create_looper_finish;
- default => remove;
- }
-
- state remove
- {
- run batch_create_remove;
- default => remove_looper;
- }
-
- state remove_looper
- {
- run batch_create_remove_looper;
- success => remove;
- default => final_response;
- }
-
- state create_looper_finish
- {
- run batch_create_create_looper_finish;
default => final_response;
}
@@ -81,61 +45,9 @@ machine pvfs2_batch_create_sm
%%
-/*
- * Function: batch_create_remove_looper
- *
- * Params: server_op *s_op,
- * job_status_s* js_p
- *
- * Pre: None
- *
- * Post: None
- *
- * Returns: int
- *
- * Synopsis: loop over create operations.
- */
-static int batch_create_remove_looper(
- struct PINT_smcb *smcb, job_status_s *js_p)
-{
- struct PINT_server_op *s_op = PINT_sm_frame(smcb, PINT_FRAME_CURRENT);
- int ret = -1;
-
- if(js_p->error_code)
- {
- /* hrm. A remove failed, but we want to report the original error
- * code that led to this.
- */
- gossip_err("Warning: failed cleanup from batch_create().\n");
- gossip_err("Warning: stranded handles may result.\n");
- if(s_op->u.batch_create.saved_error_code)
- {
- js_p->error_code = s_op->u.batch_create.saved_error_code;
- }
- return(SM_ACTION_COMPLETE);
- }
-
- s_op->u.batch_create.batch_index--;
-
- if(s_op->u.batch_create.batch_index > 0)
- {
- /* more work to do */
- js_p->error_code = 0;
- ret = SM_ACTION_COMPLETE;
- }
- else
- {
- /* done cleaning up objects, report original create error */
- js_p->error_code = s_op->u.batch_create.saved_error_code;;
- ret = SM_ACTION_COMPLETE;
- }
-
- return(ret);
-}
-
/*
- * Function: batch_create_create_looper
+ * Function: batch_create_create
*
* Params: server_op *s_op,
* job_status_s* js_p
@@ -146,66 +58,38 @@ static int batch_create_remove_looper(
*
* Returns: int
*
- * Synopsis: loop over create operations.
+ * Synopsis: Create a dataspace.
*/
-static int batch_create_create_looper(
+static int batch_create_create(
struct PINT_smcb *smcb, job_status_s *js_p)
{
struct PINT_server_op *s_op = PINT_sm_frame(smcb, PINT_FRAME_CURRENT);
int ret = -1;
+ job_id_t i;
- if(js_p->error_code)
+ if(s_op->req->u.batch_create.object_count < 1)
{
- s_op->u.batch_create.saved_error_code = js_p->error_code;
+ js_p->error_code = -PVFS_EINVAL;
return(SM_ACTION_COMPLETE);
}
- s_op->resp.u.batch_create.handle_array[s_op->u.batch_create.batch_index] =
- js_p->handle;
- s_op->u.batch_create.batch_index++;
- s_op->resp.u.batch_create.handle_count++;
+ s_op->resp.u.batch_create.handle_count
+ = s_op->req->u.batch_create.object_count;
- if(s_op->u.batch_create.batch_index <
- s_op->req->u.batch_create.object_count)
- {
- /* more work to do */
- js_p->error_code = 0;
- ret = SM_ACTION_COMPLETE;
- }
- else
+ /* allocate some space to hold the handles we create */
+ s_op->resp.u.batch_create.handle_array =
+ malloc(s_op->req->u.batch_create.object_count * sizeof(PVFS_handle));
+ if(!s_op->resp.u.batch_create.handle_array)
{
- /* done creating objects */
- js_p->error_code = ALL_DONE;
- ret = SM_ACTION_COMPLETE;
+ js_p->error_code = -PVFS_ENOMEM;
+ return(SM_ACTION_COMPLETE);
}
- return(ret);
-}
-
-/*
- * Function: batch_create_create
- *
- * Params: server_op *s_op,
- * job_status_s* js_p
- *
- * Pre: None
- *
- * Post: None
- *
- * Returns: int
- *
- * Synopsis: Create a dataspace.
- */
-static int batch_create_create(
- struct PINT_smcb *smcb, job_status_s *js_p)
-{
- struct PINT_server_op *s_op = PINT_sm_frame(smcb, PINT_FRAME_CURRENT);
- int ret = -1;
- job_id_t i;
-
- ret = job_trove_dspace_create(
+ ret = job_trove_dspace_create_list(
s_op->req->u.batch_create.fs_id,
&s_op->req->u.batch_create.handle_extent_array,
+ s_op->resp.u.batch_create.handle_array,
+ s_op->req->u.batch_create.object_count,
s_op->req->u.batch_create.object_type,
NULL,
TROVE_SYNC,
@@ -219,96 +103,6 @@ static int batch_create_create(
}
/*
- * Function: batch_create_remove
- *
- * Params: server_op *s_op,
- * job_status_s* js_p
- *
- * Pre: None
- *
- * Post: None
- *
- * Returns: int
- *
- * Synopsis: Remove a dataspace (cleanup after error).
- */
-static int batch_create_remove(
- struct PINT_smcb *smcb, job_status_s *js_p)
-{
- struct PINT_server_op *s_op = PINT_sm_frame(smcb, PINT_FRAME_CURRENT);
- int ret = -1;
- job_id_t i;
-
- if(s_op->u.batch_create.batch_index < 1)
- {
- /* nothing to clean up */
- js_p->error_code = 0;
- return(SM_ACTION_COMPLETE);
- }
-
- /* work backwards through the handle array created so far */
- ret = job_trove_dspace_remove(
- s_op->req->u.batch_create.fs_id,
- s_op->resp.u.batch_create.handle_array[
- s_op->u.batch_create.batch_index],
- TROVE_SYNC,
- smcb,
- 0,
- js_p,
- &i,
- server_job_context);
-
- return(ret);
-}
-
-
-/* batch_create_create_looper_finish()
- *
- * fills in the response structure based on results of previous operation
- */
-static int batch_create_create_looper_finish(
- struct PINT_smcb *smcb, job_status_s *js_p)
-{
- /* the sole purpose of this state is to clear out the special "ALL_DONE"
- * error code if we are successful
- */
- assert(js_p->error_code == ALL_DONE);
-
- js_p->error_code = 0;
- return SM_ACTION_COMPLETE;
-}
-
-
-/* batch_create_create_prepare()
- *
- * fills in the response structure based on results of previous operation
- */
-static int batch_create_create_prepare(
- struct PINT_smcb *smcb, job_status_s *js_p)
-{
- struct PINT_server_op *s_op = PINT_sm_frame(smcb, PINT_FRAME_CURRENT);
-
- if(s_op->req->u.batch_create.object_count < 1)
- {
- js_p->error_code = -PVFS_EINVAL;
- return(SM_ACTION_COMPLETE);
- }
-
- /* allocate some space to hold the handles we create */
- s_op->resp.u.batch_create.handle_array =
- malloc(s_op->req->u.batch_create.object_count * sizeof(PVFS_handle));
- if(!s_op->resp.u.batch_create.handle_array)
- {
- js_p->error_code = -PVFS_ENOMEM;
- return(SM_ACTION_COMPLETE);
- }
-
- js_p->error_code = 0;
- return SM_ACTION_COMPLETE;
-}
-
-
-/*
* Function: batch_create_cleanup
*
* Params: server_op *b,
@@ -327,6 +121,17 @@ static int batch_create_cleanup(
struct PINT_smcb *smcb, job_status_s *js_p)
{
struct PINT_server_op *s_op = PINT_sm_frame(smcb, PINT_FRAME_CURRENT);
+ int i;
+
+ if(s_op->resp.status == 0)
+ {
+ for(i=0; i<s_op->resp.u.batch_create.handle_count; i++)
+ {
+ gossip_debug(
+ GOSSIP_SERVER_DEBUG, "Batch created: %llu\n",
+ llu(s_op->resp.u.batch_create.handle_array[i]));
+ }
+ }
if(s_op->resp.u.batch_create.handle_array)
{
More information about the Pvfs2-cvs
mailing list