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