]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/blame - include/xfs_inode.h
bump version to 2.2, document changes -- sync shared headers, EVMS stripe
[thirdparty/xfsprogs-dev.git] / include / xfs_inode.h
CommitLineData
2bd0ea18 1/*
0d3e0b37 2 * Copyright (c) 2000-2002 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 40typedef 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__
88struct bhv_desc;
89struct cred;
90struct ktrace;
91struct vnode;
92struct xfs_buf;
93struct xfs_bmap_free;
94struct xfs_bmbt_irec;
95struct xfs_bmbt_block;
2bd0ea18
NS
96struct xfs_inode;
97struct xfs_inode_log_item;
98struct xfs_mount;
99struct xfs_trans;
100struct xfs_dquot;
101struct pm;
102
103
104/*
105 * This structure is used to communicate which extents of a file
106 * were holes when a write started from xfs_write_file() to
107 * xfs_strat_read(). This is necessary so that we can know which
108 * blocks need to be zeroed when they are read in in xfs_strat_read()
109 * if they weren\'t allocated when the buffer given to xfs_strat_read()
110 * was mapped.
111 *
112 * We keep a list of these attached to the inode. The list is
113 * protected by the inode lock and the fact that the io lock is
114 * held exclusively by writers.
115 */
116typedef struct xfs_gap {
117 struct xfs_gap *xg_next;
118 xfs_fileoff_t xg_offset_fsb;
119 xfs_extlen_t xg_count_fsb;
120} xfs_gap_t;
121
122/*
123 * This structure is used to hold common pieces of the buffer
124 * and file for xfs_dio_write and xfs_dio_read.
125 */
5000d01d 126typedef struct xfs_dio {
2bd0ea18
NS
127 struct xfs_buf *xd_bp;
128 bhv_desc_t *xd_bdp;
129 struct xfs_inode *xd_ip;
130 struct xfs_iocore *xd_io;
131 struct cred *xd_cr;
132 struct pm *xd_pmp;
133 int xd_blkalgn;
134 int xd_ioflag;
b36eef04 135 xfs_off_t xd_start;
2bd0ea18
NS
136 size_t xd_length;
137} xfs_dio_t;
138
63518810
NS
139typedef struct dm_attrs_s {
140 __uint32_t da_dmevmask; /* DMIG event mask */
141 __uint16_t da_dmstate; /* DMIG state info */
142 __uint16_t da_pad; /* DMIG extra padding */
143} dm_attrs_t;
2bd0ea18
NS
144
145typedef struct xfs_iocore {
146 void *io_obj; /* pointer to container
147 * inode or dcxvn structure */
148 struct xfs_mount *io_mount; /* fs mount struct ptr */
db15fab1
NS
149#ifdef DEBUG
150 mrlock_t *io_lock; /* inode IO lock */
2bd0ea18 151 mrlock_t *io_iolock; /* inode IO lock */
db15fab1 152#endif
2bd0ea18
NS
153
154 /* I/O state */
2bd0ea18 155 xfs_fsize_t io_new_size; /* sz when write completes */
2bd0ea18
NS
156
157 /* Miscellaneous state. */
158 unsigned int io_flags; /* IO related flags */
159
160 /* DMAPI state */
63518810
NS
161 dm_attrs_t io_dmattrs;
162
2bd0ea18
NS
163} xfs_iocore_t;
164
5000d01d
SL
165#define io_dmevmask io_dmattrs.da_dmevmask
166#define io_dmstate io_dmattrs.da_dmstate
63518810 167
2bd0ea18
NS
168#define XFS_IO_INODE(io) ((xfs_inode_t *) ((io)->io_obj))
169#define XFS_IO_DCXVN(io) ((dcxvn_t *) ((io)->io_obj))
170
171/*
172 * Flags in the flags field
173 */
174
175#define XFS_IOCORE_ISXFS 0x01
176#define XFS_IOCORE_ISCXFS 0x02
177#define XFS_IOCORE_RT 0x04
2bd0ea18
NS
178
179#define IO_IS_XFS(io) ((io)->io_flags & XFS_IOCORE_ISXFS)
180
2bd0ea18
NS
181/*
182 * xfs_iocore prototypes
183 */
184
185extern void xfs_iocore_inode_init(struct xfs_inode *);
186extern void xfs_iocore_inode_reinit(struct xfs_inode *);
2bd0ea18
NS
187
188
189/*
190 * This is the type used in the xfs inode hash table.
191 * An array of these is allocated for each mounted
192 * file system to hash the inodes for that file system.
193 */
194typedef struct xfs_ihash {
195 struct xfs_inode *ih_next;
5000d01d 196 rwlock_t ih_lock;
2bd0ea18
NS
197 uint ih_version;
198} xfs_ihash_t;
2bd0ea18
NS
199
200/*
201 * Inode hashing and hash bucket locking.
202 */
203#define XFS_BUCKETS(mp) (37*(mp)->m_sb.sb_agcount-1)
204#define XFS_IHASH(mp,ino) ((mp)->m_ihash + (((uint)ino) % (mp)->m_ihsize))
205
206/*
5000d01d 207 * This is the xfs inode cluster hash. This hash is used by xfs_iflush to
2bd0ea18
NS
208 * find inodes that share a cluster and can be flushed to disk at the same
209 * time.
210 */
211
212typedef struct xfs_chashlist {
213 struct xfs_chashlist *chl_next;
214 struct xfs_inode *chl_ip;
5000d01d 215 xfs_daddr_t chl_blkno; /* starting block number of
2bd0ea18
NS
216 * the cluster */
217#ifdef DEBUG
218 struct xfs_buf *chl_buf; /* debug: the inode buffer */
219#endif
220} xfs_chashlist_t;
221
222typedef struct xfs_chash {
223 xfs_chashlist_t *ch_list;
224 lock_t ch_lock;
225} xfs_chash_t;
226
227
228/*
229 * This is the xfs in-core inode structure.
230 * Most of the on-disk inode is embedded in the i_d field.
231 *
232 * The extent pointers/inline file space, however, are managed
5000d01d 233 * separately. The memory for this information is pointed to by
2bd0ea18
NS
234 * the if_u1 unions depending on the type of the data.
235 * This is used to linearize the array of extents for fast in-core
236 * access. This is used until the file's number of extents
237 * surpasses XFS_MAX_INCORE_EXTENTS, at which point all extent pointers
238 * are accessed through the buffer cache.
239 *
240 * Other state kept in the in-core inode is used for identification,
241 * locking, transactional updating, etc of the inode.
242 *
5000d01d
SL
243 * Generally, we do not want to hold the i_rlock while holding the
244 * i_ilock. Hierarchy is i_iolock followed by i_rlock.
2bd0ea18
NS
245 *
246 * xfs_iptr_t contains all the inode fields upto and including the
247 * i_mnext and i_mprev fields, it is used as a marker in the inode
248 * chain off the mount structure by xfs_sync calls.
249 */
250
251typedef struct {
252 struct xfs_ihash *ip_hash; /* pointer to hash header */
253 struct xfs_inode *ip_next; /* inode hash link forw */
254 struct xfs_inode *ip_mnext; /* next inode in mount list */
255 struct xfs_inode *ip_mprev; /* ptr to prev inode */
256 struct xfs_inode **ip_prevp; /* ptr to prev i_next */
257 struct xfs_mount *ip_mount; /* fs mount struct ptr */
258} xfs_iptr_t;
259
260typedef struct xfs_inode {
261 /* Inode linking and identification information. */
262 struct xfs_ihash *i_hash; /* pointer to hash header */
263 struct xfs_inode *i_next; /* inode hash link forw */
264 struct xfs_inode *i_mnext; /* next inode in mount list */
265 struct xfs_inode *i_mprev; /* ptr to prev inode */
266 struct xfs_inode **i_prevp; /* ptr to prev i_next */
267 struct xfs_mount *i_mount; /* fs mount struct ptr */
268 struct bhv_desc i_bhv_desc; /* inode behavior descriptor*/
269 struct xfs_dquot *i_udquot; /* user dquot */
b36eef04 270 struct xfs_dquot *i_gdquot; /* group dquot */
2bd0ea18
NS
271
272 /* Inode location stuff */
273 xfs_ino_t i_ino; /* inode number (agno/agino)*/
274 xfs_daddr_t i_blkno; /* blkno of inode buffer */
2bd0ea18
NS
275 ushort i_len; /* len of inode buffer */
276 ushort i_boffset; /* off of inode in buffer */
277
278 /* Extent information. */
279 xfs_ifork_t *i_afp; /* attribute fork pointer */
280 xfs_ifork_t i_df; /* data fork */
281
282 /* Transaction and locking information. */
283 struct xfs_trans *i_transp; /* ptr to owning transaction*/
284 struct xfs_inode_log_item *i_itemp; /* logging information */
285 mrlock_t i_lock; /* inode lock */
286 mrlock_t i_iolock; /* inode IO lock */
287 sema_t i_flock; /* inode flush lock */
db15fab1
NS
288 atomic_t i_pincount; /* inode pin count */
289 wait_queue_head_t i_ipin_wait; /* inode pinning wait queue */
006d8e9a 290 struct xfs_inode **i_refcache; /* ptr to entry in ref cache */
2bd0ea18
NS
291 struct xfs_inode *i_release; /* inode to unref */
292
293 /* I/O state */
294 xfs_iocore_t i_iocore; /* I/O core */
295
296 /* Miscellaneous state. */
297 unsigned short i_flags; /* see defined flags below */
3e535bba
NS
298 unsigned char i_update_core; /* timestamps/size is dirty */
299 unsigned char i_update_size; /* di_size field is dirty */
2bd0ea18 300 unsigned int i_gen; /* generation count */
5000d01d 301 unsigned int i_delayed_blks; /* count of delay alloc blks */
2bd0ea18
NS
302
303 xfs_dinode_core_t i_d; /* most of ondisk inode */
304 xfs_chashlist_t *i_chash; /* cluster hash list header */
305 struct xfs_inode *i_cnext; /* cluster hash link forward */
306 struct xfs_inode *i_cprev; /* cluster hash link backward */
307
308#ifdef DEBUG
309 /* Trace buffers per inode. */
310 struct ktrace *i_xtrace; /* inode extent list trace */
311 struct ktrace *i_btrace; /* inode bmap btree trace */
312 struct ktrace *i_rwtrace; /* inode read/write trace */
5000d01d 313 struct ktrace *i_strat_trace; /* inode strat_write trace */
2bd0ea18
NS
314 struct ktrace *i_lock_trace; /* inode lock/unlock trace */
315 struct ktrace *i_dir_trace; /* inode directory trace */
316#endif /* DEBUG */
317} xfs_inode_t;
318
319#endif /* __KERNEL__ */
320
321
322/*
323 * Fork handling.
324 */
325#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_IFORK_PTR)
326xfs_ifork_t *xfs_ifork_ptr(xfs_inode_t *ip, int w);
5000d01d 327#define XFS_IFORK_PTR(ip,w) xfs_ifork_ptr(ip,w)
2bd0ea18 328#else
5000d01d 329#define XFS_IFORK_PTR(ip,w) ((w) == XFS_DATA_FORK ? &(ip)->i_df : (ip)->i_afp)
2bd0ea18
NS
330#endif
331#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_IFORK_Q)
332int xfs_ifork_q(xfs_inode_t *ip);
5000d01d 333#define XFS_IFORK_Q(ip) xfs_ifork_q(ip)
2bd0ea18 334#else
5000d01d 335#define XFS_IFORK_Q(ip) XFS_CFORK_Q(&(ip)->i_d)
2bd0ea18
NS
336#endif
337#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_IFORK_DSIZE)
338int xfs_ifork_dsize(xfs_inode_t *ip);
5000d01d 339#define XFS_IFORK_DSIZE(ip) xfs_ifork_dsize(ip)
2bd0ea18 340#else
5000d01d 341#define XFS_IFORK_DSIZE(ip) XFS_CFORK_DSIZE(&ip->i_d, ip->i_mount)
2bd0ea18
NS
342#endif
343#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_IFORK_ASIZE)
344int xfs_ifork_asize(xfs_inode_t *ip);
5000d01d 345#define XFS_IFORK_ASIZE(ip) xfs_ifork_asize(ip)
2bd0ea18 346#else
5000d01d 347#define XFS_IFORK_ASIZE(ip) XFS_CFORK_ASIZE(&ip->i_d, ip->i_mount)
2bd0ea18
NS
348#endif
349#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_IFORK_SIZE)
350int xfs_ifork_size(xfs_inode_t *ip, int w);
5000d01d 351#define XFS_IFORK_SIZE(ip,w) xfs_ifork_size(ip,w)
2bd0ea18 352#else
5000d01d 353#define XFS_IFORK_SIZE(ip,w) XFS_CFORK_SIZE(&ip->i_d, ip->i_mount, w)
2bd0ea18
NS
354#endif
355#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_IFORK_FORMAT)
356int xfs_ifork_format(xfs_inode_t *ip, int w);
5000d01d 357#define XFS_IFORK_FORMAT(ip,w) xfs_ifork_format(ip,w)
2bd0ea18 358#else
5000d01d 359#define XFS_IFORK_FORMAT(ip,w) XFS_CFORK_FORMAT(&ip->i_d, w)
2bd0ea18
NS
360#endif
361#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_IFORK_FMT_SET)
362void xfs_ifork_fmt_set(xfs_inode_t *ip, int w, int n);
5000d01d 363#define XFS_IFORK_FMT_SET(ip,w,n) xfs_ifork_fmt_set(ip,w,n)
2bd0ea18 364#else
5000d01d 365#define XFS_IFORK_FMT_SET(ip,w,n) XFS_CFORK_FMT_SET(&ip->i_d, w, n)
2bd0ea18
NS
366#endif
367#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_IFORK_NEXTENTS)
368int xfs_ifork_nextents(xfs_inode_t *ip, int w);
5000d01d 369#define XFS_IFORK_NEXTENTS(ip,w) xfs_ifork_nextents(ip,w)
2bd0ea18 370#else
5000d01d 371#define XFS_IFORK_NEXTENTS(ip,w) XFS_CFORK_NEXTENTS(&ip->i_d, w)
2bd0ea18
NS
372#endif
373#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_IFORK_NEXT_SET)
374void xfs_ifork_next_set(xfs_inode_t *ip, int w, int n);
5000d01d 375#define XFS_IFORK_NEXT_SET(ip,w,n) xfs_ifork_next_set(ip,w,n)
2bd0ea18 376#else
5000d01d 377#define XFS_IFORK_NEXT_SET(ip,w,n) XFS_CFORK_NEXT_SET(&ip->i_d, w, n)
2bd0ea18
NS
378#endif
379
380
381#ifdef __KERNEL__
382
383/*
384 * In-core inode flags.
385 */
5000d01d
SL
386#define XFS_IGRIO 0x0001 /* inode used for guaranteed rate i/o */
387#define XFS_IUIOSZ 0x0002 /* inode i/o sizes have been explicitly set */
388#define XFS_IQUIESCE 0x0004 /* we have started quiescing for this inode */
389#define XFS_IRECLAIM 0x0008 /* we have started reclaiming this inode */
2bd0ea18
NS
390
391/*
392 * Flags for inode locking.
393 */
5000d01d
SL
394#define XFS_IOLOCK_EXCL 0x001
395#define XFS_IOLOCK_SHARED 0x002
396#define XFS_ILOCK_EXCL 0x004
397#define XFS_ILOCK_SHARED 0x008
398#define XFS_IUNLOCK_NONOTIFY 0x010
2bd0ea18
NS
399#define XFS_EXTENT_TOKEN_RD 0x040
400#define XFS_SIZE_TOKEN_RD 0x080
401#define XFS_EXTSIZE_RD (XFS_EXTENT_TOKEN_RD|XFS_SIZE_TOKEN_RD)
402#define XFS_WILLLEND 0x100 /* Always acquire tokens for lending */
403#define XFS_EXTENT_TOKEN_WR (XFS_EXTENT_TOKEN_RD | XFS_WILLLEND)
5000d01d 404#define XFS_SIZE_TOKEN_WR (XFS_SIZE_TOKEN_RD | XFS_WILLLEND)
2bd0ea18
NS
405#define XFS_EXTSIZE_WR (XFS_EXTSIZE_RD | XFS_WILLLEND)
406
407
408#define XFS_LOCK_MASK \
409 (XFS_IOLOCK_EXCL | XFS_IOLOCK_SHARED | XFS_ILOCK_EXCL | \
2bd0ea18
NS
410 XFS_ILOCK_SHARED | XFS_EXTENT_TOKEN_RD | XFS_SIZE_TOKEN_RD | \
411 XFS_WILLLEND)
412
413/*
414 * Flags for xfs_iflush()
415 */
5000d01d
SL
416#define XFS_IFLUSH_DELWRI_ELSE_SYNC 1
417#define XFS_IFLUSH_DELWRI_ELSE_ASYNC 2
418#define XFS_IFLUSH_SYNC 3
419#define XFS_IFLUSH_ASYNC 4
420#define XFS_IFLUSH_DELWRI 5
2bd0ea18
NS
421
422/*
423 * Flags for xfs_iflush_all.
424 */
5000d01d 425#define XFS_FLUSH_ALL 0x1
2bd0ea18
NS
426
427/*
428 * Flags for xfs_itruncate_start().
429 */
5000d01d
SL
430#define XFS_ITRUNC_DEFINITE 0x1
431#define XFS_ITRUNC_MAYBE 0x2
2bd0ea18
NS
432
433/*
43a8fc1e 434 * if XFS_BIG_FILES, 2^(31+PAGE_SHIFT) - 1 (due to linux page cache),
2bd0ea18 435 * else 2^40 - 1 (40=31+9) (might be an int holding a block #)
1f9cea39
ES
436 *
437 * NOTE: XFS itself can handle 2^63 - 1 (largest positive value of xfs_fsize_t)
43a8fc1e 438 * but Linux can't go above 2^(31+PAGE_SHIFT)-1: the Linux VM uses a 32 bit
5000d01d 439 * signed variable to index cache data, so 2^31 * PAGE_SIZE is as big as
1f9cea39 440 * you can go.
2bd0ea18 441 */
43a8fc1e 442#define XFS_MAX_FILE_OFFSET ((long long)((1ULL<<(31+PAGE_SHIFT))-1ULL))
2bd0ea18
NS
443
444#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_ITOV)
445struct vnode *xfs_itov(xfs_inode_t *ip);
5000d01d 446#define XFS_ITOV(ip) xfs_itov(ip)
2bd0ea18 447#else
5000d01d 448#define XFS_ITOV(ip) BHV_TO_VNODE(XFS_ITOBHV(ip))
2bd0ea18 449#endif
5000d01d 450#define XFS_ITOV_NULL(ip) BHV_TO_VNODE_NULL(XFS_ITOBHV(ip))
2bd0ea18
NS
451#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_ITOBHV)
452struct bhv_desc *xfs_itobhv(xfs_inode_t *ip);
5000d01d 453#define XFS_ITOBHV(ip) xfs_itobhv(ip)
2bd0ea18 454#else
5000d01d 455#define XFS_ITOBHV(ip) ((struct bhv_desc *)(&((ip)->i_bhv_desc)))
2bd0ea18
NS
456#endif
457#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_BHVTOI)
458xfs_inode_t *xfs_bhvtoi(struct bhv_desc *bhvp);
5000d01d 459#define XFS_BHVTOI(bhvp) xfs_bhvtoi(bhvp)
2bd0ea18 460#else
5000d01d 461#define XFS_BHVTOI(bhvp) \
2bd0ea18
NS
462 ((xfs_inode_t *)((char *)(bhvp) - \
463 (char *)&(((xfs_inode_t *)0)->i_bhv_desc)))
464#endif
465
466#define BHV_IS_XFS(bdp) (BHV_OPS(bdp) == &xfs_vnodeops)
467
468/*
469 * Pick the inode cluster hash bucket
470 * (m_chash is the same size as m_ihash)
471 */
472#define XFS_CHASH(mp,blk) ((mp)->m_chash + (((uint)blk) % (mp)->m_chsize))
473
7e039a24
NS
474/*
475 * For multiple groups support: if ISGID bit is set in the parent
476 * directory, group of new file is set to that of the parent, and
477 * new subdirectory gets ISGID bit from parent.
478 */
479#define XFS_INHERIT_GID(pip, vfsp) ((pip) != NULL && \
480 (((vfsp)->vfs_flag & VFS_GRPID) || ((pip)->i_d.di_mode & ISGID)))
2bd0ea18
NS
481
482/*
483 * xfs_iget.c prototypes.
484 */
485void xfs_ihash_init(struct xfs_mount *);
486void xfs_ihash_free(struct xfs_mount *);
487void xfs_chash_init(struct xfs_mount *);
488void xfs_chash_free(struct xfs_mount *);
489xfs_inode_t *xfs_inode_incore(struct xfs_mount *, xfs_ino_t,
490 struct xfs_trans *);
5000d01d 491void xfs_inode_lock_init(xfs_inode_t *, struct vnode *);
2bd0ea18
NS
492int xfs_iget(struct xfs_mount *, struct xfs_trans *, xfs_ino_t,
493 uint, xfs_inode_t **, xfs_daddr_t);
6c5da395 494int xfs_vn_iget(vfs_t *, struct vnode *, xfs_ino_t);
2bd0ea18 495void xfs_iput(xfs_inode_t *, uint);
d663096d 496void xfs_iput_new(xfs_inode_t *, uint);
2bd0ea18
NS
497void xfs_ilock(xfs_inode_t *, uint);
498int xfs_ilock_nowait(xfs_inode_t *, uint);
499void xfs_iunlock(xfs_inode_t *, uint);
500void xfs_ilock_demote(xfs_inode_t *, uint);
501void xfs_iflock(xfs_inode_t *);
502int xfs_iflock_nowait(xfs_inode_t *);
503uint xfs_ilock_map_shared(xfs_inode_t *);
504void xfs_iunlock_map_shared(xfs_inode_t *, uint);
505void xfs_ifunlock(xfs_inode_t *);
506void xfs_ireclaim(xfs_inode_t *);
61d8f4c3 507int xfs_finish_reclaim(xfs_inode_t *, int, int);
2bd0ea18
NS
508
509/*
510 * xfs_inode.c prototypes.
511 */
512int xfs_inotobp(struct xfs_mount *, struct xfs_trans *, xfs_ino_t,
513 xfs_dinode_t **, struct xfs_buf **, int *);
514int xfs_itobp(struct xfs_mount *, struct xfs_trans *,
515 xfs_inode_t *, xfs_dinode_t **, struct xfs_buf **,
516 xfs_daddr_t);
517int xfs_iread(struct xfs_mount *, struct xfs_trans *, xfs_ino_t,
518 xfs_inode_t **, xfs_daddr_t);
519int xfs_iread_extents(struct xfs_trans *, xfs_inode_t *, int);
520int xfs_ialloc(struct xfs_trans *, xfs_inode_t *, mode_t, nlink_t,
5000d01d 521 dev_t, struct cred *, xfs_prid_t, int,
2bd0ea18
NS
522 struct xfs_buf **, boolean_t *, xfs_inode_t **);
523void xfs_xlate_dinode_core(xfs_caddr_t, struct xfs_dinode_core *, int,
524 xfs_arch_t);
525int xfs_ifree(struct xfs_trans *, xfs_inode_t *);
526int xfs_atruncate_start(xfs_inode_t *);
527void xfs_itruncate_start(xfs_inode_t *, uint, xfs_fsize_t);
528int xfs_itruncate_finish(struct xfs_trans **, xfs_inode_t *,
529 xfs_fsize_t, int, int);
530int xfs_iunlink(struct xfs_trans *, xfs_inode_t *);
531int xfs_igrow_start(xfs_inode_t *, xfs_fsize_t, struct cred *);
532void xfs_igrow_finish(struct xfs_trans *, xfs_inode_t *,
533 xfs_fsize_t, int);
534
535void xfs_idestroy_fork(xfs_inode_t *, int);
536void xfs_idestroy(xfs_inode_t *);
537void xfs_idata_realloc(xfs_inode_t *, int, int);
538void xfs_iextract(xfs_inode_t *);
539void xfs_iext_realloc(xfs_inode_t *, int, int);
540void xfs_iroot_realloc(xfs_inode_t *, int, int);
541void xfs_ipin(xfs_inode_t *);
542void xfs_iunpin(xfs_inode_t *);
2bd0ea18
NS
543int xfs_iextents_copy(xfs_inode_t *, xfs_bmbt_rec_32_t *, int);
544int xfs_iflush(xfs_inode_t *, uint);
545int xfs_iflush_all(struct xfs_mount *, int);
5000d01d 546int xfs_ibusy_check(xfs_inode_t *, int);
90e48754 547int xfs_iaccess(xfs_inode_t *, mode_t, cred_t *);
2bd0ea18
NS
548uint xfs_iroundup(uint);
549void xfs_ichgtime(xfs_inode_t *, int);
550xfs_fsize_t xfs_file_last_byte(xfs_inode_t *);
2bd0ea18
NS
551void xfs_lock_inodes(xfs_inode_t **, int, int, uint);
552
db15fab1
NS
553#define xfs_ipincount(ip) ((unsigned int) atomic_read(&ip->i_pincount))
554
555
2bd0ea18
NS
556
557#ifdef DEBUG
558void xfs_isize_check(struct xfs_mount *, xfs_inode_t *, xfs_fsize_t);
559#else /* DEBUG */
560#define xfs_isize_check(mp, ip, isize)
561#endif /* DEBUG */
562
563#if defined(DEBUG)
564void xfs_inobp_check(struct xfs_mount *, struct xfs_buf *);
565#else
5000d01d 566#define xfs_inobp_check(mp, bp)
2bd0ea18
NS
567#endif /* DEBUG */
568
836f654f
NS
569extern struct kmem_zone *xfs_chashlist_zone;
570extern struct kmem_zone *xfs_ifork_zone;
571extern struct kmem_zone *xfs_inode_zone;
572extern struct kmem_zone *xfs_ili_zone;
2bd0ea18
NS
573extern struct vnodeops xfs_vnodeops;
574
575#ifdef XFS_ILOCK_TRACE
576#define XFS_ILOCK_KTRACE_SIZE 32
5000d01d 577void xfs_ilock_trace(xfs_inode_t *ip, int lock, unsigned int lockflags,
2bd0ea18
NS
578 inst_t *ra);
579#endif
580
581#endif /* __KERNEL__ */
582
583#endif /* __XFS_INODE_H__ */