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 / doc / design / new_operation.txt < prev    next >
Text File  |  2006-08-30  |  5KB  |  135 lines

  1. # todo: latex this
  2.  
  3. #
  4. # 18 July 2003
  5. #
  6. # rob latham and team pvfs2
  7. #
  8.  
  9. Adding a new server operation is currently rather involved.  I'm going to try
  10. to lay out what i did to add a flush operation to pvfs2
  11.  
  12. CLIENT-SIDE
  13.  
  14.  Add a prototype for your function to pvfs2-sysint.h.  If your function
  15.  just needs to know if it suceeded or failed, you are done.  If not, you
  16.  must also define a server response structure.
  17.  
  18.  We are moving to using state machines for both client and server
  19.  operations, so if you are adding a new operation, make it a state
  20.  machine.  Define your operation-specific state machine structure in
  21.  client-state-machine.h and add it to the PINT_client_sm structure. Add
  22.  your operation to the switch statement in
  23.  PINT_client_state_machine_post()
  24.  
  25.  there is an unnamed enum in client-state-machine.h with some other
  26.  operations (PVFS_SYS_REMOVE, PVFS_SYS_IO, etc).  Add your operation to
  27.  that enum.
  28.  
  29.  also in client-state-machine.h, declare your state machine 'extern'
  30.  with the other operation state machine declarations.
  31.  
  32.  add the .c file for your operation to src/client/sysint/module.mk.in
  33.  
  34.  A client-side state machine can take advantage of several nested state
  35.  machines.  The client state machines tend to have a certain pattern to
  36.  them:  check_parameters, then for each time they talk to the server
  37.  there is a 'setup/xfer/failure' triplet of states to send a msgpair (or
  38.  a bunch of msgpairs in one msgpairarray). lastly, 'cleanup'.  As with
  39.  the server, the best documentation is other state machines.
  40.  
  41. SERVER-SIDE
  42.  
  43.   It's probably a good idea to start implementing your new operation
  44.   at the trove layer, then adding support for it at the job interface.
  45.   Once the job interface is in place, then you can implement the state
  46.   machine.  Doing things this way means you can always compile the tree
  47.   to catch errors. 
  48.  
  49. Trove:
  50.  
  51.   If you need to extend trove functionality to implement your new
  52.   operation, start by adding a prototype to trove-proto.h.  This will
  53.   autogenerate the code that links the trove api to the underlying
  54.   storage implementation (currently dbpf).
  55.  
  56.   Define a new member of the TROVE_bstream_ops, TROVE_keyval_ops, and/or
  57.   TROVE_dspace_ops structure.  Add the dbpf implementation: check out
  58.   trove-dbpf/dbpf-bstream.c and trove-dbpf/dbpf-keyval.  At the bottom
  59.   of those files is a structure of function pointers.  Add your new
  60.   function.
  61.  
  62.   If your new function is nonblocking, add it to the dbpf_op_type enum.
  63.  
  64. Job:
  65.   
  66.   You can follow the example of the other job functions to get error
  67.   handling/reporting, mutex locking, and calling down to trove correct.
  68.   Add a prototype for your function to job.h
  69.  
  70. State Machine:
  71.  
  72.   Write a state machine to deal with the server-side of your operation.
  73.   The 'prelude' and 'final_response' states take care of some common
  74.   tasks.  look at the other server state machines to see how things
  75.   should go: that's the best documetnation so far.
  76.  
  77.   Declare this new state machine in pvfs2-server.h with the other server
  78.   operation state machines.
  79.  
  80.   
  81. Everything Else:
  82.  
  83.   define a PINT_server_xxx_op with the information specific to your new
  84.   operation, and add it to the union in PINT_server_op.
  85.  
  86.   Add a new enum to PVFS_server_op, just before the sentinel
  87.   PVFS_SERV_NUM_OPS.  Define a server request structure
  88.   (PVFS_servreq_xxx) and optionally (but encouraged) a
  89.   PINT_SERVREQ_xxx_FILL macro.  If your operation needs information back
  90.   from the server (beyond 'success' or 'fail'), define a
  91.   PVFS_servresp_xxx structure for the server response.  Add these new
  92.   structures to the union in the declaration of the PVFS_server_req and
  93.   PVFS_server_resp (if necessary).
  94.  
  95.  
  96.   For many operations, -TROVE_ENOENT is ok (e.g. operations on datafiles
  97.   [because we do not store attributes with datafiles], flushing a keyval
  98.   when the keyval space has not been created on disk, or setting
  99.   attributes on a file that didn't have atributes previously).  If your
  100.   operation is like that, modifly prelude_perm_check and add it to the
  101.   list of operations for which TROVE_ENOENT is ok.   If you haven't
  102.   figured out what it means to 'check permissions' for your operation,
  103.   add it towards the bottom of the function with the other oddball
  104.   operations.
  105.  
  106.   Help out the debugging helper functions by adding a text
  107.   representation of your operation to PINT_map_server_op_to_string()
  108.  
  109.   The server will not know how to handle the new operation until you've
  110.   addded it along with the other operations in
  111.   server_state_table_initialize().
  112.  
  113.   If your operation needs data from the request structure (and most of
  114.   them do), modify PINT_req_sched_target_handle to make the apropriate
  115.   copies.
  116.  
  117.  
  118. PROTOCOL
  119.   
  120.   the encode and decode system needs to know how to handle your new
  121.   operation.  If it is a self-contained structure -- that is, it has no
  122.   pointers -- then it can be added with the other self-contained
  123.   structures in do_decode_req(), do_encode_req(), do_decode_resp(), and
  124.   do_encode_resp().  Otherwise, you'll have to perform more steps like
  125.   those done in PVFS_SERV_IO and PVFS_SERV_MKDIR and others.
  126.  
  127. TESTING
  128.   
  129.   no new operation should go in without a testcase exercising that
  130.   operation.  add it to the other tests in tests/client/sysint and add
  131.   it to the list of targets to build in module.mk.in
  132.  
  133.  
  134. # vim: tw=72
  135.