home *** CD-ROM | disk | FTP | other *** search
/ ftp.parl.clemson.edu / 2015-02-07.ftp.parl.clemson.edu.tar / ftp.parl.clemson.edu / pub / pvfs2 / orangefs-2.8.3-20110323.tar.gz / orangefs-2.8.3-20110323.tar / orangefs / src / server / batch-create.sm next >
Text File  |  2008-11-19  |  3KB  |  162 lines

  1. /* 
  2.  * (C) 2001 Clemson University and The University of Chicago 
  3.  *
  4.  * See COPYING in top-level directory.
  5.  */
  6.  
  7. #include <string.h>
  8. #include <assert.h>
  9.  
  10. #include "server-config.h"
  11. #include "pvfs2-server.h"
  12. #include "pvfs2-attr.h"
  13. #include "gossip.h"
  14. #include "pvfs2-internal.h"
  15.  
  16. %%
  17.  
  18. machine pvfs2_batch_create_sm
  19. {
  20.     state prelude
  21.     {
  22.         jump pvfs2_prelude_sm;
  23.         success => create;
  24.         default => final_response;
  25.     }
  26.  
  27.     state create
  28.     {
  29.         run batch_create_create;
  30.         default => final_response;
  31.     }
  32.  
  33.     state final_response
  34.     {
  35.         jump pvfs2_final_response_sm;
  36.         default => cleanup;
  37.     }
  38.  
  39.     state cleanup
  40.     {
  41.         run batch_create_cleanup;
  42.         default => terminate;
  43.     }
  44. }
  45.  
  46. %%
  47.  
  48.  
  49. /*
  50.  * Function: batch_create_create
  51.  *
  52.  * Params:   server_op *s_op, 
  53.  *           job_status_s* js_p
  54.  *
  55.  * Pre:      None
  56.  *
  57.  * Post:     None
  58.  *
  59.  * Returns:  int
  60.  *
  61.  * Synopsis: Create a dataspace.
  62.  */
  63. static int batch_create_create(
  64.         struct PINT_smcb *smcb, job_status_s *js_p)
  65. {
  66.     struct PINT_server_op *s_op = PINT_sm_frame(smcb, PINT_FRAME_CURRENT);
  67.     int ret = -1;
  68.     job_id_t i;
  69.  
  70.     if(s_op->req->u.batch_create.object_count < 1)
  71.     {
  72.         js_p->error_code = -PVFS_EINVAL;
  73.         return(SM_ACTION_COMPLETE);
  74.     }
  75.  
  76.     s_op->resp.u.batch_create.handle_count 
  77.         = s_op->req->u.batch_create.object_count;
  78.  
  79.     /* allocate some space to hold the handles we create */
  80.     s_op->resp.u.batch_create.handle_array = 
  81.         malloc(s_op->req->u.batch_create.object_count * sizeof(PVFS_handle));
  82.     if(!s_op->resp.u.batch_create.handle_array)
  83.     {
  84.         js_p->error_code = -PVFS_ENOMEM;
  85.         return(SM_ACTION_COMPLETE);
  86.     }
  87.  
  88.     ret = job_trove_dspace_create_list(
  89.         s_op->req->u.batch_create.fs_id,
  90.         &s_op->req->u.batch_create.handle_extent_array,
  91.         s_op->resp.u.batch_create.handle_array,
  92.         s_op->req->u.batch_create.object_count,
  93.         s_op->req->u.batch_create.object_type,
  94.         NULL,
  95.         TROVE_SYNC,
  96.         smcb,
  97.         0,
  98.         js_p,
  99.         &i,
  100.         server_job_context,
  101.         s_op->req->hints);
  102.  
  103.      return(ret);
  104. }
  105.  
  106. /*
  107.  * Function: batch_create_cleanup
  108.  *
  109.  * Params:   server_op *b, 
  110.  *           job_status_s* js_p
  111.  *
  112.  * Pre:      None
  113.  *
  114.  * Post:     None
  115.  *
  116.  * Returns:  int
  117.  *
  118.  * Synopsis: free memory and return
  119.  *           
  120.  */
  121. static int batch_create_cleanup(
  122.         struct PINT_smcb *smcb, job_status_s *js_p)
  123. {
  124.     struct PINT_server_op *s_op = PINT_sm_frame(smcb, PINT_FRAME_CURRENT);
  125.     int i;
  126.  
  127.     if(s_op->resp.status == 0)
  128.     {
  129.         for(i=0; i<s_op->resp.u.batch_create.handle_count; i++)
  130.         {
  131.             gossip_debug(
  132.                 GOSSIP_SERVER_DEBUG, "Batch created: %llu\n",
  133.                 llu(s_op->resp.u.batch_create.handle_array[i]));
  134.         }
  135.     }
  136.  
  137.     if(s_op->resp.u.batch_create.handle_array)
  138.     {
  139.         free(s_op->resp.u.batch_create.handle_array);
  140.     }
  141.  
  142.     return(server_state_machine_complete(smcb));
  143. }
  144.  
  145. struct PINT_server_req_params pvfs2_batch_create_params =
  146. {
  147.     .string_name = "batch_create",
  148.     .perm = PINT_SERVER_CHECK_NONE,
  149.     .access_type = PINT_server_req_modify,
  150.     .state_machine = &pvfs2_batch_create_sm
  151. };
  152.  
  153. /*
  154.  * Local variables:
  155.  *  mode: c
  156.  *  c-indent-level: 4
  157.  *  c-basic-offset: 4
  158.  * End:
  159.  *
  160.  * vim: ft=c ts=8 sts=4 sw=4 expandtab
  161.  */
  162.