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 / mgmt-remove-dirent.sm < prev    next >
Text File  |  2008-11-19  |  4KB  |  149 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-storage.h"
  12. #include "pvfs2-server.h"
  13. #include "pvfs2-attr.h"
  14. #include "gossip.h"
  15. #include "pvfs2-internal.h"
  16.  
  17. %%
  18.  
  19. machine pvfs2_mgmt_remove_dirent_sm
  20. {
  21.     state prelude
  22.     {
  23.         jump pvfs2_prelude_sm;
  24.         success => get_dirdata_handle_from_parent;
  25.         default => final_response;
  26.     }
  27.  
  28.     state get_dirdata_handle_from_parent
  29.     {
  30.         run mgmt_remove_dirent_get_dirdata_handle_from_parent;
  31.         success => remove_dirent;
  32.         default => final_response;
  33.     }
  34.  
  35.     state remove_dirent
  36.     {
  37.         run mgmt_remove_dirent;
  38.         default => final_response;
  39.     }
  40.  
  41.     state final_response
  42.     {
  43.         jump pvfs2_final_response_sm;
  44.         default => cleanup;
  45.     }
  46.  
  47.     state cleanup
  48.     {
  49.         run mgmt_remove_dirent_cleanup;
  50.         default => terminate;
  51.     }
  52. }
  53.  
  54. %%
  55.  
  56. static int mgmt_remove_dirent_get_dirdata_handle_from_parent(
  57.         struct PINT_smcb *smcb, job_status_s *js_p)
  58. {
  59.     struct PINT_server_op *s_op = PINT_sm_frame(smcb, PINT_FRAME_CURRENT);
  60.     int ret = -PVFS_EINVAL;
  61.     job_id_t i;
  62.  
  63.     s_op->key.buffer = Trove_Common_Keys[DIR_ENT_KEY].key;
  64.     s_op->key.buffer_sz = Trove_Common_Keys[DIR_ENT_KEY].size;
  65.  
  66.     s_op->val.buffer = &s_op->u.mgmt_remove_dirent.dirdata_handle;
  67.     s_op->val.buffer_sz = sizeof(PVFS_handle);
  68.  
  69.     gossip_debug(
  70.         GOSSIP_SERVER_DEBUG,
  71.         "  reading dirdata handle (coll_id = %d, handle = %llu, "
  72.         "key = %s (%d), val_buf = %p (%d))\n",
  73.         s_op->req->u.mgmt_remove_dirent.fs_id,
  74.         llu(s_op->req->u.mgmt_remove_dirent.handle),
  75.         (char *) s_op->key.buffer, s_op->key.buffer_sz,
  76.         s_op->val.buffer, s_op->val.buffer_sz);
  77.  
  78.  
  79.     ret = job_trove_keyval_read(
  80.         s_op->req->u.mgmt_remove_dirent.fs_id,
  81.         s_op->req->u.mgmt_remove_dirent.handle,
  82.         &s_op->key, &s_op->val, 
  83.         0, 
  84.         NULL, smcb, 0, js_p, &i,
  85.         server_job_context, s_op->req->hints);
  86.  
  87.     return ret;
  88. }
  89.  
  90. static PINT_sm_action mgmt_remove_dirent(
  91.         struct PINT_smcb *smcb, job_status_s *js_p)
  92. {
  93.     struct PINT_server_op *s_op = PINT_sm_frame(smcb, PINT_FRAME_CURRENT);
  94.     int ret = -PVFS_EINVAL;
  95.     job_id_t j_id;
  96.  
  97.     s_op->key.buffer = s_op->req->u.mgmt_remove_dirent.entry;
  98.     s_op->key.buffer_sz = strlen(
  99.         s_op->req->u.mgmt_remove_dirent.entry) + 1;
  100.  
  101.     gossip_debug(
  102.         GOSSIP_SERVER_DEBUG, "  removing entry %s from dirdata "
  103.         "object (handle = %llu)\n", s_op->req->u.mgmt_remove_dirent.entry,
  104.         llu(s_op->u.mgmt_remove_dirent.dirdata_handle));
  105.  
  106.     ret = job_trove_keyval_remove(
  107.         s_op->req->u.mgmt_remove_dirent.fs_id,
  108.         s_op->u.mgmt_remove_dirent.dirdata_handle,
  109.         &s_op->key,
  110.         NULL,
  111.         TROVE_SYNC | TROVE_KEYVAL_HANDLE_COUNT,
  112.         NULL,
  113.         smcb,
  114.         0,
  115.         js_p,
  116.         &j_id,
  117.         server_job_context, s_op->req->hints);
  118.  
  119.     return ret;
  120. }
  121.  
  122. static PINT_sm_action mgmt_remove_dirent_cleanup(
  123.         struct PINT_smcb *smcb, job_status_s *js_p)
  124. {
  125.     return(server_state_machine_complete(smcb));
  126. }
  127.  
  128. PINT_GET_OBJECT_REF_DEFINE(mgmt_remove_dirent);
  129.  
  130. struct PINT_server_req_params pvfs2_mgmt_remove_dirent_params =
  131. {
  132.     .string_name = "mgmt-remove-dirent",
  133.     .perm = PINT_SERVER_CHECK_NONE,
  134.     .access_type = PINT_server_req_modify,
  135.     .sched_policy = PINT_SERVER_REQ_SCHEDULE,
  136.     .get_object_ref = PINT_get_object_ref_mgmt_remove_dirent,
  137.     .state_machine = &pvfs2_mgmt_remove_dirent_sm
  138. };
  139.  
  140. /*
  141.  * Local variables:
  142.  *  mode: c
  143.  *  c-indent-level: 4
  144.  *  c-basic-offset: 4
  145.  * End:
  146.  *
  147.  * vim: ft=c ts=8 sts=4 sw=4 expandtab
  148.  */
  149.