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.h158
1 files changed, 92 insertions, 66 deletions
diff --git a/fs/xfs/xfs_inode.h b/fs/xfs/xfs_inode.h
index 012dfd4a958c..e5aff929cc65 100644
--- a/fs/xfs/xfs_inode.h
+++ b/fs/xfs/xfs_inode.h
@@ -18,6 +18,10 @@
18#ifndef __XFS_INODE_H__ 18#ifndef __XFS_INODE_H__
19#define __XFS_INODE_H__ 19#define __XFS_INODE_H__
20 20
21struct xfs_dinode;
22struct xfs_dinode_core;
23
24
21/* 25/*
22 * Fork identifiers. 26 * Fork identifiers.
23 */ 27 */
@@ -44,7 +48,7 @@
44 * it is possible that a third level of indirection may be required. 48 * it is possible that a third level of indirection may be required.
45 */ 49 */
46typedef struct xfs_ext_irec { 50typedef struct xfs_ext_irec {
47 xfs_bmbt_rec_t *er_extbuf; /* block of extent records */ 51 xfs_bmbt_rec_host_t *er_extbuf; /* block of extent records */
48 xfs_extnum_t er_extoff; /* extent offset in file */ 52 xfs_extnum_t er_extoff; /* extent offset in file */
49 xfs_extnum_t er_extcount; /* number of extents in page/block */ 53 xfs_extnum_t er_extcount; /* number of extents in page/block */
50} xfs_ext_irec_t; 54} xfs_ext_irec_t;
@@ -65,12 +69,12 @@ typedef struct xfs_ifork {
65 unsigned char if_ext_max; /* max # of extent records */ 69 unsigned char if_ext_max; /* max # of extent records */
66 xfs_extnum_t if_lastex; /* last if_extents used */ 70 xfs_extnum_t if_lastex; /* last if_extents used */
67 union { 71 union {
68 xfs_bmbt_rec_t *if_extents; /* linear map file exts */ 72 xfs_bmbt_rec_host_t *if_extents;/* linear map file exts */
69 xfs_ext_irec_t *if_ext_irec; /* irec map file exts */ 73 xfs_ext_irec_t *if_ext_irec; /* irec map file exts */
70 char *if_data; /* inline file data */ 74 char *if_data; /* inline file data */
71 } if_u1; 75 } if_u1;
72 union { 76 union {
73 xfs_bmbt_rec_t if_inline_ext[XFS_INLINE_EXTS]; 77 xfs_bmbt_rec_host_t if_inline_ext[XFS_INLINE_EXTS];
74 /* very small file extents */ 78 /* very small file extents */
75 char if_inline_data[XFS_INLINE_DATA]; 79 char if_inline_data[XFS_INLINE_DATA];
76 /* very small file data */ 80 /* very small file data */
@@ -102,7 +106,6 @@ typedef struct xfs_ifork {
102 106
103#ifdef __KERNEL__ 107#ifdef __KERNEL__
104struct bhv_desc; 108struct bhv_desc;
105struct bhv_vnode;
106struct cred; 109struct cred;
107struct ktrace; 110struct ktrace;
108struct xfs_buf; 111struct xfs_buf;
@@ -168,41 +171,18 @@ typedef struct xfs_iocore {
168extern void xfs_iocore_inode_init(struct xfs_inode *); 171extern void xfs_iocore_inode_init(struct xfs_inode *);
169extern void xfs_iocore_inode_reinit(struct xfs_inode *); 172extern void xfs_iocore_inode_reinit(struct xfs_inode *);
170 173
171
172/*
173 * This is the type used in the xfs inode hash table.
174 * An array of these is allocated for each mounted
175 * file system to hash the inodes for that file system.
176 */
177typedef struct xfs_ihash {
178 struct xfs_inode *ih_next;
179 rwlock_t ih_lock;
180 uint ih_version;
181} xfs_ihash_t;
182
183#define XFS_IHASH(mp,ino) ((mp)->m_ihash + (((uint)(ino)) % (mp)->m_ihsize))
184
185/* 174/*
186 * This is the xfs inode cluster hash. This hash is used by xfs_iflush to 175 * This is the xfs inode cluster structure. This structure is used by
187 * find inodes that share a cluster and can be flushed to disk at the same 176 * xfs_iflush to find inodes that share a cluster and can be flushed to disk at
188 * time. 177 * the same time.
189 */ 178 */
190typedef struct xfs_chashlist { 179typedef struct xfs_icluster {
191 struct xfs_chashlist *chl_next; 180 struct hlist_head icl_inodes; /* list of inodes on cluster */
192 struct xfs_chashlist *chl_prev; 181 xfs_daddr_t icl_blkno; /* starting block number of
193 struct xfs_inode *chl_ip;
194 xfs_daddr_t chl_blkno; /* starting block number of
195 * the cluster */ 182 * the cluster */
196 struct xfs_buf *chl_buf; /* the inode buffer */ 183 struct xfs_buf *icl_buf; /* the inode buffer */
197} xfs_chashlist_t; 184 lock_t icl_lock; /* inode list lock */
198 185} xfs_icluster_t;
199typedef struct xfs_chash {
200 xfs_chashlist_t *ch_list;
201 lock_t ch_lock;
202} xfs_chash_t;
203
204#define XFS_CHASH(mp,blk) ((mp)->m_chash + (((uint)blk) % (mp)->m_chsize))
205
206 186
207/* 187/*
208 * This is the xfs in-core inode structure. 188 * This is the xfs in-core inode structure.
@@ -227,25 +207,56 @@ typedef struct xfs_chash {
227 * chain off the mount structure by xfs_sync calls. 207 * chain off the mount structure by xfs_sync calls.
228 */ 208 */
229 209
210typedef struct xfs_ictimestamp {
211 __int32_t t_sec; /* timestamp seconds */
212 __int32_t t_nsec; /* timestamp nanoseconds */
213} xfs_ictimestamp_t;
214
215/*
216 * NOTE: This structure must be kept identical to struct xfs_dinode_core
217 * in xfs_dinode.h except for the endianess annotations.
218 */
219typedef struct xfs_icdinode {
220 __uint16_t di_magic; /* inode magic # = XFS_DINODE_MAGIC */
221 __uint16_t di_mode; /* mode and type of file */
222 __int8_t di_version; /* inode version */
223 __int8_t di_format; /* format of di_c data */
224 __uint16_t di_onlink; /* old number of links to file */
225 __uint32_t di_uid; /* owner's user id */
226 __uint32_t di_gid; /* owner's group id */
227 __uint32_t di_nlink; /* number of links to file */
228 __uint16_t di_projid; /* owner's project id */
229 __uint8_t di_pad[8]; /* unused, zeroed space */
230 __uint16_t di_flushiter; /* incremented on flush */
231 xfs_ictimestamp_t di_atime; /* time last accessed */
232 xfs_ictimestamp_t di_mtime; /* time last modified */
233 xfs_ictimestamp_t di_ctime; /* time created/inode modified */
234 xfs_fsize_t di_size; /* number of bytes in file */
235 xfs_drfsbno_t di_nblocks; /* # of direct & btree blocks used */
236 xfs_extlen_t di_extsize; /* basic/minimum extent size for file */
237 xfs_extnum_t di_nextents; /* number of extents in data fork */
238 xfs_aextnum_t di_anextents; /* number of extents in attribute fork*/
239 __uint8_t di_forkoff; /* attr fork offs, <<3 for 64b align */
240 __int8_t di_aformat; /* format of attr fork's data */
241 __uint32_t di_dmevmask; /* DMIG event mask */
242 __uint16_t di_dmstate; /* DMIG state info */
243 __uint16_t di_flags; /* random flags, XFS_DIFLAG_... */
244 __uint32_t di_gen; /* generation number */
245} xfs_icdinode_t;
246
230typedef struct { 247typedef struct {
231 struct xfs_ihash *ip_hash; /* pointer to hash header */
232 struct xfs_inode *ip_next; /* inode hash link forw */
233 struct xfs_inode *ip_mnext; /* next inode in mount list */ 248 struct xfs_inode *ip_mnext; /* next inode in mount list */
234 struct xfs_inode *ip_mprev; /* ptr to prev inode */ 249 struct xfs_inode *ip_mprev; /* ptr to prev inode */
235 struct xfs_inode **ip_prevp; /* ptr to prev i_next */
236 struct xfs_mount *ip_mount; /* fs mount struct ptr */ 250 struct xfs_mount *ip_mount; /* fs mount struct ptr */
237} xfs_iptr_t; 251} xfs_iptr_t;
238 252
239typedef struct xfs_inode { 253typedef struct xfs_inode {
240 /* Inode linking and identification information. */ 254 /* Inode linking and identification information. */
241 struct xfs_ihash *i_hash; /* pointer to hash header */
242 struct xfs_inode *i_next; /* inode hash link forw */
243 struct xfs_inode *i_mnext; /* next inode in mount list */ 255 struct xfs_inode *i_mnext; /* next inode in mount list */
244 struct xfs_inode *i_mprev; /* ptr to prev inode */ 256 struct xfs_inode *i_mprev; /* ptr to prev inode */
245 struct xfs_inode **i_prevp; /* ptr to prev i_next */
246 struct xfs_mount *i_mount; /* fs mount struct ptr */ 257 struct xfs_mount *i_mount; /* fs mount struct ptr */
247 struct list_head i_reclaim; /* reclaim list */ 258 struct list_head i_reclaim; /* reclaim list */
248 struct bhv_desc i_bhv_desc; /* inode behavior descriptor*/ 259 bhv_vnode_t *i_vnode; /* vnode backpointer */
249 struct xfs_dquot *i_udquot; /* user dquot */ 260 struct xfs_dquot *i_udquot; /* user dquot */
250 struct xfs_dquot *i_gdquot; /* group dquot */ 261 struct xfs_dquot *i_gdquot; /* group dquot */
251 262
@@ -282,13 +293,16 @@ typedef struct xfs_inode {
282 unsigned int i_gen; /* generation count */ 293 unsigned int i_gen; /* generation count */
283 unsigned int i_delayed_blks; /* count of delay alloc blks */ 294 unsigned int i_delayed_blks; /* count of delay alloc blks */
284 295
285 xfs_dinode_core_t i_d; /* most of ondisk inode */ 296 xfs_icdinode_t i_d; /* most of ondisk inode */
286 xfs_chashlist_t *i_chash; /* cluster hash list header */ 297 xfs_icluster_t *i_cluster; /* cluster list header */
287 struct xfs_inode *i_cnext; /* cluster hash link forward */ 298 struct hlist_node i_cnode; /* cluster link node */
288 struct xfs_inode *i_cprev; /* cluster hash link backward */
289 299
290 xfs_fsize_t i_size; /* in-memory size */ 300 xfs_fsize_t i_size; /* in-memory size */
301 atomic_t i_iocount; /* outstanding I/O count */
291 /* Trace buffers per inode. */ 302 /* Trace buffers per inode. */
303#ifdef XFS_VNODE_TRACE
304 struct ktrace *i_trace; /* general inode trace */
305#endif
292#ifdef XFS_BMAP_TRACE 306#ifdef XFS_BMAP_TRACE
293 struct ktrace *i_xtrace; /* inode extent list trace */ 307 struct ktrace *i_xtrace; /* inode extent list trace */
294#endif 308#endif
@@ -349,6 +363,19 @@ xfs_iflags_test(xfs_inode_t *ip, unsigned short flags)
349 spin_unlock(&ip->i_flags_lock); 363 spin_unlock(&ip->i_flags_lock);
350 return ret; 364 return ret;
351} 365}
366
367static inline int
368xfs_iflags_test_and_clear(xfs_inode_t *ip, unsigned short flags)
369{
370 int ret;
371
372 spin_lock(&ip->i_flags_lock);
373 ret = ip->i_flags & flags;
374 if (ret)
375 ip->i_flags &= ~flags;
376 spin_unlock(&ip->i_flags_lock);
377 return ret;
378}
352#endif /* __KERNEL__ */ 379#endif /* __KERNEL__ */
353 380
354 381
@@ -380,6 +407,9 @@ xfs_iflags_test(xfs_inode_t *ip, unsigned short flags)
380#define XFS_IRECLAIMABLE 0x0020 /* inode can be reclaimed */ 407#define XFS_IRECLAIMABLE 0x0020 /* inode can be reclaimed */
381#define XFS_INEW 0x0040 408#define XFS_INEW 0x0040
382#define XFS_IFILESTREAM 0x0080 /* inode is in a filestream directory */ 409#define XFS_IFILESTREAM 0x0080 /* inode is in a filestream directory */
410#define XFS_IMODIFIED 0x0100 /* XFS inode state possibly differs */
411 /* to the Linux inode state. */
412#define XFS_ITRUNCATED 0x0200 /* truncated down so flush-on-close */
383 413
384/* 414/*
385 * Flags for inode locking. 415 * Flags for inode locking.
@@ -454,20 +484,17 @@ xfs_iflags_test(xfs_inode_t *ip, unsigned short flags)
454#define XFS_ITRUNC_DEFINITE 0x1 484#define XFS_ITRUNC_DEFINITE 0x1
455#define XFS_ITRUNC_MAYBE 0x2 485#define XFS_ITRUNC_MAYBE 0x2
456 486
457#define XFS_ITOV(ip) BHV_TO_VNODE(XFS_ITOBHV(ip)) 487#define XFS_ITOV(ip) ((ip)->i_vnode)
458#define XFS_ITOV_NULL(ip) BHV_TO_VNODE_NULL(XFS_ITOBHV(ip)) 488#define XFS_ITOV_NULL(ip) ((ip)->i_vnode)
459#define XFS_ITOBHV(ip) ((struct bhv_desc *)(&((ip)->i_bhv_desc)))
460#define XFS_BHVTOI(bhvp) ((xfs_inode_t *)((char *)(bhvp) - \
461 (char *)&(((xfs_inode_t *)0)->i_bhv_desc)))
462#define BHV_IS_XFS(bdp) (BHV_OPS(bdp) == &xfs_vnodeops)
463 489
464/* 490/*
465 * For multiple groups support: if S_ISGID bit is set in the parent 491 * For multiple groups support: if S_ISGID bit is set in the parent
466 * directory, group of new file is set to that of the parent, and 492 * directory, group of new file is set to that of the parent, and
467 * new subdirectory gets S_ISGID bit from parent. 493 * new subdirectory gets S_ISGID bit from parent.
468 */ 494 */
469#define XFS_INHERIT_GID(pip, vfsp) \ 495#define XFS_INHERIT_GID(pip) \
470 (((vfsp)->vfs_flag & VFS_GRPID) || ((pip)->i_d.di_mode & S_ISGID)) 496 (((pip)->i_mount->m_flags & XFS_MOUNT_GRPID) || \
497 ((pip)->i_d.di_mode & S_ISGID))
471 498
472/* 499/*
473 * Flags for xfs_iget() 500 * Flags for xfs_iget()
@@ -480,11 +507,9 @@ xfs_iflags_test(xfs_inode_t *ip, unsigned short flags)
480 */ 507 */
481void xfs_ihash_init(struct xfs_mount *); 508void xfs_ihash_init(struct xfs_mount *);
482void xfs_ihash_free(struct xfs_mount *); 509void xfs_ihash_free(struct xfs_mount *);
483void xfs_chash_init(struct xfs_mount *);
484void xfs_chash_free(struct xfs_mount *);
485xfs_inode_t *xfs_inode_incore(struct xfs_mount *, xfs_ino_t, 510xfs_inode_t *xfs_inode_incore(struct xfs_mount *, xfs_ino_t,
486 struct xfs_trans *); 511 struct xfs_trans *);
487void xfs_inode_lock_init(xfs_inode_t *, struct bhv_vnode *); 512void xfs_inode_lock_init(xfs_inode_t *, bhv_vnode_t *);
488int xfs_iget(struct xfs_mount *, struct xfs_trans *, xfs_ino_t, 513int xfs_iget(struct xfs_mount *, struct xfs_trans *, xfs_ino_t,
489 uint, uint, xfs_inode_t **, xfs_daddr_t); 514 uint, uint, xfs_inode_t **, xfs_daddr_t);
490void xfs_iput(xfs_inode_t *, uint); 515void xfs_iput(xfs_inode_t *, uint);
@@ -506,7 +531,7 @@ int xfs_finish_reclaim_all(struct xfs_mount *, int);
506 * xfs_inode.c prototypes. 531 * xfs_inode.c prototypes.
507 */ 532 */
508int xfs_itobp(struct xfs_mount *, struct xfs_trans *, 533int xfs_itobp(struct xfs_mount *, struct xfs_trans *,
509 xfs_inode_t *, xfs_dinode_t **, struct xfs_buf **, 534 xfs_inode_t *, struct xfs_dinode **, struct xfs_buf **,
510 xfs_daddr_t, uint); 535 xfs_daddr_t, uint);
511int xfs_iread(struct xfs_mount *, struct xfs_trans *, xfs_ino_t, 536int xfs_iread(struct xfs_mount *, struct xfs_trans *, xfs_ino_t,
512 xfs_inode_t **, xfs_daddr_t, uint); 537 xfs_inode_t **, xfs_daddr_t, uint);
@@ -514,8 +539,11 @@ int xfs_iread_extents(struct xfs_trans *, xfs_inode_t *, int);
514int xfs_ialloc(struct xfs_trans *, xfs_inode_t *, mode_t, 539int xfs_ialloc(struct xfs_trans *, xfs_inode_t *, mode_t,
515 xfs_nlink_t, xfs_dev_t, struct cred *, xfs_prid_t, 540 xfs_nlink_t, xfs_dev_t, struct cred *, xfs_prid_t,
516 int, struct xfs_buf **, boolean_t *, xfs_inode_t **); 541 int, struct xfs_buf **, boolean_t *, xfs_inode_t **);
517void xfs_xlate_dinode_core(xfs_caddr_t, struct xfs_dinode_core *, 542void xfs_dinode_from_disk(struct xfs_icdinode *,
518 int); 543 struct xfs_dinode_core *);
544void xfs_dinode_to_disk(struct xfs_dinode_core *,
545 struct xfs_icdinode *);
546
519uint xfs_ip2xflags(struct xfs_inode *); 547uint xfs_ip2xflags(struct xfs_inode *);
520uint xfs_dic2xflags(struct xfs_dinode_core *); 548uint xfs_dic2xflags(struct xfs_dinode_core *);
521int xfs_ifree(struct xfs_trans *, xfs_inode_t *, 549int xfs_ifree(struct xfs_trans *, xfs_inode_t *,
@@ -545,11 +573,9 @@ void xfs_ichgtime(xfs_inode_t *, int);
545xfs_fsize_t xfs_file_last_byte(xfs_inode_t *); 573xfs_fsize_t xfs_file_last_byte(xfs_inode_t *);
546void xfs_lock_inodes(xfs_inode_t **, int, int, uint); 574void xfs_lock_inodes(xfs_inode_t **, int, int, uint);
547 575
548xfs_inode_t *xfs_vtoi(struct bhv_vnode *vp);
549
550void xfs_synchronize_atime(xfs_inode_t *); 576void xfs_synchronize_atime(xfs_inode_t *);
551 577
552xfs_bmbt_rec_t *xfs_iext_get_ext(xfs_ifork_t *, xfs_extnum_t); 578xfs_bmbt_rec_host_t *xfs_iext_get_ext(xfs_ifork_t *, xfs_extnum_t);
553void xfs_iext_insert(xfs_ifork_t *, xfs_extnum_t, xfs_extnum_t, 579void xfs_iext_insert(xfs_ifork_t *, xfs_extnum_t, xfs_extnum_t,
554 xfs_bmbt_irec_t *); 580 xfs_bmbt_irec_t *);
555void xfs_iext_add(xfs_ifork_t *, xfs_extnum_t, int); 581void xfs_iext_add(xfs_ifork_t *, xfs_extnum_t, int);
@@ -564,7 +590,7 @@ void xfs_iext_indirect_to_direct(xfs_ifork_t *);
564void xfs_iext_direct_to_inline(xfs_ifork_t *, xfs_extnum_t); 590void xfs_iext_direct_to_inline(xfs_ifork_t *, xfs_extnum_t);
565void xfs_iext_inline_to_direct(xfs_ifork_t *, int); 591void xfs_iext_inline_to_direct(xfs_ifork_t *, int);
566void xfs_iext_destroy(xfs_ifork_t *); 592void xfs_iext_destroy(xfs_ifork_t *);
567xfs_bmbt_rec_t *xfs_iext_bno_to_ext(xfs_ifork_t *, xfs_fileoff_t, int *); 593xfs_bmbt_rec_host_t *xfs_iext_bno_to_ext(xfs_ifork_t *, xfs_fileoff_t, int *);
568xfs_ext_irec_t *xfs_iext_bno_to_irec(xfs_ifork_t *, xfs_fileoff_t, int *); 594xfs_ext_irec_t *xfs_iext_bno_to_irec(xfs_ifork_t *, xfs_fileoff_t, int *);
569xfs_ext_irec_t *xfs_iext_idx_to_irec(xfs_ifork_t *, xfs_extnum_t *, int *, int); 595xfs_ext_irec_t *xfs_iext_idx_to_irec(xfs_ifork_t *, xfs_extnum_t *, int *, int);
570void xfs_iext_irec_init(xfs_ifork_t *); 596void xfs_iext_irec_init(xfs_ifork_t *);
@@ -589,7 +615,7 @@ void xfs_inobp_check(struct xfs_mount *, struct xfs_buf *);
589#define xfs_inobp_check(mp, bp) 615#define xfs_inobp_check(mp, bp)
590#endif /* DEBUG */ 616#endif /* DEBUG */
591 617
592extern struct kmem_zone *xfs_chashlist_zone; 618extern struct kmem_zone *xfs_icluster_zone;
593extern struct kmem_zone *xfs_ifork_zone; 619extern struct kmem_zone *xfs_ifork_zone;
594extern struct kmem_zone *xfs_inode_zone; 620extern struct kmem_zone *xfs_inode_zone;
595extern struct kmem_zone *xfs_ili_zone; 621extern struct kmem_zone *xfs_ili_zone;