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 / io / buffer / ncac-interface.h < prev    next >
C/C++ Source or Header  |  2003-11-17  |  6KB  |  207 lines

  1. #ifndef __CACHE_NETWORK_H
  2. #define __CACHE_NETWORK_H
  3.  
  4. #include "pvfs2-types.h"
  5.  
  6. /* cache operation flags */
  7.  
  8. #define     NCAC_READ       1
  9. #define     NCAC_WRITE      2
  10. #define     NCAC_BUF_READ    3
  11. #define     NCAC_BUF_WRITE   4
  12. #define     NCAC_QUERY          5
  13. #define     NCAC_DEMOTE         6
  14. #define     NCAC_SYNC           7
  15.  
  16. typedef int cache_optype;  
  17.  
  18.  
  19. /* cache policy on each request */
  20. enum {
  21.     LRU_CACHE   = 1,
  22.     MRU_CACHE   = 2,
  23.     NO_CACHE_   = 3,
  24.     ARC_CACHE   = 4,
  25. };
  26.  
  27. struct cache_hints
  28. {
  29.     int policy;
  30.     /* add more later */
  31. };
  32. typedef struct cache_hints cache_hints_t;
  33.  
  34.  
  35. /**********************************************************
  36.  * define related structures for the interactions between *
  37.  * networks and the cache                  *
  38.  **********************************************************/
  39.  
  40. struct cache_descriptor
  41. {
  42.     PVFS_fs_id      coll_id;  
  43.     PVFS_handle     handle; /* these two direct to the right object */
  44.     PVFS_context_id context_id;
  45.     
  46.     /* support a list of regions */
  47.     int     stream_array_count;
  48.     PVFS_offset    *stream_offset_array; /* offset array in the object */
  49.     PVFS_size    *stream_size_array;
  50.     
  51.     void     *buffer; /* whether data is placed in this buffer */
  52.     PVFS_size    len;     /* how many data in the buffer */
  53.  
  54.     struct cache_hints chints; /* cache hints */
  55. };
  56. typedef struct cache_descriptor cache_desc_t;
  57.  
  58. /* read/write request desccriptor: read request to the cache module.
  59.  * If "buffer" is not NULL, the caller expects that the cache
  60.  * module to place place data into it.
  61.  */
  62.  
  63. struct cache_read_descriptor
  64. {
  65.     PVFS_fs_id  coll_id;  
  66.     PVFS_handle handle; /* these two direct to the right object */
  67.     PVFS_context_id context_id;
  68.     
  69.     /* support a list of regions */
  70.     int     stream_array_count;
  71.     PVFS_offset    *stream_offset_array; /* offset array in the object */
  72.     PVFS_size    *stream_size_array;
  73.     
  74.     void     *buffer; /* whether data is placed in this buffer */
  75.     PVFS_size    len;     /* how many data in the buffer */
  76.  
  77.     struct cache_hints chints; /* cache hints */
  78. };
  79. typedef struct cache_read_descriptor cache_read_desc_t;
  80. typedef struct cache_read_descriptor cache_write_desc_t;
  81.  
  82. /* sync request: to sync all cached dirty data into disk. 
  83.  * if "coll_id" is PVFS_FS_ANY and "handle" is PVFS_HNDL_ANY,
  84.  * it asks for "sync". Otherwise, it asks for "fdatasync"
  85.  * on a particular "coll_id, handle" tuple.
  86.  */ 
  87.  
  88. struct cache_sync_descriptor
  89. {
  90.     PVFS_fs_id  coll_id;  
  91.     PVFS_handle handle; 
  92. };
  93. typedef struct cache_sync_descriptor cache_sync_desc_t;
  94.  
  95.  
  96. /* cache_req_handle: after posting a request to the cache,
  97.  * tha caller receives a request handle and then uses it to 
  98.  * track the status of the posted request.
  99.  * status is inidcate the request status. During the lifetime
  100.  * of a request, the "status" changes over time.
  101.  *
  102.  * It is "illegal" to touch "internal_id" in the caller. 
  103.  */ 
  104.  
  105. struct cache_req_handle
  106. {
  107.     volatile int status;        /* Indicate if complete */
  108.     PVFS_size    real_len;      /* real data length in bytes */     
  109.  
  110.     cache_optype optype;    /* read/write/demotion */
  111.     int          internal_id;    /* internal id tracked by the cache */
  112.  
  113. };
  114. typedef struct cache_req_handle cache_request_t;
  115.  
  116.  
  117. /* cache_reply_descriptor: information about buffers related to a request.
  118.  * For read request, data are in buffers listed in "vector".
  119.  * For write request, the network can write data into them.
  120.  * The number of buffers is indicated by "count".
  121.  * 
  122.  * <count, cbuf_offset_array, cbuf_size_array> work together
  123.  * to show how many buffers are used for read/write data for
  124.  * the request, the buffers's adresses, and length in each buffer.
  125.  *
  126.  * When ``more flag'' is set, it indicates that this request is not
  127.  * finished yet. That is, for read, only a part of requested data 
  128.  * has been available for communication; for write, only a part of
  129.  * buffer space is available. This "flag" gives us opportunity
  130.  * to overlap communication and I/O. A large I/O can be divided
  131.  * into several segments.
  132.  */
  133.  
  134. struct cache_reply_descriptor
  135. {
  136.     int       count;               /* how many noncontiguous segments */
  137.     char      **cbuf_offset_array; /* seg. buffer address array */ 
  138.     PVFS_size *cbuf_size_array;    /* seg. size array */
  139.     int       *cbuf_flag;
  140.  
  141.     int       more_flag;           /* whether this is the last round */ 
  142.     int       errval;               /* any error code; 0 for none */
  143. };
  144. typedef struct cache_reply_descriptor cache_reply_t;
  145.  
  146.  
  147. /* cache info structure.
  148.  * 
  149.  * 
  150.  */
  151. struct cache_info
  152. {
  153.     /* general information */
  154.     int   total_size;  /* cache size in bytes */
  155.     int   free_size;   /* free buffer size in bytes */  
  156.     int   unit_size;   /* unit size in cache for real I/O */ 
  157.  
  158.     /* specific info for a particular request */
  159.     int   cached_percentage;    /* the percenage of data cached (0--100) */
  160.     int   expected_seg_size;   /* Given a request, the cache expects 
  161.                                 * that the caller can break the request 
  162.                                 * into segments with size of 
  163.                                 * "expected_seg_size". */ 
  164.  
  165.     /* add other later */
  166. };
  167. typedef struct cache_info cache_info_t;
  168.  
  169. /**********************************************************
  170.  * functions in the I/O data path                         *
  171.  **********************************************************/
  172.  
  173. /* read request submit */
  174. int cache_read_post(cache_read_desc_t *desc, 
  175.                     cache_request_t *request,
  176.                     cache_reply_t *reply,
  177.                     void *user_ptr);
  178.  
  179. /* write request submit */
  180. int cache_write_post(cache_write_desc_t *desc,
  181.                      cache_request_t *request,
  182.                      cache_reply_t *reply,
  183.                      void *user_ptr);
  184.  
  185. /* sync request submit */
  186. int cache_sync_post(cache_sync_desc_t *desc,
  187.                     cache_request_t *request,
  188.             void *user_ptr);
  189.  
  190. int cache_req_test(cache_request_t *request, 
  191.                    int *flag,
  192.                    cache_reply_t *reply,
  193.                    void *user_ptr);
  194.  
  195. int cache_req_testsome(int count, 
  196.                        cache_request_t *request, 
  197.                        int *outcount, int *indices, 
  198.                        cache_reply_t *reply,
  199.                        void *user_ptr);
  200.  
  201.  
  202. int cache_req_done(cache_request_t *request);
  203.  
  204. int cache_query_info(void *desc, cache_info_t *cache_info);
  205.  
  206. #endif  /* __CACHE_NETWORK_H */
  207.