xfs_inode.h 17 KB

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