jfs_incore.h 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199
  1. /*
  2. * Copyright (C) International Business Machines Corp., 2000-2004
  3. * Portions Copyright (C) Christoph Hellwig, 2001-2002
  4. *
  5. * This program is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation; either version 2 of the License, or
  8. * (at your option) any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
  13. * the GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this program; if not, write to the Free Software
  17. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  18. */
  19. #ifndef _H_JFS_INCORE
  20. #define _H_JFS_INCORE
  21. #include <linux/mutex.h>
  22. #include <linux/rwsem.h>
  23. #include <linux/slab.h>
  24. #include <linux/bitops.h>
  25. #include "jfs_types.h"
  26. #include "jfs_xtree.h"
  27. #include "jfs_dtree.h"
  28. /*
  29. * JFS magic number
  30. */
  31. #define JFS_SUPER_MAGIC 0x3153464a /* "JFS1" */
  32. /*
  33. * JFS-private inode information
  34. */
  35. struct jfs_inode_info {
  36. int fileset; /* fileset number (always 16)*/
  37. uint mode2; /* jfs-specific mode */
  38. pxd_t ixpxd; /* inode extent descriptor */
  39. dxd_t acl; /* dxd describing acl */
  40. dxd_t ea; /* dxd describing ea */
  41. time_t otime; /* time created */
  42. uint next_index; /* next available directory entry index */
  43. int acltype; /* Type of ACL */
  44. short btorder; /* access order */
  45. short btindex; /* btpage entry index*/
  46. struct inode *ipimap; /* inode map */
  47. long cflag; /* commit flags */
  48. u16 bxflag; /* xflag of pseudo buffer? */
  49. unchar agno; /* ag number */
  50. signed char active_ag; /* ag currently allocating from */
  51. lid_t blid; /* lid of pseudo buffer? */
  52. lid_t atlhead; /* anonymous tlock list head */
  53. lid_t atltail; /* anonymous tlock list tail */
  54. spinlock_t ag_lock; /* protects active_ag */
  55. struct list_head anon_inode_list; /* inodes having anonymous txns */
  56. /*
  57. * rdwrlock serializes xtree between reads & writes and synchronizes
  58. * changes to special inodes. It's use would be redundant on
  59. * directories since the i_mutex taken in the VFS is sufficient.
  60. */
  61. struct rw_semaphore rdwrlock;
  62. /*
  63. * commit_mutex serializes transaction processing on an inode.
  64. * It must be taken after beginning a transaction (txBegin), since
  65. * dirty inodes may be committed while a new transaction on the
  66. * inode is blocked in txBegin or TxBeginAnon
  67. */
  68. struct mutex commit_mutex;
  69. /* xattr_sem allows us to access the xattrs without taking i_mutex */
  70. struct rw_semaphore xattr_sem;
  71. lid_t xtlid; /* lid of xtree lock on directory */
  72. #ifdef CONFIG_JFS_POSIX_ACL
  73. struct posix_acl *i_acl;
  74. struct posix_acl *i_default_acl;
  75. #endif
  76. union {
  77. struct {
  78. xtpage_t _xtroot; /* 288: xtree root */
  79. struct inomap *_imap; /* 4: inode map header */
  80. } file;
  81. struct {
  82. struct dir_table_slot _table[12]; /* 96: dir index */
  83. dtroot_t _dtroot; /* 288: dtree root */
  84. } dir;
  85. struct {
  86. unchar _unused[16]; /* 16: */
  87. dxd_t _dxd; /* 16: */
  88. unchar _inline[128]; /* 128: inline symlink */
  89. /* _inline_ea may overlay the last part of
  90. * file._xtroot if maxentry = XTROOTINITSLOT
  91. */
  92. unchar _inline_ea[128]; /* 128: inline extended attr */
  93. } link;
  94. } u;
  95. u32 dev; /* will die when we get wide dev_t */
  96. struct inode vfs_inode;
  97. };
  98. #define i_xtroot u.file._xtroot
  99. #define i_imap u.file._imap
  100. #define i_dirtable u.dir._table
  101. #define i_dtroot u.dir._dtroot
  102. #define i_inline u.link._inline
  103. #define i_inline_ea u.link._inline_ea
  104. #define JFS_ACL_NOT_CACHED ((void *)-1)
  105. #define IREAD_LOCK(ip) down_read(&JFS_IP(ip)->rdwrlock)
  106. #define IREAD_UNLOCK(ip) up_read(&JFS_IP(ip)->rdwrlock)
  107. #define IWRITE_LOCK(ip) down_write(&JFS_IP(ip)->rdwrlock)
  108. #define IWRITE_UNLOCK(ip) up_write(&JFS_IP(ip)->rdwrlock)
  109. /*
  110. * cflag
  111. */
  112. enum cflags {
  113. COMMIT_Nolink, /* inode committed with zero link count */
  114. COMMIT_Inlineea, /* commit inode inline EA */
  115. COMMIT_Freewmap, /* free WMAP at iClose() */
  116. COMMIT_Dirty, /* Inode is really dirty */
  117. COMMIT_Dirtable, /* commit changes to di_dirtable */
  118. COMMIT_Stale, /* data extent is no longer valid */
  119. COMMIT_Synclist, /* metadata pages on group commit synclist */
  120. };
  121. #define set_cflag(flag, ip) set_bit(flag, &(JFS_IP(ip)->cflag))
  122. #define clear_cflag(flag, ip) clear_bit(flag, &(JFS_IP(ip)->cflag))
  123. #define test_cflag(flag, ip) test_bit(flag, &(JFS_IP(ip)->cflag))
  124. #define test_and_clear_cflag(flag, ip) \
  125. test_and_clear_bit(flag, &(JFS_IP(ip)->cflag))
  126. /*
  127. * JFS-private superblock information.
  128. */
  129. struct jfs_sb_info {
  130. struct super_block *sb; /* Point back to vfs super block */
  131. unsigned long mntflag; /* aggregate attributes */
  132. struct inode *ipbmap; /* block map inode */
  133. struct inode *ipaimap; /* aggregate inode map inode */
  134. struct inode *ipaimap2; /* secondary aimap inode */
  135. struct inode *ipimap; /* aggregate inode map inode */
  136. struct jfs_log *log; /* log */
  137. struct list_head log_list; /* volumes associated with a journal */
  138. short bsize; /* logical block size */
  139. short l2bsize; /* log2 logical block size */
  140. short nbperpage; /* blocks per page */
  141. short l2nbperpage; /* log2 blocks per page */
  142. short l2niperblk; /* log2 inodes per page */
  143. dev_t logdev; /* external log device */
  144. uint aggregate; /* volume identifier in log record */
  145. pxd_t logpxd; /* pxd describing log */
  146. pxd_t fsckpxd; /* pxd describing fsck wkspc */
  147. pxd_t ait2; /* pxd describing AIT copy */
  148. char uuid[16]; /* 128-bit uuid for volume */
  149. char loguuid[16]; /* 128-bit uuid for log */
  150. /*
  151. * commit_state is used for synchronization of the jfs_commit
  152. * threads. It is protected by LAZY_LOCK().
  153. */
  154. int commit_state; /* commit state */
  155. /* Formerly in ipimap */
  156. uint gengen; /* inode generation generator*/
  157. uint inostamp; /* shows inode belongs to fileset*/
  158. /* Formerly in ipbmap */
  159. struct bmap *bmap; /* incore bmap descriptor */
  160. struct nls_table *nls_tab; /* current codepage */
  161. struct inode *direct_inode; /* metadata inode */
  162. uint state; /* mount/recovery state */
  163. unsigned long flag; /* mount time flags */
  164. uint p_state; /* state prior to going no integrity */
  165. };
  166. /* jfs_sb_info commit_state */
  167. #define IN_LAZYCOMMIT 1
  168. static inline struct jfs_inode_info *JFS_IP(struct inode *inode)
  169. {
  170. return list_entry(inode, struct jfs_inode_info, vfs_inode);
  171. }
  172. static inline int jfs_dirtable_inline(struct inode *inode)
  173. {
  174. return (JFS_IP(inode)->next_index <= (MAX_INLINE_DIRTABLE_ENTRY + 1));
  175. }
  176. static inline struct jfs_sb_info *JFS_SBI(struct super_block *sb)
  177. {
  178. return sb->s_fs_info;
  179. }
  180. static inline int isReadOnly(struct inode *inode)
  181. {
  182. if (JFS_SBI(inode->i_sb)->log)
  183. return 0;
  184. return 1;
  185. }
  186. #endif /* _H_JFS_INCORE */