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 / aiovec.h next >
C/C++ Source or Header  |  2003-08-21  |  1KB  |  63 lines

  1. #ifndef __AIOVEC_H
  2. #define __AIOVEC_H
  3.  
  4. #include "internal.h"
  5.  
  6. /*
  7.  * aiovec.h
  8.  *
  9.  * In many places it is efficient to batch an operation up against multiple
  10.  * extents for one request to Trove. An aiovec is a multi-extent container 
  11.  * which is used for that.
  12.  */
  13.  
  14. #define AIOVEC_SIZE    6    
  15.  
  16. struct aiovec {
  17.     unsigned nr;
  18.         struct extent *extent_array[AIOVEC_SIZE];
  19.         PVFS_offset stream_offset_array[AIOVEC_SIZE];
  20.         PVFS_size stream_size_array[AIOVEC_SIZE];
  21.         char *mem_offset_array[AIOVEC_SIZE];
  22.         PVFS_size mem_size_array[AIOVEC_SIZE];
  23. };
  24.  
  25.  
  26. static inline void aiovec_init(struct aiovec *pvec)
  27. {
  28.     pvec->nr = 0;
  29.         memset(pvec, 0, sizeof(struct aiovec) );
  30. }
  31.  
  32. static inline void aiovec_reinit(struct aiovec *pvec)
  33. {
  34.     pvec->nr = 0;
  35. }
  36.  
  37. static inline unsigned aiovec_count(struct aiovec *pvec)
  38. {
  39.     return pvec->nr;
  40. }
  41.  
  42. static inline unsigned aiovec_space(struct aiovec *pvec)
  43. {
  44.     return AIOVEC_SIZE - pvec->nr;
  45. }
  46.  
  47. /*
  48.  * Add an extent to a pagevec.  Returns the number of slots still available.
  49.  */
  50. static inline unsigned aiovec_add(struct aiovec *pvec, struct extent *extent, PVFS_offset pos, PVFS_size fsize, char * memoff, PVFS_size msize)
  51. {
  52.         
  53.     pvec->extent_array[pvec->nr] = extent;
  54.     pvec->stream_offset_array[pvec->nr] = pos;
  55.     pvec->stream_size_array[pvec->nr] = fsize;
  56.     pvec->mem_offset_array[pvec->nr] = memoff;
  57.     pvec->mem_size_array[pvec->nr++] = msize;
  58.     return aiovec_space(pvec);
  59. }
  60.  
  61.  
  62. #endif
  63.