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 / client / sysint / mgmt-noop.sm < prev    next >
Text File  |  2008-11-19  |  4KB  |  165 lines

  1. /* 
  2.  * (C) 2003 Clemson University and The University of Chicago 
  3.  *
  4.  * See COPYING in top-level directory.
  5.  */
  6.  
  7. /** \file
  8.  *  \ingroup mgmtint
  9.  *
  10.  *  PVFS2 management interface routines for sending "no operation"
  11.  *  (no-op) requests.  This is primarily used for verifying connectivity
  12.  *  to servers.
  13.  */
  14.  
  15. #include <string.h>
  16. #include <assert.h>
  17.  
  18. #include "client-state-machine.h"
  19. #include "pvfs2-debug.h"
  20. #include "job.h"
  21. #include "gossip.h"
  22. #include "str-utils.h"
  23. #include "pint-cached-config.h"
  24. #include "PINT-reqproto-encode.h"
  25. #include "bmi.h"
  26.  
  27. extern job_context_id pint_client_sm_context;
  28.  
  29. %%
  30.  
  31. machine pvfs2_client_mgmt_noop_sm
  32. {
  33.     state setup_msgpair
  34.     {
  35.         run mgmt_noop_setup_msgpair;
  36.         success => xfer_msgpair;
  37.         default => cleanup;
  38.     }
  39.  
  40.     state xfer_msgpair
  41.     {
  42.         jump pvfs2_msgpairarray_sm;
  43.         default => cleanup;
  44.     }
  45.  
  46.     state cleanup
  47.     {
  48.         run mgmt_noop_cleanup;
  49.         default => terminate;
  50.     }
  51. }
  52.  
  53. %%
  54.  
  55. /** Initiate sending of no-op request to a specific server.
  56.  */
  57. PVFS_error PVFS_imgmt_noop(
  58.     PVFS_fs_id fs_id,
  59.     PVFS_credentials *credentials,
  60.     PVFS_BMI_addr_t addr,
  61.     PVFS_mgmt_op_id *op_id,
  62.     PVFS_hint hints,
  63.     void *user_ptr)
  64. {
  65.     PINT_smcb *smcb = NULL;
  66.     PINT_client_sm *sm_p = NULL;
  67.  
  68.     gossip_debug(GOSSIP_CLIENT_DEBUG, "PVFS_imgmt_noop entered\n");
  69.  
  70.     PINT_smcb_alloc(&smcb, PVFS_MGMT_NOOP,
  71.              sizeof(struct PINT_client_sm),
  72.              client_op_state_get_machine,
  73.              client_state_machine_terminate,
  74.              pint_client_sm_context);
  75.     if (!smcb)
  76.     {
  77.         return -PVFS_ENOMEM;
  78.     }
  79.     sm_p = PINT_sm_frame(smcb, PINT_FRAME_CURRENT);
  80.  
  81.     PINT_init_msgarray_params(sm_p, fs_id);
  82.     PINT_init_sysint_credentials(sm_p->cred_p, credentials);
  83.     PINT_msgpair_init(&sm_p->msgarray_op);
  84.     sm_p->msgarray_op.msgpair.fs_id = fs_id;
  85.     sm_p->msgarray_op.msgpair.retry_flag = PVFS_MSGPAIR_NO_RETRY;
  86.     sm_p->msgarray_op.msgpair.svr_addr = addr;
  87.  
  88.     PVFS_hint_copy(hints, &sm_p->hints);
  89.  
  90.     gossip_debug(GOSSIP_CLIENT_DEBUG, "PVFS_mgmt_noop calling "
  91.                  "PINT_client_state_machine_post()\n");
  92.  
  93.     return PINT_client_state_machine_post(
  94.         smcb,  op_id, user_ptr);
  95. }
  96.  
  97. /** Send a no-op request to a specific server and receive response.
  98.  */
  99. PVFS_error PVFS_mgmt_noop(
  100.     PVFS_fs_id fs_id,
  101.     PVFS_credentials *credentials,
  102.     PVFS_BMI_addr_t addr,
  103.     PVFS_hint hints)
  104. {
  105.     PVFS_error ret = -PVFS_EINVAL, error = 0;
  106.     PVFS_mgmt_op_id op_id;
  107.  
  108.     gossip_debug(GOSSIP_CLIENT_DEBUG, "PVFS_mgmt_noop entered\n");
  109.  
  110.     ret = PVFS_imgmt_noop(fs_id, credentials, addr, &op_id, hints, NULL);
  111.     if (ret)
  112.     {
  113.         PVFS_perror_gossip("PVFS_imgmt_noop call", ret);
  114.         error = ret;
  115.     }
  116.     else
  117.     {
  118.         ret = PVFS_mgmt_wait(op_id, "noop", &error);
  119.         if (ret)
  120.         {
  121.             PVFS_perror_gossip("PVFS_mgmt_wait call", ret);
  122.             error = ret;
  123.         }
  124.     }
  125.  
  126.     PINT_mgmt_release(op_id);
  127.     return error;
  128. }
  129.  
  130. static PINT_sm_action mgmt_noop_setup_msgpair(
  131.         struct PINT_smcb *smcb, job_status_s *js_p)
  132. {
  133.     struct PINT_client_sm *sm_p = PINT_sm_frame(smcb, PINT_FRAME_CURRENT);
  134.     gossip_debug(GOSSIP_CLIENT_DEBUG,
  135.                  "noop state: mgmt_noop_setup_msgpair\n");
  136.  
  137.     PINT_SERVREQ_MGMT_NOOP_FILL(sm_p->msgarray_op.msgpair.req, *sm_p->cred_p, sm_p->hints);
  138.  
  139.     PINT_sm_push_frame(smcb, 0, &sm_p->msgarray_op);
  140.     js_p->error_code = 0;
  141.     return SM_ACTION_COMPLETE;
  142. }
  143.  
  144. static PINT_sm_action mgmt_noop_cleanup(
  145.         struct PINT_smcb *smcb, job_status_s *js_p)
  146. {
  147.     struct PINT_client_sm *sm_p = PINT_sm_frame(smcb, PINT_FRAME_CURRENT);
  148.     gossip_debug(GOSSIP_CLIENT_DEBUG, "noop state: mgmt_noop_cleanup\n");
  149.  
  150.     sm_p->error_code = js_p->error_code;
  151.  
  152.     PINT_SET_OP_COMPLETE;
  153.     return SM_ACTION_TERMINATE;
  154. }
  155.  
  156. /*
  157.  * Local variables:
  158.  *  mode: c
  159.  *  c-indent-level: 4
  160.  *  c-basic-offset: 4
  161.  * End:
  162.  *
  163.  * vim: ft=c ts=8 sts=4 sw=4 expandtab
  164.  */
  165.