jfs_incore.h
上传用户:jlfgdled
上传日期:2013-04-10
资源大小:33168k
文件大小:6k
源码类别:

Linux/Unix编程

开发平台:

Unix_Linux

  1. /*
  2.  *   Copyright (c) International Business Machines Corp., 2000-2002
  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/rwsem.h>
  22. #include <linux/slab.h>
  23. #include <asm/bitops.h>
  24. #include "jfs_types.h"
  25. #include "jfs_xtree.h"
  26. #include "jfs_dtree.h"
  27. /*
  28.  * JFS magic number
  29.  */
  30. #define JFS_SUPER_MAGIC 0x3153464a /* "JFS1" */
  31. /*
  32.  * JFS-private inode information
  33.  */
  34. struct jfs_inode_info {
  35. struct inode *inode; /* pointer back to fs-independent inode */
  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. struct list_head anon_inode_list; /* inodes having anonymous txns */
  55. struct list_head mp_list; /* metapages in inode's address space */
  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_sem taken in the VFS is sufficient.
  60.  */
  61. struct rw_semaphore rdwrlock;
  62. /*
  63.  * commit_sem 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 semaphore commit_sem;
  69. lid_t xtlid; /* lid of xtree lock on directory */
  70. union {
  71. struct {
  72. xtpage_t _xtroot; /* 288: xtree root */
  73. struct inomap *_imap; /* 4: inode map header */
  74. } file;
  75. struct {
  76. struct dir_table_slot _table[12]; /* 96: dir index */
  77. dtroot_t _dtroot; /* 288: dtree root */
  78. } dir;
  79. struct {
  80. unchar _unused[16]; /* 16: */
  81. dxd_t _dxd; /* 16: */
  82. unchar _inline[128]; /* 128: inline symlink */
  83. /* _inline_ea may overlay the last part of
  84.  * file._xtroot if maxentry = XTROOTINITSLOT
  85.  */
  86. unchar _inline_ea[128]; /* 128: inline extended attr */
  87. } link;
  88. } u;
  89. };
  90. #define i_xtroot u.file._xtroot
  91. #define i_imap u.file._imap
  92. #define i_dirtable u.dir._table
  93. #define i_dtroot u.dir._dtroot
  94. #define i_inline u.link._inline
  95. #define i_inline_ea u.link._inline_ea
  96. #define IREAD_LOCK(ip) down_read(&JFS_IP(ip)->rdwrlock)
  97. #define IREAD_UNLOCK(ip) up_read(&JFS_IP(ip)->rdwrlock)
  98. #define IWRITE_LOCK(ip) down_write(&JFS_IP(ip)->rdwrlock)
  99. #define IWRITE_UNLOCK(ip) up_write(&JFS_IP(ip)->rdwrlock)
  100. /*
  101.  * cflag
  102.  */
  103. enum cflags {
  104. COMMIT_New, /* never committed inode   */
  105. COMMIT_Nolink, /* inode committed with zero link count */
  106. COMMIT_Inlineea, /* commit inode inline EA */
  107. COMMIT_Freewmap, /* free WMAP at iClose() */
  108. COMMIT_Dirty, /* Inode is really dirty */
  109. COMMIT_Holdlock, /* Hold the IWRITE_LOCK until commit is done */
  110. COMMIT_Dirtable, /* commit changes to di_dirtable */
  111. COMMIT_Stale, /* data extent is no longer valid */
  112. COMMIT_Synclist, /* metadata pages on group commit synclist */
  113. };
  114. #define set_cflag(flag, ip) set_bit(flag, &(JFS_IP(ip)->cflag))
  115. #define clear_cflag(flag, ip) clear_bit(flag, &(JFS_IP(ip)->cflag))
  116. #define test_cflag(flag, ip) test_bit(flag, &(JFS_IP(ip)->cflag))
  117. #define test_and_clear_cflag(flag, ip) 
  118. test_and_clear_bit(flag, &(JFS_IP(ip)->cflag))
  119. /*
  120.  * JFS-private superblock information.
  121.  */
  122. struct jfs_sb_info {
  123. unsigned long mntflag; /* 4: aggregate attributes */
  124. struct inode *ipbmap; /* 4: block map inode */
  125. struct inode *ipaimap; /* 4: aggregate inode map inode */
  126. struct inode *ipaimap2; /* 4: secondary aimap inode */
  127. struct inode *ipimap; /* 4: aggregate inode map inode */
  128. struct jfs_log *log; /* 4: log */
  129. short bsize; /* 2: logical block size */
  130. short l2bsize; /* 2: log2 logical block size */
  131. short nbperpage; /* 2: blocks per page */
  132. short l2nbperpage; /* 2: log2 blocks per page */
  133. short l2niperblk; /* 2: log2 inodes per page */
  134. kdev_t logdev; /* 2: external log device */
  135. uint aggregate; /* volume identifier in log record */
  136. pxd_t logpxd; /* 8: pxd describing log */
  137. pxd_t fsckpxd; /* 8: pxd describing fsck wkspc */
  138. pxd_t ait2; /* 8: pxd describing AIT copy */
  139. char uuid[16]; /* 16: 128-bit uuid for volume */
  140. char loguuid[16]; /* 16: 128-bit uuid for log */
  141. /* Formerly in ipimap */
  142. uint gengen; /* 4: inode generation generator*/
  143. uint inostamp; /* 4: shows inode belongs to fileset*/
  144.         /* Formerly in ipbmap */
  145. struct bmap *bmap; /* 4: incore bmap descriptor */
  146. struct nls_table *nls_tab; /* 4: current codepage */
  147. uint state; /* 4: mount/recovery state */
  148. };
  149. static inline struct jfs_inode_info *JFS_IP(struct inode *inode)
  150. {
  151. return inode->u.generic_ip;
  152. }
  153. static inline struct jfs_sb_info *JFS_SBI(struct super_block *sb)
  154. {
  155. return sb->u.generic_sbp;
  156. }
  157. static inline int isReadOnly(struct inode *inode)
  158. {
  159. if (JFS_SBI(inode->i_sb)->log)
  160. return 0;
  161. return 1;
  162. }
  163. /*
  164.  * Allocating and freeing the structure
  165.  */
  166. extern kmem_cache_t *jfs_inode_cachep;
  167. extern int alloc_jfs_inode(struct inode *);
  168. #define free_jfs_inode(inode) 
  169. kmem_cache_free(jfs_inode_cachep, (inode)->u.generic_ip)
  170. #endif /* _H_JFS_INCORE */