jfs_types.h 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  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. #include "endian24.h"
  31. /*
  32. * transaction and lock id's
  33. *
  34. * Don't change these without carefully considering the impact on the
  35. * size and alignment of all of the linelock variants
  36. */
  37. typedef u16 tid_t;
  38. typedef u16 lid_t;
  39. /*
  40. * Almost identical to Linux's timespec, but not quite
  41. */
  42. struct timestruc_t {
  43. __le32 tv_sec;
  44. __le32 tv_nsec;
  45. };
  46. /*
  47. * handy
  48. */
  49. #define LEFTMOSTONE 0x80000000
  50. #define HIGHORDER 0x80000000u /* high order bit on */
  51. #define ONES 0xffffffffu /* all bit on */
  52. /*
  53. * logical xd (lxd)
  54. */
  55. typedef struct {
  56. unsigned len:24;
  57. unsigned off1:8;
  58. u32 off2;
  59. } lxd_t;
  60. /* lxd_t field construction */
  61. #define LXDlength(lxd, length32) ( (lxd)->len = length32 )
  62. #define LXDoffset(lxd, offset64)\
  63. {\
  64. (lxd)->off1 = ((s64)offset64) >> 32;\
  65. (lxd)->off2 = (offset64) & 0xffffffff;\
  66. }
  67. /* lxd_t field extraction */
  68. #define lengthLXD(lxd) ( (lxd)->len )
  69. #define offsetLXD(lxd)\
  70. ( ((s64)((lxd)->off1)) << 32 | (lxd)->off2 )
  71. /* lxd list */
  72. struct lxdlist {
  73. s16 maxnlxd;
  74. s16 nlxd;
  75. lxd_t *lxd;
  76. };
  77. /*
  78. * physical xd (pxd)
  79. */
  80. typedef struct {
  81. unsigned len:24;
  82. unsigned addr1:8;
  83. __le32 addr2;
  84. } pxd_t;
  85. /* xd_t field construction */
  86. #define PXDlength(pxd, length32) ((pxd)->len = __cpu_to_le24(length32))
  87. #define PXDaddress(pxd, address64)\
  88. {\
  89. (pxd)->addr1 = ((s64)address64) >> 32;\
  90. (pxd)->addr2 = __cpu_to_le32((address64) & 0xffffffff);\
  91. }
  92. /* xd_t field extraction */
  93. #define lengthPXD(pxd) __le24_to_cpu((pxd)->len)
  94. #define addressPXD(pxd)\
  95. ( ((s64)((pxd)->addr1)) << 32 | __le32_to_cpu((pxd)->addr2))
  96. #define MAXTREEHEIGHT 8
  97. /* pxd list */
  98. struct pxdlist {
  99. s16 maxnpxd;
  100. s16 npxd;
  101. pxd_t pxd[MAXTREEHEIGHT];
  102. };
  103. /*
  104. * data extent descriptor (dxd)
  105. */
  106. typedef struct {
  107. unsigned flag:8; /* 1: flags */
  108. unsigned rsrvd:24;
  109. __le32 size; /* 4: size in byte */
  110. unsigned len:24; /* 3: length in unit of fsblksize */
  111. unsigned addr1:8; /* 1: address in unit of fsblksize */
  112. __le32 addr2; /* 4: address in unit of fsblksize */
  113. } dxd_t; /* - 16 - */
  114. /* dxd_t flags */
  115. #define DXD_INDEX 0x80 /* B+-tree index */
  116. #define DXD_INLINE 0x40 /* in-line data extent */
  117. #define DXD_EXTENT 0x20 /* out-of-line single extent */
  118. #define DXD_FILE 0x10 /* out-of-line file (inode) */
  119. #define DXD_CORRUPT 0x08 /* Inconsistency detected */
  120. /* dxd_t field construction
  121. * Conveniently, the PXD macros work for DXD
  122. */
  123. #define DXDlength PXDlength
  124. #define DXDaddress PXDaddress
  125. #define lengthDXD lengthPXD
  126. #define addressDXD addressPXD
  127. #define DXDsize(dxd, size32) ((dxd)->size = cpu_to_le32(size32))
  128. #define sizeDXD(dxd) le32_to_cpu((dxd)->size)
  129. /*
  130. * directory entry argument
  131. */
  132. struct component_name {
  133. int namlen;
  134. wchar_t *name;
  135. };
  136. /*
  137. * DASD limit information - stored in directory inode
  138. */
  139. struct dasd {
  140. u8 thresh; /* Alert Threshold (in percent) */
  141. u8 delta; /* Alert Threshold delta (in percent) */
  142. u8 rsrvd1;
  143. u8 limit_hi; /* DASD limit (in logical blocks) */
  144. __le32 limit_lo; /* DASD limit (in logical blocks) */
  145. u8 rsrvd2[3];
  146. u8 used_hi; /* DASD usage (in logical blocks) */
  147. __le32 used_lo; /* DASD usage (in logical blocks) */
  148. };
  149. #define DASDLIMIT(dasdp) \
  150. (((u64)((dasdp)->limit_hi) << 32) + __le32_to_cpu((dasdp)->limit_lo))
  151. #define setDASDLIMIT(dasdp, limit)\
  152. {\
  153. (dasdp)->limit_hi = ((u64)limit) >> 32;\
  154. (dasdp)->limit_lo = __cpu_to_le32(limit);\
  155. }
  156. #define DASDUSED(dasdp) \
  157. (((u64)((dasdp)->used_hi) << 32) + __le32_to_cpu((dasdp)->used_lo))
  158. #define setDASDUSED(dasdp, used)\
  159. {\
  160. (dasdp)->used_hi = ((u64)used) >> 32;\
  161. (dasdp)->used_lo = __cpu_to_le32(used);\
  162. }
  163. #endif /* !_H_JFS_TYPES */