aboutsummaryrefslogtreecommitdiffstats
path: root/fs/xfs/xfs_inode.h
diff options
context:
space:
mode:
Diffstat (limited to 'fs/xfs/xfs_inode.h')
-rw-r--r--fs/xfs/xfs_inode.h288
1 files changed, 149 insertions, 139 deletions
diff --git a/fs/xfs/xfs_inode.h b/fs/xfs/xfs_inode.h
index 1420c49674d7..7f007ef4bbb3 100644
--- a/fs/xfs/xfs_inode.h
+++ b/fs/xfs/xfs_inode.h
@@ -20,7 +20,7 @@
20 20
21struct xfs_dinode; 21struct xfs_dinode;
22struct xfs_dinode_core; 22struct xfs_dinode_core;
23 23struct xfs_inode;
24 24
25/* 25/*
26 * Fork identifiers. 26 * Fork identifiers.
@@ -63,7 +63,7 @@ typedef struct xfs_ext_irec {
63typedef struct xfs_ifork { 63typedef struct xfs_ifork {
64 int if_bytes; /* bytes in if_u1 */ 64 int if_bytes; /* bytes in if_u1 */
65 int if_real_bytes; /* bytes allocated in if_u1 */ 65 int if_real_bytes; /* bytes allocated in if_u1 */
66 xfs_bmbt_block_t *if_broot; /* file's incore btree root */ 66 struct xfs_btree_block *if_broot; /* file's incore btree root */
67 short if_broot_bytes; /* bytes allocated for root */ 67 short if_broot_bytes; /* bytes allocated for root */
68 unsigned char if_flags; /* per-fork flags */ 68 unsigned char if_flags; /* per-fork flags */
69 unsigned char if_ext_max; /* max # of extent records */ 69 unsigned char if_ext_max; /* max # of extent records */
@@ -84,54 +84,6 @@ typedef struct xfs_ifork {
84} xfs_ifork_t; 84} xfs_ifork_t;
85 85
86/* 86/*
87 * Flags for xfs_ichgtime().
88 */
89#define XFS_ICHGTIME_MOD 0x1 /* data fork modification timestamp */
90#define XFS_ICHGTIME_CHG 0x2 /* inode field change timestamp */
91
92/*
93 * Per-fork incore inode flags.
94 */
95#define XFS_IFINLINE 0x01 /* Inline data is read in */
96#define XFS_IFEXTENTS 0x02 /* All extent pointers are read in */
97#define XFS_IFBROOT 0x04 /* i_broot points to the bmap b-tree root */
98#define XFS_IFEXTIREC 0x08 /* Indirection array of extent blocks */
99
100/*
101 * Flags for xfs_itobp(), xfs_imap() and xfs_dilocate().
102 */
103#define XFS_IMAP_LOOKUP 0x1
104#define XFS_IMAP_BULKSTAT 0x2
105
106#ifdef __KERNEL__
107struct bhv_desc;
108struct cred;
109struct ktrace;
110struct xfs_buf;
111struct xfs_bmap_free;
112struct xfs_bmbt_irec;
113struct xfs_bmbt_block;
114struct xfs_inode;
115struct xfs_inode_log_item;
116struct xfs_mount;
117struct xfs_trans;
118struct xfs_dquot;
119
120#if defined(XFS_ILOCK_TRACE)
121#define XFS_ILOCK_KTRACE_SIZE 32
122extern ktrace_t *xfs_ilock_trace_buf;
123extern void xfs_ilock_trace(struct xfs_inode *, int, unsigned int, inst_t *);
124#else
125#define xfs_ilock_trace(i,n,f,ra)
126#endif
127
128typedef 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/*
135 * This is the xfs in-core inode structure. 87 * This is the xfs in-core inode structure.
136 * Most of the on-disk inode is embedded in the i_d field. 88 * Most of the on-disk inode is embedded in the i_d field.
137 * 89 *
@@ -191,19 +143,98 @@ typedef struct xfs_icdinode {
191 __uint32_t di_gen; /* generation number */ 143 __uint32_t di_gen; /* generation number */
192} xfs_icdinode_t; 144} xfs_icdinode_t;
193 145
194typedef struct { 146/*
195 struct xfs_inode *ip_mnext; /* next inode in mount list */ 147 * Flags for xfs_ichgtime().
196 struct xfs_inode *ip_mprev; /* ptr to prev inode */ 148 */
197 struct xfs_mount *ip_mount; /* fs mount struct ptr */ 149#define XFS_ICHGTIME_MOD 0x1 /* data fork modification timestamp */
198} xfs_iptr_t; 150#define XFS_ICHGTIME_CHG 0x2 /* inode field change timestamp */
151
152/*
153 * Per-fork incore inode flags.
154 */
155#define XFS_IFINLINE 0x01 /* Inline data is read in */
156#define XFS_IFEXTENTS 0x02 /* All extent pointers are read in */
157#define XFS_IFBROOT 0x04 /* i_broot points to the bmap b-tree root */
158#define XFS_IFEXTIREC 0x08 /* Indirection array of extent blocks */
159
160/*
161 * Flags for xfs_inotobp, xfs_itobp(), xfs_imap() and xfs_dilocate().
162 */
163#define XFS_IMAP_LOOKUP 0x1
164#define XFS_IMAP_BULKSTAT 0x2
165
166/*
167 * Fork handling.
168 */
169
170#define XFS_IFORK_Q(ip) ((ip)->i_d.di_forkoff != 0)
171#define XFS_IFORK_BOFF(ip) ((int)((ip)->i_d.di_forkoff << 3))
172
173#define XFS_IFORK_PTR(ip,w) \
174 ((w) == XFS_DATA_FORK ? \
175 &(ip)->i_df : \
176 (ip)->i_afp)
177#define XFS_IFORK_DSIZE(ip) \
178 (XFS_IFORK_Q(ip) ? \
179 XFS_IFORK_BOFF(ip) : \
180 XFS_LITINO((ip)->i_mount))
181#define XFS_IFORK_ASIZE(ip) \
182 (XFS_IFORK_Q(ip) ? \
183 XFS_LITINO((ip)->i_mount) - XFS_IFORK_BOFF(ip) : \
184 0)
185#define XFS_IFORK_SIZE(ip,w) \
186 ((w) == XFS_DATA_FORK ? \
187 XFS_IFORK_DSIZE(ip) : \
188 XFS_IFORK_ASIZE(ip))
189#define XFS_IFORK_FORMAT(ip,w) \
190 ((w) == XFS_DATA_FORK ? \
191 (ip)->i_d.di_format : \
192 (ip)->i_d.di_aformat)
193#define XFS_IFORK_FMT_SET(ip,w,n) \
194 ((w) == XFS_DATA_FORK ? \
195 ((ip)->i_d.di_format = (n)) : \
196 ((ip)->i_d.di_aformat = (n)))
197#define XFS_IFORK_NEXTENTS(ip,w) \
198 ((w) == XFS_DATA_FORK ? \
199 (ip)->i_d.di_nextents : \
200 (ip)->i_d.di_anextents)
201#define XFS_IFORK_NEXT_SET(ip,w,n) \
202 ((w) == XFS_DATA_FORK ? \
203 ((ip)->i_d.di_nextents = (n)) : \
204 ((ip)->i_d.di_anextents = (n)))
205
206
207
208#ifdef __KERNEL__
209
210struct bhv_desc;
211struct cred;
212struct ktrace;
213struct xfs_buf;
214struct xfs_bmap_free;
215struct xfs_bmbt_irec;
216struct xfs_inode_log_item;
217struct xfs_mount;
218struct xfs_trans;
219struct xfs_dquot;
220
221#if defined(XFS_ILOCK_TRACE)
222#define XFS_ILOCK_KTRACE_SIZE 32
223extern ktrace_t *xfs_ilock_trace_buf;
224extern void xfs_ilock_trace(struct xfs_inode *, int, unsigned int, inst_t *);
225#else
226#define xfs_ilock_trace(i,n,f,ra)
227#endif
228
229typedef struct dm_attrs_s {
230 __uint32_t da_dmevmask; /* DMIG event mask */
231 __uint16_t da_dmstate; /* DMIG state info */
232 __uint16_t da_pad; /* DMIG extra padding */
233} dm_attrs_t;
199 234
200typedef struct xfs_inode { 235typedef struct xfs_inode {
201 /* Inode linking and identification information. */ 236 /* Inode linking and identification information. */
202 struct xfs_inode *i_mnext; /* next inode in mount list */
203 struct xfs_inode *i_mprev; /* ptr to prev inode */
204 struct xfs_mount *i_mount; /* fs mount struct ptr */ 237 struct xfs_mount *i_mount; /* fs mount struct ptr */
205 struct list_head i_reclaim; /* reclaim list */
206 struct inode *i_vnode; /* vnode backpointer */
207 struct xfs_dquot *i_udquot; /* user dquot */ 238 struct xfs_dquot *i_udquot; /* user dquot */
208 struct xfs_dquot *i_gdquot; /* group dquot */ 239 struct xfs_dquot *i_gdquot; /* group dquot */
209 240
@@ -238,6 +269,10 @@ typedef struct xfs_inode {
238 xfs_fsize_t i_size; /* in-memory size */ 269 xfs_fsize_t i_size; /* in-memory size */
239 xfs_fsize_t i_new_size; /* size when write completes */ 270 xfs_fsize_t i_new_size; /* size when write completes */
240 atomic_t i_iocount; /* outstanding I/O count */ 271 atomic_t i_iocount; /* outstanding I/O count */
272
273 /* VFS inode */
274 struct inode i_vnode; /* embedded VFS inode */
275
241 /* Trace buffers per inode. */ 276 /* Trace buffers per inode. */
242#ifdef XFS_INODE_TRACE 277#ifdef XFS_INODE_TRACE
243 struct ktrace *i_trace; /* general inode trace */ 278 struct ktrace *i_trace; /* general inode trace */
@@ -245,7 +280,7 @@ typedef struct xfs_inode {
245#ifdef XFS_BMAP_TRACE 280#ifdef XFS_BMAP_TRACE
246 struct ktrace *i_xtrace; /* inode extent list trace */ 281 struct ktrace *i_xtrace; /* inode extent list trace */
247#endif 282#endif
248#ifdef XFS_BMBT_TRACE 283#ifdef XFS_BTREE_TRACE
249 struct ktrace *i_btrace; /* inode bmap btree trace */ 284 struct ktrace *i_btrace; /* inode bmap btree trace */
250#endif 285#endif
251#ifdef XFS_RW_TRACE 286#ifdef XFS_RW_TRACE
@@ -265,13 +300,30 @@ typedef struct xfs_inode {
265/* Convert from vfs inode to xfs inode */ 300/* Convert from vfs inode to xfs inode */
266static inline struct xfs_inode *XFS_I(struct inode *inode) 301static inline struct xfs_inode *XFS_I(struct inode *inode)
267{ 302{
268 return (struct xfs_inode *)inode->i_private; 303 return container_of(inode, struct xfs_inode, i_vnode);
269} 304}
270 305
271/* convert from xfs inode to vfs inode */ 306/* convert from xfs inode to vfs inode */
272static inline struct inode *VFS_I(struct xfs_inode *ip) 307static inline struct inode *VFS_I(struct xfs_inode *ip)
273{ 308{
274 return (struct inode *)ip->i_vnode; 309 return &ip->i_vnode;
310}
311
312/*
313 * Get rid of a partially initialized inode.
314 *
315 * We have to go through destroy_inode to make sure allocations
316 * from init_inode_always like the security data are undone.
317 *
318 * We mark the inode bad so that it takes the short cut in
319 * the reclaim path instead of going through the flush path
320 * which doesn't make sense for an inode that has never seen the
321 * light of day.
322 */
323static inline void xfs_destroy_inode(struct xfs_inode *ip)
324{
325 make_bad_inode(VFS_I(ip));
326 return destroy_inode(VFS_I(ip));
275} 327}
276 328
277/* 329/*
@@ -327,50 +379,26 @@ xfs_iflags_test_and_clear(xfs_inode_t *ip, unsigned short flags)
327 spin_unlock(&ip->i_flags_lock); 379 spin_unlock(&ip->i_flags_lock);
328 return ret; 380 return ret;
329} 381}
330#endif /* __KERNEL__ */
331
332 382
333/* 383/*
334 * Fork handling. 384 * Manage the i_flush queue embedded in the inode. This completion
385 * queue synchronizes processes attempting to flush the in-core
386 * inode back to disk.
335 */ 387 */
388static inline void xfs_iflock(xfs_inode_t *ip)
389{
390 wait_for_completion(&ip->i_flush);
391}
336 392
337#define XFS_IFORK_Q(ip) ((ip)->i_d.di_forkoff != 0) 393static inline int xfs_iflock_nowait(xfs_inode_t *ip)
338#define XFS_IFORK_BOFF(ip) ((int)((ip)->i_d.di_forkoff << 3)) 394{
339 395 return try_wait_for_completion(&ip->i_flush);
340#define XFS_IFORK_PTR(ip,w) \ 396}
341 ((w) == XFS_DATA_FORK ? \
342 &(ip)->i_df : \
343 (ip)->i_afp)
344#define XFS_IFORK_DSIZE(ip) \
345 (XFS_IFORK_Q(ip) ? \
346 XFS_IFORK_BOFF(ip) : \
347 XFS_LITINO((ip)->i_mount))
348#define XFS_IFORK_ASIZE(ip) \
349 (XFS_IFORK_Q(ip) ? \
350 XFS_LITINO((ip)->i_mount) - XFS_IFORK_BOFF(ip) : \
351 0)
352#define XFS_IFORK_SIZE(ip,w) \
353 ((w) == XFS_DATA_FORK ? \
354 XFS_IFORK_DSIZE(ip) : \
355 XFS_IFORK_ASIZE(ip))
356#define XFS_IFORK_FORMAT(ip,w) \
357 ((w) == XFS_DATA_FORK ? \
358 (ip)->i_d.di_format : \
359 (ip)->i_d.di_aformat)
360#define XFS_IFORK_FMT_SET(ip,w,n) \
361 ((w) == XFS_DATA_FORK ? \
362 ((ip)->i_d.di_format = (n)) : \
363 ((ip)->i_d.di_aformat = (n)))
364#define XFS_IFORK_NEXTENTS(ip,w) \
365 ((w) == XFS_DATA_FORK ? \
366 (ip)->i_d.di_nextents : \
367 (ip)->i_d.di_anextents)
368#define XFS_IFORK_NEXT_SET(ip,w,n) \
369 ((w) == XFS_DATA_FORK ? \
370 ((ip)->i_d.di_nextents = (n)) : \
371 ((ip)->i_d.di_anextents = (n)))
372 397
373#ifdef __KERNEL__ 398static inline void xfs_ifunlock(xfs_inode_t *ip)
399{
400 complete(&ip->i_flush);
401}
374 402
375/* 403/*
376 * In-core inode flags. 404 * In-core inode flags.
@@ -484,25 +512,15 @@ int xfs_isilocked(xfs_inode_t *, uint);
484uint xfs_ilock_map_shared(xfs_inode_t *); 512uint xfs_ilock_map_shared(xfs_inode_t *);
485void xfs_iunlock_map_shared(xfs_inode_t *, uint); 513void xfs_iunlock_map_shared(xfs_inode_t *, uint);
486void xfs_ireclaim(xfs_inode_t *); 514void xfs_ireclaim(xfs_inode_t *);
487int xfs_finish_reclaim(xfs_inode_t *, int, int);
488int xfs_finish_reclaim_all(struct xfs_mount *, int);
489 515
490/* 516/*
491 * xfs_inode.c prototypes. 517 * xfs_inode.c prototypes.
492 */ 518 */
493int xfs_itobp(struct xfs_mount *, struct xfs_trans *,
494 xfs_inode_t *, struct xfs_dinode **, struct xfs_buf **,
495 xfs_daddr_t, uint, uint);
496int xfs_iread(struct xfs_mount *, struct xfs_trans *, xfs_ino_t, 519int xfs_iread(struct xfs_mount *, struct xfs_trans *, xfs_ino_t,
497 xfs_inode_t **, xfs_daddr_t, uint); 520 xfs_inode_t **, xfs_daddr_t, uint);
498int xfs_iread_extents(struct xfs_trans *, xfs_inode_t *, int);
499int xfs_ialloc(struct xfs_trans *, xfs_inode_t *, mode_t, 521int xfs_ialloc(struct xfs_trans *, xfs_inode_t *, mode_t,
500 xfs_nlink_t, xfs_dev_t, struct cred *, xfs_prid_t, 522 xfs_nlink_t, xfs_dev_t, struct cred *, xfs_prid_t,
501 int, struct xfs_buf **, boolean_t *, xfs_inode_t **); 523 int, struct xfs_buf **, boolean_t *, xfs_inode_t **);
502void xfs_dinode_from_disk(struct xfs_icdinode *,
503 struct xfs_dinode_core *);
504void xfs_dinode_to_disk(struct xfs_dinode_core *,
505 struct xfs_icdinode *);
506 524
507uint xfs_ip2xflags(struct xfs_inode *); 525uint xfs_ip2xflags(struct xfs_inode *);
508uint xfs_dic2xflags(struct xfs_dinode *); 526uint xfs_dic2xflags(struct xfs_dinode *);
@@ -513,17 +531,12 @@ int xfs_itruncate_finish(struct xfs_trans **, xfs_inode_t *,
513 xfs_fsize_t, int, int); 531 xfs_fsize_t, int, int);
514int xfs_iunlink(struct xfs_trans *, xfs_inode_t *); 532int xfs_iunlink(struct xfs_trans *, xfs_inode_t *);
515 533
516void xfs_idestroy_fork(xfs_inode_t *, int);
517void xfs_idestroy(xfs_inode_t *); 534void xfs_idestroy(xfs_inode_t *);
518void xfs_idata_realloc(xfs_inode_t *, int, int);
519void xfs_iextract(xfs_inode_t *); 535void xfs_iextract(xfs_inode_t *);
520void xfs_iext_realloc(xfs_inode_t *, int, int); 536void xfs_iext_realloc(xfs_inode_t *, int, int);
521void xfs_iroot_realloc(xfs_inode_t *, int, int);
522void xfs_ipin(xfs_inode_t *); 537void xfs_ipin(xfs_inode_t *);
523void xfs_iunpin(xfs_inode_t *); 538void xfs_iunpin(xfs_inode_t *);
524int xfs_iextents_copy(xfs_inode_t *, xfs_bmbt_rec_t *, int);
525int xfs_iflush(xfs_inode_t *, uint); 539int xfs_iflush(xfs_inode_t *, uint);
526void xfs_iflush_all(struct xfs_mount *);
527void xfs_ichgtime(xfs_inode_t *, int); 540void xfs_ichgtime(xfs_inode_t *, int);
528xfs_fsize_t xfs_file_last_byte(xfs_inode_t *); 541xfs_fsize_t xfs_file_last_byte(xfs_inode_t *);
529void xfs_lock_inodes(xfs_inode_t **, int, uint); 542void xfs_lock_inodes(xfs_inode_t **, int, uint);
@@ -532,6 +545,24 @@ void xfs_lock_two_inodes(xfs_inode_t *, xfs_inode_t *, uint);
532void xfs_synchronize_atime(xfs_inode_t *); 545void xfs_synchronize_atime(xfs_inode_t *);
533void xfs_mark_inode_dirty_sync(xfs_inode_t *); 546void xfs_mark_inode_dirty_sync(xfs_inode_t *);
534 547
548#endif /* __KERNEL__ */
549
550int xfs_inotobp(struct xfs_mount *, struct xfs_trans *,
551 xfs_ino_t, struct xfs_dinode **,
552 struct xfs_buf **, int *, uint);
553int xfs_itobp(struct xfs_mount *, struct xfs_trans *,
554 struct xfs_inode *, struct xfs_dinode **,
555 struct xfs_buf **, xfs_daddr_t, uint, uint);
556void xfs_dinode_from_disk(struct xfs_icdinode *,
557 struct xfs_dinode_core *);
558void xfs_dinode_to_disk(struct xfs_dinode_core *,
559 struct xfs_icdinode *);
560void xfs_idestroy_fork(struct xfs_inode *, int);
561void xfs_idata_realloc(struct xfs_inode *, int, int);
562void xfs_iroot_realloc(struct xfs_inode *, int, int);
563int xfs_iread_extents(struct xfs_trans *, struct xfs_inode *, int);
564int xfs_iextents_copy(struct xfs_inode *, xfs_bmbt_rec_t *, int);
565
535xfs_bmbt_rec_host_t *xfs_iext_get_ext(xfs_ifork_t *, xfs_extnum_t); 566xfs_bmbt_rec_host_t *xfs_iext_get_ext(xfs_ifork_t *, xfs_extnum_t);
536void xfs_iext_insert(xfs_ifork_t *, xfs_extnum_t, xfs_extnum_t, 567void xfs_iext_insert(xfs_ifork_t *, xfs_extnum_t, xfs_extnum_t,
537 xfs_bmbt_irec_t *); 568 xfs_bmbt_irec_t *);
@@ -561,7 +592,8 @@ void xfs_iext_irec_update_extoffs(xfs_ifork_t *, int, int);
561#define xfs_ipincount(ip) ((unsigned int) atomic_read(&ip->i_pincount)) 592#define xfs_ipincount(ip) ((unsigned int) atomic_read(&ip->i_pincount))
562 593
563#ifdef DEBUG 594#ifdef DEBUG
564void xfs_isize_check(struct xfs_mount *, xfs_inode_t *, xfs_fsize_t); 595void xfs_isize_check(struct xfs_mount *, struct xfs_inode *,
596 xfs_fsize_t);
565#else /* DEBUG */ 597#else /* DEBUG */
566#define xfs_isize_check(mp, ip, isize) 598#define xfs_isize_check(mp, ip, isize)
567#endif /* DEBUG */ 599#endif /* DEBUG */
@@ -576,26 +608,4 @@ extern struct kmem_zone *xfs_ifork_zone;
576extern struct kmem_zone *xfs_inode_zone; 608extern struct kmem_zone *xfs_inode_zone;
577extern struct kmem_zone *xfs_ili_zone; 609extern struct kmem_zone *xfs_ili_zone;
578 610
579/*
580 * Manage the i_flush queue embedded in the inode. This completion
581 * queue synchronizes processes attempting to flush the in-core
582 * inode back to disk.
583 */
584static inline void xfs_iflock(xfs_inode_t *ip)
585{
586 wait_for_completion(&ip->i_flush);
587}
588
589static inline int xfs_iflock_nowait(xfs_inode_t *ip)
590{
591 return try_wait_for_completion(&ip->i_flush);
592}
593
594static inline void xfs_ifunlock(xfs_inode_t *ip)
595{
596 complete(&ip->i_flush);
597}
598
599#endif /* __KERNEL__ */
600
601#endif /* __XFS_INODE_H__ */ 611#endif /* __XFS_INODE_H__ */