2 * Copyright (c) International Business Machines Corp., 2000-2003
3 * Portions Copyright (c) Christoph Hellwig, 2001-2002
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.
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.
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
22 #include <linux/rwsem.h>
23 #include <linux/slab.h>
24 #include <asm/bitops.h>
25 #include "jfs_types.h"
26 #include "jfs_xtree.h"
27 #include "jfs_dtree.h"
32 #define JFS_SUPER_MAGIC 0x3153464a /* "JFS1" */
35 * JFS-private inode information
37 struct jfs_inode_info {
38 struct inode *inode; /* pointer back to fs-independent inode */
39 int fileset; /* fileset number (always 16)*/
40 uint mode2; /* jfs-specific mode */
41 pxd_t ixpxd; /* inode extent descriptor */
42 dxd_t acl; /* dxd describing acl */
43 dxd_t ea; /* dxd describing ea */
44 time_t otime; /* time created */
45 uint next_index; /* next available directory entry index */
46 int acltype; /* Type of ACL */
47 short btorder; /* access order */
48 short btindex; /* btpage entry index*/
49 struct inode *ipimap; /* inode map */
50 long cflag; /* commit flags */
51 u16 bxflag; /* xflag of pseudo buffer? */
52 unchar agno; /* ag number */
53 signed char active_ag; /* ag currently allocating from */
54 lid_t blid; /* lid of pseudo buffer? */
55 lid_t atlhead; /* anonymous tlock list head */
56 lid_t atltail; /* anonymous tlock list tail */
57 spinlock_t ag_lock; /* protects active_ag */
58 struct list_head anon_inode_list; /* inodes having anonymous txns */
60 * rdwrlock serializes xtree between reads & writes and synchronizes
61 * changes to special inodes. It's use would be redundant on
62 * directories since the i_sem taken in the VFS is sufficient.
64 struct rw_semaphore rdwrlock;
66 * commit_sem serializes transaction processing on an inode.
67 * It must be taken after beginning a transaction (txBegin), since
68 * dirty inodes may be committed while a new transaction on the
69 * inode is blocked in txBegin or TxBeginAnon
71 struct semaphore commit_sem;
72 lid_t xtlid; /* lid of xtree lock on directory */
75 xtpage_t _xtroot; /* 288: xtree root */
76 struct inomap *_imap; /* 4: inode map header */
79 struct dir_table_slot _table[12]; /* 96: dir index */
80 dtroot_t _dtroot; /* 288: dtree root */
83 unchar _unused[16]; /* 16: */
85 unchar _inline[128]; /* 128: inline symlink */
86 /* _inline_ea may overlay the last part of
87 * file._xtroot if maxentry = XTROOTINITSLOT
89 unchar _inline_ea[128]; /* 128: inline extended attr */
93 #define i_xtroot u.file._xtroot
94 #define i_imap u.file._imap
95 #define i_dirtable u.dir._table
96 #define i_dtroot u.dir._dtroot
97 #define i_inline u.link._inline
98 #define i_inline_ea u.link._inline_ea
101 #define IREAD_LOCK(ip) down_read(&JFS_IP(ip)->rdwrlock)
102 #define IREAD_UNLOCK(ip) up_read(&JFS_IP(ip)->rdwrlock)
103 #define IWRITE_LOCK(ip) down_write(&JFS_IP(ip)->rdwrlock)
104 #define IWRITE_UNLOCK(ip) up_write(&JFS_IP(ip)->rdwrlock)
110 COMMIT_New, /* never committed inode */
111 COMMIT_Nolink, /* inode committed with zero link count */
112 COMMIT_Inlineea, /* commit inode inline EA */
113 COMMIT_Freewmap, /* free WMAP at iClose() */
114 COMMIT_Dirty, /* Inode is really dirty */
115 COMMIT_Dirtable, /* commit changes to di_dirtable */
116 COMMIT_Stale, /* data extent is no longer valid */
117 COMMIT_Synclist, /* metadata pages on group commit synclist */
118 COMMIT_Syncdata, /* Data must be synced before inode committed */
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))
127 * JFS-private superblock information.
130 unsigned long mntflag; /* aggregate attributes */
131 struct inode *ipbmap; /* block map inode */
132 struct inode *ipaimap; /* aggregate inode map inode */
133 struct inode *ipaimap2; /* secondary aimap inode */
134 struct inode *ipimap; /* aggregate inode map inode */
135 struct jfs_log *log; /* log */
136 short bsize; /* logical block size */
137 short l2bsize; /* log2 logical block size */
138 short nbperpage; /* blocks per page */
139 short l2nbperpage; /* log2 blocks per page */
140 short l2niperblk; /* log2 inodes per page */
141 kdev_t logdev; /* external log device */
142 uint aggregate; /* volume identifier in log record */
143 pxd_t logpxd; /* pxd describing log */
144 pxd_t fsckpxd; /* pxd describing fsck wkspc */
145 pxd_t ait2; /* pxd describing AIT copy */
146 char uuid[16]; /* 128-bit uuid for volume */
147 char loguuid[16]; /* 128-bit uuid for log */
148 /* Formerly in ipimap */
149 uint gengen; /* inode generation generator*/
150 uint inostamp; /* shows inode belongs to fileset*/
152 /* Formerly in ipbmap */
153 struct bmap *bmap; /* incore bmap descriptor */
154 struct nls_table *nls_tab; /* current codepage */
155 uint state; /* mount/recovery state */
156 unsigned long flag; /* mount time flags */
157 uint p_state; /* state prior to going no integrity */
160 static inline struct jfs_inode_info *JFS_IP(struct inode *inode)
162 return inode->u.generic_ip;
165 static inline struct jfs_sb_info *JFS_SBI(struct super_block *sb)
167 return sb->u.generic_sbp;
170 static inline int isReadOnly(struct inode *inode)
172 if (JFS_SBI(inode->i_sb)->log)
178 * Allocating and freeing the structure
180 extern kmem_cache_t *jfs_inode_cachep;
181 extern int alloc_jfs_inode(struct inode *);
183 #define free_jfs_inode(inode) \
184 kmem_cache_free(jfs_inode_cachep, (inode)->u.generic_ip)
186 #endif /* _H_JFS_INCORE */