diff options
author | Christoph Hellwig <hch@infradead.org> | 2007-12-06 22:07:20 -0500 |
---|---|---|
committer | Lachlan McIlroy <lachlan@redback.melbourne.sgi.com> | 2008-02-07 02:19:24 -0500 |
commit | 45ba598e56fa9f77801e06432b50580d97994fa4 (patch) | |
tree | 4c0bd022cbdc705426e6d2fba19ab7c23edefb55 | |
parent | a9759f2de38a3443d5107bddde03b4f3f550060e (diff) |
[XFS] Remove CFORK macros and use code directly in IFORK and DFORK macros.
Currently XFS_IFORK_* and XFS_DFORK* are implemented by means of
XFS_CFORK* macros. But given that XFS_IFORK_* operates on an xfs_inode
that embedds and xfs_icdinode_core and XFS_DFORK_* operates on an
xfs_dinode that embedds a xfs_dinode_core one will have to do endian
swapping while the other doesn't. Instead of having the current mess with
the CFORK macros that have byteswapping and non-byteswapping version
(which are inconsistantly named while we're at it) just define each family
of the macros to stand by itself and simplify the whole matter.
A few direct references to the CFORK variants were cleaned up to use IFORK
or DFORK to make this possible.
SGI-PV: 971186
SGI-Modid: xfs-linux-melb:xfs-kern:30163a
Signed-off-by: Christoph Hellwig <hch@infradead.org>
Signed-off-by: Tim Shimmin <tes@sgi.com>
Signed-off-by: Lachlan McIlroy <lachlan@sgi.com>
-rw-r--r-- | fs/xfs/xfs_dinode.h | 76 | ||||
-rw-r--r-- | fs/xfs/xfs_inode.c | 8 | ||||
-rw-r--r-- | fs/xfs/xfs_inode.h | 47 | ||||
-rw-r--r-- | fs/xfs/xfs_itable.c | 4 |
4 files changed, 64 insertions, 71 deletions
diff --git a/fs/xfs/xfs_dinode.h b/fs/xfs/xfs_dinode.h index 85030cbcdd87..c9065eaf2a4d 100644 --- a/fs/xfs/xfs_dinode.h +++ b/fs/xfs/xfs_dinode.h | |||
@@ -171,69 +171,35 @@ typedef enum xfs_dinode_fmt | |||
171 | /* | 171 | /* |
172 | * Inode data & attribute fork sizes, per inode. | 172 | * Inode data & attribute fork sizes, per inode. |
173 | */ | 173 | */ |
174 | #define XFS_CFORK_Q(dcp) ((dcp)->di_forkoff != 0) | 174 | #define XFS_DFORK_Q(dip) ((dip)->di_core.di_forkoff != 0) |
175 | #define XFS_CFORK_Q_DISK(dcp) ((dcp)->di_forkoff != 0) | 175 | #define XFS_DFORK_BOFF(dip) ((int)((dip)->di_core.di_forkoff << 3)) |
176 | |||
177 | #define XFS_CFORK_BOFF(dcp) ((int)((dcp)->di_forkoff << 3)) | ||
178 | #define XFS_CFORK_BOFF_DISK(dcp) ((int)((dcp)->di_forkoff << 3)) | ||
179 | |||
180 | #define XFS_CFORK_DSIZE_DISK(dcp,mp) \ | ||
181 | (XFS_CFORK_Q_DISK(dcp) ? XFS_CFORK_BOFF_DISK(dcp) : XFS_LITINO(mp)) | ||
182 | #define XFS_CFORK_DSIZE(dcp,mp) \ | ||
183 | (XFS_CFORK_Q(dcp) ? XFS_CFORK_BOFF(dcp) : XFS_LITINO(mp)) | ||
184 | |||
185 | #define XFS_CFORK_ASIZE_DISK(dcp,mp) \ | ||
186 | (XFS_CFORK_Q_DISK(dcp) ? XFS_LITINO(mp) - XFS_CFORK_BOFF_DISK(dcp) : 0) | ||
187 | #define XFS_CFORK_ASIZE(dcp,mp) \ | ||
188 | (XFS_CFORK_Q(dcp) ? XFS_LITINO(mp) - XFS_CFORK_BOFF(dcp) : 0) | ||
189 | |||
190 | #define XFS_CFORK_SIZE_DISK(dcp,mp,w) \ | ||
191 | ((w) == XFS_DATA_FORK ? \ | ||
192 | XFS_CFORK_DSIZE_DISK(dcp, mp) : \ | ||
193 | XFS_CFORK_ASIZE_DISK(dcp, mp)) | ||
194 | #define XFS_CFORK_SIZE(dcp,mp,w) \ | ||
195 | ((w) == XFS_DATA_FORK ? \ | ||
196 | XFS_CFORK_DSIZE(dcp, mp) : XFS_CFORK_ASIZE(dcp, mp)) | ||
197 | 176 | ||
198 | #define XFS_DFORK_DSIZE(dip,mp) \ | 177 | #define XFS_DFORK_DSIZE(dip,mp) \ |
199 | XFS_CFORK_DSIZE_DISK(&(dip)->di_core, mp) | 178 | (XFS_DFORK_Q(dip) ? \ |
200 | #define XFS_DFORK_DSIZE_HOST(dip,mp) \ | 179 | XFS_DFORK_BOFF(dip) : \ |
201 | XFS_CFORK_DSIZE(&(dip)->di_core, mp) | 180 | XFS_LITINO(mp)) |
202 | #define XFS_DFORK_ASIZE(dip,mp) \ | 181 | #define XFS_DFORK_ASIZE(dip,mp) \ |
203 | XFS_CFORK_ASIZE_DISK(&(dip)->di_core, mp) | 182 | (XFS_DFORK_Q(dip) ? \ |
204 | #define XFS_DFORK_ASIZE_HOST(dip,mp) \ | 183 | XFS_LITINO(mp) - XFS_DFORK_BOFF(dip) : \ |
205 | XFS_CFORK_ASIZE(&(dip)->di_core, mp) | 184 | 0) |
206 | #define XFS_DFORK_SIZE(dip,mp,w) \ | 185 | #define XFS_DFORK_SIZE(dip,mp,w) \ |
207 | XFS_CFORK_SIZE_DISK(&(dip)->di_core, mp, w) | 186 | ((w) == XFS_DATA_FORK ? \ |
208 | #define XFS_DFORK_SIZE_HOST(dip,mp,w) \ | 187 | XFS_DFORK_DSIZE(dip, mp) : \ |
209 | XFS_CFORK_SIZE(&(dip)->di_core, mp, w) | 188 | XFS_DFORK_ASIZE(dip, mp)) |
210 | 189 | ||
211 | #define XFS_DFORK_Q(dip) XFS_CFORK_Q_DISK(&(dip)->di_core) | 190 | #define XFS_DFORK_DPTR(dip) ((dip)->di_u.di_c) |
212 | #define XFS_DFORK_BOFF(dip) XFS_CFORK_BOFF_DISK(&(dip)->di_core) | 191 | #define XFS_DFORK_APTR(dip) \ |
213 | #define XFS_DFORK_DPTR(dip) ((dip)->di_u.di_c) | ||
214 | #define XFS_DFORK_APTR(dip) \ | ||
215 | ((dip)->di_u.di_c + XFS_DFORK_BOFF(dip)) | 192 | ((dip)->di_u.di_c + XFS_DFORK_BOFF(dip)) |
216 | #define XFS_DFORK_PTR(dip,w) \ | 193 | #define XFS_DFORK_PTR(dip,w) \ |
217 | ((w) == XFS_DATA_FORK ? XFS_DFORK_DPTR(dip) : XFS_DFORK_APTR(dip)) | 194 | ((w) == XFS_DATA_FORK ? XFS_DFORK_DPTR(dip) : XFS_DFORK_APTR(dip)) |
218 | #define XFS_CFORK_FORMAT(dcp,w) \ | 195 | #define XFS_DFORK_FORMAT(dip,w) \ |
219 | ((w) == XFS_DATA_FORK ? (dcp)->di_format : (dcp)->di_aformat) | ||
220 | #define XFS_CFORK_FMT_SET(dcp,w,n) \ | ||
221 | ((w) == XFS_DATA_FORK ? \ | 196 | ((w) == XFS_DATA_FORK ? \ |
222 | ((dcp)->di_format = (n)) : ((dcp)->di_aformat = (n))) | 197 | (dip)->di_core.di_format : \ |
223 | #define XFS_DFORK_FORMAT(dip,w) XFS_CFORK_FORMAT(&(dip)->di_core, w) | 198 | (dip)->di_core.di_aformat) |
224 | 199 | #define XFS_DFORK_NEXTENTS(dip,w) \ | |
225 | #define XFS_CFORK_NEXTENTS_DISK(dcp,w) \ | ||
226 | ((w) == XFS_DATA_FORK ? \ | ||
227 | be32_to_cpu((dcp)->di_nextents) : \ | ||
228 | be16_to_cpu((dcp)->di_anextents)) | ||
229 | #define XFS_CFORK_NEXTENTS(dcp,w) \ | ||
230 | ((w) == XFS_DATA_FORK ? (dcp)->di_nextents : (dcp)->di_anextents) | ||
231 | #define XFS_DFORK_NEXTENTS(dip,w) XFS_CFORK_NEXTENTS_DISK(&(dip)->di_core, w) | ||
232 | #define XFS_DFORK_NEXTENTS_HOST(dip,w) XFS_CFORK_NEXTENTS(&(dip)->di_core, w) | ||
233 | |||
234 | #define XFS_CFORK_NEXT_SET(dcp,w,n) \ | ||
235 | ((w) == XFS_DATA_FORK ? \ | 200 | ((w) == XFS_DATA_FORK ? \ |
236 | ((dcp)->di_nextents = (n)) : ((dcp)->di_anextents = (n))) | 201 | be32_to_cpu((dip)->di_core.di_nextents) : \ |
202 | be16_to_cpu((dip)->di_core.di_anextents)) | ||
237 | 203 | ||
238 | #define XFS_BUF_TO_DINODE(bp) ((xfs_dinode_t *)XFS_BUF_PTR(bp)) | 204 | #define XFS_BUF_TO_DINODE(bp) ((xfs_dinode_t *)XFS_BUF_PTR(bp)) |
239 | 205 | ||
diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c index dc4b8bd33f4f..75b636c14876 100644 --- a/fs/xfs/xfs_inode.c +++ b/fs/xfs/xfs_inode.c | |||
@@ -828,15 +828,17 @@ xfs_ip2xflags( | |||
828 | xfs_icdinode_t *dic = &ip->i_d; | 828 | xfs_icdinode_t *dic = &ip->i_d; |
829 | 829 | ||
830 | return _xfs_dic2xflags(dic->di_flags) | | 830 | return _xfs_dic2xflags(dic->di_flags) | |
831 | (XFS_CFORK_Q(dic) ? XFS_XFLAG_HASATTR : 0); | 831 | (XFS_IFORK_Q(ip) ? XFS_XFLAG_HASATTR : 0); |
832 | } | 832 | } |
833 | 833 | ||
834 | uint | 834 | uint |
835 | xfs_dic2xflags( | 835 | xfs_dic2xflags( |
836 | xfs_dinode_core_t *dic) | 836 | xfs_dinode_t *dip) |
837 | { | 837 | { |
838 | xfs_dinode_core_t *dic = &dip->di_core; | ||
839 | |||
838 | return _xfs_dic2xflags(be16_to_cpu(dic->di_flags)) | | 840 | return _xfs_dic2xflags(be16_to_cpu(dic->di_flags)) | |
839 | (XFS_CFORK_Q_DISK(dic) ? XFS_XFLAG_HASATTR : 0); | 841 | (XFS_DFORK_Q(dip) ? XFS_XFLAG_HASATTR : 0); |
840 | } | 842 | } |
841 | 843 | ||
842 | /* | 844 | /* |
diff --git a/fs/xfs/xfs_inode.h b/fs/xfs/xfs_inode.h index b2d7b2cd7851..a8d6f5e251aa 100644 --- a/fs/xfs/xfs_inode.h +++ b/fs/xfs/xfs_inode.h | |||
@@ -341,17 +341,42 @@ xfs_iflags_test_and_clear(xfs_inode_t *ip, unsigned short flags) | |||
341 | /* | 341 | /* |
342 | * Fork handling. | 342 | * Fork handling. |
343 | */ | 343 | */ |
344 | #define XFS_IFORK_PTR(ip,w) \ | ||
345 | ((w) == XFS_DATA_FORK ? &(ip)->i_df : (ip)->i_afp) | ||
346 | #define XFS_IFORK_Q(ip) XFS_CFORK_Q(&(ip)->i_d) | ||
347 | #define XFS_IFORK_DSIZE(ip) XFS_CFORK_DSIZE(&ip->i_d, ip->i_mount) | ||
348 | #define XFS_IFORK_ASIZE(ip) XFS_CFORK_ASIZE(&ip->i_d, ip->i_mount) | ||
349 | #define XFS_IFORK_SIZE(ip,w) XFS_CFORK_SIZE(&ip->i_d, ip->i_mount, w) | ||
350 | #define XFS_IFORK_FORMAT(ip,w) XFS_CFORK_FORMAT(&ip->i_d, w) | ||
351 | #define XFS_IFORK_FMT_SET(ip,w,n) XFS_CFORK_FMT_SET(&ip->i_d, w, n) | ||
352 | #define XFS_IFORK_NEXTENTS(ip,w) XFS_CFORK_NEXTENTS(&ip->i_d, w) | ||
353 | #define XFS_IFORK_NEXT_SET(ip,w,n) XFS_CFORK_NEXT_SET(&ip->i_d, w, n) | ||
354 | 344 | ||
345 | #define XFS_IFORK_Q(ip) ((ip)->i_d.di_forkoff != 0) | ||
346 | #define XFS_IFORK_BOFF(ip) ((int)((ip)->i_d.di_forkoff << 3)) | ||
347 | |||
348 | #define XFS_IFORK_PTR(ip,w) \ | ||
349 | ((w) == XFS_DATA_FORK ? \ | ||
350 | &(ip)->i_df : \ | ||
351 | (ip)->i_afp) | ||
352 | #define XFS_IFORK_DSIZE(ip) \ | ||
353 | (XFS_IFORK_Q(ip) ? \ | ||
354 | XFS_IFORK_BOFF(ip) : \ | ||
355 | XFS_LITINO((ip)->i_mount)) | ||
356 | #define XFS_IFORK_ASIZE(ip) \ | ||
357 | (XFS_IFORK_Q(ip) ? \ | ||
358 | XFS_LITINO((ip)->i_mount) - XFS_IFORK_BOFF(ip) : \ | ||
359 | 0) | ||
360 | #define XFS_IFORK_SIZE(ip,w) \ | ||
361 | ((w) == XFS_DATA_FORK ? \ | ||
362 | XFS_IFORK_DSIZE(ip) : \ | ||
363 | XFS_IFORK_ASIZE(ip)) | ||
364 | #define XFS_IFORK_FORMAT(ip,w) \ | ||
365 | ((w) == XFS_DATA_FORK ? \ | ||
366 | (ip)->i_d.di_format : \ | ||
367 | (ip)->i_d.di_aformat) | ||
368 | #define XFS_IFORK_FMT_SET(ip,w,n) \ | ||
369 | ((w) == XFS_DATA_FORK ? \ | ||
370 | ((ip)->i_d.di_format = (n)) : \ | ||
371 | ((ip)->i_d.di_aformat = (n))) | ||
372 | #define XFS_IFORK_NEXTENTS(ip,w) \ | ||
373 | ((w) == XFS_DATA_FORK ? \ | ||
374 | (ip)->i_d.di_nextents : \ | ||
375 | (ip)->i_d.di_anextents) | ||
376 | #define XFS_IFORK_NEXT_SET(ip,w,n) \ | ||
377 | ((w) == XFS_DATA_FORK ? \ | ||
378 | ((ip)->i_d.di_nextents = (n)) : \ | ||
379 | ((ip)->i_d.di_anextents = (n))) | ||
355 | 380 | ||
356 | #ifdef __KERNEL__ | 381 | #ifdef __KERNEL__ |
357 | 382 | ||
@@ -503,7 +528,7 @@ void xfs_dinode_to_disk(struct xfs_dinode_core *, | |||
503 | struct xfs_icdinode *); | 528 | struct xfs_icdinode *); |
504 | 529 | ||
505 | uint xfs_ip2xflags(struct xfs_inode *); | 530 | uint xfs_ip2xflags(struct xfs_inode *); |
506 | uint xfs_dic2xflags(struct xfs_dinode_core *); | 531 | uint xfs_dic2xflags(struct xfs_dinode *); |
507 | int xfs_ifree(struct xfs_trans *, xfs_inode_t *, | 532 | int xfs_ifree(struct xfs_trans *, xfs_inode_t *, |
508 | struct xfs_bmap_free *); | 533 | struct xfs_bmap_free *); |
509 | int xfs_itruncate_start(xfs_inode_t *, uint, xfs_fsize_t); | 534 | int xfs_itruncate_start(xfs_inode_t *, uint, xfs_fsize_t); |
diff --git a/fs/xfs/xfs_itable.c b/fs/xfs/xfs_itable.c index a451baaeede8..658aab6b1bbf 100644 --- a/fs/xfs/xfs_itable.c +++ b/fs/xfs/xfs_itable.c | |||
@@ -170,7 +170,7 @@ xfs_bulkstat_one_dinode( | |||
170 | buf->bs_mtime.tv_nsec = be32_to_cpu(dic->di_mtime.t_nsec); | 170 | buf->bs_mtime.tv_nsec = be32_to_cpu(dic->di_mtime.t_nsec); |
171 | buf->bs_ctime.tv_sec = be32_to_cpu(dic->di_ctime.t_sec); | 171 | buf->bs_ctime.tv_sec = be32_to_cpu(dic->di_ctime.t_sec); |
172 | buf->bs_ctime.tv_nsec = be32_to_cpu(dic->di_ctime.t_nsec); | 172 | buf->bs_ctime.tv_nsec = be32_to_cpu(dic->di_ctime.t_nsec); |
173 | buf->bs_xflags = xfs_dic2xflags(dic); | 173 | buf->bs_xflags = xfs_dic2xflags(dip); |
174 | buf->bs_extsize = be32_to_cpu(dic->di_extsize) << mp->m_sb.sb_blocklog; | 174 | buf->bs_extsize = be32_to_cpu(dic->di_extsize) << mp->m_sb.sb_blocklog; |
175 | buf->bs_extents = be32_to_cpu(dic->di_nextents); | 175 | buf->bs_extents = be32_to_cpu(dic->di_nextents); |
176 | buf->bs_gen = be32_to_cpu(dic->di_gen); | 176 | buf->bs_gen = be32_to_cpu(dic->di_gen); |
@@ -307,7 +307,7 @@ xfs_bulkstat_use_dinode( | |||
307 | } | 307 | } |
308 | /* BULKSTAT_FG_INLINE: if attr fork is local, or not there, use it */ | 308 | /* BULKSTAT_FG_INLINE: if attr fork is local, or not there, use it */ |
309 | aformat = dip->di_core.di_aformat; | 309 | aformat = dip->di_core.di_aformat; |
310 | if ((XFS_CFORK_Q(&dip->di_core) == 0) || | 310 | if ((XFS_DFORK_Q(dip) == 0) || |
311 | (aformat == XFS_DINODE_FMT_LOCAL) || | 311 | (aformat == XFS_DINODE_FMT_LOCAL) || |
312 | (aformat == XFS_DINODE_FMT_EXTENTS && !dip->di_core.di_anextents)) { | 312 | (aformat == XFS_DINODE_FMT_EXTENTS && !dip->di_core.di_anextents)) { |
313 | *dipp = dip; | 313 | *dipp = dip; |