]>
Commit | Line | Data |
---|---|---|
1da177e4 | 1 | /* |
7b718769 NS |
2 | * Copyright (c) 2000-2003,2005 Silicon Graphics, Inc. |
3 | * All Rights Reserved. | |
1da177e4 | 4 | * |
7b718769 NS |
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 | |
1da177e4 LT |
7 | * published by the Free Software Foundation. |
8 | * | |
7b718769 NS |
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. | |
1da177e4 | 13 | * |
7b718769 NS |
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 | |
1da177e4 LT |
17 | */ |
18 | #ifndef __XFS_INODE_H__ | |
19 | #define __XFS_INODE_H__ | |
20 | ||
ef14f0c1 | 21 | struct posix_acl; |
347d1c01 | 22 | struct xfs_dinode; |
847fff5c | 23 | struct xfs_inode; |
347d1c01 | 24 | |
0293ce3a MK |
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 { | |
a6f64d4a | 45 | xfs_bmbt_rec_host_t *er_extbuf; /* block of extent records */ |
0293ce3a MK |
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 | ||
1da177e4 LT |
50 | /* |
51 | * File incore extent information, present for each of data & attr forks. | |
52 | */ | |
0293ce3a MK |
53 | #define XFS_IEXT_BUFSZ 4096 |
54 | #define XFS_LINEAR_EXTS (XFS_IEXT_BUFSZ / (uint)sizeof(xfs_bmbt_rec_t)) | |
55 | #define XFS_INLINE_EXTS 2 | |
56 | #define XFS_INLINE_DATA 32 | |
1da177e4 LT |
57 | typedef struct xfs_ifork { |
58 | int if_bytes; /* bytes in if_u1 */ | |
59 | int if_real_bytes; /* bytes allocated in if_u1 */ | |
7cc95a82 | 60 | struct xfs_btree_block *if_broot; /* file's incore btree root */ |
1da177e4 LT |
61 | short if_broot_bytes; /* bytes allocated for root */ |
62 | unsigned char if_flags; /* per-fork flags */ | |
1da177e4 | 63 | union { |
a6f64d4a | 64 | xfs_bmbt_rec_host_t *if_extents;/* linear map file exts */ |
0293ce3a | 65 | xfs_ext_irec_t *if_ext_irec; /* irec map file exts */ |
1da177e4 LT |
66 | char *if_data; /* inline file data */ |
67 | } if_u1; | |
68 | union { | |
a6f64d4a | 69 | xfs_bmbt_rec_host_t if_inline_ext[XFS_INLINE_EXTS]; |
1da177e4 LT |
70 | /* very small file extents */ |
71 | char if_inline_data[XFS_INLINE_DATA]; | |
72 | /* very small file data */ | |
73 | xfs_dev_t if_rdev; /* dev number if special */ | |
74 | uuid_t if_uuid; /* mount point value */ | |
75 | } if_u2; | |
76 | } xfs_ifork_t; | |
77 | ||
92bfc6e7 CH |
78 | /* |
79 | * Inode location information. Stored in the inode and passed to | |
80 | * xfs_imap_to_bp() to get a buffer and dinode for a given inode. | |
81 | */ | |
82 | struct xfs_imap { | |
83 | xfs_daddr_t im_blkno; /* starting BB of inode chunk */ | |
84 | ushort im_len; /* length in BBs of inode chunk */ | |
85 | ushort im_boffset; /* inode offset in block in bytes */ | |
86 | }; | |
87 | ||
1da177e4 LT |
88 | /* |
89 | * This is the xfs in-core inode structure. | |
90 | * Most of the on-disk inode is embedded in the i_d field. | |
91 | * | |
92 | * The extent pointers/inline file space, however, are managed | |
93 | * separately. The memory for this information is pointed to by | |
94 | * the if_u1 unions depending on the type of the data. | |
95 | * This is used to linearize the array of extents for fast in-core | |
96 | * access. This is used until the file's number of extents | |
97 | * surpasses XFS_MAX_INCORE_EXTENTS, at which point all extent pointers | |
98 | * are accessed through the buffer cache. | |
99 | * | |
100 | * Other state kept in the in-core inode is used for identification, | |
101 | * locking, transactional updating, etc of the inode. | |
102 | * | |
103 | * Generally, we do not want to hold the i_rlock while holding the | |
104 | * i_ilock. Hierarchy is i_iolock followed by i_rlock. | |
105 | * | |
25985edc | 106 | * xfs_iptr_t contains all the inode fields up to and including the |
1da177e4 LT |
107 | * i_mnext and i_mprev fields, it is used as a marker in the inode |
108 | * chain off the mount structure by xfs_sync calls. | |
109 | */ | |
110 | ||
847fff5c BN |
111 | /* |
112 | * Flags for xfs_ichgtime(). | |
113 | */ | |
114 | #define XFS_ICHGTIME_MOD 0x1 /* data fork modification timestamp */ | |
115 | #define XFS_ICHGTIME_CHG 0x2 /* inode field change timestamp */ | |
93848a99 | 116 | #define XFS_ICHGTIME_CREATE 0x4 /* inode create timestamp */ |
847fff5c BN |
117 | |
118 | /* | |
119 | * Per-fork incore inode flags. | |
120 | */ | |
121 | #define XFS_IFINLINE 0x01 /* Inline data is read in */ | |
122 | #define XFS_IFEXTENTS 0x02 /* All extent pointers are read in */ | |
123 | #define XFS_IFBROOT 0x04 /* i_broot points to the bmap b-tree root */ | |
124 | #define XFS_IFEXTIREC 0x08 /* Indirection array of extent blocks */ | |
125 | ||
847fff5c BN |
126 | /* |
127 | * Fork handling. | |
128 | */ | |
129 | ||
130 | #define XFS_IFORK_Q(ip) ((ip)->i_d.di_forkoff != 0) | |
131 | #define XFS_IFORK_BOFF(ip) ((int)((ip)->i_d.di_forkoff << 3)) | |
132 | ||
133 | #define XFS_IFORK_PTR(ip,w) \ | |
134 | ((w) == XFS_DATA_FORK ? \ | |
135 | &(ip)->i_df : \ | |
136 | (ip)->i_afp) | |
137 | #define XFS_IFORK_DSIZE(ip) \ | |
138 | (XFS_IFORK_Q(ip) ? \ | |
139 | XFS_IFORK_BOFF(ip) : \ | |
56cea2d0 | 140 | XFS_LITINO((ip)->i_mount, (ip)->i_d.di_version)) |
847fff5c BN |
141 | #define XFS_IFORK_ASIZE(ip) \ |
142 | (XFS_IFORK_Q(ip) ? \ | |
56cea2d0 CH |
143 | XFS_LITINO((ip)->i_mount, (ip)->i_d.di_version) - \ |
144 | XFS_IFORK_BOFF(ip) : \ | |
847fff5c BN |
145 | 0) |
146 | #define XFS_IFORK_SIZE(ip,w) \ | |
147 | ((w) == XFS_DATA_FORK ? \ | |
148 | XFS_IFORK_DSIZE(ip) : \ | |
149 | XFS_IFORK_ASIZE(ip)) | |
150 | #define XFS_IFORK_FORMAT(ip,w) \ | |
151 | ((w) == XFS_DATA_FORK ? \ | |
152 | (ip)->i_d.di_format : \ | |
153 | (ip)->i_d.di_aformat) | |
154 | #define XFS_IFORK_FMT_SET(ip,w,n) \ | |
155 | ((w) == XFS_DATA_FORK ? \ | |
156 | ((ip)->i_d.di_format = (n)) : \ | |
157 | ((ip)->i_d.di_aformat = (n))) | |
158 | #define XFS_IFORK_NEXTENTS(ip,w) \ | |
159 | ((w) == XFS_DATA_FORK ? \ | |
160 | (ip)->i_d.di_nextents : \ | |
161 | (ip)->i_d.di_anextents) | |
162 | #define XFS_IFORK_NEXT_SET(ip,w,n) \ | |
163 | ((w) == XFS_DATA_FORK ? \ | |
164 | ((ip)->i_d.di_nextents = (n)) : \ | |
165 | ((ip)->i_d.di_anextents = (n))) | |
8096b1eb CH |
166 | #define XFS_IFORK_MAXEXT(ip, w) \ |
167 | (XFS_IFORK_SIZE(ip, w) / sizeof(xfs_bmbt_rec_t)) | |
847fff5c BN |
168 | |
169 | ||
170 | #ifdef __KERNEL__ | |
171 | ||
847fff5c BN |
172 | struct xfs_buf; |
173 | struct xfs_bmap_free; | |
174 | struct xfs_bmbt_irec; | |
847fff5c BN |
175 | struct xfs_inode_log_item; |
176 | struct xfs_mount; | |
177 | struct xfs_trans; | |
178 | struct xfs_dquot; | |
179 | ||
1da177e4 LT |
180 | typedef struct xfs_inode { |
181 | /* Inode linking and identification information. */ | |
1da177e4 | 182 | struct xfs_mount *i_mount; /* fs mount struct ptr */ |
1da177e4 LT |
183 | struct xfs_dquot *i_udquot; /* user dquot */ |
184 | struct xfs_dquot *i_gdquot; /* group dquot */ | |
92f8ff73 | 185 | struct xfs_dquot *i_pdquot; /* project dquot */ |
1da177e4 LT |
186 | |
187 | /* Inode location stuff */ | |
188 | xfs_ino_t i_ino; /* inode number (agno/agino)*/ | |
92bfc6e7 | 189 | struct xfs_imap i_imap; /* location for xfs_imap() */ |
1da177e4 LT |
190 | |
191 | /* Extent information. */ | |
192 | xfs_ifork_t *i_afp; /* attribute fork pointer */ | |
193 | xfs_ifork_t i_df; /* data fork */ | |
194 | ||
195 | /* Transaction and locking information. */ | |
1da177e4 LT |
196 | struct xfs_inode_log_item *i_itemp; /* logging information */ |
197 | mrlock_t i_lock; /* inode lock */ | |
198 | mrlock_t i_iolock; /* inode IO lock */ | |
1da177e4 | 199 | atomic_t i_pincount; /* inode pin count */ |
f273ab84 | 200 | spinlock_t i_flags_lock; /* inode i_flags lock */ |
1da177e4 | 201 | /* Miscellaneous state. */ |
49e4c70e | 202 | unsigned long i_flags; /* see defined flags below */ |
1da177e4 LT |
203 | unsigned int i_delayed_blks; /* count of delay alloc blks */ |
204 | ||
347d1c01 | 205 | xfs_icdinode_t i_d; /* most of ondisk inode */ |
1da177e4 | 206 | |
bf904248 DC |
207 | /* VFS inode */ |
208 | struct inode i_vnode; /* embedded VFS inode */ | |
1da177e4 LT |
209 | } xfs_inode_t; |
210 | ||
01651646 DC |
211 | /* Convert from vfs inode to xfs inode */ |
212 | static inline struct xfs_inode *XFS_I(struct inode *inode) | |
213 | { | |
bf904248 | 214 | return container_of(inode, struct xfs_inode, i_vnode); |
01651646 DC |
215 | } |
216 | ||
01651646 DC |
217 | /* convert from xfs inode to vfs inode */ |
218 | static inline struct inode *VFS_I(struct xfs_inode *ip) | |
219 | { | |
bf904248 | 220 | return &ip->i_vnode; |
01651646 | 221 | } |
01651646 | 222 | |
ce7ae151 CH |
223 | /* |
224 | * For regular files we only update the on-disk filesize when actually | |
225 | * writing data back to disk. Until then only the copy in the VFS inode | |
226 | * is uptodate. | |
227 | */ | |
228 | static inline xfs_fsize_t XFS_ISIZE(struct xfs_inode *ip) | |
229 | { | |
230 | if (S_ISREG(ip->i_d.di_mode)) | |
231 | return i_size_read(VFS_I(ip)); | |
232 | return ip->i_d.di_size; | |
233 | } | |
234 | ||
6923e686 CH |
235 | /* |
236 | * If this I/O goes past the on-disk inode size update it unless it would | |
237 | * be past the current in-core inode size. | |
238 | */ | |
239 | static inline xfs_fsize_t | |
240 | xfs_new_eof(struct xfs_inode *ip, xfs_fsize_t new_size) | |
241 | { | |
242 | xfs_fsize_t i_size = i_size_read(VFS_I(ip)); | |
243 | ||
244 | if (new_size > i_size) | |
245 | new_size = i_size; | |
246 | return new_size > ip->i_d.di_size ? new_size : 0; | |
247 | } | |
248 | ||
7a18c386 DC |
249 | /* |
250 | * i_flags helper functions | |
251 | */ | |
252 | static inline void | |
253 | __xfs_iflags_set(xfs_inode_t *ip, unsigned short flags) | |
254 | { | |
255 | ip->i_flags |= flags; | |
256 | } | |
257 | ||
258 | static inline void | |
259 | xfs_iflags_set(xfs_inode_t *ip, unsigned short flags) | |
260 | { | |
261 | spin_lock(&ip->i_flags_lock); | |
262 | __xfs_iflags_set(ip, flags); | |
263 | spin_unlock(&ip->i_flags_lock); | |
264 | } | |
265 | ||
266 | static inline void | |
267 | xfs_iflags_clear(xfs_inode_t *ip, unsigned short flags) | |
268 | { | |
269 | spin_lock(&ip->i_flags_lock); | |
270 | ip->i_flags &= ~flags; | |
271 | spin_unlock(&ip->i_flags_lock); | |
272 | } | |
273 | ||
274 | static inline int | |
275 | __xfs_iflags_test(xfs_inode_t *ip, unsigned short flags) | |
276 | { | |
277 | return (ip->i_flags & flags); | |
278 | } | |
279 | ||
280 | static inline int | |
281 | xfs_iflags_test(xfs_inode_t *ip, unsigned short flags) | |
282 | { | |
283 | int ret; | |
284 | spin_lock(&ip->i_flags_lock); | |
285 | ret = __xfs_iflags_test(ip, flags); | |
286 | spin_unlock(&ip->i_flags_lock); | |
287 | return ret; | |
288 | } | |
09262b43 CH |
289 | |
290 | static inline int | |
291 | xfs_iflags_test_and_clear(xfs_inode_t *ip, unsigned short flags) | |
292 | { | |
293 | int ret; | |
294 | ||
295 | spin_lock(&ip->i_flags_lock); | |
296 | ret = ip->i_flags & flags; | |
297 | if (ret) | |
298 | ip->i_flags &= ~flags; | |
299 | spin_unlock(&ip->i_flags_lock); | |
300 | return ret; | |
301 | } | |
1da177e4 | 302 | |
474fce06 CH |
303 | static inline int |
304 | xfs_iflags_test_and_set(xfs_inode_t *ip, unsigned short flags) | |
305 | { | |
306 | int ret; | |
307 | ||
308 | spin_lock(&ip->i_flags_lock); | |
309 | ret = ip->i_flags & flags; | |
310 | if (!ret) | |
311 | ip->i_flags |= flags; | |
312 | spin_unlock(&ip->i_flags_lock); | |
313 | return ret; | |
314 | } | |
315 | ||
6743099c AM |
316 | /* |
317 | * Project quota id helpers (previously projid was 16bit only | |
25985edc | 318 | * and using two 16bit values to hold new 32bit projid was chosen |
6743099c AM |
319 | * to retain compatibility with "old" filesystems). |
320 | */ | |
321 | static inline prid_t | |
322 | xfs_get_projid(struct xfs_inode *ip) | |
323 | { | |
324 | return (prid_t)ip->i_d.di_projid_hi << 16 | ip->i_d.di_projid_lo; | |
325 | } | |
326 | ||
327 | static inline void | |
328 | xfs_set_projid(struct xfs_inode *ip, | |
329 | prid_t projid) | |
330 | { | |
331 | ip->i_d.di_projid_hi = (__uint16_t) (projid >> 16); | |
332 | ip->i_d.di_projid_lo = (__uint16_t) (projid & 0xffff); | |
333 | } | |
334 | ||
1da177e4 LT |
335 | /* |
336 | * In-core inode flags. | |
337 | */ | |
474fce06 CH |
338 | #define XFS_IRECLAIM (1 << 0) /* started reclaiming this inode */ |
339 | #define XFS_ISTALE (1 << 1) /* inode has been staled */ | |
340 | #define XFS_IRECLAIMABLE (1 << 2) /* inode can be reclaimed */ | |
341 | #define XFS_INEW (1 << 3) /* inode has just been allocated */ | |
342 | #define XFS_IFILESTREAM (1 << 4) /* inode is in a filestream dir. */ | |
343 | #define XFS_ITRUNCATED (1 << 5) /* truncated down so flush-on-close */ | |
344 | #define XFS_IDIRTY_RELEASE (1 << 6) /* dirty release already seen */ | |
345 | #define __XFS_IFLOCK_BIT 7 /* inode is being flushed right now */ | |
346 | #define XFS_IFLOCK (1 << __XFS_IFLOCK_BIT) | |
f392e631 CH |
347 | #define __XFS_IPINNED_BIT 8 /* wakeup key for zero pin count */ |
348 | #define XFS_IPINNED (1 << __XFS_IPINNED_BIT) | |
5132ba8f | 349 | #define XFS_IDONTCACHE (1 << 9) /* don't cache the inode long term */ |
1da177e4 | 350 | |
778e24bb DC |
351 | /* |
352 | * Per-lifetime flags need to be reset when re-using a reclaimable inode during | |
5132ba8f | 353 | * inode lookup. This prevents unintended behaviour on the new inode from |
778e24bb DC |
354 | * ocurring. |
355 | */ | |
356 | #define XFS_IRECLAIM_RESET_FLAGS \ | |
357 | (XFS_IRECLAIMABLE | XFS_IRECLAIM | \ | |
358 | XFS_IDIRTY_RELEASE | XFS_ITRUNCATED | \ | |
359 | XFS_IFILESTREAM); | |
360 | ||
474fce06 CH |
361 | /* |
362 | * Synchronize processes attempting to flush the in-core inode back to disk. | |
363 | */ | |
364 | ||
365 | extern void __xfs_iflock(struct xfs_inode *ip); | |
366 | ||
367 | static inline int xfs_iflock_nowait(struct xfs_inode *ip) | |
368 | { | |
369 | return !xfs_iflags_test_and_set(ip, XFS_IFLOCK); | |
370 | } | |
371 | ||
372 | static inline void xfs_iflock(struct xfs_inode *ip) | |
373 | { | |
374 | if (!xfs_iflock_nowait(ip)) | |
375 | __xfs_iflock(ip); | |
376 | } | |
377 | ||
378 | static inline void xfs_ifunlock(struct xfs_inode *ip) | |
379 | { | |
380 | xfs_iflags_clear(ip, XFS_IFLOCK); | |
311f08ac | 381 | smp_mb(); |
474fce06 CH |
382 | wake_up_bit(&ip->i_flags, __XFS_IFLOCK_BIT); |
383 | } | |
384 | ||
385 | static inline int xfs_isiflocked(struct xfs_inode *ip) | |
386 | { | |
387 | return xfs_iflags_test(ip, XFS_IFLOCK); | |
388 | } | |
389 | ||
1da177e4 LT |
390 | /* |
391 | * Flags for inode locking. | |
f7c66ce3 LM |
392 | * Bit ranges: 1<<1 - 1<<16-1 -- iolock/ilock modes (bitfield) |
393 | * 1<<16 - 1<<32-1 -- lockdep annotation (integers) | |
1da177e4 | 394 | */ |
f7c66ce3 LM |
395 | #define XFS_IOLOCK_EXCL (1<<0) |
396 | #define XFS_IOLOCK_SHARED (1<<1) | |
397 | #define XFS_ILOCK_EXCL (1<<2) | |
398 | #define XFS_ILOCK_SHARED (1<<3) | |
1da177e4 | 399 | |
f7c66ce3 | 400 | #define XFS_LOCK_MASK (XFS_IOLOCK_EXCL | XFS_IOLOCK_SHARED \ |
579aa9ca | 401 | | XFS_ILOCK_EXCL | XFS_ILOCK_SHARED) |
f7c66ce3 | 402 | |
0b1b213f CH |
403 | #define XFS_LOCK_FLAGS \ |
404 | { XFS_IOLOCK_EXCL, "IOLOCK_EXCL" }, \ | |
405 | { XFS_IOLOCK_SHARED, "IOLOCK_SHARED" }, \ | |
406 | { XFS_ILOCK_EXCL, "ILOCK_EXCL" }, \ | |
5b03ff1b | 407 | { XFS_ILOCK_SHARED, "ILOCK_SHARED" } |
0b1b213f CH |
408 | |
409 | ||
f7c66ce3 LM |
410 | /* |
411 | * Flags for lockdep annotations. | |
412 | * | |
9681153b CH |
413 | * XFS_LOCK_PARENT - for directory operations that require locking a |
414 | * parent directory inode and a child entry inode. The parent gets locked | |
415 | * with this flag so it gets a lockdep subclass of 1 and the child entry | |
416 | * lock will have a lockdep subclass of 0. | |
417 | * | |
418 | * XFS_LOCK_RTBITMAP/XFS_LOCK_RTSUM - the realtime device bitmap and summary | |
419 | * inodes do not participate in the normal lock order, and thus have their | |
420 | * own subclasses. | |
f7c66ce3 | 421 | * |
0f1145cc | 422 | * XFS_LOCK_INUMORDER - for locking several inodes at the some time |
f7c66ce3 LM |
423 | * with xfs_lock_inodes(). This flag is used as the starting subclass |
424 | * and each subsequent lock acquired will increment the subclass by one. | |
9681153b CH |
425 | * So the first lock acquired will have a lockdep subclass of 4, the |
426 | * second lock will have a lockdep subclass of 5, and so on. It is | |
0f1145cc DC |
427 | * the responsibility of the class builder to shift this to the correct |
428 | * portion of the lock_mode lockdep mask. | |
f7c66ce3 | 429 | */ |
0f1145cc | 430 | #define XFS_LOCK_PARENT 1 |
9681153b CH |
431 | #define XFS_LOCK_RTBITMAP 2 |
432 | #define XFS_LOCK_RTSUM 3 | |
433 | #define XFS_LOCK_INUMORDER 4 | |
0f1145cc | 434 | |
f7c66ce3 | 435 | #define XFS_IOLOCK_SHIFT 16 |
0f1145cc | 436 | #define XFS_IOLOCK_PARENT (XFS_LOCK_PARENT << XFS_IOLOCK_SHIFT) |
f7c66ce3 LM |
437 | |
438 | #define XFS_ILOCK_SHIFT 24 | |
0f1145cc | 439 | #define XFS_ILOCK_PARENT (XFS_LOCK_PARENT << XFS_ILOCK_SHIFT) |
9681153b CH |
440 | #define XFS_ILOCK_RTBITMAP (XFS_LOCK_RTBITMAP << XFS_ILOCK_SHIFT) |
441 | #define XFS_ILOCK_RTSUM (XFS_LOCK_RTSUM << XFS_ILOCK_SHIFT) | |
f7c66ce3 LM |
442 | |
443 | #define XFS_IOLOCK_DEP_MASK 0x00ff0000 | |
444 | #define XFS_ILOCK_DEP_MASK 0xff000000 | |
445 | #define XFS_LOCK_DEP_MASK (XFS_IOLOCK_DEP_MASK | XFS_ILOCK_DEP_MASK) | |
446 | ||
447 | #define XFS_IOLOCK_DEP(flags) (((flags) & XFS_IOLOCK_DEP_MASK) >> XFS_IOLOCK_SHIFT) | |
448 | #define XFS_ILOCK_DEP(flags) (((flags) & XFS_ILOCK_DEP_MASK) >> XFS_ILOCK_SHIFT) | |
1da177e4 | 449 | |
1da177e4 LT |
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 | */ | |
bd186aa9 CH |
455 | #define XFS_INHERIT_GID(pip) \ |
456 | (((pip)->i_mount->m_flags & XFS_MOUNT_GRPID) || \ | |
457 | ((pip)->i_d.di_mode & S_ISGID)) | |
1da177e4 | 458 | |
33479e05 | 459 | |
745b1f47 | 460 | /* |
33479e05 | 461 | * xfs_inode.c prototypes. |
745b1f47 | 462 | */ |
1da177e4 LT |
463 | void xfs_ilock(xfs_inode_t *, uint); |
464 | int xfs_ilock_nowait(xfs_inode_t *, uint); | |
465 | void xfs_iunlock(xfs_inode_t *, uint); | |
466 | void xfs_ilock_demote(xfs_inode_t *, uint); | |
579aa9ca | 467 | int xfs_isilocked(xfs_inode_t *, uint); |
1da177e4 LT |
468 | uint xfs_ilock_map_shared(xfs_inode_t *); |
469 | void xfs_iunlock_map_shared(xfs_inode_t *, uint); | |
576b1d67 | 470 | int xfs_ialloc(struct xfs_trans *, xfs_inode_t *, umode_t, |
6743099c | 471 | xfs_nlink_t, xfs_dev_t, prid_t, int, |
08358906 | 472 | struct xfs_buf **, xfs_inode_t **); |
347d1c01 | 473 | |
1da177e4 | 474 | uint xfs_ip2xflags(struct xfs_inode *); |
45ba598e | 475 | uint xfs_dic2xflags(struct xfs_dinode *); |
1da177e4 LT |
476 | int xfs_ifree(struct xfs_trans *, xfs_inode_t *, |
477 | struct xfs_bmap_free *); | |
8f04c47a CH |
478 | int xfs_itruncate_extents(struct xfs_trans **, struct xfs_inode *, |
479 | int, xfs_fsize_t); | |
1da177e4 | 480 | int xfs_iunlink(struct xfs_trans *, xfs_inode_t *); |
1da177e4 | 481 | |
1da177e4 | 482 | void xfs_iext_realloc(xfs_inode_t *, int, int); |
777df5af | 483 | void xfs_iunpin_wait(xfs_inode_t *); |
4c46819a | 484 | int xfs_iflush(struct xfs_inode *, struct xfs_buf **); |
cfa853e4 | 485 | void xfs_lock_inodes(xfs_inode_t **, int, uint); |
e1cccd91 | 486 | void xfs_lock_two_inodes(xfs_inode_t *, xfs_inode_t *, uint); |
1da177e4 | 487 | |
2a0ec1d9 DC |
488 | xfs_extlen_t xfs_get_extsz_hint(struct xfs_inode *ip); |
489 | ||
5a8d0f3c CH |
490 | #define IHOLD(ip) \ |
491 | do { \ | |
492 | ASSERT(atomic_read(&VFS_I(ip)->i_count) > 0) ; \ | |
7de9c6ee | 493 | ihold(VFS_I(ip)); \ |
0b1b213f | 494 | trace_xfs_ihold(ip, _THIS_IP_); \ |
5a8d0f3c CH |
495 | } while (0) |
496 | ||
497 | #define IRELE(ip) \ | |
498 | do { \ | |
0b1b213f | 499 | trace_xfs_irele(ip, _THIS_IP_); \ |
5a8d0f3c CH |
500 | iput(VFS_I(ip)); \ |
501 | } while (0) | |
502 | ||
847fff5c BN |
503 | #endif /* __KERNEL__ */ |
504 | ||
6d73cf13 CH |
505 | /* |
506 | * Flags for xfs_iget() | |
507 | */ | |
508 | #define XFS_IGET_CREATE 0x1 | |
1920779e | 509 | #define XFS_IGET_UNTRUSTED 0x2 |
5132ba8f | 510 | #define XFS_IGET_DONTCACHE 0x4 |
6d73cf13 | 511 | |
475ee413 CH |
512 | int xfs_imap_to_bp(struct xfs_mount *, struct xfs_trans *, |
513 | struct xfs_imap *, struct xfs_dinode **, | |
514 | struct xfs_buf **, uint, uint); | |
6d73cf13 | 515 | int xfs_iread(struct xfs_mount *, struct xfs_trans *, |
7b6259e7 | 516 | struct xfs_inode *, uint); |
93848a99 | 517 | void xfs_dinode_calc_crc(struct xfs_mount *, struct xfs_dinode *); |
81591fe2 | 518 | void xfs_dinode_to_disk(struct xfs_dinode *, |
847fff5c BN |
519 | struct xfs_icdinode *); |
520 | void xfs_idestroy_fork(struct xfs_inode *, int); | |
521 | void xfs_idata_realloc(struct xfs_inode *, int, int); | |
522 | void xfs_iroot_realloc(struct xfs_inode *, int, int); | |
523 | int xfs_iread_extents(struct xfs_trans *, struct xfs_inode *, int); | |
524 | int xfs_iextents_copy(struct xfs_inode *, xfs_bmbt_rec_t *, int); | |
525 | ||
a6f64d4a | 526 | xfs_bmbt_rec_host_t *xfs_iext_get_ext(xfs_ifork_t *, xfs_extnum_t); |
6ef35544 CH |
527 | void xfs_iext_insert(xfs_inode_t *, xfs_extnum_t, xfs_extnum_t, |
528 | xfs_bmbt_irec_t *, int); | |
4eea22f0 | 529 | void xfs_iext_add(xfs_ifork_t *, xfs_extnum_t, int); |
0293ce3a | 530 | void xfs_iext_add_indirect_multi(xfs_ifork_t *, int, xfs_extnum_t, int); |
6ef35544 | 531 | void xfs_iext_remove(xfs_inode_t *, xfs_extnum_t, int, int); |
4eea22f0 MK |
532 | void xfs_iext_remove_inline(xfs_ifork_t *, xfs_extnum_t, int); |
533 | void xfs_iext_remove_direct(xfs_ifork_t *, xfs_extnum_t, int); | |
0293ce3a | 534 | void xfs_iext_remove_indirect(xfs_ifork_t *, xfs_extnum_t, int); |
4eea22f0 MK |
535 | void xfs_iext_realloc_direct(xfs_ifork_t *, int); |
536 | void xfs_iext_direct_to_inline(xfs_ifork_t *, xfs_extnum_t); | |
537 | void xfs_iext_inline_to_direct(xfs_ifork_t *, int); | |
538 | void xfs_iext_destroy(xfs_ifork_t *); | |
a6f64d4a | 539 | xfs_bmbt_rec_host_t *xfs_iext_bno_to_ext(xfs_ifork_t *, xfs_fileoff_t, int *); |
0293ce3a MK |
540 | xfs_ext_irec_t *xfs_iext_bno_to_irec(xfs_ifork_t *, xfs_fileoff_t, int *); |
541 | xfs_ext_irec_t *xfs_iext_idx_to_irec(xfs_ifork_t *, xfs_extnum_t *, int *, int); | |
542 | void xfs_iext_irec_init(xfs_ifork_t *); | |
543 | xfs_ext_irec_t *xfs_iext_irec_new(xfs_ifork_t *, int); | |
544 | void xfs_iext_irec_remove(xfs_ifork_t *, int); | |
545 | void xfs_iext_irec_compact(xfs_ifork_t *); | |
546 | void xfs_iext_irec_compact_pages(xfs_ifork_t *); | |
547 | void xfs_iext_irec_compact_full(xfs_ifork_t *); | |
548 | void xfs_iext_irec_update_extoffs(xfs_ifork_t *, int, int); | |
72b53efa | 549 | bool xfs_can_free_eofblocks(struct xfs_inode *, bool); |
4eea22f0 | 550 | |
1da177e4 LT |
551 | #define xfs_ipincount(ip) ((unsigned int) atomic_read(&ip->i_pincount)) |
552 | ||
1da177e4 LT |
553 | #if defined(DEBUG) |
554 | void xfs_inobp_check(struct xfs_mount *, struct xfs_buf *); | |
555 | #else | |
556 | #define xfs_inobp_check(mp, bp) | |
557 | #endif /* DEBUG */ | |
558 | ||
1da177e4 LT |
559 | extern struct kmem_zone *xfs_ifork_zone; |
560 | extern struct kmem_zone *xfs_inode_zone; | |
1813dd64 | 561 | extern const struct xfs_buf_ops xfs_inode_buf_ops; |
1da177e4 | 562 | |
1da177e4 | 563 | #endif /* __XFS_INODE_H__ */ |