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