Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
Nathan Scott | 7b71876 | 2005-11-02 14:58:39 +1100 | [diff] [blame] | 2 | * Copyright (c) 2000-2003,2005 Silicon Graphics, Inc. |
| 3 | * All Rights Reserved. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4 | * |
Nathan Scott | 7b71876 | 2005-11-02 14:58:39 +1100 | [diff] [blame] | 5 | * This program is free software; you can redistribute it and/or |
| 6 | * modify it under the terms of the GNU General Public License as |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7 | * published by the Free Software Foundation. |
| 8 | * |
Nathan Scott | 7b71876 | 2005-11-02 14:58:39 +1100 | [diff] [blame] | 9 | * This program is distributed in the hope that it would be useful, |
| 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 | * GNU General Public License for more details. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 13 | * |
Nathan Scott | 7b71876 | 2005-11-02 14:58:39 +1100 | [diff] [blame] | 14 | * You should have received a copy of the GNU General Public License |
| 15 | * along with this program; if not, write the Free Software Foundation, |
| 16 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 17 | */ |
| 18 | #ifndef __XFS_INODE_H__ |
| 19 | #define __XFS_INODE_H__ |
| 20 | |
| 21 | /* |
Nathan Scott | a844f45 | 2005-11-02 14:38:42 +1100 | [diff] [blame] | 22 | * Fork identifiers. |
| 23 | */ |
| 24 | #define XFS_DATA_FORK 0 |
| 25 | #define XFS_ATTR_FORK 1 |
| 26 | |
| 27 | /* |
Mandy Kirkconnell | 0293ce3 | 2006-03-14 13:30:23 +1100 | [diff] [blame] | 28 | * The following xfs_ext_irec_t struct introduces a second (top) level |
| 29 | * to the in-core extent allocation scheme. These structs are allocated |
| 30 | * in a contiguous block, creating an indirection array where each entry |
| 31 | * (irec) contains a pointer to a buffer of in-core extent records which |
| 32 | * it manages. Each extent buffer is 4k in size, since 4k is the system |
| 33 | * page size on Linux i386 and systems with larger page sizes don't seem |
| 34 | * to gain much, if anything, by using their native page size as the |
| 35 | * extent buffer size. Also, using 4k extent buffers everywhere provides |
| 36 | * a consistent interface for CXFS across different platforms. |
| 37 | * |
| 38 | * There is currently no limit on the number of irec's (extent lists) |
| 39 | * allowed, so heavily fragmented files may require an indirection array |
| 40 | * which spans multiple system pages of memory. The number of extents |
| 41 | * which would require this amount of contiguous memory is very large |
| 42 | * and should not cause problems in the foreseeable future. However, |
| 43 | * if the memory needed for the contiguous array ever becomes a problem, |
| 44 | * it is possible that a third level of indirection may be required. |
| 45 | */ |
| 46 | typedef struct xfs_ext_irec { |
| 47 | xfs_bmbt_rec_t *er_extbuf; /* block of extent records */ |
| 48 | xfs_extnum_t er_extoff; /* extent offset in file */ |
| 49 | xfs_extnum_t er_extcount; /* number of extents in page/block */ |
| 50 | } xfs_ext_irec_t; |
| 51 | |
| 52 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 53 | * File incore extent information, present for each of data & attr forks. |
| 54 | */ |
Mandy Kirkconnell | 0293ce3 | 2006-03-14 13:30:23 +1100 | [diff] [blame] | 55 | #define XFS_IEXT_BUFSZ 4096 |
| 56 | #define XFS_LINEAR_EXTS (XFS_IEXT_BUFSZ / (uint)sizeof(xfs_bmbt_rec_t)) |
| 57 | #define XFS_INLINE_EXTS 2 |
| 58 | #define XFS_INLINE_DATA 32 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 59 | typedef struct xfs_ifork { |
| 60 | int if_bytes; /* bytes in if_u1 */ |
| 61 | int if_real_bytes; /* bytes allocated in if_u1 */ |
| 62 | xfs_bmbt_block_t *if_broot; /* file's incore btree root */ |
| 63 | short if_broot_bytes; /* bytes allocated for root */ |
| 64 | unsigned char if_flags; /* per-fork flags */ |
| 65 | unsigned char if_ext_max; /* max # of extent records */ |
| 66 | xfs_extnum_t if_lastex; /* last if_extents used */ |
| 67 | union { |
| 68 | xfs_bmbt_rec_t *if_extents; /* linear map file exts */ |
Mandy Kirkconnell | 0293ce3 | 2006-03-14 13:30:23 +1100 | [diff] [blame] | 69 | xfs_ext_irec_t *if_ext_irec; /* irec map file exts */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 70 | char *if_data; /* inline file data */ |
| 71 | } if_u1; |
| 72 | union { |
| 73 | xfs_bmbt_rec_t if_inline_ext[XFS_INLINE_EXTS]; |
| 74 | /* very small file extents */ |
| 75 | char if_inline_data[XFS_INLINE_DATA]; |
| 76 | /* very small file data */ |
| 77 | xfs_dev_t if_rdev; /* dev number if special */ |
| 78 | uuid_t if_uuid; /* mount point value */ |
| 79 | } if_u2; |
| 80 | } xfs_ifork_t; |
| 81 | |
| 82 | /* |
| 83 | * Flags for xfs_ichgtime(). |
| 84 | */ |
| 85 | #define XFS_ICHGTIME_MOD 0x1 /* data fork modification timestamp */ |
| 86 | #define XFS_ICHGTIME_ACC 0x2 /* data fork access timestamp */ |
| 87 | #define XFS_ICHGTIME_CHG 0x4 /* inode field change timestamp */ |
| 88 | |
| 89 | /* |
| 90 | * Per-fork incore inode flags. |
| 91 | */ |
Mandy Kirkconnell | 0293ce3 | 2006-03-14 13:30:23 +1100 | [diff] [blame] | 92 | #define XFS_IFINLINE 0x01 /* Inline data is read in */ |
| 93 | #define XFS_IFEXTENTS 0x02 /* All extent pointers are read in */ |
| 94 | #define XFS_IFBROOT 0x04 /* i_broot points to the bmap b-tree root */ |
| 95 | #define XFS_IFEXTIREC 0x08 /* Indirection array of extent blocks */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 96 | |
| 97 | /* |
Nathan Scott | b12dd34 | 2006-03-17 17:26:04 +1100 | [diff] [blame] | 98 | * Flags for xfs_itobp(), xfs_imap() and xfs_dilocate(). |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 99 | */ |
Nathan Scott | b12dd34 | 2006-03-17 17:26:04 +1100 | [diff] [blame] | 100 | #define XFS_IMAP_LOOKUP 0x1 |
| 101 | #define XFS_IMAP_BULKSTAT 0x2 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 102 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 103 | #ifdef __KERNEL__ |
| 104 | struct bhv_desc; |
| 105 | struct cred; |
| 106 | struct ktrace; |
| 107 | struct vnode; |
| 108 | struct xfs_buf; |
| 109 | struct xfs_bmap_free; |
| 110 | struct xfs_bmbt_irec; |
| 111 | struct xfs_bmbt_block; |
| 112 | struct xfs_inode; |
| 113 | struct xfs_inode_log_item; |
| 114 | struct xfs_mount; |
| 115 | struct xfs_trans; |
| 116 | struct xfs_dquot; |
| 117 | |
| 118 | #if defined(XFS_ILOCK_TRACE) |
| 119 | #define XFS_ILOCK_KTRACE_SIZE 32 |
| 120 | extern ktrace_t *xfs_ilock_trace_buf; |
| 121 | extern void xfs_ilock_trace(struct xfs_inode *, int, unsigned int, inst_t *); |
| 122 | #else |
| 123 | #define xfs_ilock_trace(i,n,f,ra) |
| 124 | #endif |
| 125 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 126 | typedef struct dm_attrs_s { |
| 127 | __uint32_t da_dmevmask; /* DMIG event mask */ |
| 128 | __uint16_t da_dmstate; /* DMIG state info */ |
| 129 | __uint16_t da_pad; /* DMIG extra padding */ |
| 130 | } dm_attrs_t; |
| 131 | |
| 132 | typedef struct xfs_iocore { |
| 133 | void *io_obj; /* pointer to container |
| 134 | * inode or dcxvn structure */ |
| 135 | struct xfs_mount *io_mount; /* fs mount struct ptr */ |
| 136 | #ifdef DEBUG |
| 137 | mrlock_t *io_lock; /* inode IO lock */ |
| 138 | mrlock_t *io_iolock; /* inode IO lock */ |
| 139 | #endif |
| 140 | |
| 141 | /* I/O state */ |
| 142 | xfs_fsize_t io_new_size; /* sz when write completes */ |
| 143 | |
| 144 | /* Miscellaneous state. */ |
| 145 | unsigned int io_flags; /* IO related flags */ |
| 146 | |
| 147 | /* DMAPI state */ |
| 148 | dm_attrs_t io_dmattrs; |
| 149 | |
| 150 | } xfs_iocore_t; |
| 151 | |
| 152 | #define io_dmevmask io_dmattrs.da_dmevmask |
| 153 | #define io_dmstate io_dmattrs.da_dmstate |
| 154 | |
| 155 | #define XFS_IO_INODE(io) ((xfs_inode_t *) ((io)->io_obj)) |
| 156 | #define XFS_IO_DCXVN(io) ((dcxvn_t *) ((io)->io_obj)) |
| 157 | |
| 158 | /* |
| 159 | * Flags in the flags field |
| 160 | */ |
| 161 | |
| 162 | #define XFS_IOCORE_RT 0x1 |
| 163 | |
| 164 | /* |
| 165 | * xfs_iocore prototypes |
| 166 | */ |
| 167 | |
| 168 | extern void xfs_iocore_inode_init(struct xfs_inode *); |
| 169 | extern void xfs_iocore_inode_reinit(struct xfs_inode *); |
| 170 | |
| 171 | |
| 172 | /* |
| 173 | * This is the type used in the xfs inode hash table. |
| 174 | * An array of these is allocated for each mounted |
| 175 | * file system to hash the inodes for that file system. |
| 176 | */ |
| 177 | typedef struct xfs_ihash { |
| 178 | struct xfs_inode *ih_next; |
| 179 | rwlock_t ih_lock; |
| 180 | uint ih_version; |
| 181 | } xfs_ihash_t; |
| 182 | |
| 183 | #define XFS_IHASH(mp,ino) ((mp)->m_ihash + (((uint)(ino)) % (mp)->m_ihsize)) |
| 184 | |
| 185 | /* |
| 186 | * This is the xfs inode cluster hash. This hash is used by xfs_iflush to |
| 187 | * find inodes that share a cluster and can be flushed to disk at the same |
| 188 | * time. |
| 189 | */ |
| 190 | typedef struct xfs_chashlist { |
| 191 | struct xfs_chashlist *chl_next; |
David Chinner | 1fc5d95 | 2006-04-11 15:11:12 +1000 | [diff] [blame^] | 192 | struct xfs_chashlist *chl_prev; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 193 | struct xfs_inode *chl_ip; |
| 194 | xfs_daddr_t chl_blkno; /* starting block number of |
| 195 | * the cluster */ |
| 196 | struct xfs_buf *chl_buf; /* the inode buffer */ |
| 197 | } xfs_chashlist_t; |
| 198 | |
| 199 | typedef struct xfs_chash { |
| 200 | xfs_chashlist_t *ch_list; |
| 201 | lock_t ch_lock; |
| 202 | } xfs_chash_t; |
| 203 | |
| 204 | #define XFS_CHASH(mp,blk) ((mp)->m_chash + (((uint)blk) % (mp)->m_chsize)) |
| 205 | |
| 206 | |
| 207 | /* |
| 208 | * This is the xfs in-core inode structure. |
| 209 | * Most of the on-disk inode is embedded in the i_d field. |
| 210 | * |
| 211 | * The extent pointers/inline file space, however, are managed |
| 212 | * separately. The memory for this information is pointed to by |
| 213 | * the if_u1 unions depending on the type of the data. |
| 214 | * This is used to linearize the array of extents for fast in-core |
| 215 | * access. This is used until the file's number of extents |
| 216 | * surpasses XFS_MAX_INCORE_EXTENTS, at which point all extent pointers |
| 217 | * are accessed through the buffer cache. |
| 218 | * |
| 219 | * Other state kept in the in-core inode is used for identification, |
| 220 | * locking, transactional updating, etc of the inode. |
| 221 | * |
| 222 | * Generally, we do not want to hold the i_rlock while holding the |
| 223 | * i_ilock. Hierarchy is i_iolock followed by i_rlock. |
| 224 | * |
| 225 | * xfs_iptr_t contains all the inode fields upto and including the |
| 226 | * i_mnext and i_mprev fields, it is used as a marker in the inode |
| 227 | * chain off the mount structure by xfs_sync calls. |
| 228 | */ |
| 229 | |
| 230 | typedef struct { |
| 231 | struct xfs_ihash *ip_hash; /* pointer to hash header */ |
| 232 | struct xfs_inode *ip_next; /* inode hash link forw */ |
| 233 | struct xfs_inode *ip_mnext; /* next inode in mount list */ |
| 234 | struct xfs_inode *ip_mprev; /* ptr to prev inode */ |
| 235 | struct xfs_inode **ip_prevp; /* ptr to prev i_next */ |
| 236 | struct xfs_mount *ip_mount; /* fs mount struct ptr */ |
| 237 | } xfs_iptr_t; |
| 238 | |
| 239 | typedef struct xfs_inode { |
| 240 | /* Inode linking and identification information. */ |
| 241 | struct xfs_ihash *i_hash; /* pointer to hash header */ |
| 242 | struct xfs_inode *i_next; /* inode hash link forw */ |
| 243 | struct xfs_inode *i_mnext; /* next inode in mount list */ |
| 244 | struct xfs_inode *i_mprev; /* ptr to prev inode */ |
| 245 | struct xfs_inode **i_prevp; /* ptr to prev i_next */ |
| 246 | struct xfs_mount *i_mount; /* fs mount struct ptr */ |
| 247 | struct list_head i_reclaim; /* reclaim list */ |
| 248 | struct bhv_desc i_bhv_desc; /* inode behavior descriptor*/ |
| 249 | struct xfs_dquot *i_udquot; /* user dquot */ |
| 250 | struct xfs_dquot *i_gdquot; /* group dquot */ |
| 251 | |
| 252 | /* Inode location stuff */ |
| 253 | xfs_ino_t i_ino; /* inode number (agno/agino)*/ |
| 254 | xfs_daddr_t i_blkno; /* blkno of inode buffer */ |
| 255 | ushort i_len; /* len of inode buffer */ |
| 256 | ushort i_boffset; /* off of inode in buffer */ |
| 257 | |
| 258 | /* Extent information. */ |
| 259 | xfs_ifork_t *i_afp; /* attribute fork pointer */ |
| 260 | xfs_ifork_t i_df; /* data fork */ |
| 261 | |
| 262 | /* Transaction and locking information. */ |
| 263 | struct xfs_trans *i_transp; /* ptr to owning transaction*/ |
| 264 | struct xfs_inode_log_item *i_itemp; /* logging information */ |
| 265 | mrlock_t i_lock; /* inode lock */ |
| 266 | mrlock_t i_iolock; /* inode IO lock */ |
| 267 | sema_t i_flock; /* inode flush lock */ |
| 268 | atomic_t i_pincount; /* inode pin count */ |
| 269 | wait_queue_head_t i_ipin_wait; /* inode pinning wait queue */ |
| 270 | #ifdef HAVE_REFCACHE |
| 271 | struct xfs_inode **i_refcache; /* ptr to entry in ref cache */ |
| 272 | struct xfs_inode *i_release; /* inode to unref */ |
| 273 | #endif |
| 274 | /* I/O state */ |
| 275 | xfs_iocore_t i_iocore; /* I/O core */ |
| 276 | |
| 277 | /* Miscellaneous state. */ |
| 278 | unsigned short i_flags; /* see defined flags below */ |
| 279 | unsigned char i_update_core; /* timestamps/size is dirty */ |
| 280 | unsigned char i_update_size; /* di_size field is dirty */ |
| 281 | unsigned int i_gen; /* generation count */ |
| 282 | unsigned int i_delayed_blks; /* count of delay alloc blks */ |
| 283 | |
| 284 | xfs_dinode_core_t i_d; /* most of ondisk inode */ |
| 285 | xfs_chashlist_t *i_chash; /* cluster hash list header */ |
| 286 | struct xfs_inode *i_cnext; /* cluster hash link forward */ |
| 287 | struct xfs_inode *i_cprev; /* cluster hash link backward */ |
| 288 | |
| 289 | /* Trace buffers per inode. */ |
| 290 | #ifdef XFS_BMAP_TRACE |
| 291 | struct ktrace *i_xtrace; /* inode extent list trace */ |
| 292 | #endif |
| 293 | #ifdef XFS_BMBT_TRACE |
| 294 | struct ktrace *i_btrace; /* inode bmap btree trace */ |
| 295 | #endif |
| 296 | #ifdef XFS_RW_TRACE |
| 297 | struct ktrace *i_rwtrace; /* inode read/write trace */ |
| 298 | #endif |
| 299 | #ifdef XFS_ILOCK_TRACE |
| 300 | struct ktrace *i_lock_trace; /* inode lock/unlock trace */ |
| 301 | #endif |
| 302 | #ifdef XFS_DIR2_TRACE |
| 303 | struct ktrace *i_dir_trace; /* inode directory trace */ |
| 304 | #endif |
| 305 | } xfs_inode_t; |
| 306 | |
| 307 | #endif /* __KERNEL__ */ |
| 308 | |
| 309 | |
| 310 | /* |
| 311 | * Fork handling. |
| 312 | */ |
Nathan Scott | a844f45 | 2005-11-02 14:38:42 +1100 | [diff] [blame] | 313 | #define XFS_IFORK_PTR(ip,w) \ |
| 314 | ((w) == XFS_DATA_FORK ? &(ip)->i_df : (ip)->i_afp) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 315 | #define XFS_IFORK_Q(ip) XFS_CFORK_Q(&(ip)->i_d) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 316 | #define XFS_IFORK_DSIZE(ip) XFS_CFORK_DSIZE(&ip->i_d, ip->i_mount) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 317 | #define XFS_IFORK_ASIZE(ip) XFS_CFORK_ASIZE(&ip->i_d, ip->i_mount) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 318 | #define XFS_IFORK_SIZE(ip,w) XFS_CFORK_SIZE(&ip->i_d, ip->i_mount, w) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 319 | #define XFS_IFORK_FORMAT(ip,w) XFS_CFORK_FORMAT(&ip->i_d, w) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 320 | #define XFS_IFORK_FMT_SET(ip,w,n) XFS_CFORK_FMT_SET(&ip->i_d, w, n) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 321 | #define XFS_IFORK_NEXTENTS(ip,w) XFS_CFORK_NEXTENTS(&ip->i_d, w) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 322 | #define XFS_IFORK_NEXT_SET(ip,w,n) XFS_CFORK_NEXT_SET(&ip->i_d, w, n) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 323 | |
| 324 | |
| 325 | #ifdef __KERNEL__ |
| 326 | |
| 327 | /* |
| 328 | * In-core inode flags. |
| 329 | */ |
| 330 | #define XFS_IGRIO 0x0001 /* inode used for guaranteed rate i/o */ |
| 331 | #define XFS_IUIOSZ 0x0002 /* inode i/o sizes have been explicitly set */ |
| 332 | #define XFS_IQUIESCE 0x0004 /* we have started quiescing for this inode */ |
| 333 | #define XFS_IRECLAIM 0x0008 /* we have started reclaiming this inode */ |
| 334 | #define XFS_ISTALE 0x0010 /* inode has been staled */ |
| 335 | #define XFS_IRECLAIMABLE 0x0020 /* inode can be reclaimed */ |
| 336 | #define XFS_INEW 0x0040 |
| 337 | |
| 338 | /* |
| 339 | * Flags for inode locking. |
| 340 | */ |
| 341 | #define XFS_IOLOCK_EXCL 0x001 |
| 342 | #define XFS_IOLOCK_SHARED 0x002 |
| 343 | #define XFS_ILOCK_EXCL 0x004 |
| 344 | #define XFS_ILOCK_SHARED 0x008 |
| 345 | #define XFS_IUNLOCK_NONOTIFY 0x010 |
Nathan Scott | 30dab21 | 2005-11-02 10:31:13 +1100 | [diff] [blame] | 346 | /* XFS_IOLOCK_NESTED 0x020 */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 347 | #define XFS_EXTENT_TOKEN_RD 0x040 |
| 348 | #define XFS_SIZE_TOKEN_RD 0x080 |
| 349 | #define XFS_EXTSIZE_RD (XFS_EXTENT_TOKEN_RD|XFS_SIZE_TOKEN_RD) |
| 350 | #define XFS_WILLLEND 0x100 /* Always acquire tokens for lending */ |
| 351 | #define XFS_EXTENT_TOKEN_WR (XFS_EXTENT_TOKEN_RD | XFS_WILLLEND) |
| 352 | #define XFS_SIZE_TOKEN_WR (XFS_SIZE_TOKEN_RD | XFS_WILLLEND) |
| 353 | #define XFS_EXTSIZE_WR (XFS_EXTSIZE_RD | XFS_WILLLEND) |
Nathan Scott | 30dab21 | 2005-11-02 10:31:13 +1100 | [diff] [blame] | 354 | /* XFS_SIZE_TOKEN_WANT 0x200 */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 355 | |
| 356 | #define XFS_LOCK_MASK \ |
| 357 | (XFS_IOLOCK_EXCL | XFS_IOLOCK_SHARED | XFS_ILOCK_EXCL | \ |
| 358 | XFS_ILOCK_SHARED | XFS_EXTENT_TOKEN_RD | XFS_SIZE_TOKEN_RD | \ |
| 359 | XFS_WILLLEND) |
| 360 | |
| 361 | /* |
| 362 | * Flags for xfs_iflush() |
| 363 | */ |
| 364 | #define XFS_IFLUSH_DELWRI_ELSE_SYNC 1 |
| 365 | #define XFS_IFLUSH_DELWRI_ELSE_ASYNC 2 |
| 366 | #define XFS_IFLUSH_SYNC 3 |
| 367 | #define XFS_IFLUSH_ASYNC 4 |
| 368 | #define XFS_IFLUSH_DELWRI 5 |
| 369 | |
| 370 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 371 | * Flags for xfs_itruncate_start(). |
| 372 | */ |
| 373 | #define XFS_ITRUNC_DEFINITE 0x1 |
| 374 | #define XFS_ITRUNC_MAYBE 0x2 |
| 375 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 376 | #define XFS_ITOV(ip) BHV_TO_VNODE(XFS_ITOBHV(ip)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 377 | #define XFS_ITOV_NULL(ip) BHV_TO_VNODE_NULL(XFS_ITOBHV(ip)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 378 | #define XFS_ITOBHV(ip) ((struct bhv_desc *)(&((ip)->i_bhv_desc))) |
Nathan Scott | a844f45 | 2005-11-02 14:38:42 +1100 | [diff] [blame] | 379 | #define XFS_BHVTOI(bhvp) ((xfs_inode_t *)((char *)(bhvp) - \ |
| 380 | (char *)&(((xfs_inode_t *)0)->i_bhv_desc))) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 381 | #define BHV_IS_XFS(bdp) (BHV_OPS(bdp) == &xfs_vnodeops) |
| 382 | |
| 383 | /* |
| 384 | * For multiple groups support: if S_ISGID bit is set in the parent |
| 385 | * directory, group of new file is set to that of the parent, and |
| 386 | * new subdirectory gets S_ISGID bit from parent. |
| 387 | */ |
| 388 | #define XFS_INHERIT_GID(pip, vfsp) \ |
| 389 | (((vfsp)->vfs_flag & VFS_GRPID) || ((pip)->i_d.di_mode & S_ISGID)) |
| 390 | |
| 391 | /* |
| 392 | * xfs_iget.c prototypes. |
| 393 | */ |
| 394 | |
| 395 | #define IGET_CREATE 1 |
| 396 | |
| 397 | void xfs_ihash_init(struct xfs_mount *); |
| 398 | void xfs_ihash_free(struct xfs_mount *); |
| 399 | void xfs_chash_init(struct xfs_mount *); |
| 400 | void xfs_chash_free(struct xfs_mount *); |
| 401 | xfs_inode_t *xfs_inode_incore(struct xfs_mount *, xfs_ino_t, |
| 402 | struct xfs_trans *); |
| 403 | void xfs_inode_lock_init(xfs_inode_t *, struct vnode *); |
| 404 | int xfs_iget(struct xfs_mount *, struct xfs_trans *, xfs_ino_t, |
| 405 | uint, uint, xfs_inode_t **, xfs_daddr_t); |
| 406 | void xfs_iput(xfs_inode_t *, uint); |
| 407 | void xfs_iput_new(xfs_inode_t *, uint); |
| 408 | void xfs_ilock(xfs_inode_t *, uint); |
| 409 | int xfs_ilock_nowait(xfs_inode_t *, uint); |
| 410 | void xfs_iunlock(xfs_inode_t *, uint); |
| 411 | void xfs_ilock_demote(xfs_inode_t *, uint); |
| 412 | void xfs_iflock(xfs_inode_t *); |
| 413 | int xfs_iflock_nowait(xfs_inode_t *); |
| 414 | uint xfs_ilock_map_shared(xfs_inode_t *); |
| 415 | void xfs_iunlock_map_shared(xfs_inode_t *, uint); |
| 416 | void xfs_ifunlock(xfs_inode_t *); |
| 417 | void xfs_ireclaim(xfs_inode_t *); |
| 418 | int xfs_finish_reclaim(xfs_inode_t *, int, int); |
| 419 | int xfs_finish_reclaim_all(struct xfs_mount *, int); |
| 420 | |
| 421 | /* |
| 422 | * xfs_inode.c prototypes. |
| 423 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 424 | int xfs_itobp(struct xfs_mount *, struct xfs_trans *, |
| 425 | xfs_inode_t *, xfs_dinode_t **, struct xfs_buf **, |
Nathan Scott | b12dd34 | 2006-03-17 17:26:04 +1100 | [diff] [blame] | 426 | xfs_daddr_t, uint); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 427 | int xfs_iread(struct xfs_mount *, struct xfs_trans *, xfs_ino_t, |
| 428 | xfs_inode_t **, xfs_daddr_t); |
| 429 | int xfs_iread_extents(struct xfs_trans *, xfs_inode_t *, int); |
Nathan Scott | 31b084a | 2005-05-05 13:25:00 -0700 | [diff] [blame] | 430 | int xfs_ialloc(struct xfs_trans *, xfs_inode_t *, mode_t, |
| 431 | xfs_nlink_t, xfs_dev_t, struct cred *, xfs_prid_t, |
| 432 | int, struct xfs_buf **, boolean_t *, xfs_inode_t **); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 433 | void xfs_xlate_dinode_core(xfs_caddr_t, struct xfs_dinode_core *, |
| 434 | int); |
| 435 | uint xfs_ip2xflags(struct xfs_inode *); |
| 436 | uint xfs_dic2xflags(struct xfs_dinode_core *); |
| 437 | int xfs_ifree(struct xfs_trans *, xfs_inode_t *, |
| 438 | struct xfs_bmap_free *); |
| 439 | void xfs_itruncate_start(xfs_inode_t *, uint, xfs_fsize_t); |
| 440 | int xfs_itruncate_finish(struct xfs_trans **, xfs_inode_t *, |
| 441 | xfs_fsize_t, int, int); |
| 442 | int xfs_iunlink(struct xfs_trans *, xfs_inode_t *); |
| 443 | int xfs_igrow_start(xfs_inode_t *, xfs_fsize_t, struct cred *); |
| 444 | void xfs_igrow_finish(struct xfs_trans *, xfs_inode_t *, |
| 445 | xfs_fsize_t, int); |
| 446 | |
| 447 | void xfs_idestroy_fork(xfs_inode_t *, int); |
| 448 | void xfs_idestroy(xfs_inode_t *); |
| 449 | void xfs_idata_realloc(xfs_inode_t *, int, int); |
| 450 | void xfs_iextract(xfs_inode_t *); |
| 451 | void xfs_iext_realloc(xfs_inode_t *, int, int); |
| 452 | void xfs_iroot_realloc(xfs_inode_t *, int, int); |
| 453 | void xfs_ipin(xfs_inode_t *); |
| 454 | void xfs_iunpin(xfs_inode_t *); |
| 455 | int xfs_iextents_copy(xfs_inode_t *, xfs_bmbt_rec_t *, int); |
| 456 | int xfs_iflush(xfs_inode_t *, uint); |
Christoph Hellwig | efa8027 | 2005-06-21 15:37:17 +1000 | [diff] [blame] | 457 | void xfs_iflush_all(struct xfs_mount *); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 458 | int xfs_iaccess(xfs_inode_t *, mode_t, cred_t *); |
| 459 | uint xfs_iroundup(uint); |
| 460 | void xfs_ichgtime(xfs_inode_t *, int); |
| 461 | xfs_fsize_t xfs_file_last_byte(xfs_inode_t *); |
| 462 | void xfs_lock_inodes(xfs_inode_t **, int, int, uint); |
| 463 | |
Christoph Hellwig | 75e17b3 | 2006-01-11 20:58:44 +1100 | [diff] [blame] | 464 | xfs_inode_t *xfs_vtoi(struct vnode *vp); |
| 465 | |
Christoph Hellwig | 42fe2b1 | 2006-01-11 15:35:17 +1100 | [diff] [blame] | 466 | void xfs_synchronize_atime(xfs_inode_t *); |
| 467 | |
Mandy Kirkconnell | 4eea22f | 2006-03-14 13:29:52 +1100 | [diff] [blame] | 468 | xfs_bmbt_rec_t *xfs_iext_get_ext(xfs_ifork_t *, xfs_extnum_t); |
| 469 | void xfs_iext_insert(xfs_ifork_t *, xfs_extnum_t, xfs_extnum_t, |
| 470 | xfs_bmbt_irec_t *); |
| 471 | void xfs_iext_add(xfs_ifork_t *, xfs_extnum_t, int); |
Mandy Kirkconnell | 0293ce3 | 2006-03-14 13:30:23 +1100 | [diff] [blame] | 472 | void xfs_iext_add_indirect_multi(xfs_ifork_t *, int, xfs_extnum_t, int); |
Mandy Kirkconnell | 4eea22f | 2006-03-14 13:29:52 +1100 | [diff] [blame] | 473 | void xfs_iext_remove(xfs_ifork_t *, xfs_extnum_t, int); |
| 474 | void xfs_iext_remove_inline(xfs_ifork_t *, xfs_extnum_t, int); |
| 475 | void xfs_iext_remove_direct(xfs_ifork_t *, xfs_extnum_t, int); |
Mandy Kirkconnell | 0293ce3 | 2006-03-14 13:30:23 +1100 | [diff] [blame] | 476 | void xfs_iext_remove_indirect(xfs_ifork_t *, xfs_extnum_t, int); |
Mandy Kirkconnell | 4eea22f | 2006-03-14 13:29:52 +1100 | [diff] [blame] | 477 | void xfs_iext_realloc_direct(xfs_ifork_t *, int); |
Mandy Kirkconnell | 0293ce3 | 2006-03-14 13:30:23 +1100 | [diff] [blame] | 478 | void xfs_iext_realloc_indirect(xfs_ifork_t *, int); |
| 479 | void xfs_iext_indirect_to_direct(xfs_ifork_t *); |
Mandy Kirkconnell | 4eea22f | 2006-03-14 13:29:52 +1100 | [diff] [blame] | 480 | void xfs_iext_direct_to_inline(xfs_ifork_t *, xfs_extnum_t); |
| 481 | void xfs_iext_inline_to_direct(xfs_ifork_t *, int); |
| 482 | void xfs_iext_destroy(xfs_ifork_t *); |
Mandy Kirkconnell | 8867bc9 | 2006-03-17 17:25:04 +1100 | [diff] [blame] | 483 | xfs_bmbt_rec_t *xfs_iext_bno_to_ext(xfs_ifork_t *, xfs_fileoff_t, int *); |
Mandy Kirkconnell | 0293ce3 | 2006-03-14 13:30:23 +1100 | [diff] [blame] | 484 | xfs_ext_irec_t *xfs_iext_bno_to_irec(xfs_ifork_t *, xfs_fileoff_t, int *); |
| 485 | xfs_ext_irec_t *xfs_iext_idx_to_irec(xfs_ifork_t *, xfs_extnum_t *, int *, int); |
| 486 | void xfs_iext_irec_init(xfs_ifork_t *); |
| 487 | xfs_ext_irec_t *xfs_iext_irec_new(xfs_ifork_t *, int); |
| 488 | void xfs_iext_irec_remove(xfs_ifork_t *, int); |
| 489 | void xfs_iext_irec_compact(xfs_ifork_t *); |
| 490 | void xfs_iext_irec_compact_pages(xfs_ifork_t *); |
| 491 | void xfs_iext_irec_compact_full(xfs_ifork_t *); |
| 492 | void xfs_iext_irec_update_extoffs(xfs_ifork_t *, int, int); |
Mandy Kirkconnell | 4eea22f | 2006-03-14 13:29:52 +1100 | [diff] [blame] | 493 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 494 | #define xfs_ipincount(ip) ((unsigned int) atomic_read(&ip->i_pincount)) |
| 495 | |
| 496 | #ifdef DEBUG |
| 497 | void xfs_isize_check(struct xfs_mount *, xfs_inode_t *, xfs_fsize_t); |
| 498 | #else /* DEBUG */ |
| 499 | #define xfs_isize_check(mp, ip, isize) |
| 500 | #endif /* DEBUG */ |
| 501 | |
| 502 | #if defined(DEBUG) |
| 503 | void xfs_inobp_check(struct xfs_mount *, struct xfs_buf *); |
| 504 | #else |
| 505 | #define xfs_inobp_check(mp, bp) |
| 506 | #endif /* DEBUG */ |
| 507 | |
| 508 | extern struct kmem_zone *xfs_chashlist_zone; |
| 509 | extern struct kmem_zone *xfs_ifork_zone; |
| 510 | extern struct kmem_zone *xfs_inode_zone; |
| 511 | extern struct kmem_zone *xfs_ili_zone; |
| 512 | extern struct vnodeops xfs_vnodeops; |
| 513 | |
| 514 | #endif /* __KERNEL__ */ |
| 515 | |
| 516 | #endif /* __XFS_INODE_H__ */ |