blob: 439901d205feaf1b1a0243ea6141490267f1be30 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
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
Dave Kleikamp63f83c92006-10-02 09:55:27 -05007 * the Free Software Foundation; either version 2 of the License, or
Linus Torvalds1da177e2005-04-16 15:20:36 -07008 * (at your option) any later version.
Dave Kleikamp63f83c92006-10-02 09:55:27 -05009 *
Linus Torvalds1da177e2005-04-16 15:20:36 -070010 * 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
Dave Kleikamp63f83c92006-10-02 09:55:27 -050016 * along with this program; if not, write to the Free Software
Linus Torvalds1da177e2005-04-16 15:20:36 -070017 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Dave Kleikamp63f83c92006-10-02 09:55:27 -050018 */
Linus Torvalds1da177e2005-04-16 15:20:36 -070019#ifndef _H_JFS_INCORE
20#define _H_JFS_INCORE
21
Ingo Molnar1de87442006-01-24 15:22:50 -060022#include <linux/mutex.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070023#include <linux/rwsem.h>
24#include <linux/slab.h>
25#include <linux/bitops.h>
26#include "jfs_types.h"
27#include "jfs_xtree.h"
28#include "jfs_dtree.h"
29
30/*
31 * JFS magic number
32 */
33#define JFS_SUPER_MAGIC 0x3153464a /* "JFS1" */
34
35/*
36 * JFS-private inode information
37 */
38struct jfs_inode_info {
39 int fileset; /* fileset number (always 16)*/
40 uint mode2; /* jfs-specific mode */
Dave Kleikamp69eb66d2006-03-09 13:59:30 -060041 uint saved_uid; /* saved for uid mount option */
42 uint saved_gid; /* saved for gid mount option */
Dave Kleikampf720e3b2007-06-06 15:28:35 -050043 pxd_t ixpxd; /* inode extent descriptor */
Linus Torvalds1da177e2005-04-16 15:20:36 -070044 dxd_t acl; /* dxd describing acl */
45 dxd_t ea; /* dxd describing ea */
46 time_t otime; /* time created */
47 uint next_index; /* next available directory entry index */
48 int acltype; /* Type of ACL */
49 short btorder; /* access order */
50 short btindex; /* btpage entry index*/
51 struct inode *ipimap; /* inode map */
Al Viro5ba25332007-10-14 19:35:50 +010052 unsigned long cflag; /* commit flags */
Linus Torvalds1da177e2005-04-16 15:20:36 -070053 u16 bxflag; /* xflag of pseudo buffer? */
54 unchar agno; /* ag number */
55 signed char active_ag; /* ag currently allocating from */
56 lid_t blid; /* lid of pseudo buffer? */
57 lid_t atlhead; /* anonymous tlock list head */
58 lid_t atltail; /* anonymous tlock list tail */
59 spinlock_t ag_lock; /* protects active_ag */
60 struct list_head anon_inode_list; /* inodes having anonymous txns */
61 /*
62 * rdwrlock serializes xtree between reads & writes and synchronizes
63 * changes to special inodes. It's use would be redundant on
Jes Sorensen1b1dcc12006-01-09 15:59:24 -080064 * directories since the i_mutex taken in the VFS is sufficient.
Linus Torvalds1da177e2005-04-16 15:20:36 -070065 */
66 struct rw_semaphore rdwrlock;
67 /*
Ingo Molnar1de87442006-01-24 15:22:50 -060068 * commit_mutex serializes transaction processing on an inode.
Linus Torvalds1da177e2005-04-16 15:20:36 -070069 * It must be taken after beginning a transaction (txBegin), since
70 * dirty inodes may be committed while a new transaction on the
71 * inode is blocked in txBegin or TxBeginAnon
72 */
Ingo Molnar1de87442006-01-24 15:22:50 -060073 struct mutex commit_mutex;
Jes Sorensen1b1dcc12006-01-09 15:59:24 -080074 /* xattr_sem allows us to access the xattrs without taking i_mutex */
Linus Torvalds1da177e2005-04-16 15:20:36 -070075 struct rw_semaphore xattr_sem;
76 lid_t xtlid; /* lid of xtree lock on directory */
77#ifdef CONFIG_JFS_POSIX_ACL
78 struct posix_acl *i_acl;
79 struct posix_acl *i_default_acl;
80#endif
81 union {
82 struct {
83 xtpage_t _xtroot; /* 288: xtree root */
84 struct inomap *_imap; /* 4: inode map header */
85 } file;
86 struct {
87 struct dir_table_slot _table[12]; /* 96: dir index */
88 dtroot_t _dtroot; /* 288: dtree root */
89 } dir;
90 struct {
91 unchar _unused[16]; /* 16: */
92 dxd_t _dxd; /* 16: */
93 unchar _inline[128]; /* 128: inline symlink */
94 /* _inline_ea may overlay the last part of
95 * file._xtroot if maxentry = XTROOTINITSLOT
96 */
97 unchar _inline_ea[128]; /* 128: inline extended attr */
98 } link;
99 } u;
100 u32 dev; /* will die when we get wide dev_t */
101 struct inode vfs_inode;
102};
103#define i_xtroot u.file._xtroot
104#define i_imap u.file._imap
105#define i_dirtable u.dir._table
106#define i_dtroot u.dir._dtroot
107#define i_inline u.link._inline
108#define i_inline_ea u.link._inline_ea
109
110#define JFS_ACL_NOT_CACHED ((void *)-1)
111
Dave Kleikamp82d5b9a2007-01-09 14:14:48 -0600112#define IREAD_LOCK(ip, subclass) \
113 down_read_nested(&JFS_IP(ip)->rdwrlock, subclass)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700114#define IREAD_UNLOCK(ip) up_read(&JFS_IP(ip)->rdwrlock)
Dave Kleikamp82d5b9a2007-01-09 14:14:48 -0600115#define IWRITE_LOCK(ip, subclass) \
116 down_write_nested(&JFS_IP(ip)->rdwrlock, subclass)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700117#define IWRITE_UNLOCK(ip) up_write(&JFS_IP(ip)->rdwrlock)
118
119/*
120 * cflag
121 */
122enum cflags {
123 COMMIT_Nolink, /* inode committed with zero link count */
124 COMMIT_Inlineea, /* commit inode inline EA */
125 COMMIT_Freewmap, /* free WMAP at iClose() */
126 COMMIT_Dirty, /* Inode is really dirty */
127 COMMIT_Dirtable, /* commit changes to di_dirtable */
128 COMMIT_Stale, /* data extent is no longer valid */
129 COMMIT_Synclist, /* metadata pages on group commit synclist */
130};
131
Dave Kleikamp82d5b9a2007-01-09 14:14:48 -0600132/*
133 * commit_mutex nesting subclasses:
134 */
135enum commit_mutex_class
136{
137 COMMIT_MUTEX_PARENT,
138 COMMIT_MUTEX_CHILD,
139 COMMIT_MUTEX_SECOND_PARENT, /* Renaming */
140 COMMIT_MUTEX_VICTIM /* Inode being unlinked due to rename */
141};
142
143/*
144 * rdwrlock subclasses:
145 * The dmap inode may be locked while a normal inode or the imap inode are
146 * locked.
147 */
148enum rdwrlock_class
149{
150 RDWRLOCK_NORMAL,
151 RDWRLOCK_IMAP,
152 RDWRLOCK_DMAP
153};
154
Linus Torvalds1da177e2005-04-16 15:20:36 -0700155#define set_cflag(flag, ip) set_bit(flag, &(JFS_IP(ip)->cflag))
156#define clear_cflag(flag, ip) clear_bit(flag, &(JFS_IP(ip)->cflag))
157#define test_cflag(flag, ip) test_bit(flag, &(JFS_IP(ip)->cflag))
158#define test_and_clear_cflag(flag, ip) \
159 test_and_clear_bit(flag, &(JFS_IP(ip)->cflag))
160/*
161 * JFS-private superblock information.
162 */
163struct jfs_sb_info {
164 struct super_block *sb; /* Point back to vfs super block */
165 unsigned long mntflag; /* aggregate attributes */
166 struct inode *ipbmap; /* block map inode */
167 struct inode *ipaimap; /* aggregate inode map inode */
168 struct inode *ipaimap2; /* secondary aimap inode */
169 struct inode *ipimap; /* aggregate inode map inode */
170 struct jfs_log *log; /* log */
171 struct list_head log_list; /* volumes associated with a journal */
172 short bsize; /* logical block size */
173 short l2bsize; /* log2 logical block size */
174 short nbperpage; /* blocks per page */
175 short l2nbperpage; /* log2 blocks per page */
176 short l2niperblk; /* log2 inodes per page */
177 dev_t logdev; /* external log device */
178 uint aggregate; /* volume identifier in log record */
179 pxd_t logpxd; /* pxd describing log */
180 pxd_t fsckpxd; /* pxd describing fsck wkspc */
181 pxd_t ait2; /* pxd describing AIT copy */
182 char uuid[16]; /* 128-bit uuid for volume */
183 char loguuid[16]; /* 128-bit uuid for log */
184 /*
185 * commit_state is used for synchronization of the jfs_commit
186 * threads. It is protected by LAZY_LOCK().
187 */
188 int commit_state; /* commit state */
189 /* Formerly in ipimap */
190 uint gengen; /* inode generation generator*/
191 uint inostamp; /* shows inode belongs to fileset*/
192
Dave Kleikampf720e3b2007-06-06 15:28:35 -0500193 /* Formerly in ipbmap */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700194 struct bmap *bmap; /* incore bmap descriptor */
195 struct nls_table *nls_tab; /* current codepage */
Dave Kleikamp7fab4792005-05-02 12:25:02 -0600196 struct inode *direct_inode; /* metadata inode */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700197 uint state; /* mount/recovery state */
198 unsigned long flag; /* mount time flags */
199 uint p_state; /* state prior to going no integrity */
Dave Kleikamp69eb66d2006-03-09 13:59:30 -0600200 uint uid; /* uid to override on-disk uid */
201 uint gid; /* gid to override on-disk gid */
202 uint umask; /* umask to override on-disk umask */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700203};
204
205/* jfs_sb_info commit_state */
206#define IN_LAZYCOMMIT 1
207
208static inline struct jfs_inode_info *JFS_IP(struct inode *inode)
209{
210 return list_entry(inode, struct jfs_inode_info, vfs_inode);
211}
212
213static inline int jfs_dirtable_inline(struct inode *inode)
214{
215 return (JFS_IP(inode)->next_index <= (MAX_INLINE_DIRTABLE_ENTRY + 1));
216}
217
218static inline struct jfs_sb_info *JFS_SBI(struct super_block *sb)
219{
220 return sb->s_fs_info;
221}
222
223static inline int isReadOnly(struct inode *inode)
224{
225 if (JFS_SBI(inode->i_sb)->log)
226 return 0;
227 return 1;
228}
229#endif /* _H_JFS_INCORE */