xfs_inode.h 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644
  1. // SPDX-License-Identifier: GPL-2.0
  2. /*
  3. * Copyright (c) 2000-2003,2005 Silicon Graphics, Inc.
  4. * All Rights Reserved.
  5. */
  6. #ifndef __XFS_INODE_H__
  7. #define __XFS_INODE_H__
  8. #include "xfs_inode_buf.h"
  9. #include "xfs_inode_fork.h"
  10. #include "xfs_inode_util.h"
  11. /*
  12. * Kernel only inode definitions
  13. */
  14. struct xfs_dinode;
  15. struct xfs_inode;
  16. struct xfs_buf;
  17. struct xfs_bmbt_irec;
  18. struct xfs_inode_log_item;
  19. struct xfs_mount;
  20. struct xfs_trans;
  21. struct xfs_dquot;
  22. typedef struct xfs_inode {
  23. /* Inode linking and identification information. */
  24. struct xfs_mount *i_mount; /* fs mount struct ptr */
  25. struct xfs_dquot *i_udquot; /* user dquot */
  26. struct xfs_dquot *i_gdquot; /* group dquot */
  27. struct xfs_dquot *i_pdquot; /* project dquot */
  28. /* Inode location stuff */
  29. xfs_ino_t i_ino; /* inode number (agno/agino)*/
  30. struct xfs_imap i_imap; /* location for xfs_imap() */
  31. /* Extent information. */
  32. struct xfs_ifork *i_cowfp; /* copy on write extents */
  33. struct xfs_ifork i_df; /* data fork */
  34. struct xfs_ifork i_af; /* attribute fork */
  35. /* Transaction and locking information. */
  36. struct xfs_inode_log_item *i_itemp; /* logging information */
  37. struct rw_semaphore i_lock; /* inode lock */
  38. atomic_t i_pincount; /* inode pin count */
  39. struct llist_node i_gclist; /* deferred inactivation list */
  40. /*
  41. * Bitsets of inode metadata that have been checked and/or are sick.
  42. * Callers must hold i_flags_lock before accessing this field.
  43. */
  44. uint16_t i_checked;
  45. uint16_t i_sick;
  46. spinlock_t i_flags_lock; /* inode i_flags lock */
  47. /* Miscellaneous state. */
  48. unsigned long i_flags; /* see defined flags below */
  49. uint64_t i_delayed_blks; /* count of delay alloc blks */
  50. xfs_fsize_t i_disk_size; /* number of bytes in file */
  51. xfs_rfsblock_t i_nblocks; /* # of direct & btree blocks */
  52. prid_t i_projid; /* owner's project id */
  53. xfs_extlen_t i_extsize; /* basic/minimum extent size */
  54. /* cowextsize is only used for v3 inodes, flushiter for v1/2 */
  55. union {
  56. xfs_extlen_t i_cowextsize; /* basic cow extent size */
  57. uint16_t i_flushiter; /* incremented on flush */
  58. };
  59. uint8_t i_forkoff; /* attr fork offset >> 3 */
  60. uint16_t i_diflags; /* XFS_DIFLAG_... */
  61. uint64_t i_diflags2; /* XFS_DIFLAG2_... */
  62. struct timespec64 i_crtime; /* time created */
  63. /*
  64. * Unlinked list pointers. These point to the next and previous inodes
  65. * in the AGI unlinked bucket list, respectively. These fields can
  66. * only be updated with the AGI locked.
  67. *
  68. * i_next_unlinked caches di_next_unlinked.
  69. */
  70. xfs_agino_t i_next_unlinked;
  71. /*
  72. * If the inode is not on an unlinked list, this field is zero. If the
  73. * inode is the first element in an unlinked list, this field is
  74. * NULLAGINO. Otherwise, i_prev_unlinked points to the previous inode
  75. * in the unlinked list.
  76. */
  77. xfs_agino_t i_prev_unlinked;
  78. /* VFS inode */
  79. struct inode i_vnode; /* embedded VFS inode */
  80. /* pending io completions */
  81. spinlock_t i_ioend_lock;
  82. struct work_struct i_ioend_work;
  83. struct list_head i_ioend_list;
  84. } xfs_inode_t;
  85. static inline bool xfs_inode_on_unlinked_list(const struct xfs_inode *ip)
  86. {
  87. return ip->i_prev_unlinked != 0;
  88. }
  89. static inline bool xfs_inode_has_attr_fork(struct xfs_inode *ip)
  90. {
  91. return ip->i_forkoff > 0;
  92. }
  93. static inline struct xfs_ifork *
  94. xfs_ifork_ptr(
  95. struct xfs_inode *ip,
  96. int whichfork)
  97. {
  98. switch (whichfork) {
  99. case XFS_DATA_FORK:
  100. return &ip->i_df;
  101. case XFS_ATTR_FORK:
  102. if (!xfs_inode_has_attr_fork(ip))
  103. return NULL;
  104. return &ip->i_af;
  105. case XFS_COW_FORK:
  106. return ip->i_cowfp;
  107. default:
  108. ASSERT(0);
  109. return NULL;
  110. }
  111. }
  112. static inline unsigned int xfs_inode_fork_boff(struct xfs_inode *ip)
  113. {
  114. return ip->i_forkoff << 3;
  115. }
  116. static inline unsigned int xfs_inode_data_fork_size(struct xfs_inode *ip)
  117. {
  118. if (xfs_inode_has_attr_fork(ip))
  119. return xfs_inode_fork_boff(ip);
  120. return XFS_LITINO(ip->i_mount);
  121. }
  122. static inline unsigned int xfs_inode_attr_fork_size(struct xfs_inode *ip)
  123. {
  124. if (xfs_inode_has_attr_fork(ip))
  125. return XFS_LITINO(ip->i_mount) - xfs_inode_fork_boff(ip);
  126. return 0;
  127. }
  128. static inline unsigned int
  129. xfs_inode_fork_size(
  130. struct xfs_inode *ip,
  131. int whichfork)
  132. {
  133. switch (whichfork) {
  134. case XFS_DATA_FORK:
  135. return xfs_inode_data_fork_size(ip);
  136. case XFS_ATTR_FORK:
  137. return xfs_inode_attr_fork_size(ip);
  138. default:
  139. return 0;
  140. }
  141. }
  142. /* Convert from vfs inode to xfs inode */
  143. static inline struct xfs_inode *XFS_I(struct inode *inode)
  144. {
  145. return container_of(inode, struct xfs_inode, i_vnode);
  146. }
  147. /* convert from xfs inode to vfs inode */
  148. static inline struct inode *VFS_I(struct xfs_inode *ip)
  149. {
  150. return &ip->i_vnode;
  151. }
  152. /* convert from const xfs inode to const vfs inode */
  153. static inline const struct inode *VFS_IC(const struct xfs_inode *ip)
  154. {
  155. return &ip->i_vnode;
  156. }
  157. /*
  158. * For regular files we only update the on-disk filesize when actually
  159. * writing data back to disk. Until then only the copy in the VFS inode
  160. * is uptodate.
  161. */
  162. static inline xfs_fsize_t XFS_ISIZE(struct xfs_inode *ip)
  163. {
  164. if (S_ISREG(VFS_I(ip)->i_mode))
  165. return i_size_read(VFS_I(ip));
  166. return ip->i_disk_size;
  167. }
  168. /*
  169. * If this I/O goes past the on-disk inode size update it unless it would
  170. * be past the current in-core inode size.
  171. */
  172. static inline xfs_fsize_t
  173. xfs_new_eof(struct xfs_inode *ip, xfs_fsize_t new_size)
  174. {
  175. xfs_fsize_t i_size = i_size_read(VFS_I(ip));
  176. if (new_size > i_size || new_size < 0)
  177. new_size = i_size;
  178. return new_size > ip->i_disk_size ? new_size : 0;
  179. }
  180. /*
  181. * i_flags helper functions
  182. */
  183. static inline void
  184. __xfs_iflags_set(xfs_inode_t *ip, unsigned long flags)
  185. {
  186. ip->i_flags |= flags;
  187. }
  188. static inline void
  189. xfs_iflags_set(xfs_inode_t *ip, unsigned long flags)
  190. {
  191. spin_lock(&ip->i_flags_lock);
  192. __xfs_iflags_set(ip, flags);
  193. spin_unlock(&ip->i_flags_lock);
  194. }
  195. static inline void
  196. xfs_iflags_clear(xfs_inode_t *ip, unsigned long flags)
  197. {
  198. spin_lock(&ip->i_flags_lock);
  199. ip->i_flags &= ~flags;
  200. spin_unlock(&ip->i_flags_lock);
  201. }
  202. static inline int
  203. __xfs_iflags_test(xfs_inode_t *ip, unsigned long flags)
  204. {
  205. return (ip->i_flags & flags);
  206. }
  207. static inline int
  208. xfs_iflags_test(xfs_inode_t *ip, unsigned long flags)
  209. {
  210. int ret;
  211. spin_lock(&ip->i_flags_lock);
  212. ret = __xfs_iflags_test(ip, flags);
  213. spin_unlock(&ip->i_flags_lock);
  214. return ret;
  215. }
  216. static inline int
  217. xfs_iflags_test_and_clear(xfs_inode_t *ip, unsigned long flags)
  218. {
  219. int ret;
  220. spin_lock(&ip->i_flags_lock);
  221. ret = ip->i_flags & flags;
  222. if (ret)
  223. ip->i_flags &= ~flags;
  224. spin_unlock(&ip->i_flags_lock);
  225. return ret;
  226. }
  227. static inline int
  228. xfs_iflags_test_and_set(xfs_inode_t *ip, unsigned long flags)
  229. {
  230. int ret;
  231. spin_lock(&ip->i_flags_lock);
  232. ret = ip->i_flags & flags;
  233. if (!ret)
  234. ip->i_flags |= flags;
  235. spin_unlock(&ip->i_flags_lock);
  236. return ret;
  237. }
  238. static inline bool xfs_is_reflink_inode(struct xfs_inode *ip)
  239. {
  240. return ip->i_diflags2 & XFS_DIFLAG2_REFLINK;
  241. }
  242. static inline bool xfs_is_metadata_inode(const struct xfs_inode *ip)
  243. {
  244. struct xfs_mount *mp = ip->i_mount;
  245. return ip->i_ino == mp->m_sb.sb_rbmino ||
  246. ip->i_ino == mp->m_sb.sb_rsumino ||
  247. xfs_is_quota_inode(&mp->m_sb, ip->i_ino);
  248. }
  249. bool xfs_is_always_cow_inode(struct xfs_inode *ip);
  250. static inline bool xfs_is_cow_inode(struct xfs_inode *ip)
  251. {
  252. return xfs_is_reflink_inode(ip) || xfs_is_always_cow_inode(ip);
  253. }
  254. static inline bool xfs_inode_has_filedata(const struct xfs_inode *ip)
  255. {
  256. return ip->i_df.if_nextents > 0 || ip->i_delayed_blks > 0;
  257. }
  258. /*
  259. * Check if an inode has any data in the COW fork. This might be often false
  260. * even for inodes with the reflink flag when there is no pending COW operation.
  261. */
  262. static inline bool xfs_inode_has_cow_data(struct xfs_inode *ip)
  263. {
  264. return ip->i_cowfp && ip->i_cowfp->if_bytes;
  265. }
  266. static inline bool xfs_inode_has_bigtime(struct xfs_inode *ip)
  267. {
  268. return ip->i_diflags2 & XFS_DIFLAG2_BIGTIME;
  269. }
  270. static inline bool xfs_inode_has_large_extent_counts(struct xfs_inode *ip)
  271. {
  272. return ip->i_diflags2 & XFS_DIFLAG2_NREXT64;
  273. }
  274. /*
  275. * Decide if this file is a realtime file whose data allocation unit is larger
  276. * than a single filesystem block.
  277. */
  278. static inline bool xfs_inode_has_bigrtalloc(struct xfs_inode *ip)
  279. {
  280. return XFS_IS_REALTIME_INODE(ip) && ip->i_mount->m_sb.sb_rextsize > 1;
  281. }
  282. /*
  283. * Return the buftarg used for data allocations on a given inode.
  284. */
  285. #define xfs_inode_buftarg(ip) \
  286. (XFS_IS_REALTIME_INODE(ip) ? \
  287. (ip)->i_mount->m_rtdev_targp : (ip)->i_mount->m_ddev_targp)
  288. /*
  289. * In-core inode flags.
  290. */
  291. #define XFS_IRECLAIM (1 << 0) /* started reclaiming this inode */
  292. #define XFS_ISTALE (1 << 1) /* inode has been staled */
  293. #define XFS_IRECLAIMABLE (1 << 2) /* inode can be reclaimed */
  294. #define XFS_INEW (1 << 3) /* inode has just been allocated */
  295. #define XFS_IPRESERVE_DM_FIELDS (1 << 4) /* has legacy DMAPI fields set */
  296. #define XFS_ITRUNCATED (1 << 5) /* truncated down so flush-on-close */
  297. #define XFS_EOFBLOCKS_RELEASED (1 << 6) /* eofblocks were freed in ->release */
  298. #define XFS_IFLUSHING (1 << 7) /* inode is being flushed */
  299. #define __XFS_IPINNED_BIT 8 /* wakeup key for zero pin count */
  300. #define XFS_IPINNED (1 << __XFS_IPINNED_BIT)
  301. #define XFS_IEOFBLOCKS (1 << 9) /* has the preallocblocks tag set */
  302. #define XFS_NEED_INACTIVE (1 << 10) /* see XFS_INACTIVATING below */
  303. /*
  304. * If this unlinked inode is in the middle of recovery, don't let drop_inode
  305. * truncate and free the inode. This can happen if we iget the inode during
  306. * log recovery to replay a bmap operation on the inode.
  307. */
  308. #define XFS_IRECOVERY (1 << 11)
  309. #define XFS_ICOWBLOCKS (1 << 12)/* has the cowblocks tag set */
  310. /*
  311. * If we need to update on-disk metadata before this IRECLAIMABLE inode can be
  312. * freed, then NEED_INACTIVE will be set. Once we start the updates, the
  313. * INACTIVATING bit will be set to keep iget away from this inode. After the
  314. * inactivation completes, both flags will be cleared and the inode is a
  315. * plain old IRECLAIMABLE inode.
  316. */
  317. #define XFS_INACTIVATING (1 << 13)
  318. /* Quotacheck is running but inode has not been added to quota counts. */
  319. #define XFS_IQUOTAUNCHECKED (1 << 14)
  320. /*
  321. * Remap in progress. Callers that wish to update file data while
  322. * holding a shared IOLOCK or MMAPLOCK must drop the lock and retake
  323. * the lock in exclusive mode. Relocking the file will block until
  324. * IREMAPPING is cleared.
  325. */
  326. #define XFS_IREMAPPING (1U << 15)
  327. /* All inode state flags related to inode reclaim. */
  328. #define XFS_ALL_IRECLAIM_FLAGS (XFS_IRECLAIMABLE | \
  329. XFS_IRECLAIM | \
  330. XFS_NEED_INACTIVE | \
  331. XFS_INACTIVATING)
  332. /*
  333. * Per-lifetime flags need to be reset when re-using a reclaimable inode during
  334. * inode lookup. This prevents unintended behaviour on the new inode from
  335. * ocurring.
  336. */
  337. #define XFS_IRECLAIM_RESET_FLAGS \
  338. (XFS_IRECLAIMABLE | XFS_IRECLAIM | \
  339. XFS_EOFBLOCKS_RELEASED | XFS_ITRUNCATED | XFS_NEED_INACTIVE | \
  340. XFS_INACTIVATING | XFS_IQUOTAUNCHECKED)
  341. /*
  342. * Flags for inode locking.
  343. * Bit ranges: 1<<1 - 1<<16-1 -- iolock/ilock modes (bitfield)
  344. * 1<<16 - 1<<32-1 -- lockdep annotation (integers)
  345. */
  346. #define XFS_IOLOCK_EXCL (1u << 0)
  347. #define XFS_IOLOCK_SHARED (1u << 1)
  348. #define XFS_ILOCK_EXCL (1u << 2)
  349. #define XFS_ILOCK_SHARED (1u << 3)
  350. #define XFS_MMAPLOCK_EXCL (1u << 4)
  351. #define XFS_MMAPLOCK_SHARED (1u << 5)
  352. #define XFS_LOCK_MASK (XFS_IOLOCK_EXCL | XFS_IOLOCK_SHARED \
  353. | XFS_ILOCK_EXCL | XFS_ILOCK_SHARED \
  354. | XFS_MMAPLOCK_EXCL | XFS_MMAPLOCK_SHARED)
  355. #define XFS_LOCK_FLAGS \
  356. { XFS_IOLOCK_EXCL, "IOLOCK_EXCL" }, \
  357. { XFS_IOLOCK_SHARED, "IOLOCK_SHARED" }, \
  358. { XFS_ILOCK_EXCL, "ILOCK_EXCL" }, \
  359. { XFS_ILOCK_SHARED, "ILOCK_SHARED" }, \
  360. { XFS_MMAPLOCK_EXCL, "MMAPLOCK_EXCL" }, \
  361. { XFS_MMAPLOCK_SHARED, "MMAPLOCK_SHARED" }
  362. /*
  363. * Flags for lockdep annotations.
  364. *
  365. * XFS_LOCK_PARENT - for directory operations that require locking a
  366. * parent directory inode and a child entry inode. IOLOCK requires nesting,
  367. * MMAPLOCK does not support this class, ILOCK requires a single subclass
  368. * to differentiate parent from child.
  369. *
  370. * XFS_LOCK_RTBITMAP/XFS_LOCK_RTSUM - the realtime device bitmap and summary
  371. * inodes do not participate in the normal lock order, and thus have their
  372. * own subclasses.
  373. *
  374. * XFS_LOCK_INUMORDER - for locking several inodes at the some time
  375. * with xfs_lock_inodes(). This flag is used as the starting subclass
  376. * and each subsequent lock acquired will increment the subclass by one.
  377. * However, MAX_LOCKDEP_SUBCLASSES == 8, which means we are greatly
  378. * limited to the subclasses we can represent via nesting. We need at least
  379. * 5 inodes nest depth for the ILOCK through rename, and we also have to support
  380. * XFS_ILOCK_PARENT, which gives 6 subclasses. Then we have XFS_ILOCK_RTBITMAP
  381. * and XFS_ILOCK_RTSUM, which are another 2 unique subclasses, so that's all
  382. * 8 subclasses supported by lockdep.
  383. *
  384. * This also means we have to number the sub-classes in the lowest bits of
  385. * the mask we keep, and we have to ensure we never exceed 3 bits of lockdep
  386. * mask and we can't use bit-masking to build the subclasses. What a mess.
  387. *
  388. * Bit layout:
  389. *
  390. * Bit Lock Region
  391. * 16-19 XFS_IOLOCK_SHIFT dependencies
  392. * 20-23 XFS_MMAPLOCK_SHIFT dependencies
  393. * 24-31 XFS_ILOCK_SHIFT dependencies
  394. *
  395. * IOLOCK values
  396. *
  397. * 0-3 subclass value
  398. * 4-7 unused
  399. *
  400. * MMAPLOCK values
  401. *
  402. * 0-3 subclass value
  403. * 4-7 unused
  404. *
  405. * ILOCK values
  406. * 0-4 subclass values
  407. * 5 PARENT subclass (not nestable)
  408. * 6 RTBITMAP subclass (not nestable)
  409. * 7 RTSUM subclass (not nestable)
  410. *
  411. */
  412. #define XFS_IOLOCK_SHIFT 16
  413. #define XFS_IOLOCK_MAX_SUBCLASS 3
  414. #define XFS_IOLOCK_DEP_MASK 0x000f0000u
  415. #define XFS_MMAPLOCK_SHIFT 20
  416. #define XFS_MMAPLOCK_NUMORDER 0
  417. #define XFS_MMAPLOCK_MAX_SUBCLASS 3
  418. #define XFS_MMAPLOCK_DEP_MASK 0x00f00000u
  419. #define XFS_ILOCK_SHIFT 24
  420. #define XFS_ILOCK_PARENT_VAL 5u
  421. #define XFS_ILOCK_MAX_SUBCLASS (XFS_ILOCK_PARENT_VAL - 1)
  422. #define XFS_ILOCK_RTBITMAP_VAL 6u
  423. #define XFS_ILOCK_RTSUM_VAL 7u
  424. #define XFS_ILOCK_DEP_MASK 0xff000000u
  425. #define XFS_ILOCK_PARENT (XFS_ILOCK_PARENT_VAL << XFS_ILOCK_SHIFT)
  426. #define XFS_ILOCK_RTBITMAP (XFS_ILOCK_RTBITMAP_VAL << XFS_ILOCK_SHIFT)
  427. #define XFS_ILOCK_RTSUM (XFS_ILOCK_RTSUM_VAL << XFS_ILOCK_SHIFT)
  428. #define XFS_LOCK_SUBCLASS_MASK (XFS_IOLOCK_DEP_MASK | \
  429. XFS_MMAPLOCK_DEP_MASK | \
  430. XFS_ILOCK_DEP_MASK)
  431. #define XFS_IOLOCK_DEP(flags) (((flags) & XFS_IOLOCK_DEP_MASK) \
  432. >> XFS_IOLOCK_SHIFT)
  433. #define XFS_MMAPLOCK_DEP(flags) (((flags) & XFS_MMAPLOCK_DEP_MASK) \
  434. >> XFS_MMAPLOCK_SHIFT)
  435. #define XFS_ILOCK_DEP(flags) (((flags) & XFS_ILOCK_DEP_MASK) \
  436. >> XFS_ILOCK_SHIFT)
  437. /*
  438. * Layouts are broken in the BREAK_WRITE case to ensure that
  439. * layout-holders do not collide with local writes. Additionally,
  440. * layouts are broken in the BREAK_UNMAP case to make sure the
  441. * layout-holder has a consistent view of the file's extent map. While
  442. * BREAK_WRITE breaks can be satisfied by recalling FL_LAYOUT leases,
  443. * BREAK_UNMAP breaks additionally require waiting for busy dax-pages to
  444. * go idle.
  445. */
  446. enum layout_break_reason {
  447. BREAK_WRITE,
  448. BREAK_UNMAP,
  449. };
  450. /*
  451. * For multiple groups support: if S_ISGID bit is set in the parent
  452. * directory, group of new file is set to that of the parent, and
  453. * new subdirectory gets S_ISGID bit from parent.
  454. */
  455. #define XFS_INHERIT_GID(pip) \
  456. (xfs_has_grpid((pip)->i_mount) || (VFS_I(pip)->i_mode & S_ISGID))
  457. int xfs_inactive(struct xfs_inode *ip);
  458. int xfs_lookup(struct xfs_inode *dp, const struct xfs_name *name,
  459. struct xfs_inode **ipp, struct xfs_name *ci_name);
  460. int xfs_create(const struct xfs_icreate_args *iargs,
  461. struct xfs_name *name, struct xfs_inode **ipp);
  462. int xfs_create_tmpfile(const struct xfs_icreate_args *iargs,
  463. struct xfs_inode **ipp);
  464. int xfs_remove(struct xfs_inode *dp, struct xfs_name *name,
  465. struct xfs_inode *ip);
  466. int xfs_link(struct xfs_inode *tdp, struct xfs_inode *sip,
  467. struct xfs_name *target_name);
  468. int xfs_rename(struct mnt_idmap *idmap,
  469. struct xfs_inode *src_dp, struct xfs_name *src_name,
  470. struct xfs_inode *src_ip, struct xfs_inode *target_dp,
  471. struct xfs_name *target_name,
  472. struct xfs_inode *target_ip, unsigned int flags);
  473. void xfs_ilock(xfs_inode_t *, uint);
  474. int xfs_ilock_nowait(xfs_inode_t *, uint);
  475. void xfs_iunlock(xfs_inode_t *, uint);
  476. void xfs_ilock_demote(xfs_inode_t *, uint);
  477. void xfs_assert_ilocked(struct xfs_inode *, uint);
  478. uint xfs_ilock_data_map_shared(struct xfs_inode *);
  479. uint xfs_ilock_attr_map_shared(struct xfs_inode *);
  480. int xfs_ifree(struct xfs_trans *, struct xfs_inode *);
  481. int xfs_itruncate_extents_flags(struct xfs_trans **,
  482. struct xfs_inode *, int, xfs_fsize_t, int);
  483. void xfs_iext_realloc(xfs_inode_t *, int, int);
  484. int xfs_log_force_inode(struct xfs_inode *ip);
  485. void xfs_iunpin_wait(xfs_inode_t *);
  486. #define xfs_ipincount(ip) ((unsigned int) atomic_read(&ip->i_pincount))
  487. int xfs_iflush_cluster(struct xfs_buf *);
  488. void xfs_lock_two_inodes(struct xfs_inode *ip0, uint ip0_mode,
  489. struct xfs_inode *ip1, uint ip1_mode);
  490. int xfs_icreate(struct xfs_trans *tp, xfs_ino_t ino,
  491. const struct xfs_icreate_args *args, struct xfs_inode **ipp);
  492. static inline int
  493. xfs_itruncate_extents(
  494. struct xfs_trans **tpp,
  495. struct xfs_inode *ip,
  496. int whichfork,
  497. xfs_fsize_t new_size)
  498. {
  499. return xfs_itruncate_extents_flags(tpp, ip, whichfork, new_size, 0);
  500. }
  501. int xfs_break_dax_layouts(struct inode *inode, bool *retry);
  502. int xfs_break_layouts(struct inode *inode, uint *iolock,
  503. enum layout_break_reason reason);
  504. static inline void xfs_update_stable_writes(struct xfs_inode *ip)
  505. {
  506. if (bdev_stable_writes(xfs_inode_buftarg(ip)->bt_bdev))
  507. mapping_set_stable_writes(VFS_I(ip)->i_mapping);
  508. else
  509. mapping_clear_stable_writes(VFS_I(ip)->i_mapping);
  510. }
  511. /*
  512. * When setting up a newly allocated inode, we need to call
  513. * xfs_finish_inode_setup() once the inode is fully instantiated at
  514. * the VFS level to prevent the rest of the world seeing the inode
  515. * before we've completed instantiation. Otherwise we can do it
  516. * the moment the inode lookup is complete.
  517. */
  518. static inline void xfs_finish_inode_setup(struct xfs_inode *ip)
  519. {
  520. xfs_iflags_clear(ip, XFS_INEW);
  521. barrier();
  522. unlock_new_inode(VFS_I(ip));
  523. }
  524. static inline void xfs_setup_existing_inode(struct xfs_inode *ip)
  525. {
  526. xfs_setup_inode(ip);
  527. xfs_setup_iops(ip);
  528. xfs_finish_inode_setup(ip);
  529. }
  530. void xfs_irele(struct xfs_inode *ip);
  531. extern struct kmem_cache *xfs_inode_cache;
  532. /* The default CoW extent size hint. */
  533. #define XFS_DEFAULT_COWEXTSZ_HINT 32
  534. bool xfs_inode_needs_inactive(struct xfs_inode *ip);
  535. struct xfs_inode *xfs_iunlink_lookup(struct xfs_perag *pag, xfs_agino_t agino);
  536. int xfs_iunlink_reload_next(struct xfs_trans *tp, struct xfs_buf *agibp,
  537. xfs_agino_t prev_agino, xfs_agino_t next_agino);
  538. void xfs_end_io(struct work_struct *work);
  539. int xfs_ilock2_io_mmap(struct xfs_inode *ip1, struct xfs_inode *ip2);
  540. void xfs_iunlock2_io_mmap(struct xfs_inode *ip1, struct xfs_inode *ip2);
  541. void xfs_iunlock2_remapping(struct xfs_inode *ip1, struct xfs_inode *ip2);
  542. void xfs_lock_inodes(struct xfs_inode **ips, int inodes, uint lock_mode);
  543. void xfs_sort_inodes(struct xfs_inode **i_tab, unsigned int num_inodes);
  544. static inline bool
  545. xfs_inode_unlinked_incomplete(
  546. struct xfs_inode *ip)
  547. {
  548. return VFS_I(ip)->i_nlink == 0 && !xfs_inode_on_unlinked_list(ip);
  549. }
  550. int xfs_inode_reload_unlinked_bucket(struct xfs_trans *tp, struct xfs_inode *ip);
  551. int xfs_inode_reload_unlinked(struct xfs_inode *ip);
  552. bool xfs_ifork_zapped(const struct xfs_inode *ip, int whichfork);
  553. void xfs_inode_count_blocks(struct xfs_trans *tp, struct xfs_inode *ip,
  554. xfs_filblks_t *dblocks, xfs_filblks_t *rblocks);
  555. unsigned int xfs_inode_alloc_unitsize(struct xfs_inode *ip);
  556. int xfs_icreate_dqalloc(const struct xfs_icreate_args *args,
  557. struct xfs_dquot **udqpp, struct xfs_dquot **gdqpp,
  558. struct xfs_dquot **pdqpp);
  559. #endif /* __XFS_INODE_H__ */