]>
Commit | Line | Data |
---|---|---|
2bd0ea18 | 1 | /* |
eae766ca | 2 | * Copyright (c) 2000-2003 Silicon Graphics, Inc. All Rights Reserved. |
5000d01d | 3 | * |
2bd0ea18 NS |
4 | * This program is free software; you can redistribute it and/or modify it |
5 | * under the terms of version 2 of the GNU General Public License as | |
6 | * published by the Free Software Foundation. | |
5000d01d | 7 | * |
2bd0ea18 NS |
8 | * This program is distributed in the hope that it would be useful, but |
9 | * WITHOUT ANY WARRANTY; without even the implied warranty of | |
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | |
5000d01d | 11 | * |
2bd0ea18 NS |
12 | * Further, this software is distributed without any warranty that it is |
13 | * free of the rightful claim of any third person regarding infringement | |
5000d01d | 14 | * or the like. Any license provided herein, whether implied or |
2bd0ea18 NS |
15 | * otherwise, applies only to this software file. Patent licenses, if |
16 | * any, provided herein do not apply to combinations of this program with | |
17 | * other software, or any other product whatsoever. | |
5000d01d | 18 | * |
2bd0ea18 NS |
19 | * You should have received a copy of the GNU General Public License along |
20 | * with this program; if not, write the Free Software Foundation, Inc., 59 | |
21 | * Temple Place - Suite 330, Boston MA 02111-1307, USA. | |
5000d01d | 22 | * |
2bd0ea18 NS |
23 | * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, |
24 | * Mountain View, CA 94043, or: | |
5000d01d SL |
25 | * |
26 | * http://www.sgi.com | |
27 | * | |
28 | * For further information regarding this notice, see: | |
29 | * | |
2bd0ea18 NS |
30 | * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/ |
31 | */ | |
5000d01d SL |
32 | #ifndef __XFS_INODE_H__ |
33 | #define __XFS_INODE_H__ | |
2bd0ea18 NS |
34 | |
35 | /* | |
36 | * File incore extent information, present for each of data & attr forks. | |
37 | */ | |
5000d01d SL |
38 | #define XFS_INLINE_EXTS 2 |
39 | #define XFS_INLINE_DATA 32 | |
2bd0ea18 | 40 | typedef struct xfs_ifork { |
5000d01d | 41 | int if_bytes; /* bytes in if_u1 */ |
2bd0ea18 NS |
42 | int if_real_bytes; /* bytes allocated in if_u1 */ |
43 | xfs_bmbt_block_t *if_broot; /* file's incore btree root */ | |
5000d01d | 44 | short if_broot_bytes; /* bytes allocated for root */ |
2bd0ea18 NS |
45 | unsigned char if_flags; /* per-fork flags */ |
46 | unsigned char if_ext_max; /* max # of extent records */ | |
47 | xfs_extnum_t if_lastex; /* last if_extents used */ | |
48 | union { | |
49 | xfs_bmbt_rec_t *if_extents; /* linear map file exts */ | |
50 | char *if_data; /* inline file data */ | |
51 | } if_u1; | |
52 | union { | |
53 | xfs_bmbt_rec_t if_inline_ext[XFS_INLINE_EXTS]; | |
54 | /* very small file extents */ | |
55 | char if_inline_data[XFS_INLINE_DATA]; | |
56 | /* very small file data */ | |
57 | xfs_dev_t if_rdev; /* dev number if special */ | |
58 | uuid_t if_uuid; /* mount point value */ | |
59 | } if_u2; | |
60 | } xfs_ifork_t; | |
61 | ||
62 | /* | |
63 | * Flags for xfs_ichgtime(). | |
64 | */ | |
5000d01d SL |
65 | #define XFS_ICHGTIME_MOD 0x1 /* data fork modification timestamp */ |
66 | #define XFS_ICHGTIME_ACC 0x2 /* data fork access timestamp */ | |
67 | #define XFS_ICHGTIME_CHG 0x4 /* inode field change timestamp */ | |
2bd0ea18 NS |
68 | |
69 | /* | |
70 | * Per-fork incore inode flags. | |
71 | */ | |
5000d01d SL |
72 | #define XFS_IFINLINE 0x0001 /* Inline data is read in */ |
73 | #define XFS_IFEXTENTS 0x0002 /* All extent pointers are read in */ | |
74 | #define XFS_IFBROOT 0x0004 /* i_broot points to the bmap b-tree root */ | |
2bd0ea18 NS |
75 | |
76 | /* | |
77 | * Flags for xfs_imap() and xfs_dilocate(). | |
78 | */ | |
5000d01d | 79 | #define XFS_IMAP_LOOKUP 0x1 |
2bd0ea18 NS |
80 | |
81 | /* | |
82 | * Maximum number of extent pointers in if_u1.if_extents. | |
83 | */ | |
5000d01d | 84 | #define XFS_MAX_INCORE_EXTENTS 32768 |
2bd0ea18 NS |
85 | |
86 | ||
87 | #ifdef __KERNEL__ | |
88 | struct bhv_desc; | |
89 | struct cred; | |
90 | struct ktrace; | |
91 | struct vnode; | |
92 | struct xfs_buf; | |
93 | struct xfs_bmap_free; | |
94 | struct xfs_bmbt_irec; | |
95 | struct xfs_bmbt_block; | |
2bd0ea18 NS |
96 | struct xfs_inode; |
97 | struct xfs_inode_log_item; | |
98 | struct xfs_mount; | |
99 | struct xfs_trans; | |
100 | struct xfs_dquot; | |
2bd0ea18 NS |
101 | |
102 | ||
103 | /* | |
104 | * This structure is used to communicate which extents of a file | |
105 | * were holes when a write started from xfs_write_file() to | |
106 | * xfs_strat_read(). This is necessary so that we can know which | |
107 | * blocks need to be zeroed when they are read in in xfs_strat_read() | |
108 | * if they weren\'t allocated when the buffer given to xfs_strat_read() | |
109 | * was mapped. | |
110 | * | |
111 | * We keep a list of these attached to the inode. The list is | |
112 | * protected by the inode lock and the fact that the io lock is | |
113 | * held exclusively by writers. | |
114 | */ | |
115 | typedef struct xfs_gap { | |
116 | struct xfs_gap *xg_next; | |
117 | xfs_fileoff_t xg_offset_fsb; | |
118 | xfs_extlen_t xg_count_fsb; | |
119 | } xfs_gap_t; | |
120 | ||
63518810 NS |
121 | typedef struct dm_attrs_s { |
122 | __uint32_t da_dmevmask; /* DMIG event mask */ | |
123 | __uint16_t da_dmstate; /* DMIG state info */ | |
124 | __uint16_t da_pad; /* DMIG extra padding */ | |
125 | } dm_attrs_t; | |
2bd0ea18 NS |
126 | |
127 | typedef struct xfs_iocore { | |
128 | void *io_obj; /* pointer to container | |
129 | * inode or dcxvn structure */ | |
130 | struct xfs_mount *io_mount; /* fs mount struct ptr */ | |
db15fab1 NS |
131 | #ifdef DEBUG |
132 | mrlock_t *io_lock; /* inode IO lock */ | |
2bd0ea18 | 133 | mrlock_t *io_iolock; /* inode IO lock */ |
db15fab1 | 134 | #endif |
2bd0ea18 NS |
135 | |
136 | /* I/O state */ | |
2bd0ea18 | 137 | xfs_fsize_t io_new_size; /* sz when write completes */ |
2bd0ea18 NS |
138 | |
139 | /* Miscellaneous state. */ | |
140 | unsigned int io_flags; /* IO related flags */ | |
141 | ||
142 | /* DMAPI state */ | |
63518810 NS |
143 | dm_attrs_t io_dmattrs; |
144 | ||
2bd0ea18 NS |
145 | } xfs_iocore_t; |
146 | ||
5000d01d SL |
147 | #define io_dmevmask io_dmattrs.da_dmevmask |
148 | #define io_dmstate io_dmattrs.da_dmstate | |
63518810 | 149 | |
2bd0ea18 NS |
150 | #define XFS_IO_INODE(io) ((xfs_inode_t *) ((io)->io_obj)) |
151 | #define XFS_IO_DCXVN(io) ((dcxvn_t *) ((io)->io_obj)) | |
152 | ||
153 | /* | |
154 | * Flags in the flags field | |
155 | */ | |
156 | ||
eae766ca | 157 | #define XFS_IOCORE_RT 0x1 |
2bd0ea18 | 158 | |
2bd0ea18 NS |
159 | /* |
160 | * xfs_iocore prototypes | |
161 | */ | |
162 | ||
163 | extern void xfs_iocore_inode_init(struct xfs_inode *); | |
164 | extern void xfs_iocore_inode_reinit(struct xfs_inode *); | |
2bd0ea18 NS |
165 | |
166 | ||
167 | /* | |
168 | * This is the type used in the xfs inode hash table. | |
169 | * An array of these is allocated for each mounted | |
170 | * file system to hash the inodes for that file system. | |
171 | */ | |
172 | typedef struct xfs_ihash { | |
173 | struct xfs_inode *ih_next; | |
5000d01d | 174 | rwlock_t ih_lock; |
2bd0ea18 NS |
175 | uint ih_version; |
176 | } xfs_ihash_t; | |
2bd0ea18 NS |
177 | |
178 | /* | |
179 | * Inode hashing and hash bucket locking. | |
180 | */ | |
181 | #define XFS_BUCKETS(mp) (37*(mp)->m_sb.sb_agcount-1) | |
182 | #define XFS_IHASH(mp,ino) ((mp)->m_ihash + (((uint)ino) % (mp)->m_ihsize)) | |
183 | ||
184 | /* | |
5000d01d | 185 | * This is the xfs inode cluster hash. This hash is used by xfs_iflush to |
2bd0ea18 NS |
186 | * find inodes that share a cluster and can be flushed to disk at the same |
187 | * time. | |
188 | */ | |
189 | ||
190 | typedef struct xfs_chashlist { | |
191 | struct xfs_chashlist *chl_next; | |
192 | struct xfs_inode *chl_ip; | |
5000d01d | 193 | xfs_daddr_t chl_blkno; /* starting block number of |
2bd0ea18 NS |
194 | * the cluster */ |
195 | #ifdef DEBUG | |
196 | struct xfs_buf *chl_buf; /* debug: the inode buffer */ | |
197 | #endif | |
198 | } xfs_chashlist_t; | |
199 | ||
200 | typedef struct xfs_chash { | |
201 | xfs_chashlist_t *ch_list; | |
202 | lock_t ch_lock; | |
203 | } xfs_chash_t; | |
204 | ||
205 | ||
206 | /* | |
207 | * This is the xfs in-core inode structure. | |
208 | * Most of the on-disk inode is embedded in the i_d field. | |
209 | * | |
210 | * The extent pointers/inline file space, however, are managed | |
5000d01d | 211 | * separately. The memory for this information is pointed to by |
2bd0ea18 NS |
212 | * the if_u1 unions depending on the type of the data. |
213 | * This is used to linearize the array of extents for fast in-core | |
214 | * access. This is used until the file's number of extents | |
215 | * surpasses XFS_MAX_INCORE_EXTENTS, at which point all extent pointers | |
216 | * are accessed through the buffer cache. | |
217 | * | |
218 | * Other state kept in the in-core inode is used for identification, | |
219 | * locking, transactional updating, etc of the inode. | |
220 | * | |
5000d01d SL |
221 | * Generally, we do not want to hold the i_rlock while holding the |
222 | * i_ilock. Hierarchy is i_iolock followed by i_rlock. | |
2bd0ea18 NS |
223 | * |
224 | * xfs_iptr_t contains all the inode fields upto and including the | |
225 | * i_mnext and i_mprev fields, it is used as a marker in the inode | |
226 | * chain off the mount structure by xfs_sync calls. | |
227 | */ | |
228 | ||
229 | typedef struct { | |
230 | struct xfs_ihash *ip_hash; /* pointer to hash header */ | |
231 | struct xfs_inode *ip_next; /* inode hash link forw */ | |
232 | struct xfs_inode *ip_mnext; /* next inode in mount list */ | |
233 | struct xfs_inode *ip_mprev; /* ptr to prev inode */ | |
234 | struct xfs_inode **ip_prevp; /* ptr to prev i_next */ | |
235 | struct xfs_mount *ip_mount; /* fs mount struct ptr */ | |
236 | } xfs_iptr_t; | |
237 | ||
238 | typedef struct xfs_inode { | |
239 | /* Inode linking and identification information. */ | |
240 | struct xfs_ihash *i_hash; /* pointer to hash header */ | |
241 | struct xfs_inode *i_next; /* inode hash link forw */ | |
242 | struct xfs_inode *i_mnext; /* next inode in mount list */ | |
243 | struct xfs_inode *i_mprev; /* ptr to prev inode */ | |
244 | struct xfs_inode **i_prevp; /* ptr to prev i_next */ | |
245 | struct xfs_mount *i_mount; /* fs mount struct ptr */ | |
246 | struct bhv_desc i_bhv_desc; /* inode behavior descriptor*/ | |
247 | struct xfs_dquot *i_udquot; /* user dquot */ | |
b36eef04 | 248 | struct xfs_dquot *i_gdquot; /* group dquot */ |
2bd0ea18 NS |
249 | |
250 | /* Inode location stuff */ | |
251 | xfs_ino_t i_ino; /* inode number (agno/agino)*/ | |
252 | xfs_daddr_t i_blkno; /* blkno of inode buffer */ | |
2bd0ea18 NS |
253 | ushort i_len; /* len of inode buffer */ |
254 | ushort i_boffset; /* off of inode in buffer */ | |
255 | ||
256 | /* Extent information. */ | |
257 | xfs_ifork_t *i_afp; /* attribute fork pointer */ | |
258 | xfs_ifork_t i_df; /* data fork */ | |
259 | ||
260 | /* Transaction and locking information. */ | |
261 | struct xfs_trans *i_transp; /* ptr to owning transaction*/ | |
262 | struct xfs_inode_log_item *i_itemp; /* logging information */ | |
263 | mrlock_t i_lock; /* inode lock */ | |
264 | mrlock_t i_iolock; /* inode IO lock */ | |
265 | sema_t i_flock; /* inode flush lock */ | |
db15fab1 NS |
266 | atomic_t i_pincount; /* inode pin count */ |
267 | wait_queue_head_t i_ipin_wait; /* inode pinning wait queue */ | |
006d8e9a | 268 | struct xfs_inode **i_refcache; /* ptr to entry in ref cache */ |
2bd0ea18 NS |
269 | struct xfs_inode *i_release; /* inode to unref */ |
270 | ||
271 | /* I/O state */ | |
272 | xfs_iocore_t i_iocore; /* I/O core */ | |
273 | ||
274 | /* Miscellaneous state. */ | |
275 | unsigned short i_flags; /* see defined flags below */ | |
3e535bba NS |
276 | unsigned char i_update_core; /* timestamps/size is dirty */ |
277 | unsigned char i_update_size; /* di_size field is dirty */ | |
2bd0ea18 | 278 | unsigned int i_gen; /* generation count */ |
5000d01d | 279 | unsigned int i_delayed_blks; /* count of delay alloc blks */ |
2bd0ea18 NS |
280 | |
281 | xfs_dinode_core_t i_d; /* most of ondisk inode */ | |
282 | xfs_chashlist_t *i_chash; /* cluster hash list header */ | |
283 | struct xfs_inode *i_cnext; /* cluster hash link forward */ | |
284 | struct xfs_inode *i_cprev; /* cluster hash link backward */ | |
285 | ||
286 | #ifdef DEBUG | |
287 | /* Trace buffers per inode. */ | |
288 | struct ktrace *i_xtrace; /* inode extent list trace */ | |
289 | struct ktrace *i_btrace; /* inode bmap btree trace */ | |
290 | struct ktrace *i_rwtrace; /* inode read/write trace */ | |
5000d01d | 291 | struct ktrace *i_strat_trace; /* inode strat_write trace */ |
2bd0ea18 NS |
292 | struct ktrace *i_lock_trace; /* inode lock/unlock trace */ |
293 | struct ktrace *i_dir_trace; /* inode directory trace */ | |
294 | #endif /* DEBUG */ | |
295 | } xfs_inode_t; | |
296 | ||
297 | #endif /* __KERNEL__ */ | |
298 | ||
299 | ||
300 | /* | |
301 | * Fork handling. | |
302 | */ | |
303 | #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_IFORK_PTR) | |
304 | xfs_ifork_t *xfs_ifork_ptr(xfs_inode_t *ip, int w); | |
5000d01d | 305 | #define XFS_IFORK_PTR(ip,w) xfs_ifork_ptr(ip,w) |
2bd0ea18 | 306 | #else |
5000d01d | 307 | #define XFS_IFORK_PTR(ip,w) ((w) == XFS_DATA_FORK ? &(ip)->i_df : (ip)->i_afp) |
2bd0ea18 NS |
308 | #endif |
309 | #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_IFORK_Q) | |
310 | int xfs_ifork_q(xfs_inode_t *ip); | |
5000d01d | 311 | #define XFS_IFORK_Q(ip) xfs_ifork_q(ip) |
2bd0ea18 | 312 | #else |
5000d01d | 313 | #define XFS_IFORK_Q(ip) XFS_CFORK_Q(&(ip)->i_d) |
2bd0ea18 NS |
314 | #endif |
315 | #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_IFORK_DSIZE) | |
316 | int xfs_ifork_dsize(xfs_inode_t *ip); | |
5000d01d | 317 | #define XFS_IFORK_DSIZE(ip) xfs_ifork_dsize(ip) |
2bd0ea18 | 318 | #else |
5000d01d | 319 | #define XFS_IFORK_DSIZE(ip) XFS_CFORK_DSIZE(&ip->i_d, ip->i_mount) |
2bd0ea18 NS |
320 | #endif |
321 | #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_IFORK_ASIZE) | |
322 | int xfs_ifork_asize(xfs_inode_t *ip); | |
5000d01d | 323 | #define XFS_IFORK_ASIZE(ip) xfs_ifork_asize(ip) |
2bd0ea18 | 324 | #else |
5000d01d | 325 | #define XFS_IFORK_ASIZE(ip) XFS_CFORK_ASIZE(&ip->i_d, ip->i_mount) |
2bd0ea18 NS |
326 | #endif |
327 | #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_IFORK_SIZE) | |
328 | int xfs_ifork_size(xfs_inode_t *ip, int w); | |
5000d01d | 329 | #define XFS_IFORK_SIZE(ip,w) xfs_ifork_size(ip,w) |
2bd0ea18 | 330 | #else |
5000d01d | 331 | #define XFS_IFORK_SIZE(ip,w) XFS_CFORK_SIZE(&ip->i_d, ip->i_mount, w) |
2bd0ea18 NS |
332 | #endif |
333 | #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_IFORK_FORMAT) | |
334 | int xfs_ifork_format(xfs_inode_t *ip, int w); | |
5000d01d | 335 | #define XFS_IFORK_FORMAT(ip,w) xfs_ifork_format(ip,w) |
2bd0ea18 | 336 | #else |
5000d01d | 337 | #define XFS_IFORK_FORMAT(ip,w) XFS_CFORK_FORMAT(&ip->i_d, w) |
2bd0ea18 NS |
338 | #endif |
339 | #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_IFORK_FMT_SET) | |
340 | void xfs_ifork_fmt_set(xfs_inode_t *ip, int w, int n); | |
5000d01d | 341 | #define XFS_IFORK_FMT_SET(ip,w,n) xfs_ifork_fmt_set(ip,w,n) |
2bd0ea18 | 342 | #else |
5000d01d | 343 | #define XFS_IFORK_FMT_SET(ip,w,n) XFS_CFORK_FMT_SET(&ip->i_d, w, n) |
2bd0ea18 NS |
344 | #endif |
345 | #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_IFORK_NEXTENTS) | |
346 | int xfs_ifork_nextents(xfs_inode_t *ip, int w); | |
5000d01d | 347 | #define XFS_IFORK_NEXTENTS(ip,w) xfs_ifork_nextents(ip,w) |
2bd0ea18 | 348 | #else |
5000d01d | 349 | #define XFS_IFORK_NEXTENTS(ip,w) XFS_CFORK_NEXTENTS(&ip->i_d, w) |
2bd0ea18 NS |
350 | #endif |
351 | #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_IFORK_NEXT_SET) | |
352 | void xfs_ifork_next_set(xfs_inode_t *ip, int w, int n); | |
5000d01d | 353 | #define XFS_IFORK_NEXT_SET(ip,w,n) xfs_ifork_next_set(ip,w,n) |
2bd0ea18 | 354 | #else |
5000d01d | 355 | #define XFS_IFORK_NEXT_SET(ip,w,n) XFS_CFORK_NEXT_SET(&ip->i_d, w, n) |
2bd0ea18 NS |
356 | #endif |
357 | ||
358 | ||
359 | #ifdef __KERNEL__ | |
360 | ||
361 | /* | |
362 | * In-core inode flags. | |
363 | */ | |
5000d01d SL |
364 | #define XFS_IGRIO 0x0001 /* inode used for guaranteed rate i/o */ |
365 | #define XFS_IUIOSZ 0x0002 /* inode i/o sizes have been explicitly set */ | |
366 | #define XFS_IQUIESCE 0x0004 /* we have started quiescing for this inode */ | |
367 | #define XFS_IRECLAIM 0x0008 /* we have started reclaiming this inode */ | |
2bd0ea18 NS |
368 | |
369 | /* | |
370 | * Flags for inode locking. | |
371 | */ | |
5000d01d SL |
372 | #define XFS_IOLOCK_EXCL 0x001 |
373 | #define XFS_IOLOCK_SHARED 0x002 | |
374 | #define XFS_ILOCK_EXCL 0x004 | |
375 | #define XFS_ILOCK_SHARED 0x008 | |
376 | #define XFS_IUNLOCK_NONOTIFY 0x010 | |
2bd0ea18 NS |
377 | #define XFS_EXTENT_TOKEN_RD 0x040 |
378 | #define XFS_SIZE_TOKEN_RD 0x080 | |
379 | #define XFS_EXTSIZE_RD (XFS_EXTENT_TOKEN_RD|XFS_SIZE_TOKEN_RD) | |
380 | #define XFS_WILLLEND 0x100 /* Always acquire tokens for lending */ | |
381 | #define XFS_EXTENT_TOKEN_WR (XFS_EXTENT_TOKEN_RD | XFS_WILLLEND) | |
5000d01d | 382 | #define XFS_SIZE_TOKEN_WR (XFS_SIZE_TOKEN_RD | XFS_WILLLEND) |
2bd0ea18 NS |
383 | #define XFS_EXTSIZE_WR (XFS_EXTSIZE_RD | XFS_WILLLEND) |
384 | ||
385 | ||
386 | #define XFS_LOCK_MASK \ | |
387 | (XFS_IOLOCK_EXCL | XFS_IOLOCK_SHARED | XFS_ILOCK_EXCL | \ | |
2bd0ea18 NS |
388 | XFS_ILOCK_SHARED | XFS_EXTENT_TOKEN_RD | XFS_SIZE_TOKEN_RD | \ |
389 | XFS_WILLLEND) | |
390 | ||
391 | /* | |
392 | * Flags for xfs_iflush() | |
393 | */ | |
5000d01d SL |
394 | #define XFS_IFLUSH_DELWRI_ELSE_SYNC 1 |
395 | #define XFS_IFLUSH_DELWRI_ELSE_ASYNC 2 | |
396 | #define XFS_IFLUSH_SYNC 3 | |
397 | #define XFS_IFLUSH_ASYNC 4 | |
398 | #define XFS_IFLUSH_DELWRI 5 | |
2bd0ea18 NS |
399 | |
400 | /* | |
401 | * Flags for xfs_iflush_all. | |
402 | */ | |
5000d01d | 403 | #define XFS_FLUSH_ALL 0x1 |
2bd0ea18 NS |
404 | |
405 | /* | |
406 | * Flags for xfs_itruncate_start(). | |
407 | */ | |
5000d01d SL |
408 | #define XFS_ITRUNC_DEFINITE 0x1 |
409 | #define XFS_ITRUNC_MAYBE 0x2 | |
2bd0ea18 NS |
410 | |
411 | /* | |
b391b7cd | 412 | * max file offset is 2^(31+PAGE_SHIFT) - 1 (due to linux page cache) |
1f9cea39 ES |
413 | * |
414 | * NOTE: XFS itself can handle 2^63 - 1 (largest positive value of xfs_fsize_t) | |
f9e56f43 | 415 | * but this is the Linux limit. |
2bd0ea18 | 416 | */ |
f9e56f43 | 417 | #define XFS_MAX_FILE_OFFSET MAX_LFS_FILESIZE |
2bd0ea18 NS |
418 | |
419 | #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_ITOV) | |
420 | struct vnode *xfs_itov(xfs_inode_t *ip); | |
5000d01d | 421 | #define XFS_ITOV(ip) xfs_itov(ip) |
2bd0ea18 | 422 | #else |
5000d01d | 423 | #define XFS_ITOV(ip) BHV_TO_VNODE(XFS_ITOBHV(ip)) |
2bd0ea18 | 424 | #endif |
5000d01d | 425 | #define XFS_ITOV_NULL(ip) BHV_TO_VNODE_NULL(XFS_ITOBHV(ip)) |
2bd0ea18 NS |
426 | #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_ITOBHV) |
427 | struct bhv_desc *xfs_itobhv(xfs_inode_t *ip); | |
5000d01d | 428 | #define XFS_ITOBHV(ip) xfs_itobhv(ip) |
2bd0ea18 | 429 | #else |
5000d01d | 430 | #define XFS_ITOBHV(ip) ((struct bhv_desc *)(&((ip)->i_bhv_desc))) |
2bd0ea18 NS |
431 | #endif |
432 | #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_BHVTOI) | |
433 | xfs_inode_t *xfs_bhvtoi(struct bhv_desc *bhvp); | |
5000d01d | 434 | #define XFS_BHVTOI(bhvp) xfs_bhvtoi(bhvp) |
2bd0ea18 | 435 | #else |
5000d01d | 436 | #define XFS_BHVTOI(bhvp) \ |
2bd0ea18 NS |
437 | ((xfs_inode_t *)((char *)(bhvp) - \ |
438 | (char *)&(((xfs_inode_t *)0)->i_bhv_desc))) | |
439 | #endif | |
440 | ||
441 | #define BHV_IS_XFS(bdp) (BHV_OPS(bdp) == &xfs_vnodeops) | |
442 | ||
443 | /* | |
444 | * Pick the inode cluster hash bucket | |
445 | * (m_chash is the same size as m_ihash) | |
446 | */ | |
447 | #define XFS_CHASH(mp,blk) ((mp)->m_chash + (((uint)blk) % (mp)->m_chsize)) | |
448 | ||
7e039a24 NS |
449 | /* |
450 | * For multiple groups support: if ISGID bit is set in the parent | |
451 | * directory, group of new file is set to that of the parent, and | |
452 | * new subdirectory gets ISGID bit from parent. | |
453 | */ | |
454 | #define XFS_INHERIT_GID(pip, vfsp) ((pip) != NULL && \ | |
455 | (((vfsp)->vfs_flag & VFS_GRPID) || ((pip)->i_d.di_mode & ISGID))) | |
2bd0ea18 NS |
456 | |
457 | /* | |
458 | * xfs_iget.c prototypes. | |
459 | */ | |
460 | void xfs_ihash_init(struct xfs_mount *); | |
461 | void xfs_ihash_free(struct xfs_mount *); | |
462 | void xfs_chash_init(struct xfs_mount *); | |
463 | void xfs_chash_free(struct xfs_mount *); | |
464 | xfs_inode_t *xfs_inode_incore(struct xfs_mount *, xfs_ino_t, | |
465 | struct xfs_trans *); | |
5000d01d | 466 | void xfs_inode_lock_init(xfs_inode_t *, struct vnode *); |
2bd0ea18 NS |
467 | int xfs_iget(struct xfs_mount *, struct xfs_trans *, xfs_ino_t, |
468 | uint, xfs_inode_t **, xfs_daddr_t); | |
2bd0ea18 | 469 | void xfs_iput(xfs_inode_t *, uint); |
d663096d | 470 | void xfs_iput_new(xfs_inode_t *, uint); |
2bd0ea18 NS |
471 | void xfs_ilock(xfs_inode_t *, uint); |
472 | int xfs_ilock_nowait(xfs_inode_t *, uint); | |
473 | void xfs_iunlock(xfs_inode_t *, uint); | |
474 | void xfs_ilock_demote(xfs_inode_t *, uint); | |
475 | void xfs_iflock(xfs_inode_t *); | |
476 | int xfs_iflock_nowait(xfs_inode_t *); | |
477 | uint xfs_ilock_map_shared(xfs_inode_t *); | |
478 | void xfs_iunlock_map_shared(xfs_inode_t *, uint); | |
479 | void xfs_ifunlock(xfs_inode_t *); | |
480 | void xfs_ireclaim(xfs_inode_t *); | |
61d8f4c3 | 481 | int xfs_finish_reclaim(xfs_inode_t *, int, int); |
33254bd8 | 482 | int xfs_finish_reclaim_all(struct xfs_mount *); |
2bd0ea18 NS |
483 | |
484 | /* | |
485 | * xfs_inode.c prototypes. | |
486 | */ | |
487 | int xfs_inotobp(struct xfs_mount *, struct xfs_trans *, xfs_ino_t, | |
488 | xfs_dinode_t **, struct xfs_buf **, int *); | |
489 | int xfs_itobp(struct xfs_mount *, struct xfs_trans *, | |
490 | xfs_inode_t *, xfs_dinode_t **, struct xfs_buf **, | |
491 | xfs_daddr_t); | |
492 | int xfs_iread(struct xfs_mount *, struct xfs_trans *, xfs_ino_t, | |
493 | xfs_inode_t **, xfs_daddr_t); | |
494 | int xfs_iread_extents(struct xfs_trans *, xfs_inode_t *, int); | |
495 | int xfs_ialloc(struct xfs_trans *, xfs_inode_t *, mode_t, nlink_t, | |
32181a02 | 496 | xfs_dev_t, struct cred *, xfs_prid_t, int, |
2bd0ea18 NS |
497 | struct xfs_buf **, boolean_t *, xfs_inode_t **); |
498 | void xfs_xlate_dinode_core(xfs_caddr_t, struct xfs_dinode_core *, int, | |
499 | xfs_arch_t); | |
500 | int xfs_ifree(struct xfs_trans *, xfs_inode_t *); | |
501 | int xfs_atruncate_start(xfs_inode_t *); | |
502 | void xfs_itruncate_start(xfs_inode_t *, uint, xfs_fsize_t); | |
503 | int xfs_itruncate_finish(struct xfs_trans **, xfs_inode_t *, | |
504 | xfs_fsize_t, int, int); | |
505 | int xfs_iunlink(struct xfs_trans *, xfs_inode_t *); | |
506 | int xfs_igrow_start(xfs_inode_t *, xfs_fsize_t, struct cred *); | |
507 | void xfs_igrow_finish(struct xfs_trans *, xfs_inode_t *, | |
508 | xfs_fsize_t, int); | |
509 | ||
510 | void xfs_idestroy_fork(xfs_inode_t *, int); | |
511 | void xfs_idestroy(xfs_inode_t *); | |
512 | void xfs_idata_realloc(xfs_inode_t *, int, int); | |
513 | void xfs_iextract(xfs_inode_t *); | |
514 | void xfs_iext_realloc(xfs_inode_t *, int, int); | |
515 | void xfs_iroot_realloc(xfs_inode_t *, int, int); | |
516 | void xfs_ipin(xfs_inode_t *); | |
517 | void xfs_iunpin(xfs_inode_t *); | |
f9e56f43 | 518 | int xfs_iextents_copy(xfs_inode_t *, xfs_bmbt_rec_t *, int); |
2bd0ea18 NS |
519 | int xfs_iflush(xfs_inode_t *, uint); |
520 | int xfs_iflush_all(struct xfs_mount *, int); | |
5000d01d | 521 | int xfs_ibusy_check(xfs_inode_t *, int); |
90e48754 | 522 | int xfs_iaccess(xfs_inode_t *, mode_t, cred_t *); |
2bd0ea18 NS |
523 | uint xfs_iroundup(uint); |
524 | void xfs_ichgtime(xfs_inode_t *, int); | |
525 | xfs_fsize_t xfs_file_last_byte(xfs_inode_t *); | |
2bd0ea18 NS |
526 | void xfs_lock_inodes(xfs_inode_t **, int, int, uint); |
527 | ||
db15fab1 NS |
528 | #define xfs_ipincount(ip) ((unsigned int) atomic_read(&ip->i_pincount)) |
529 | ||
2bd0ea18 NS |
530 | #ifdef DEBUG |
531 | void xfs_isize_check(struct xfs_mount *, xfs_inode_t *, xfs_fsize_t); | |
532 | #else /* DEBUG */ | |
533 | #define xfs_isize_check(mp, ip, isize) | |
534 | #endif /* DEBUG */ | |
535 | ||
536 | #if defined(DEBUG) | |
537 | void xfs_inobp_check(struct xfs_mount *, struct xfs_buf *); | |
538 | #else | |
5000d01d | 539 | #define xfs_inobp_check(mp, bp) |
2bd0ea18 NS |
540 | #endif /* DEBUG */ |
541 | ||
836f654f NS |
542 | extern struct kmem_zone *xfs_chashlist_zone; |
543 | extern struct kmem_zone *xfs_ifork_zone; | |
544 | extern struct kmem_zone *xfs_inode_zone; | |
545 | extern struct kmem_zone *xfs_ili_zone; | |
2bd0ea18 NS |
546 | extern struct vnodeops xfs_vnodeops; |
547 | ||
548 | #ifdef XFS_ILOCK_TRACE | |
549 | #define XFS_ILOCK_KTRACE_SIZE 32 | |
5000d01d | 550 | void xfs_ilock_trace(xfs_inode_t *ip, int lock, unsigned int lockflags, |
2bd0ea18 NS |
551 | inst_t *ra); |
552 | #endif | |
553 | ||
554 | #endif /* __KERNEL__ */ | |
555 | ||
556 | #endif /* __XFS_INODE_H__ */ |