aboutsummaryrefslogtreecommitdiffstats
path: root/fs/xfs/xfs_dinode.h
diff options
context:
space:
mode:
Diffstat (limited to 'fs/xfs/xfs_dinode.h')
-rw-r--r--fs/xfs/xfs_dinode.h148
1 files changed, 53 insertions, 95 deletions
diff --git a/fs/xfs/xfs_dinode.h b/fs/xfs/xfs_dinode.h
index c9065eaf2a4d..162e8726df5e 100644
--- a/fs/xfs/xfs_dinode.h
+++ b/fs/xfs/xfs_dinode.h
@@ -18,32 +18,29 @@
18#ifndef __XFS_DINODE_H__ 18#ifndef __XFS_DINODE_H__
19#define __XFS_DINODE_H__ 19#define __XFS_DINODE_H__
20 20
21struct xfs_buf; 21#define XFS_DINODE_MAGIC 0x494e /* 'IN' */
22struct xfs_mount; 22#define XFS_DINODE_GOOD_VERSION(v) (((v) == 1 || (v) == 2))
23 23
24#define XFS_DINODE_VERSION_1 1
25#define XFS_DINODE_VERSION_2 2
26#define XFS_DINODE_GOOD_VERSION(v) \
27 (((v) == XFS_DINODE_VERSION_1 || (v) == XFS_DINODE_VERSION_2))
28#define XFS_DINODE_MAGIC 0x494e /* 'IN' */
29
30/*
31 * Disk inode structure.
32 * This is just the header; the inode is expanded to fill a variable size
33 * with the last field expanding. It is split into the core and "other"
34 * because we only need the core part in the in-core inode.
35 */
36typedef struct xfs_timestamp { 24typedef struct xfs_timestamp {
37 __be32 t_sec; /* timestamp seconds */ 25 __be32 t_sec; /* timestamp seconds */
38 __be32 t_nsec; /* timestamp nanoseconds */ 26 __be32 t_nsec; /* timestamp nanoseconds */
39} xfs_timestamp_t; 27} xfs_timestamp_t;
40 28
41/* 29/*
42 * Note: Coordinate changes to this structure with the XFS_DI_* #defines 30 * On-disk inode structure.
43 * below, the offsets table in xfs_ialloc_log_di() and struct xfs_icdinode 31 *
44 * in xfs_inode.h. 32 * This is just the header or "dinode core", the inode is expanded to fill a
33 * variable size the leftover area split into a data and an attribute fork.
34 * The format of the data and attribute fork depends on the format of the
35 * inode as indicated by di_format and di_aformat. To access the data and
36 * attribute use the XFS_DFORK_PTR, XFS_DFORK_DPTR, and XFS_DFORK_PTR macros
37 * below.
38 *
39 * There is a very similar struct icdinode in xfs_inode which matches the
40 * layout of the first 96 bytes of this structure, but is kept in native
41 * format instead of big endian.
45 */ 42 */
46typedef struct xfs_dinode_core { 43typedef struct xfs_dinode {
47 __be16 di_magic; /* inode magic # = XFS_DINODE_MAGIC */ 44 __be16 di_magic; /* inode magic # = XFS_DINODE_MAGIC */
48 __be16 di_mode; /* mode and type of file */ 45 __be16 di_mode; /* mode and type of file */
49 __u8 di_version; /* inode version */ 46 __u8 di_version; /* inode version */
@@ -69,34 +66,12 @@ typedef struct xfs_dinode_core {
69 __be16 di_dmstate; /* DMIG state info */ 66 __be16 di_dmstate; /* DMIG state info */
70 __be16 di_flags; /* random flags, XFS_DIFLAG_... */ 67 __be16 di_flags; /* random flags, XFS_DIFLAG_... */
71 __be32 di_gen; /* generation number */ 68 __be32 di_gen; /* generation number */
72} xfs_dinode_core_t;
73 69
74#define DI_MAX_FLUSH 0xffff 70 /* di_next_unlinked is the only non-core field in the old dinode */
71 __be32 di_next_unlinked;/* agi unlinked list ptr */
72} __attribute__((packed)) xfs_dinode_t;
75 73
76typedef struct xfs_dinode 74#define DI_MAX_FLUSH 0xffff
77{
78 xfs_dinode_core_t di_core;
79 /*
80 * In adding anything between the core and the union, be
81 * sure to update the macros like XFS_LITINO below and
82 * XFS_BMAP_RBLOCK_DSIZE in xfs_bmap_btree.h.
83 */
84 __be32 di_next_unlinked;/* agi unlinked list ptr */
85 union {
86 xfs_bmdr_block_t di_bmbt; /* btree root block */
87 xfs_bmbt_rec_32_t di_bmx[1]; /* extent list */
88 xfs_dir2_sf_t di_dir2sf; /* shortform directory v2 */
89 char di_c[1]; /* local contents */
90 __be32 di_dev; /* device for S_IFCHR/S_IFBLK */
91 uuid_t di_muuid; /* mount point value */
92 char di_symlink[1]; /* local symbolic link */
93 } di_u;
94 union {
95 xfs_bmdr_block_t di_abmbt; /* btree root block */
96 xfs_bmbt_rec_32_t di_abmx[1]; /* extent list */
97 xfs_attr_shortform_t di_attrsf; /* shortform attribute list */
98 } di_a;
99} xfs_dinode_t;
100 75
101/* 76/*
102 * The 32 bit link count in the inode theoretically maxes out at UINT_MAX. 77 * The 32 bit link count in the inode theoretically maxes out at UINT_MAX.
@@ -107,50 +82,14 @@ typedef struct xfs_dinode
107#define XFS_MAXLINK_1 65535U 82#define XFS_MAXLINK_1 65535U
108 83
109/* 84/*
110 * Bit names for logging disk inodes only
111 */
112#define XFS_DI_MAGIC 0x0000001
113#define XFS_DI_MODE 0x0000002
114#define XFS_DI_VERSION 0x0000004
115#define XFS_DI_FORMAT 0x0000008
116#define XFS_DI_ONLINK 0x0000010
117#define XFS_DI_UID 0x0000020
118#define XFS_DI_GID 0x0000040
119#define XFS_DI_NLINK 0x0000080
120#define XFS_DI_PROJID 0x0000100
121#define XFS_DI_PAD 0x0000200
122#define XFS_DI_ATIME 0x0000400
123#define XFS_DI_MTIME 0x0000800
124#define XFS_DI_CTIME 0x0001000
125#define XFS_DI_SIZE 0x0002000
126#define XFS_DI_NBLOCKS 0x0004000
127#define XFS_DI_EXTSIZE 0x0008000
128#define XFS_DI_NEXTENTS 0x0010000
129#define XFS_DI_NAEXTENTS 0x0020000
130#define XFS_DI_FORKOFF 0x0040000
131#define XFS_DI_AFORMAT 0x0080000
132#define XFS_DI_DMEVMASK 0x0100000
133#define XFS_DI_DMSTATE 0x0200000
134#define XFS_DI_FLAGS 0x0400000
135#define XFS_DI_GEN 0x0800000
136#define XFS_DI_NEXT_UNLINKED 0x1000000
137#define XFS_DI_U 0x2000000
138#define XFS_DI_A 0x4000000
139#define XFS_DI_NUM_BITS 27
140#define XFS_DI_ALL_BITS ((1 << XFS_DI_NUM_BITS) - 1)
141#define XFS_DI_CORE_BITS (XFS_DI_ALL_BITS & ~(XFS_DI_U|XFS_DI_A))
142
143/*
144 * Values for di_format 85 * Values for di_format
145 */ 86 */
146typedef enum xfs_dinode_fmt 87typedef enum xfs_dinode_fmt {
147{ 88 XFS_DINODE_FMT_DEV, /* xfs_dev_t */
148 XFS_DINODE_FMT_DEV, /* CHR, BLK: di_dev */ 89 XFS_DINODE_FMT_LOCAL, /* bulk data */
149 XFS_DINODE_FMT_LOCAL, /* DIR, REG: di_c */ 90 XFS_DINODE_FMT_EXTENTS, /* struct xfs_bmbt_rec */
150 /* LNK: di_symlink */ 91 XFS_DINODE_FMT_BTREE, /* struct xfs_bmdr_block */
151 XFS_DINODE_FMT_EXTENTS, /* DIR, REG, LNK: di_bmx */ 92 XFS_DINODE_FMT_UUID /* uuid_t */
152 XFS_DINODE_FMT_BTREE, /* DIR, REG, LNK: di_bmbt */
153 XFS_DINODE_FMT_UUID /* MNT: di_uuid */
154} xfs_dinode_fmt_t; 93} xfs_dinode_fmt_t;
155 94
156/* 95/*
@@ -166,13 +105,13 @@ typedef enum xfs_dinode_fmt
166 */ 105 */
167#define XFS_LITINO(mp) ((mp)->m_litino) 106#define XFS_LITINO(mp) ((mp)->m_litino)
168#define XFS_BROOT_SIZE_ADJ \ 107#define XFS_BROOT_SIZE_ADJ \
169 (sizeof(xfs_bmbt_block_t) - sizeof(xfs_bmdr_block_t)) 108 (XFS_BTREE_LBLOCK_LEN - sizeof(xfs_bmdr_block_t))
170 109
171/* 110/*
172 * Inode data & attribute fork sizes, per inode. 111 * Inode data & attribute fork sizes, per inode.
173 */ 112 */
174#define XFS_DFORK_Q(dip) ((dip)->di_core.di_forkoff != 0) 113#define XFS_DFORK_Q(dip) ((dip)->di_forkoff != 0)
175#define XFS_DFORK_BOFF(dip) ((int)((dip)->di_core.di_forkoff << 3)) 114#define XFS_DFORK_BOFF(dip) ((int)((dip)->di_forkoff << 3))
176 115
177#define XFS_DFORK_DSIZE(dip,mp) \ 116#define XFS_DFORK_DSIZE(dip,mp) \
178 (XFS_DFORK_Q(dip) ? \ 117 (XFS_DFORK_Q(dip) ? \
@@ -187,23 +126,42 @@ typedef enum xfs_dinode_fmt
187 XFS_DFORK_DSIZE(dip, mp) : \ 126 XFS_DFORK_DSIZE(dip, mp) : \
188 XFS_DFORK_ASIZE(dip, mp)) 127 XFS_DFORK_ASIZE(dip, mp))
189 128
190#define XFS_DFORK_DPTR(dip) ((dip)->di_u.di_c) 129/*
130 * Return pointers to the data or attribute forks.
131 */
132#define XFS_DFORK_DPTR(dip) \
133 ((char *)(dip) + sizeof(struct xfs_dinode))
191#define XFS_DFORK_APTR(dip) \ 134#define XFS_DFORK_APTR(dip) \
192 ((dip)->di_u.di_c + XFS_DFORK_BOFF(dip)) 135 (XFS_DFORK_DPTR(dip) + XFS_DFORK_BOFF(dip))
193#define XFS_DFORK_PTR(dip,w) \ 136#define XFS_DFORK_PTR(dip,w) \
194 ((w) == XFS_DATA_FORK ? XFS_DFORK_DPTR(dip) : XFS_DFORK_APTR(dip)) 137 ((w) == XFS_DATA_FORK ? XFS_DFORK_DPTR(dip) : XFS_DFORK_APTR(dip))
138
195#define XFS_DFORK_FORMAT(dip,w) \ 139#define XFS_DFORK_FORMAT(dip,w) \
196 ((w) == XFS_DATA_FORK ? \ 140 ((w) == XFS_DATA_FORK ? \
197 (dip)->di_core.di_format : \ 141 (dip)->di_format : \
198 (dip)->di_core.di_aformat) 142 (dip)->di_aformat)
199#define XFS_DFORK_NEXTENTS(dip,w) \ 143#define XFS_DFORK_NEXTENTS(dip,w) \
200 ((w) == XFS_DATA_FORK ? \ 144 ((w) == XFS_DATA_FORK ? \
201 be32_to_cpu((dip)->di_core.di_nextents) : \ 145 be32_to_cpu((dip)->di_nextents) : \
202 be16_to_cpu((dip)->di_core.di_anextents)) 146 be16_to_cpu((dip)->di_anextents))
203 147
204#define XFS_BUF_TO_DINODE(bp) ((xfs_dinode_t *)XFS_BUF_PTR(bp)) 148#define XFS_BUF_TO_DINODE(bp) ((xfs_dinode_t *)XFS_BUF_PTR(bp))
205 149
206/* 150/*
151 * For block and character special files the 32bit dev_t is stored at the
152 * beginning of the data fork.
153 */
154static inline xfs_dev_t xfs_dinode_get_rdev(struct xfs_dinode *dip)
155{
156 return be32_to_cpu(*(__be32 *)XFS_DFORK_DPTR(dip));
157}
158
159static inline void xfs_dinode_put_rdev(struct xfs_dinode *dip, xfs_dev_t rdev)
160{
161 *(__be32 *)XFS_DFORK_DPTR(dip) = cpu_to_be32(rdev);
162}
163
164/*
207 * Values for di_flags 165 * Values for di_flags
208 * There should be a one-to-one correspondence between these flags and the 166 * There should be a one-to-one correspondence between these flags and the
209 * XFS_XFLAG_s. 167 * XFS_XFLAG_s.