xfs_inode.h 20 KB

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