Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

at v2.6.15-rc2 461 lines 15 kB view raw
1/* 2 * Copyright (c) 2000-2003,2005 Silicon Graphics, Inc. 3 * All Rights Reserved. 4 * 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 7 * published by the Free Software Foundation. 8 * 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. 13 * 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 17 */ 18#ifndef __XFS_INODE_H__ 19#define __XFS_INODE_H__ 20 21/* 22 * Fork identifiers. 23 */ 24#define XFS_DATA_FORK 0 25#define XFS_ATTR_FORK 1 26 27/* 28 * File incore extent information, present for each of data & attr forks. 29 */ 30#define XFS_INLINE_EXTS 2 31#define XFS_INLINE_DATA 32 32typedef struct xfs_ifork { 33 int if_bytes; /* bytes in if_u1 */ 34 int if_real_bytes; /* bytes allocated in if_u1 */ 35 xfs_bmbt_block_t *if_broot; /* file's incore btree root */ 36 short if_broot_bytes; /* bytes allocated for root */ 37 unsigned char if_flags; /* per-fork flags */ 38 unsigned char if_ext_max; /* max # of extent records */ 39 xfs_extnum_t if_lastex; /* last if_extents used */ 40 union { 41 xfs_bmbt_rec_t *if_extents; /* linear map file exts */ 42 char *if_data; /* inline file data */ 43 } if_u1; 44 union { 45 xfs_bmbt_rec_t if_inline_ext[XFS_INLINE_EXTS]; 46 /* very small file extents */ 47 char if_inline_data[XFS_INLINE_DATA]; 48 /* very small file data */ 49 xfs_dev_t if_rdev; /* dev number if special */ 50 uuid_t if_uuid; /* mount point value */ 51 } if_u2; 52} xfs_ifork_t; 53 54/* 55 * Flags for xfs_ichgtime(). 56 */ 57#define XFS_ICHGTIME_MOD 0x1 /* data fork modification timestamp */ 58#define XFS_ICHGTIME_ACC 0x2 /* data fork access timestamp */ 59#define XFS_ICHGTIME_CHG 0x4 /* inode field change timestamp */ 60 61/* 62 * Per-fork incore inode flags. 63 */ 64#define XFS_IFINLINE 0x0001 /* Inline data is read in */ 65#define XFS_IFEXTENTS 0x0002 /* All extent pointers are read in */ 66#define XFS_IFBROOT 0x0004 /* i_broot points to the bmap b-tree root */ 67 68/* 69 * Flags for xfs_imap() and xfs_dilocate(). 70 */ 71#define XFS_IMAP_LOOKUP 0x1 72 73/* 74 * Maximum number of extent pointers in if_u1.if_extents. 75 */ 76#define XFS_MAX_INCORE_EXTENTS 32768 77 78 79#ifdef __KERNEL__ 80struct bhv_desc; 81struct cred; 82struct ktrace; 83struct vnode; 84struct xfs_buf; 85struct xfs_bmap_free; 86struct xfs_bmbt_irec; 87struct xfs_bmbt_block; 88struct xfs_inode; 89struct xfs_inode_log_item; 90struct xfs_mount; 91struct xfs_trans; 92struct xfs_dquot; 93 94#if defined(XFS_ILOCK_TRACE) 95#define XFS_ILOCK_KTRACE_SIZE 32 96extern ktrace_t *xfs_ilock_trace_buf; 97extern void xfs_ilock_trace(struct xfs_inode *, int, unsigned int, inst_t *); 98#else 99#define xfs_ilock_trace(i,n,f,ra) 100#endif 101 102typedef struct dm_attrs_s { 103 __uint32_t da_dmevmask; /* DMIG event mask */ 104 __uint16_t da_dmstate; /* DMIG state info */ 105 __uint16_t da_pad; /* DMIG extra padding */ 106} dm_attrs_t; 107 108typedef struct xfs_iocore { 109 void *io_obj; /* pointer to container 110 * inode or dcxvn structure */ 111 struct xfs_mount *io_mount; /* fs mount struct ptr */ 112#ifdef DEBUG 113 mrlock_t *io_lock; /* inode IO lock */ 114 mrlock_t *io_iolock; /* inode IO lock */ 115#endif 116 117 /* I/O state */ 118 xfs_fsize_t io_new_size; /* sz when write completes */ 119 120 /* Miscellaneous state. */ 121 unsigned int io_flags; /* IO related flags */ 122 123 /* DMAPI state */ 124 dm_attrs_t io_dmattrs; 125 126} xfs_iocore_t; 127 128#define io_dmevmask io_dmattrs.da_dmevmask 129#define io_dmstate io_dmattrs.da_dmstate 130 131#define XFS_IO_INODE(io) ((xfs_inode_t *) ((io)->io_obj)) 132#define XFS_IO_DCXVN(io) ((dcxvn_t *) ((io)->io_obj)) 133 134/* 135 * Flags in the flags field 136 */ 137 138#define XFS_IOCORE_RT 0x1 139 140/* 141 * xfs_iocore prototypes 142 */ 143 144extern void xfs_iocore_inode_init(struct xfs_inode *); 145extern void xfs_iocore_inode_reinit(struct xfs_inode *); 146 147 148/* 149 * This is the type used in the xfs inode hash table. 150 * An array of these is allocated for each mounted 151 * file system to hash the inodes for that file system. 152 */ 153typedef struct xfs_ihash { 154 struct xfs_inode *ih_next; 155 rwlock_t ih_lock; 156 uint ih_version; 157} xfs_ihash_t; 158 159#define XFS_IHASH(mp,ino) ((mp)->m_ihash + (((uint)(ino)) % (mp)->m_ihsize)) 160 161/* 162 * This is the xfs inode cluster hash. This hash is used by xfs_iflush to 163 * find inodes that share a cluster and can be flushed to disk at the same 164 * time. 165 */ 166typedef struct xfs_chashlist { 167 struct xfs_chashlist *chl_next; 168 struct xfs_inode *chl_ip; 169 xfs_daddr_t chl_blkno; /* starting block number of 170 * the cluster */ 171 struct xfs_buf *chl_buf; /* the inode buffer */ 172} xfs_chashlist_t; 173 174typedef struct xfs_chash { 175 xfs_chashlist_t *ch_list; 176 lock_t ch_lock; 177} xfs_chash_t; 178 179#define XFS_CHASH(mp,blk) ((mp)->m_chash + (((uint)blk) % (mp)->m_chsize)) 180 181 182/* 183 * This is the xfs in-core inode structure. 184 * Most of the on-disk inode is embedded in the i_d field. 185 * 186 * The extent pointers/inline file space, however, are managed 187 * separately. The memory for this information is pointed to by 188 * the if_u1 unions depending on the type of the data. 189 * This is used to linearize the array of extents for fast in-core 190 * access. This is used until the file's number of extents 191 * surpasses XFS_MAX_INCORE_EXTENTS, at which point all extent pointers 192 * are accessed through the buffer cache. 193 * 194 * Other state kept in the in-core inode is used for identification, 195 * locking, transactional updating, etc of the inode. 196 * 197 * Generally, we do not want to hold the i_rlock while holding the 198 * i_ilock. Hierarchy is i_iolock followed by i_rlock. 199 * 200 * xfs_iptr_t contains all the inode fields upto and including the 201 * i_mnext and i_mprev fields, it is used as a marker in the inode 202 * chain off the mount structure by xfs_sync calls. 203 */ 204 205typedef struct { 206 struct xfs_ihash *ip_hash; /* pointer to hash header */ 207 struct xfs_inode *ip_next; /* inode hash link forw */ 208 struct xfs_inode *ip_mnext; /* next inode in mount list */ 209 struct xfs_inode *ip_mprev; /* ptr to prev inode */ 210 struct xfs_inode **ip_prevp; /* ptr to prev i_next */ 211 struct xfs_mount *ip_mount; /* fs mount struct ptr */ 212} xfs_iptr_t; 213 214typedef struct xfs_inode { 215 /* Inode linking and identification information. */ 216 struct xfs_ihash *i_hash; /* pointer to hash header */ 217 struct xfs_inode *i_next; /* inode hash link forw */ 218 struct xfs_inode *i_mnext; /* next inode in mount list */ 219 struct xfs_inode *i_mprev; /* ptr to prev inode */ 220 struct xfs_inode **i_prevp; /* ptr to prev i_next */ 221 struct xfs_mount *i_mount; /* fs mount struct ptr */ 222 struct list_head i_reclaim; /* reclaim list */ 223 struct bhv_desc i_bhv_desc; /* inode behavior descriptor*/ 224 struct xfs_dquot *i_udquot; /* user dquot */ 225 struct xfs_dquot *i_gdquot; /* group dquot */ 226 227 /* Inode location stuff */ 228 xfs_ino_t i_ino; /* inode number (agno/agino)*/ 229 xfs_daddr_t i_blkno; /* blkno of inode buffer */ 230 ushort i_len; /* len of inode buffer */ 231 ushort i_boffset; /* off of inode in buffer */ 232 233 /* Extent information. */ 234 xfs_ifork_t *i_afp; /* attribute fork pointer */ 235 xfs_ifork_t i_df; /* data fork */ 236 237 /* Transaction and locking information. */ 238 struct xfs_trans *i_transp; /* ptr to owning transaction*/ 239 struct xfs_inode_log_item *i_itemp; /* logging information */ 240 mrlock_t i_lock; /* inode lock */ 241 mrlock_t i_iolock; /* inode IO lock */ 242 sema_t i_flock; /* inode flush lock */ 243 atomic_t i_pincount; /* inode pin count */ 244 wait_queue_head_t i_ipin_wait; /* inode pinning wait queue */ 245#ifdef HAVE_REFCACHE 246 struct xfs_inode **i_refcache; /* ptr to entry in ref cache */ 247 struct xfs_inode *i_release; /* inode to unref */ 248#endif 249 /* I/O state */ 250 xfs_iocore_t i_iocore; /* I/O core */ 251 252 /* Miscellaneous state. */ 253 unsigned short i_flags; /* see defined flags below */ 254 unsigned char i_update_core; /* timestamps/size is dirty */ 255 unsigned char i_update_size; /* di_size field is dirty */ 256 unsigned int i_gen; /* generation count */ 257 unsigned int i_delayed_blks; /* count of delay alloc blks */ 258 259 xfs_dinode_core_t i_d; /* most of ondisk inode */ 260 xfs_chashlist_t *i_chash; /* cluster hash list header */ 261 struct xfs_inode *i_cnext; /* cluster hash link forward */ 262 struct xfs_inode *i_cprev; /* cluster hash link backward */ 263 264 /* Trace buffers per inode. */ 265#ifdef XFS_BMAP_TRACE 266 struct ktrace *i_xtrace; /* inode extent list trace */ 267#endif 268#ifdef XFS_BMBT_TRACE 269 struct ktrace *i_btrace; /* inode bmap btree trace */ 270#endif 271#ifdef XFS_RW_TRACE 272 struct ktrace *i_rwtrace; /* inode read/write trace */ 273#endif 274#ifdef XFS_ILOCK_TRACE 275 struct ktrace *i_lock_trace; /* inode lock/unlock trace */ 276#endif 277#ifdef XFS_DIR2_TRACE 278 struct ktrace *i_dir_trace; /* inode directory trace */ 279#endif 280} xfs_inode_t; 281 282#endif /* __KERNEL__ */ 283 284 285/* 286 * Fork handling. 287 */ 288#define XFS_IFORK_PTR(ip,w) \ 289 ((w) == XFS_DATA_FORK ? &(ip)->i_df : (ip)->i_afp) 290#define XFS_IFORK_Q(ip) XFS_CFORK_Q(&(ip)->i_d) 291#define XFS_IFORK_DSIZE(ip) XFS_CFORK_DSIZE(&ip->i_d, ip->i_mount) 292#define XFS_IFORK_ASIZE(ip) XFS_CFORK_ASIZE(&ip->i_d, ip->i_mount) 293#define XFS_IFORK_SIZE(ip,w) XFS_CFORK_SIZE(&ip->i_d, ip->i_mount, w) 294#define XFS_IFORK_FORMAT(ip,w) XFS_CFORK_FORMAT(&ip->i_d, w) 295#define XFS_IFORK_FMT_SET(ip,w,n) XFS_CFORK_FMT_SET(&ip->i_d, w, n) 296#define XFS_IFORK_NEXTENTS(ip,w) XFS_CFORK_NEXTENTS(&ip->i_d, w) 297#define XFS_IFORK_NEXT_SET(ip,w,n) XFS_CFORK_NEXT_SET(&ip->i_d, w, n) 298 299 300#ifdef __KERNEL__ 301 302/* 303 * In-core inode flags. 304 */ 305#define XFS_IGRIO 0x0001 /* inode used for guaranteed rate i/o */ 306#define XFS_IUIOSZ 0x0002 /* inode i/o sizes have been explicitly set */ 307#define XFS_IQUIESCE 0x0004 /* we have started quiescing for this inode */ 308#define XFS_IRECLAIM 0x0008 /* we have started reclaiming this inode */ 309#define XFS_ISTALE 0x0010 /* inode has been staled */ 310#define XFS_IRECLAIMABLE 0x0020 /* inode can be reclaimed */ 311#define XFS_INEW 0x0040 312 313/* 314 * Flags for inode locking. 315 */ 316#define XFS_IOLOCK_EXCL 0x001 317#define XFS_IOLOCK_SHARED 0x002 318#define XFS_ILOCK_EXCL 0x004 319#define XFS_ILOCK_SHARED 0x008 320#define XFS_IUNLOCK_NONOTIFY 0x010 321/* XFS_IOLOCK_NESTED 0x020 */ 322#define XFS_EXTENT_TOKEN_RD 0x040 323#define XFS_SIZE_TOKEN_RD 0x080 324#define XFS_EXTSIZE_RD (XFS_EXTENT_TOKEN_RD|XFS_SIZE_TOKEN_RD) 325#define XFS_WILLLEND 0x100 /* Always acquire tokens for lending */ 326#define XFS_EXTENT_TOKEN_WR (XFS_EXTENT_TOKEN_RD | XFS_WILLLEND) 327#define XFS_SIZE_TOKEN_WR (XFS_SIZE_TOKEN_RD | XFS_WILLLEND) 328#define XFS_EXTSIZE_WR (XFS_EXTSIZE_RD | XFS_WILLLEND) 329/* XFS_SIZE_TOKEN_WANT 0x200 */ 330 331#define XFS_LOCK_MASK \ 332 (XFS_IOLOCK_EXCL | XFS_IOLOCK_SHARED | XFS_ILOCK_EXCL | \ 333 XFS_ILOCK_SHARED | XFS_EXTENT_TOKEN_RD | XFS_SIZE_TOKEN_RD | \ 334 XFS_WILLLEND) 335 336/* 337 * Flags for xfs_iflush() 338 */ 339#define XFS_IFLUSH_DELWRI_ELSE_SYNC 1 340#define XFS_IFLUSH_DELWRI_ELSE_ASYNC 2 341#define XFS_IFLUSH_SYNC 3 342#define XFS_IFLUSH_ASYNC 4 343#define XFS_IFLUSH_DELWRI 5 344 345/* 346 * Flags for xfs_itruncate_start(). 347 */ 348#define XFS_ITRUNC_DEFINITE 0x1 349#define XFS_ITRUNC_MAYBE 0x2 350 351#define XFS_ITOV(ip) BHV_TO_VNODE(XFS_ITOBHV(ip)) 352#define XFS_ITOV_NULL(ip) BHV_TO_VNODE_NULL(XFS_ITOBHV(ip)) 353#define XFS_ITOBHV(ip) ((struct bhv_desc *)(&((ip)->i_bhv_desc))) 354#define XFS_BHVTOI(bhvp) ((xfs_inode_t *)((char *)(bhvp) - \ 355 (char *)&(((xfs_inode_t *)0)->i_bhv_desc))) 356#define BHV_IS_XFS(bdp) (BHV_OPS(bdp) == &xfs_vnodeops) 357 358/* 359 * For multiple groups support: if S_ISGID bit is set in the parent 360 * directory, group of new file is set to that of the parent, and 361 * new subdirectory gets S_ISGID bit from parent. 362 */ 363#define XFS_INHERIT_GID(pip, vfsp) \ 364 (((vfsp)->vfs_flag & VFS_GRPID) || ((pip)->i_d.di_mode & S_ISGID)) 365 366/* 367 * xfs_iget.c prototypes. 368 */ 369 370#define IGET_CREATE 1 371 372void xfs_ihash_init(struct xfs_mount *); 373void xfs_ihash_free(struct xfs_mount *); 374void xfs_chash_init(struct xfs_mount *); 375void xfs_chash_free(struct xfs_mount *); 376xfs_inode_t *xfs_inode_incore(struct xfs_mount *, xfs_ino_t, 377 struct xfs_trans *); 378void xfs_inode_lock_init(xfs_inode_t *, struct vnode *); 379int xfs_iget(struct xfs_mount *, struct xfs_trans *, xfs_ino_t, 380 uint, uint, xfs_inode_t **, xfs_daddr_t); 381void xfs_iput(xfs_inode_t *, uint); 382void xfs_iput_new(xfs_inode_t *, uint); 383void xfs_ilock(xfs_inode_t *, uint); 384int xfs_ilock_nowait(xfs_inode_t *, uint); 385void xfs_iunlock(xfs_inode_t *, uint); 386void xfs_ilock_demote(xfs_inode_t *, uint); 387void xfs_iflock(xfs_inode_t *); 388int xfs_iflock_nowait(xfs_inode_t *); 389uint xfs_ilock_map_shared(xfs_inode_t *); 390void xfs_iunlock_map_shared(xfs_inode_t *, uint); 391void xfs_ifunlock(xfs_inode_t *); 392void xfs_ireclaim(xfs_inode_t *); 393int xfs_finish_reclaim(xfs_inode_t *, int, int); 394int xfs_finish_reclaim_all(struct xfs_mount *, int); 395 396/* 397 * xfs_inode.c prototypes. 398 */ 399int xfs_itobp(struct xfs_mount *, struct xfs_trans *, 400 xfs_inode_t *, xfs_dinode_t **, struct xfs_buf **, 401 xfs_daddr_t); 402int xfs_iread(struct xfs_mount *, struct xfs_trans *, xfs_ino_t, 403 xfs_inode_t **, xfs_daddr_t); 404int xfs_iread_extents(struct xfs_trans *, xfs_inode_t *, int); 405int xfs_ialloc(struct xfs_trans *, xfs_inode_t *, mode_t, 406 xfs_nlink_t, xfs_dev_t, struct cred *, xfs_prid_t, 407 int, struct xfs_buf **, boolean_t *, xfs_inode_t **); 408void xfs_xlate_dinode_core(xfs_caddr_t, struct xfs_dinode_core *, 409 int); 410uint xfs_ip2xflags(struct xfs_inode *); 411uint xfs_dic2xflags(struct xfs_dinode_core *); 412int xfs_ifree(struct xfs_trans *, xfs_inode_t *, 413 struct xfs_bmap_free *); 414void xfs_itruncate_start(xfs_inode_t *, uint, xfs_fsize_t); 415int xfs_itruncate_finish(struct xfs_trans **, xfs_inode_t *, 416 xfs_fsize_t, int, int); 417int xfs_iunlink(struct xfs_trans *, xfs_inode_t *); 418int xfs_igrow_start(xfs_inode_t *, xfs_fsize_t, struct cred *); 419void xfs_igrow_finish(struct xfs_trans *, xfs_inode_t *, 420 xfs_fsize_t, int); 421 422void xfs_idestroy_fork(xfs_inode_t *, int); 423void xfs_idestroy(xfs_inode_t *); 424void xfs_idata_realloc(xfs_inode_t *, int, int); 425void xfs_iextract(xfs_inode_t *); 426void xfs_iext_realloc(xfs_inode_t *, int, int); 427void xfs_iroot_realloc(xfs_inode_t *, int, int); 428void xfs_ipin(xfs_inode_t *); 429void xfs_iunpin(xfs_inode_t *); 430int xfs_iextents_copy(xfs_inode_t *, xfs_bmbt_rec_t *, int); 431int xfs_iflush(xfs_inode_t *, uint); 432void xfs_iflush_all(struct xfs_mount *); 433int xfs_iaccess(xfs_inode_t *, mode_t, cred_t *); 434uint xfs_iroundup(uint); 435void xfs_ichgtime(xfs_inode_t *, int); 436xfs_fsize_t xfs_file_last_byte(xfs_inode_t *); 437void xfs_lock_inodes(xfs_inode_t **, int, int, uint); 438 439#define xfs_ipincount(ip) ((unsigned int) atomic_read(&ip->i_pincount)) 440 441#ifdef DEBUG 442void xfs_isize_check(struct xfs_mount *, xfs_inode_t *, xfs_fsize_t); 443#else /* DEBUG */ 444#define xfs_isize_check(mp, ip, isize) 445#endif /* DEBUG */ 446 447#if defined(DEBUG) 448void xfs_inobp_check(struct xfs_mount *, struct xfs_buf *); 449#else 450#define xfs_inobp_check(mp, bp) 451#endif /* DEBUG */ 452 453extern struct kmem_zone *xfs_chashlist_zone; 454extern struct kmem_zone *xfs_ifork_zone; 455extern struct kmem_zone *xfs_inode_zone; 456extern struct kmem_zone *xfs_ili_zone; 457extern struct vnodeops xfs_vnodeops; 458 459#endif /* __KERNEL__ */ 460 461#endif /* __XFS_INODE_H__ */