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 / pjmp-machines.sm < prev    next >
Text File  |  2011-03-23  |  9KB  |  305 lines

  1. /* 
  2.  * (C) 2001 Clemson University and The University of Chicago 
  3.  *
  4.  * See COPYING in top-level directory.
  5.  *
  6.  * Changes by Acxiom Corporation to add dirent_count field to attributes
  7.  * Copyright ┬⌐ Acxiom Corporation, 2005.
  8.  */
  9.  
  10. #include <string.h>
  11. #include <assert.h>
  12.  
  13. #include "server-config.h"
  14. #include "pvfs2-server.h"
  15. #include "pvfs2-attr.h"
  16. #include "pvfs2-types.h"
  17. #include "pvfs2-types-debug.h"
  18. #include "pvfs2-util.h"
  19. #include "pint-util.h"
  20. #include "pvfs2-internal.h"
  21. #include "pint-cached-config.h"
  22.  
  23. %%
  24. machine pvfs2_pjmp_get_attr_work_sm
  25. {
  26.     state pjmp_get_attr_work_initialize
  27.     {
  28.         run pjmp_initialize;
  29.         default => pjmp_call_get_attr_work_sm;
  30.     }
  31.  
  32.     state pjmp_call_get_attr_work_sm
  33.     {
  34.         jump pvfs2_get_attr_work_sm;
  35.         default => pjmp_get_attr_work_execute_terminate;
  36.     }
  37.  
  38.     state pjmp_get_attr_work_execute_terminate
  39.     {
  40.         run pjmp_execute_terminate;
  41.         default => terminate;
  42.     }
  43. }
  44.  
  45.  
  46. machine pvfs2_pjmp_create_immutable_copies_sm
  47. {
  48.     state pjmp_create_immutable_copies_initialize
  49.     {
  50.         run pjmp_initialize;
  51.         default => pjmp_call_create_immutable_copies_sm;
  52.     }
  53.  
  54.     state pjmp_call_create_immutable_copies_sm
  55.     {
  56.         jump pvfs2_create_immutable_copies_sm;
  57.         default => pjmp_create_immutable_copies_execute_terminate;
  58.     }
  59.  
  60.     state pjmp_create_immutable_copies_execute_terminate
  61.     {
  62.         run pjmp_execute_terminate;
  63.         default => terminate;
  64.     }
  65. }
  66.  
  67.  
  68. machine pvfs2_pjmp_mirror_work_sm
  69. {
  70.     state pjmp_mirror_work_initialize
  71.     {
  72.         run pjmp_initialize;
  73.         default => pjmp_call_mirror_work_sm;
  74.     }
  75.  
  76.     state pjmp_call_mirror_work_sm
  77.     {
  78.         jump pvfs2_mirror_work_sm;
  79.         default => pjmp_mirror_work_execute_terminate;
  80.     }
  81.  
  82.     state pjmp_mirror_work_execute_terminate
  83.     {
  84.         run pjmp_execute_terminate;
  85.         default => terminate;
  86.     }
  87. }
  88.  
  89.  
  90. machine pvfs2_pjmp_remove_work_sm
  91. {
  92.     state pjmp_remove_work_initialize
  93.     {
  94.         run pjmp_remove_work_schedule_job;
  95.         success => pjmp_call_remove_work_sm;
  96.         default => pjmp_remove_work_execute_terminate;
  97.     }
  98.  
  99.     state pjmp_call_remove_work_sm
  100.     {
  101.         jump pvfs2_remove_work_sm;
  102.         default => pjmp_remove_work_release_job;
  103.     }
  104.  
  105.     state pjmp_remove_work_release_job
  106.     {
  107.         run pjmp_remove_work_release_job;
  108.         default => pjmp_remove_work_execute_terminate;
  109.     }
  110.     state pjmp_remove_work_execute_terminate
  111.     {
  112.         run pjmp_remove_work_execute_terminate;
  113.         default => terminate;
  114.     }
  115. }
  116.  
  117.  
  118. machine pvfs2_pjmp_get_attr_with_prelude_sm
  119. {
  120.     state pjmp_initialize
  121.     {
  122.         run pjmp_initialize;
  123.         default => pjmp_call_get_attr_with_prelude;
  124.     }
  125.  
  126.     state pjmp_call_get_attr_with_prelude
  127.     {
  128.         jump pvfs2_get_attr_with_prelude_sm;
  129.         default => pjmp_execute_terminate;
  130.     }
  131.  
  132.     state pjmp_execute_terminate
  133.     {
  134.         run pjmp_execute_terminate;
  135.         default => terminate;
  136.     } 
  137. }
  138.  
  139.  
  140. machine pvfs2_pjmp_call_msgpairarray_sm
  141. {
  142.    state call_msgpairarray
  143.     {
  144.         run call_msgpairarray;
  145.         success => transfer_msgpair;
  146.         default => cleanup_msgpairarray;
  147.     }
  148.  
  149.    state transfer_msgpair
  150.     {
  151.          jump pvfs2_msgpairarray_sm;
  152.          default => cleanup_msgpairarray;
  153.     }
  154.  
  155.    state cleanup_msgpairarray
  156.     {
  157.         run cleanup_msgpairarray;
  158.         default => terminate;
  159.     }
  160. } /*end state machine pvfs2_pjmp_call_msgpairarray_sm*/
  161. %%
  162.  
  163. static PINT_sm_action pjmp_initialize( struct PINT_smcb *smcb
  164.                                      , job_status_s *js_p)
  165. {
  166.     js_p->error_code = 0;
  167.     return SM_ACTION_COMPLETE;
  168. }
  169.  
  170. static PINT_sm_action pjmp_execute_terminate( struct PINT_smcb *smcb
  171.                                             , job_status_s *js_p)
  172. {
  173.     return SM_ACTION_TERMINATE;
  174. }
  175.  
  176. /****************************************************************************/
  177. /* Actions for pvfs2_pjmp_call_msgpairarray_sm                              */
  178. /****************************************************************************/
  179.  
  180. /*We use a separate nested state machine to call msgpairarray because */
  181. /*msgpairarray.sm is setup to work only with a "jump".  When "pjmp"   */
  182. /*is used, the frame stack gets corrupted.                            */
  183. static PINT_sm_action call_msgpairarray (struct PINT_smcb *smcb
  184.                                         ,job_status_s *js_p)
  185. {   
  186.    gossip_debug(GOSSIP_SERVER_DEBUG,"Executing pvfs2_pjmp_call_msgpairarray_sm:"
  187.                                     "call_msgpairarray for operation (%s)\n"
  188.                                    ,PINT_map_server_op_to_string(smcb->op));
  189.    gossip_debug(GOSSIP_MIRROR_DEBUG,"Executing pvfs2_pjmp_call_msgpairarray_sm:"
  190.                                     "call_msgpairarray for operation (%s)\n"
  191.                                    ,PINT_map_server_op_to_string(smcb->op));
  192.    gossip_debug(GOSSIP_MIRROR_DEBUG,"\tframe count is %d.\n",smcb->frame_count);
  193.    gossip_debug(GOSSIP_MIRROR_DEBUG,"\t base frame is %d.\n",smcb->base_frame);
  194.    gossip_debug(GOSSIP_MIRROR_DEBUG,"\t op nbr is #%d.\n",smcb->op);
  195.  
  196.    struct PINT_server_op *s_op = PINT_sm_frame(smcb,PINT_FRAME_CURRENT);
  197.    PINT_sm_msgarray_op *msgarray = &(s_op->msgarray_op);
  198.  
  199.    gossip_debug(GOSSIP_MIRROR_DEBUG,"\ts_op:%p\n",s_op);
  200.  
  201.    js_p->error_code = 0;
  202.  
  203.    gossip_debug(GOSSIP_MIRROR_DEBUG,"\tmsgarray->msgpair.req.op:%d\n"
  204.                                     ,msgarray->msgpair.req.op );
  205.  
  206.    PINT_sm_push_frame(smcb,0,msgarray);
  207.    
  208.    gossip_debug(GOSSIP_MIRROR_DEBUG,"\tAFTER PUSH:smcb->base_frame:%d"
  209.                                     "\tframe_count:%d\n"
  210.                                    ,smcb->base_frame,smcb->frame_count);
  211.  
  212.    return SM_ACTION_COMPLETE;
  213. }/*end action call_msgpairarray*/
  214.  
  215. static PINT_sm_action cleanup_msgpairarray (struct PINT_smcb *smcb
  216.                                            ,job_status_s *js_p)
  217. {   
  218.    gossip_debug(GOSSIP_MIRROR_DEBUG,"Executing pvfs2_pjmp_call_msgpairarray_sm:cleanup_msgpairarray"
  219.                                     "....\n");
  220.    struct PINT_server_op *s_op = PINT_sm_frame(smcb,PINT_FRAME_CURRENT);
  221.    PINT_sm_msgarray_op *msgarray = &(s_op->msgarray_op);
  222.  
  223.    gossip_debug(GOSSIP_MIRROR_DEBUG,"\ts_op:%p\n",s_op);
  224.  
  225.    gossip_debug(GOSSIP_MIRROR_DEBUG,"\tjs_p->error_code:%d\n"
  226.                                    ,js_p->error_code);
  227.    gossip_debug(GOSSIP_MIRROR_DEBUG,"\tBEFORE POP:smcb->frame_base:%d"
  228.                                     "\tframe_count:%d\n"
  229.                                    ,smcb->base_frame,smcb->frame_count);
  230.  
  231.  
  232.    gossip_debug(GOSSIP_MIRROR_DEBUG,"\tmsgarray->msgpair.req.op:%d\n"
  233.                                     ,msgarray->msgpair.req.op );
  234.  
  235.    gossip_debug(GOSSIP_MIRROR_DEBUG,"\ts_op->resp.status:%d\n"
  236.                                    ,s_op->resp.status);
  237.  
  238.    return SM_ACTION_TERMINATE;
  239. }/*end action cleanup_msgpairarray*/
  240.  
  241. static PINT_sm_action pjmp_remove_work_schedule_job(struct PINT_smcb *smcb, job_status_s *js_p)
  242. {
  243.    int ret;
  244.    struct PINT_server_op *s_op = PINT_sm_frame(smcb, PINT_FRAME_CURRENT);
  245.  
  246.    ret = PINT_server_req_get_object_ref(s_op->req
  247.                                        ,&s_op->target_fs_id
  248.                                        ,&s_op->target_handle);
  249.    s_op->access_type = PINT_server_req_get_access_type(s_op->req);
  250.    s_op->sched_policy = PINT_server_req_get_sched_policy(s_op->req);
  251.  
  252.    js_p->error_code = 0;
  253.    ret = job_req_sched_post( s_op->op
  254.                             ,s_op->target_fs_id
  255.                             ,s_op->target_handle
  256.                             ,s_op->access_type
  257.                             ,s_op->sched_policy
  258.                             ,smcb
  259.                             ,0
  260.                             ,js_p
  261.                             ,&(s_op->scheduled_id)
  262.                             ,server_job_context);
  263.    return ret;
  264. }/*end pjmp_remove_work_schedule_job*/
  265.  
  266.  
  267. static PINT_sm_action pjmp_remove_work_release_job(struct PINT_smcb *smcb, job_status_s *js_p)
  268. {
  269.    int ret = -1;
  270.    job_id_t tmp_id;
  271.    struct PINT_server_op *s_op = PINT_sm_frame(smcb, PINT_FRAME_CURRENT);
  272.  
  273.    /* save the error-code returned from the previous step */
  274.    s_op->u.remove.saved_error_code = js_p->error_code;
  275.  
  276.    ret = job_req_sched_release( s_op->scheduled_id
  277.                                ,smcb
  278.                                ,0
  279.                                ,js_p
  280.                                ,&tmp_id
  281.                                ,server_job_context);
  282.  
  283.    return ret;  
  284. }/*end pjmp_remove_work_release_job*/
  285.  
  286. static PINT_sm_action pjmp_remove_work_execute_terminate(struct PINT_smcb *smcb, job_status_s *js_p)
  287. {
  288.    struct PINT_server_op *s_op = PINT_sm_frame(smcb, PINT_FRAME_CURRENT);
  289.  
  290.    js_p->error_code = s_op->u.remove.saved_error_code;
  291.  
  292.    return SM_ACTION_TERMINATE;
  293. }/*end pjmp_remove_execute_terminate */
  294.  
  295.  
  296. /*
  297.  * Local variables:
  298.  *  mode: c
  299.  *  c-indent-level: 4
  300.  *  c-basic-offset: 4
  301.  * End:
  302.  *
  303.  * vim: ft=c ts=8 sts=4 sw=4 expandtab
  304.  */
  305.