jfs_types.h 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. /*
  2. * Copyright (C) International Business Machines Corp., 2000-2004
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License as published by
  6. * the Free Software Foundation; either version 2 of the License, or
  7. * (at your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
  12. * the GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program; if not, write to the Free Software
  16. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  17. */
  18. #ifndef _H_JFS_TYPES
  19. #define _H_JFS_TYPES
  20. /*
  21. * jfs_types.h:
  22. *
  23. * basic type/utility definitions
  24. *
  25. * note: this header file must be the 1st include file
  26. * of JFS include list in all JFS .c file.
  27. */
  28. #include <linux/types.h>
  29. #include <linux/nls.h>
  30. /*
  31. * transaction and lock id's
  32. *
  33. * Don't change these without carefully considering the impact on the
  34. * size and alignment of all of the linelock variants
  35. */
  36. typedef u16 tid_t;
  37. typedef u16 lid_t;
  38. /*
  39. * Almost identical to Linux's timespec, but not quite
  40. */
  41. struct timestruc_t {
  42. __le32 tv_sec;
  43. __le32 tv_nsec;
  44. };
  45. /*
  46. * handy
  47. */
  48. #define LEFTMOSTONE 0x80000000
  49. #define HIGHORDER 0x80000000u /* high order bit on */
  50. #define ONES 0xffffffffu /* all bit on */
  51. /*
  52. * physical xd (pxd)
  53. *
  54. * The leftmost 24 bits of len_addr are the extent length.
  55. * The rightmost 8 bits of len_addr are the most signficant bits of
  56. * the extent address
  57. */
  58. typedef struct {
  59. __le32 len_addr;
  60. __le32 addr2;
  61. } pxd_t;
  62. /* xd_t field construction */
  63. static inline void PXDlength(pxd_t *pxd, __u32 len)
  64. {
  65. pxd->len_addr = (pxd->len_addr & cpu_to_le32(~0xffffff)) |
  66. cpu_to_le32(len & 0xffffff);
  67. }
  68. static inline void PXDaddress(pxd_t *pxd, __u64 addr)
  69. {
  70. pxd->len_addr = (pxd->len_addr & cpu_to_le32(0xffffff)) |
  71. cpu_to_le32((addr >> 32)<<24);
  72. pxd->addr2 = cpu_to_le32(addr & 0xffffffff);
  73. }
  74. /* xd_t field extraction */
  75. static inline __u32 lengthPXD(pxd_t *pxd)
  76. {
  77. return le32_to_cpu((pxd)->len_addr) & 0xffffff;
  78. }
  79. static inline __u64 addressPXD(pxd_t *pxd)
  80. {
  81. __u64 n = le32_to_cpu(pxd->len_addr) & ~0xffffff;
  82. return (n << 8) + le32_to_cpu(pxd->addr2);
  83. }
  84. #define MAXTREEHEIGHT 8
  85. /* pxd list */
  86. struct pxdlist {
  87. s16 maxnpxd;
  88. s16 npxd;
  89. pxd_t pxd[MAXTREEHEIGHT];
  90. };
  91. /*
  92. * data extent descriptor (dxd)
  93. */
  94. typedef struct {
  95. __u8 flag; /* 1: flags */
  96. __u8 rsrvd[3];
  97. __le32 size; /* 4: size in byte */
  98. pxd_t loc; /* 8: address and length in unit of fsblksize */
  99. } dxd_t; /* - 16 - */
  100. /* dxd_t flags */
  101. #define DXD_INDEX 0x80 /* B+-tree index */
  102. #define DXD_INLINE 0x40 /* in-line data extent */
  103. #define DXD_EXTENT 0x20 /* out-of-line single extent */
  104. #define DXD_FILE 0x10 /* out-of-line file (inode) */
  105. #define DXD_CORRUPT 0x08 /* Inconsistency detected */
  106. /* dxd_t field construction
  107. */
  108. #define DXDlength(dxd, len) PXDlength(&(dxd)->loc, len)
  109. #define DXDaddress(dxd, addr) PXDaddress(&(dxd)->loc, addr)
  110. #define lengthDXD(dxd) lengthPXD(&(dxd)->loc)
  111. #define addressDXD(dxd) addressPXD(&(dxd)->loc)
  112. #define DXDsize(dxd, size32) ((dxd)->size = cpu_to_le32(size32))
  113. #define sizeDXD(dxd) le32_to_cpu((dxd)->size)
  114. /*
  115. * directory entry argument
  116. */
  117. struct component_name {
  118. int namlen;
  119. wchar_t *name;
  120. };
  121. /*
  122. * DASD limit information - stored in directory inode
  123. */
  124. struct dasd {
  125. u8 thresh; /* Alert Threshold (in percent) */
  126. u8 delta; /* Alert Threshold delta (in percent) */
  127. u8 rsrvd1;
  128. u8 limit_hi; /* DASD limit (in logical blocks) */
  129. __le32 limit_lo; /* DASD limit (in logical blocks) */
  130. u8 rsrvd2[3];
  131. u8 used_hi; /* DASD usage (in logical blocks) */
  132. __le32 used_lo; /* DASD usage (in logical blocks) */
  133. };
  134. #define DASDLIMIT(dasdp) \
  135. (((u64)((dasdp)->limit_hi) << 32) + __le32_to_cpu((dasdp)->limit_lo))
  136. #define setDASDLIMIT(dasdp, limit)\
  137. {\
  138. (dasdp)->limit_hi = ((u64)limit) >> 32;\
  139. (dasdp)->limit_lo = __cpu_to_le32(limit);\
  140. }
  141. #define DASDUSED(dasdp) \
  142. (((u64)((dasdp)->used_hi) << 32) + __le32_to_cpu((dasdp)->used_lo))
  143. #define setDASDUSED(dasdp, used)\
  144. {\
  145. (dasdp)->used_hi = ((u64)used) >> 32;\
  146. (dasdp)->used_lo = __cpu_to_le32(used);\
  147. }
  148. #endif /* !_H_JFS_TYPES */