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 / dev / pint-dev-shared.h < prev    next >
C/C++ Source or Header  |  2007-07-20  |  4KB  |  131 lines

  1. /*
  2.  * (C) 2001 Clemson University and The University of Chicago
  3.  *
  4.  * See COPYING in top-level directory.
  5.  */
  6.  
  7. /* types and #defines shared between user space and kernel space for
  8.  * device interaction
  9.  */
  10.  
  11. #ifndef __PINT_DEV_SHARED_H
  12. #define __PINT_DEV_SHARED_H
  13.  
  14.  
  15. #ifdef __KERNEL__
  16. #include <linux/ioctl.h>
  17. #else
  18. #include <sys/ioctl.h>  /* needed for constructing the _IO macros */
  19. #endif
  20.  
  21. /* version number for use in communicating between kernel space and user
  22.  * space
  23.  */
  24. #define PVFS_KERNEL_PROTO_VERSION ((PVFS2_VERSION_MAJOR * 10000) + \
  25.   (PVFS2_VERSION_MINOR * 100) + PVFS2_VERSION_SUB)
  26.  
  27. /* This is the default number of discrete buffers we will break the mapped I/O
  28.  * region into.  In some sense it governs the number of concurrent I/O
  29.  * operations that we will allow
  30.  */
  31. #define PVFS2_BUFMAP_DEFAULT_DESC_COUNT    5
  32.  
  33. /*
  34.   by default, we assume each description size is 4MB; this value
  35.   dictates the initial blocksize stored in the superblock, but after
  36.   the request device is initialized, a subsequent statfs updates the
  37.   superblock blocksize to be the configured decsription size (gathered
  38.   using pvfs_bufmap_size_query).
  39.  
  40.   don't change this value without updating the shift value below, or
  41.   else we may break size reporting in the kernel
  42. */
  43. #define PVFS2_BUFMAP_DEFAULT_DESC_SIZE  (4 * (1024 * 1024))
  44. #define PVFS2_BUFMAP_DEFAULT_DESC_SHIFT 22 /* NOTE: 2^22 == 4MB */
  45.  
  46. /* size of mapped buffer region to use for I/O transfers (in bytes) */
  47. #define PVFS2_BUFMAP_DEFAULT_TOTAL_SIZE \
  48. (PVFS2_BUFMAP_DEFAULT_DESC_COUNT * PVFS2_BUFMAP_DEFAULT_DESC_SIZE)
  49.  
  50. /* Sane maximum values for these parameters (128 MB) */
  51. #define PVFS2_BUFMAP_MAX_TOTAL_SIZE      (128ULL * (1024 * 1024))
  52.  
  53. /* log to base 2 when we know that number is a power of 2 */
  54. static inline int LOG2(int number)
  55. {
  56.     int count = 0;
  57.     if (number == 0 || (number & (number - 1))) 
  58.     {
  59.         return -1;
  60.     }
  61.     while (number >>= 1)
  62.     {
  63.         count++;
  64.     }
  65.     return count;
  66. }
  67.  
  68. #define PVFS2_READDIR_DEFAULT_DESC_COUNT  5
  69. #define PVFS2_READDIR_DEFAULT_DESC_SIZE  (128 * 1024)
  70. #define PVFS2_READDIR_DEFAULT_DESC_SHIFT 17
  71. #define PVFS2_READDIR_DEFAULT_TOTAL_SIZE \
  72. (PVFS2_READDIR_DEFAULT_DESC_COUNT * PVFS2_READDIR_DEFAULT_DESC_SIZE)
  73.  
  74. /* pvfs2-client-core can cache readahead data up to this size in bytes */
  75. #define PVFS2_MMAP_RACACHE_MAX_SIZE ((loff_t)(8 * (1024 * 1024)))
  76.  
  77. /* describes memory regions to map in the PVFS_DEV_MAP ioctl.
  78.  * NOTE: See devpvfs2-req.c for 32 bit compat structure.
  79.  * Since this structure has a variable-sized layout that is different
  80.  * on 32 and 64 bit platforms, we need to normalize to a 64 bit layout
  81.  * on such systems before servicing ioctl calls from user-space binaries
  82.  * that may be 32 bit!
  83.  */
  84. struct PVFS_dev_map_desc
  85. {
  86.     void     *ptr;
  87.     int32_t  total_size; 
  88.     int32_t  size;
  89.     int32_t  count;
  90. };
  91.  
  92. /*
  93.  * Disable this code when not compiling for the use of the linux kernel
  94.  * module helper code.  Not all client machines have ioctl, poll.
  95.  */
  96. #ifdef WITH_LINUX_KMOD
  97.  
  98. #define PVFS_DEV_MAGIC 'k'
  99.  
  100. #define DEV_GET_MAGIC           0x1
  101. #define DEV_GET_MAX_UPSIZE      0x2
  102. #define DEV_GET_MAX_DOWNSIZE    0x3
  103. #define DEV_MAP                 0x4
  104. #define DEV_REMOUNT_ALL         0x5
  105. #define DEV_DEBUG               0x6
  106. #define DEV_MAX_NR              0x7
  107.  
  108. /* supported ioctls, codes are with respect to user-space */
  109. enum {
  110. PVFS_DEV_GET_MAGIC          = _IOW(PVFS_DEV_MAGIC , DEV_GET_MAGIC, int32_t),
  111. PVFS_DEV_GET_MAX_UPSIZE     = _IOW(PVFS_DEV_MAGIC , DEV_GET_MAX_UPSIZE, int32_t),
  112. PVFS_DEV_GET_MAX_DOWNSIZE   = _IOW(PVFS_DEV_MAGIC , DEV_GET_MAX_DOWNSIZE, int32_t),
  113. PVFS_DEV_MAP                =  _IO(PVFS_DEV_MAGIC , DEV_MAP),
  114. PVFS_DEV_REMOUNT_ALL        =  _IO(PVFS_DEV_MAGIC , DEV_REMOUNT_ALL),
  115. PVFS_DEV_DEBUG              =  _IOR(PVFS_DEV_MAGIC, DEV_DEBUG, int32_t),
  116. PVFS_DEV_MAXNR              =  DEV_MAX_NR,
  117. };
  118.  
  119. #endif  /* WITH_LINUX_KMOD */
  120.  
  121. #endif /* __PINT_DEV_SHARED_H */
  122.  
  123. /*
  124.  * Local variables:
  125.  *  c-indent-level: 4
  126.  *  c-basic-offset: 4
  127.  * End:
  128.  *
  129.  * vim: ts=8 sts=4 sw=4 expandtab
  130.  */
  131.