Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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 | |
| 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 | /* |
| 30 | * JFS magic number |
| 31 | */ |
| 32 | #define JFS_SUPER_MAGIC 0x3153464a /* "JFS1" */ |
| 33 | |
| 34 | /* |
| 35 | * JFS-private inode information |
| 36 | */ |
| 37 | struct jfs_inode_info { |
| 38 | int fileset; /* fileset number (always 16)*/ |
| 39 | uint mode2; /* jfs-specific mode */ |
| 40 | pxd_t ixpxd; /* inode extent descriptor */ |
| 41 | dxd_t acl; /* dxd describing acl */ |
| 42 | dxd_t ea; /* dxd describing ea */ |
| 43 | time_t otime; /* time created */ |
| 44 | uint next_index; /* next available directory entry index */ |
| 45 | int acltype; /* Type of ACL */ |
| 46 | short btorder; /* access order */ |
| 47 | short btindex; /* btpage entry index*/ |
| 48 | struct inode *ipimap; /* inode map */ |
| 49 | long cflag; /* commit flags */ |
| 50 | u16 bxflag; /* xflag of pseudo buffer? */ |
| 51 | unchar agno; /* ag number */ |
| 52 | signed char active_ag; /* ag currently allocating from */ |
| 53 | lid_t blid; /* lid of pseudo buffer? */ |
| 54 | lid_t atlhead; /* anonymous tlock list head */ |
| 55 | lid_t atltail; /* anonymous tlock list tail */ |
| 56 | spinlock_t ag_lock; /* protects active_ag */ |
| 57 | struct list_head anon_inode_list; /* inodes having anonymous txns */ |
| 58 | /* |
| 59 | * rdwrlock serializes xtree between reads & writes and synchronizes |
| 60 | * changes to special inodes. It's use would be redundant on |
| 61 | * directories since the i_sem taken in the VFS is sufficient. |
| 62 | */ |
| 63 | struct rw_semaphore rdwrlock; |
| 64 | /* |
| 65 | * commit_sem serializes transaction processing on an inode. |
| 66 | * It must be taken after beginning a transaction (txBegin), since |
| 67 | * dirty inodes may be committed while a new transaction on the |
| 68 | * inode is blocked in txBegin or TxBeginAnon |
| 69 | */ |
| 70 | struct semaphore commit_sem; |
| 71 | /* xattr_sem allows us to access the xattrs without taking i_sem */ |
| 72 | struct rw_semaphore xattr_sem; |
| 73 | lid_t xtlid; /* lid of xtree lock on directory */ |
| 74 | #ifdef CONFIG_JFS_POSIX_ACL |
| 75 | struct posix_acl *i_acl; |
| 76 | struct posix_acl *i_default_acl; |
| 77 | #endif |
| 78 | union { |
| 79 | struct { |
| 80 | xtpage_t _xtroot; /* 288: xtree root */ |
| 81 | struct inomap *_imap; /* 4: inode map header */ |
| 82 | } file; |
| 83 | struct { |
| 84 | struct dir_table_slot _table[12]; /* 96: dir index */ |
| 85 | dtroot_t _dtroot; /* 288: dtree root */ |
| 86 | } dir; |
| 87 | struct { |
| 88 | unchar _unused[16]; /* 16: */ |
| 89 | dxd_t _dxd; /* 16: */ |
| 90 | unchar _inline[128]; /* 128: inline symlink */ |
| 91 | /* _inline_ea may overlay the last part of |
| 92 | * file._xtroot if maxentry = XTROOTINITSLOT |
| 93 | */ |
| 94 | unchar _inline_ea[128]; /* 128: inline extended attr */ |
| 95 | } link; |
| 96 | } u; |
| 97 | u32 dev; /* will die when we get wide dev_t */ |
| 98 | struct inode vfs_inode; |
| 99 | }; |
| 100 | #define i_xtroot u.file._xtroot |
| 101 | #define i_imap u.file._imap |
| 102 | #define i_dirtable u.dir._table |
| 103 | #define i_dtroot u.dir._dtroot |
| 104 | #define i_inline u.link._inline |
| 105 | #define i_inline_ea u.link._inline_ea |
| 106 | |
| 107 | #define JFS_ACL_NOT_CACHED ((void *)-1) |
| 108 | |
| 109 | #define IREAD_LOCK(ip) down_read(&JFS_IP(ip)->rdwrlock) |
| 110 | #define IREAD_UNLOCK(ip) up_read(&JFS_IP(ip)->rdwrlock) |
| 111 | #define IWRITE_LOCK(ip) down_write(&JFS_IP(ip)->rdwrlock) |
| 112 | #define IWRITE_UNLOCK(ip) up_write(&JFS_IP(ip)->rdwrlock) |
| 113 | |
| 114 | /* |
| 115 | * cflag |
| 116 | */ |
| 117 | enum cflags { |
| 118 | COMMIT_Nolink, /* inode committed with zero link count */ |
| 119 | COMMIT_Inlineea, /* commit inode inline EA */ |
| 120 | COMMIT_Freewmap, /* free WMAP at iClose() */ |
| 121 | COMMIT_Dirty, /* Inode is really dirty */ |
| 122 | COMMIT_Dirtable, /* commit changes to di_dirtable */ |
| 123 | COMMIT_Stale, /* data extent is no longer valid */ |
| 124 | COMMIT_Synclist, /* metadata pages on group commit synclist */ |
| 125 | }; |
| 126 | |
| 127 | #define set_cflag(flag, ip) set_bit(flag, &(JFS_IP(ip)->cflag)) |
| 128 | #define clear_cflag(flag, ip) clear_bit(flag, &(JFS_IP(ip)->cflag)) |
| 129 | #define test_cflag(flag, ip) test_bit(flag, &(JFS_IP(ip)->cflag)) |
| 130 | #define test_and_clear_cflag(flag, ip) \ |
| 131 | test_and_clear_bit(flag, &(JFS_IP(ip)->cflag)) |
| 132 | /* |
| 133 | * JFS-private superblock information. |
| 134 | */ |
| 135 | struct jfs_sb_info { |
| 136 | struct super_block *sb; /* Point back to vfs super block */ |
| 137 | unsigned long mntflag; /* aggregate attributes */ |
| 138 | struct inode *ipbmap; /* block map inode */ |
| 139 | struct inode *ipaimap; /* aggregate inode map inode */ |
| 140 | struct inode *ipaimap2; /* secondary aimap inode */ |
| 141 | struct inode *ipimap; /* aggregate inode map inode */ |
| 142 | struct jfs_log *log; /* log */ |
| 143 | struct list_head log_list; /* volumes associated with a journal */ |
| 144 | short bsize; /* logical block size */ |
| 145 | short l2bsize; /* log2 logical block size */ |
| 146 | short nbperpage; /* blocks per page */ |
| 147 | short l2nbperpage; /* log2 blocks per page */ |
| 148 | short l2niperblk; /* log2 inodes per page */ |
| 149 | dev_t logdev; /* external log device */ |
| 150 | uint aggregate; /* volume identifier in log record */ |
| 151 | pxd_t logpxd; /* pxd describing log */ |
| 152 | pxd_t fsckpxd; /* pxd describing fsck wkspc */ |
| 153 | pxd_t ait2; /* pxd describing AIT copy */ |
| 154 | char uuid[16]; /* 128-bit uuid for volume */ |
| 155 | char loguuid[16]; /* 128-bit uuid for log */ |
| 156 | /* |
| 157 | * commit_state is used for synchronization of the jfs_commit |
| 158 | * threads. It is protected by LAZY_LOCK(). |
| 159 | */ |
| 160 | int commit_state; /* commit state */ |
| 161 | /* Formerly in ipimap */ |
| 162 | uint gengen; /* inode generation generator*/ |
| 163 | uint inostamp; /* shows inode belongs to fileset*/ |
| 164 | |
| 165 | /* Formerly in ipbmap */ |
| 166 | struct bmap *bmap; /* incore bmap descriptor */ |
| 167 | struct nls_table *nls_tab; /* current codepage */ |
Dave Kleikamp | 7fab479 | 2005-05-02 12:25:02 -0600 | [diff] [blame] | 168 | struct inode *direct_inode; /* metadata inode */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 169 | uint state; /* mount/recovery state */ |
| 170 | unsigned long flag; /* mount time flags */ |
| 171 | uint p_state; /* state prior to going no integrity */ |
| 172 | }; |
| 173 | |
| 174 | /* jfs_sb_info commit_state */ |
| 175 | #define IN_LAZYCOMMIT 1 |
| 176 | |
| 177 | static inline struct jfs_inode_info *JFS_IP(struct inode *inode) |
| 178 | { |
| 179 | return list_entry(inode, struct jfs_inode_info, vfs_inode); |
| 180 | } |
| 181 | |
| 182 | static inline int jfs_dirtable_inline(struct inode *inode) |
| 183 | { |
| 184 | return (JFS_IP(inode)->next_index <= (MAX_INLINE_DIRTABLE_ENTRY + 1)); |
| 185 | } |
| 186 | |
| 187 | static inline struct jfs_sb_info *JFS_SBI(struct super_block *sb) |
| 188 | { |
| 189 | return sb->s_fs_info; |
| 190 | } |
| 191 | |
| 192 | static inline int isReadOnly(struct inode *inode) |
| 193 | { |
| 194 | if (JFS_SBI(inode->i_sb)->log) |
| 195 | return 0; |
| 196 | return 1; |
| 197 | } |
| 198 | #endif /* _H_JFS_INCORE */ |