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 / trove / pvfs2-storage.h < prev    next >
C/C++ Source or Header  |  2010-04-30  |  7KB  |  187 lines

  1. /*
  2.  * (C) 2001 Clemson University and The University of Chicago
  3.  *
  4.  * See COPYING in top-level directory.
  5.  */
  6.  
  7. #ifndef __PVFS2_STORAGE_H
  8. #define __PVFS2_STORAGE_H
  9.  
  10. #include <time.h>
  11. #include "pvfs2-types.h"
  12.  
  13. /************************************************************
  14.  * Types and structures specific to the storage interface
  15.  */
  16.  
  17. enum PVFS_coll_getinfo_options_e
  18. {
  19.     PVFS_COLLECTION_STATFS = 1
  20. };
  21. typedef enum PVFS_coll_getinfo_options_e PVFS_coll_getinfo_options;
  22.  
  23. struct PVFS_vtag_s
  24. {
  25.     /* undefined */
  26. };
  27. typedef struct PVFS_vtag_s PVFS_vtag;
  28. /* key/value descriptor definition moved to include/pvfs2-types.h */
  29. #if 0
  30. /* key/value descriptors */
  31. struct PVFS_ds_keyval_s
  32. {
  33.     void *buffer;
  34.     /* size of memory region pointed to by buffer */
  35.     int32_t buffer_sz;
  36.     /* size of data read into buffer (only valid after a read) */
  37.     int32_t read_sz;
  38. };
  39.  
  40. typedef struct PVFS_ds_keyval_s PVFS_ds_keyval;
  41. #endif
  42.  
  43. struct PVFS_ds_metadata_attr_s
  44. {
  45.     uint32_t dfile_count;
  46.     uint32_t dist_size;
  47. };
  48.  
  49. struct PVFS_ds_datafile_attr_s
  50. {
  51.     PVFS_size b_size; /* bstream size */
  52. };
  53.  
  54. struct PVFS_ds_dirdata_attr_s
  55. {
  56.     uint64_t count;
  57. };
  58.  
  59. /* dataspace attributes that are not explicitly stored within the
  60.  * dataspace itself.
  61.  *
  62.  * Note: this is what is being stored by the trove code as the
  63.  * attributes right now.  this is separate from the attributes as sent
  64.  * across the wire/to the user, so some translation is done.
  65.  *
  66.  * PVFS_object_attr attributes are what the users and the server deal
  67.  * with.  Trove deals with TROVE_ds_attributes (trove on disk and in-memory format).
  68.  *
  69.  * Trove version 0.0.1 and version 0.0.2 differ in this aspect, since
  70.  * many members have been moved, added to make this structure friendlier
  71.  * for 32 and 64 bit users. Consequently, this means we would require a
  72.  * migrate utility that will convert from one to the other by reading from
  73.  * the dspace and writing it out to the new dspace.
  74.  */
  75. struct PVFS_ds_attributes_s
  76. {
  77.     PVFS_ds_type type;
  78.     PVFS_fs_id fs_id;
  79.     PVFS_handle handle;
  80.     PVFS_uid uid;
  81.     PVFS_gid gid;
  82.     PVFS_permissions mode;
  83.     int32_t   __pad1;
  84.  
  85.     PVFS_time ctime;
  86.     PVFS_time mtime;
  87.     PVFS_time atime;
  88.  
  89.     union
  90.     {
  91.         struct PVFS_ds_metadata_attr_s metafile;
  92.         struct PVFS_ds_datafile_attr_s datafile;
  93.         struct PVFS_ds_dirdata_attr_s dirdata;
  94.     } u;
  95. } ;
  96. typedef struct PVFS_ds_attributes_s PVFS_ds_attributes;
  97.  
  98. #define PVFS_ds_init_time(__dsa)                        \
  99. do {                                                    \
  100.     (__dsa)->ctime = time(NULL);                        \
  101.     (__dsa)->atime = time(NULL);                        \
  102.     (__dsa)->mtime = time(NULL);                        \
  103. } while (0)
  104.  
  105. #define PVFS_ds_attr_to_object_attr(__dsa, __oa)                   \
  106. do {                                                               \
  107.     (__oa)->owner = (__dsa)->uid;                                  \
  108.     (__oa)->group = (__dsa)->gid;                                  \
  109.     (__oa)->perms = (__dsa)->mode;                                 \
  110.     (__oa)->ctime = (__dsa)->ctime;                                \
  111.     (__oa)->mtime = (__dsa)->mtime;                                \
  112.     (__oa)->atime = (__dsa)->atime;                                \
  113.     (__oa)->objtype = (__dsa)->type;                               \
  114.     (__oa)->u.meta.dfile_count = (__dsa)->u.metafile.dfile_count;  \
  115.     (__oa)->u.meta.dist_size = (__dsa)->u.metafile.dist_size;      \
  116. } while(0)
  117.  
  118. #define PVFS_object_attr_to_ds_attr(__oa, __dsa)                      \
  119.     do {                                                              \
  120.         (__dsa)->uid = (__oa)->owner;                                 \
  121.         (__dsa)->gid = (__oa)->group;                                 \
  122.         (__dsa)->mode = (__oa)->perms;                                \
  123.         (__dsa)->ctime = (__oa)->ctime;                               \
  124.         (__dsa)->mtime = (__oa)->mtime;                               \
  125.         (__dsa)->atime = (__oa)->atime;                               \
  126.         (__dsa)->type = (__oa)->objtype;                              \
  127.         (__dsa)->u.metafile.dfile_count = (__oa)->u.meta.dfile_count; \
  128.         (__dsa)->u.metafile.dist_size = (__oa)->u.meta.dist_size;     \
  129. } while(0)
  130.  
  131. #define PVFS_object_attr_overwrite_setable(dest, src)          \
  132. do {                                                           \
  133.     if ((src)->mask & PVFS_ATTR_COMMON_UID)                    \
  134.         (dest)->owner = (src)->owner;                          \
  135.     if ((src)->mask & PVFS_ATTR_COMMON_GID)                    \
  136.         (dest)->group = (src)->group;                          \
  137.     if ((src)->mask & PVFS_ATTR_COMMON_PERM)                   \
  138.         (dest)->perms = (src)->perms;                          \
  139.     if ((src)->mask & PVFS_ATTR_COMMON_ATIME)                  \
  140.     {                                                          \
  141.         if ((src)->mask & PVFS_ATTR_COMMON_ATIME_SET)          \
  142.         {                                                      \
  143.             (dest)->atime = (src)->atime;                      \
  144.         }                                                      \
  145.         else                                                   \
  146.         {                                                      \
  147.             (dest)->atime = time(NULL);                        \
  148.         }                                                      \
  149.     }                                                          \
  150.     if ((src)->mask & PVFS_ATTR_COMMON_MTIME)                  \
  151.     {                                                          \
  152.         if ((src)->mask & PVFS_ATTR_COMMON_MTIME_SET)          \
  153.         {                                                      \
  154.             (dest)->mtime = (src)->mtime;                      \
  155.         }                                                      \
  156.         else                                                   \
  157.         {                                                      \
  158.             (dest)->mtime = PINT_util_mktime_version(time(NULL)); \
  159.         }                                                      \
  160.     }                                                          \
  161.     if ((src)->mask & PVFS_ATTR_COMMON_CTIME)                  \
  162.     {                                                          \
  163.         (dest)->ctime = time(NULL);                            \
  164.     }                                                          \
  165.     if ((src)->mask & PVFS_ATTR_COMMON_TYPE)                   \
  166.     {                                                          \
  167.         (dest)->objtype = (src)->objtype;                      \
  168.         if (((src)->objtype == PVFS_TYPE_METAFILE) &&          \
  169.             ((src)->mask & PVFS_ATTR_META_DIST))               \
  170.             (dest)->u.meta.dist_size = (src)->u.meta.dist_size;\
  171.         if (((src)->objtype == PVFS_TYPE_METAFILE) &&          \
  172.             ((src)->mask & PVFS_ATTR_META_DFILES))             \
  173.             (dest)->u.meta.dfile_count = (src)->u.meta.dfile_count;\
  174.     }                                                          \
  175. } while(0)
  176.  
  177. #endif /* __PVFS2_STORAGE_H */
  178.  
  179. /*
  180.  * Local variables:
  181.  *  c-indent-level: 4
  182.  *  c-basic-offset: 4
  183.  * End:
  184.  *
  185.  * vim: ts=8 sts=4 sw=4 expandtab
  186.  */
  187.