diff options
author | Christoph Hellwig <hch@lst.de> | 2008-11-27 22:23:39 -0500 |
---|---|---|
committer | Niv Sardi <xaiki@sgi.com> | 2008-11-30 19:37:35 -0500 |
commit | 81591fe2db19d0fc1ec2aaaa6a790a5ab97ac3ab (patch) | |
tree | 254b73b8f0b19bfbadda0e89021767f04dd20308 /fs/xfs/xfs_dinode.h | |
parent | d42f08f61c5e7f0ed4c6b6df4c9987ddb85ec66e (diff) |
[XFS] kill xfs_dinode_core_t
Now that we have a separate xfs_icdinode_t for the in-core inode which
gets logged there is no need anymore for the xfs_dinode vs xfs_dinode_core
split - the fact that part of the structure gets logged through the inode
log item and a small part not can better be described in a comment.
All sizeof operations on the dinode_core either really wanted the
icdinode and are switched to that one, or had already added the size
of the agi unlinked list pointer. Later both will be replaced with
helpers once we get the larger CRC-enabled dinode.
Removing the data and attribute fork unions also has the advantage that
xfs_dinode.h doesn't need to pull in every header under the sun.
While we're at it also add some more comments describing the dinode
structure.
(First sent on October 7th)
Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Dave Chinner <david@fromorbit.com>
Signed-off-by: Niv Sardi <xaiki@sgi.com>
Diffstat (limited to 'fs/xfs/xfs_dinode.h')
-rw-r--r-- | fs/xfs/xfs_dinode.h | 104 |
1 files changed, 50 insertions, 54 deletions
diff --git a/fs/xfs/xfs_dinode.h b/fs/xfs/xfs_dinode.h index 10f9204b81eb..0b7ebf922aff 100644 --- a/fs/xfs/xfs_dinode.h +++ b/fs/xfs/xfs_dinode.h | |||
@@ -18,32 +18,32 @@ | |||
18 | #ifndef __XFS_DINODE_H__ | 18 | #ifndef __XFS_DINODE_H__ |
19 | #define __XFS_DINODE_H__ | 19 | #define __XFS_DINODE_H__ |
20 | 20 | ||
21 | struct xfs_buf; | ||
22 | struct xfs_mount; | ||
23 | |||
24 | #define XFS_DINODE_VERSION_1 1 | 21 | #define XFS_DINODE_VERSION_1 1 |
25 | #define XFS_DINODE_VERSION_2 2 | 22 | #define XFS_DINODE_VERSION_2 2 |
26 | #define XFS_DINODE_GOOD_VERSION(v) \ | 23 | #define XFS_DINODE_GOOD_VERSION(v) \ |
27 | (((v) == XFS_DINODE_VERSION_1 || (v) == XFS_DINODE_VERSION_2)) | 24 | (((v) == XFS_DINODE_VERSION_1 || (v) == XFS_DINODE_VERSION_2)) |
28 | #define XFS_DINODE_MAGIC 0x494e /* 'IN' */ | 25 | #define XFS_DINODE_MAGIC 0x494e /* 'IN' */ |
29 | 26 | ||
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 | */ | ||
36 | typedef struct xfs_timestamp { | 27 | typedef struct xfs_timestamp { |
37 | __be32 t_sec; /* timestamp seconds */ | 28 | __be32 t_sec; /* timestamp seconds */ |
38 | __be32 t_nsec; /* timestamp nanoseconds */ | 29 | __be32 t_nsec; /* timestamp nanoseconds */ |
39 | } xfs_timestamp_t; | 30 | } xfs_timestamp_t; |
40 | 31 | ||
41 | /* | 32 | /* |
42 | * Note: Coordinate changes to this structure with the XFS_DI_* #defines | 33 | * On-disk inode structure. |
43 | * below, the offsets table in xfs_ialloc_log_di() and struct xfs_icdinode | 34 | * |
44 | * in xfs_inode.h. | 35 | * This is just the header or "dinode core", the inode is expanded to fill a |
36 | * variable size the leftover area split into a data and an attribute fork. | ||
37 | * The format of the data and attribute fork depends on the format of the | ||
38 | * inode as indicated by di_format and di_aformat. To access the data and | ||
39 | * attribute use the XFS_DFORK_PTR, XFS_DFORK_DPTR, and XFS_DFORK_PTR macros | ||
40 | * below. | ||
41 | * | ||
42 | * There is a very similar struct icdinode in xfs_inode which matches the | ||
43 | * layout of the first 96 bytes of this structure, but is kept in native | ||
44 | * format instead of big endian. | ||
45 | */ | 45 | */ |
46 | typedef struct xfs_dinode_core { | 46 | typedef struct xfs_dinode { |
47 | __be16 di_magic; /* inode magic # = XFS_DINODE_MAGIC */ | 47 | __be16 di_magic; /* inode magic # = XFS_DINODE_MAGIC */ |
48 | __be16 di_mode; /* mode and type of file */ | 48 | __be16 di_mode; /* mode and type of file */ |
49 | __u8 di_version; /* inode version */ | 49 | __u8 di_version; /* inode version */ |
@@ -69,33 +69,12 @@ typedef struct xfs_dinode_core { | |||
69 | __be16 di_dmstate; /* DMIG state info */ | 69 | __be16 di_dmstate; /* DMIG state info */ |
70 | __be16 di_flags; /* random flags, XFS_DIFLAG_... */ | 70 | __be16 di_flags; /* random flags, XFS_DIFLAG_... */ |
71 | __be32 di_gen; /* generation number */ | 71 | __be32 di_gen; /* generation number */ |
72 | } xfs_dinode_core_t; | ||
73 | 72 | ||
74 | #define DI_MAX_FLUSH 0xffff | 73 | /* di_next_unlinked is the only non-core field in the old dinode */ |
74 | __be32 di_next_unlinked;/* agi unlinked list ptr */ | ||
75 | } __attribute__((packed)) xfs_dinode_t; | ||
75 | 76 | ||
76 | typedef struct xfs_dinode | 77 | #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. | ||
82 | */ | ||
83 | __be32 di_next_unlinked;/* agi unlinked list ptr */ | ||
84 | union { | ||
85 | xfs_bmdr_block_t di_bmbt; /* btree root block */ | ||
86 | xfs_bmbt_rec_32_t di_bmx[1]; /* extent list */ | ||
87 | xfs_dir2_sf_t di_dir2sf; /* shortform directory v2 */ | ||
88 | char di_c[1]; /* local contents */ | ||
89 | __be32 di_dev; /* device for S_IFCHR/S_IFBLK */ | ||
90 | uuid_t di_muuid; /* mount point value */ | ||
91 | char di_symlink[1]; /* local symbolic link */ | ||
92 | } di_u; | ||
93 | union { | ||
94 | xfs_bmdr_block_t di_abmbt; /* btree root block */ | ||
95 | xfs_bmbt_rec_32_t di_abmx[1]; /* extent list */ | ||
96 | xfs_attr_shortform_t di_attrsf; /* shortform attribute list */ | ||
97 | } di_a; | ||
98 | } xfs_dinode_t; | ||
99 | 78 | ||
100 | /* | 79 | /* |
101 | * The 32 bit link count in the inode theoretically maxes out at UINT_MAX. | 80 | * The 32 bit link count in the inode theoretically maxes out at UINT_MAX. |
@@ -108,14 +87,12 @@ typedef struct xfs_dinode | |||
108 | /* | 87 | /* |
109 | * Values for di_format | 88 | * Values for di_format |
110 | */ | 89 | */ |
111 | typedef enum xfs_dinode_fmt | 90 | typedef enum xfs_dinode_fmt { |
112 | { | 91 | XFS_DINODE_FMT_DEV, /* xfs_dev_t */ |
113 | XFS_DINODE_FMT_DEV, /* CHR, BLK: di_dev */ | 92 | XFS_DINODE_FMT_LOCAL, /* bulk data */ |
114 | XFS_DINODE_FMT_LOCAL, /* DIR, REG: di_c */ | 93 | XFS_DINODE_FMT_EXTENTS, /* struct xfs_bmbt_rec */ |
115 | /* LNK: di_symlink */ | 94 | XFS_DINODE_FMT_BTREE, /* struct xfs_bmdr_block */ |
116 | XFS_DINODE_FMT_EXTENTS, /* DIR, REG, LNK: di_bmx */ | 95 | XFS_DINODE_FMT_UUID /* uuid_t */ |
117 | XFS_DINODE_FMT_BTREE, /* DIR, REG, LNK: di_bmbt */ | ||
118 | XFS_DINODE_FMT_UUID /* MNT: di_uuid */ | ||
119 | } xfs_dinode_fmt_t; | 96 | } xfs_dinode_fmt_t; |
120 | 97 | ||
121 | /* | 98 | /* |
@@ -136,8 +113,8 @@ typedef enum xfs_dinode_fmt | |||
136 | /* | 113 | /* |
137 | * Inode data & attribute fork sizes, per inode. | 114 | * Inode data & attribute fork sizes, per inode. |
138 | */ | 115 | */ |
139 | #define XFS_DFORK_Q(dip) ((dip)->di_core.di_forkoff != 0) | 116 | #define XFS_DFORK_Q(dip) ((dip)->di_forkoff != 0) |
140 | #define XFS_DFORK_BOFF(dip) ((int)((dip)->di_core.di_forkoff << 3)) | 117 | #define XFS_DFORK_BOFF(dip) ((int)((dip)->di_forkoff << 3)) |
141 | 118 | ||
142 | #define XFS_DFORK_DSIZE(dip,mp) \ | 119 | #define XFS_DFORK_DSIZE(dip,mp) \ |
143 | (XFS_DFORK_Q(dip) ? \ | 120 | (XFS_DFORK_Q(dip) ? \ |
@@ -152,23 +129,42 @@ typedef enum xfs_dinode_fmt | |||
152 | XFS_DFORK_DSIZE(dip, mp) : \ | 129 | XFS_DFORK_DSIZE(dip, mp) : \ |
153 | XFS_DFORK_ASIZE(dip, mp)) | 130 | XFS_DFORK_ASIZE(dip, mp)) |
154 | 131 | ||
155 | #define XFS_DFORK_DPTR(dip) ((dip)->di_u.di_c) | 132 | /* |
133 | * Return pointers to the data or attribute forks. | ||
134 | */ | ||
135 | #define XFS_DFORK_DPTR(dip) \ | ||
136 | ((char *)(dip) + sizeof(struct xfs_dinode)) | ||
156 | #define XFS_DFORK_APTR(dip) \ | 137 | #define XFS_DFORK_APTR(dip) \ |
157 | ((dip)->di_u.di_c + XFS_DFORK_BOFF(dip)) | 138 | (XFS_DFORK_DPTR(dip) + XFS_DFORK_BOFF(dip)) |
158 | #define XFS_DFORK_PTR(dip,w) \ | 139 | #define XFS_DFORK_PTR(dip,w) \ |
159 | ((w) == XFS_DATA_FORK ? XFS_DFORK_DPTR(dip) : XFS_DFORK_APTR(dip)) | 140 | ((w) == XFS_DATA_FORK ? XFS_DFORK_DPTR(dip) : XFS_DFORK_APTR(dip)) |
141 | |||
160 | #define XFS_DFORK_FORMAT(dip,w) \ | 142 | #define XFS_DFORK_FORMAT(dip,w) \ |
161 | ((w) == XFS_DATA_FORK ? \ | 143 | ((w) == XFS_DATA_FORK ? \ |
162 | (dip)->di_core.di_format : \ | 144 | (dip)->di_format : \ |
163 | (dip)->di_core.di_aformat) | 145 | (dip)->di_aformat) |
164 | #define XFS_DFORK_NEXTENTS(dip,w) \ | 146 | #define XFS_DFORK_NEXTENTS(dip,w) \ |
165 | ((w) == XFS_DATA_FORK ? \ | 147 | ((w) == XFS_DATA_FORK ? \ |
166 | be32_to_cpu((dip)->di_core.di_nextents) : \ | 148 | be32_to_cpu((dip)->di_nextents) : \ |
167 | be16_to_cpu((dip)->di_core.di_anextents)) | 149 | be16_to_cpu((dip)->di_anextents)) |
168 | 150 | ||
169 | #define XFS_BUF_TO_DINODE(bp) ((xfs_dinode_t *)XFS_BUF_PTR(bp)) | 151 | #define XFS_BUF_TO_DINODE(bp) ((xfs_dinode_t *)XFS_BUF_PTR(bp)) |
170 | 152 | ||
171 | /* | 153 | /* |
154 | * For block and character special files the 32bit dev_t is stored at the | ||
155 | * beginning of the data fork. | ||
156 | */ | ||
157 | static inline xfs_dev_t xfs_dinode_get_rdev(struct xfs_dinode *dip) | ||
158 | { | ||
159 | return be32_to_cpu(*(__be32 *)XFS_DFORK_DPTR(dip)); | ||
160 | } | ||
161 | |||
162 | static inline void xfs_dinode_put_rdev(struct xfs_dinode *dip, xfs_dev_t rdev) | ||
163 | { | ||
164 | *(__be32 *)XFS_DFORK_DPTR(dip) = cpu_to_be32(rdev); | ||
165 | } | ||
166 | |||
167 | /* | ||
172 | * Values for di_flags | 168 | * Values for di_flags |
173 | * There should be a one-to-one correspondence between these flags and the | 169 | * There should be a one-to-one correspondence between these flags and the |
174 | * XFS_XFLAG_s. | 170 | * XFS_XFLAG_s. |