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