Commit 45ba598e56fa9f77801e06432b50580d97994fa4

Authored by Christoph Hellwig
Committed by Lachlan McIlroy
1 parent a9759f2de3

[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>

Showing 4 changed files with 64 additions and 71 deletions Side-by-side Diff

... ... @@ -171,69 +171,35 @@
171 171 /*
172 172 * Inode data & attribute fork sizes, per inode.
173 173 */
174   -#define XFS_CFORK_Q(dcp) ((dcp)->di_forkoff != 0)
175   -#define XFS_CFORK_Q_DISK(dcp) ((dcp)->di_forkoff != 0)
  174 +#define XFS_DFORK_Q(dip) ((dip)->di_core.di_forkoff != 0)
  175 +#define XFS_DFORK_BOFF(dip) ((int)((dip)->di_core.di_forkoff << 3))
176 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   -
198 177 #define XFS_DFORK_DSIZE(dip,mp) \
199   - XFS_CFORK_DSIZE_DISK(&(dip)->di_core, mp)
200   -#define XFS_DFORK_DSIZE_HOST(dip,mp) \
201   - XFS_CFORK_DSIZE(&(dip)->di_core, mp)
  178 + (XFS_DFORK_Q(dip) ? \
  179 + XFS_DFORK_BOFF(dip) : \
  180 + XFS_LITINO(mp))
202 181 #define XFS_DFORK_ASIZE(dip,mp) \
203   - XFS_CFORK_ASIZE_DISK(&(dip)->di_core, mp)
204   -#define XFS_DFORK_ASIZE_HOST(dip,mp) \
205   - XFS_CFORK_ASIZE(&(dip)->di_core, mp)
206   -#define XFS_DFORK_SIZE(dip,mp,w) \
207   - XFS_CFORK_SIZE_DISK(&(dip)->di_core, mp, w)
208   -#define XFS_DFORK_SIZE_HOST(dip,mp,w) \
209   - XFS_CFORK_SIZE(&(dip)->di_core, mp, w)
  182 + (XFS_DFORK_Q(dip) ? \
  183 + XFS_LITINO(mp) - XFS_DFORK_BOFF(dip) : \
  184 + 0)
  185 +#define XFS_DFORK_SIZE(dip,mp,w) \
  186 + ((w) == XFS_DATA_FORK ? \
  187 + XFS_DFORK_DSIZE(dip, mp) : \
  188 + XFS_DFORK_ASIZE(dip, mp))
210 189  
211   -#define XFS_DFORK_Q(dip) XFS_CFORK_Q_DISK(&(dip)->di_core)
212   -#define XFS_DFORK_BOFF(dip) XFS_CFORK_BOFF_DISK(&(dip)->di_core)
213   -#define XFS_DFORK_DPTR(dip) ((dip)->di_u.di_c)
214   -#define XFS_DFORK_APTR(dip) \
  190 +#define XFS_DFORK_DPTR(dip) ((dip)->di_u.di_c)
  191 +#define XFS_DFORK_APTR(dip) \
215 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 194 ((w) == XFS_DATA_FORK ? XFS_DFORK_DPTR(dip) : XFS_DFORK_APTR(dip))
218   -#define XFS_CFORK_FORMAT(dcp,w) \
219   - ((w) == XFS_DATA_FORK ? (dcp)->di_format : (dcp)->di_aformat)
220   -#define XFS_CFORK_FMT_SET(dcp,w,n) \
  195 +#define XFS_DFORK_FORMAT(dip,w) \
221 196 ((w) == XFS_DATA_FORK ? \
222   - ((dcp)->di_format = (n)) : ((dcp)->di_aformat = (n)))
223   -#define XFS_DFORK_FORMAT(dip,w) XFS_CFORK_FORMAT(&(dip)->di_core, w)
224   -
225   -#define XFS_CFORK_NEXTENTS_DISK(dcp,w) \
  197 + (dip)->di_core.di_format : \
  198 + (dip)->di_core.di_aformat)
  199 +#define XFS_DFORK_NEXTENTS(dip,w) \
226 200 ((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 ? \
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 204 #define XFS_BUF_TO_DINODE(bp) ((xfs_dinode_t *)XFS_BUF_PTR(bp))
239 205  
... ... @@ -828,15 +828,17 @@
828 828 xfs_icdinode_t *dic = &ip->i_d;
829 829  
830 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 834 uint
835 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 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 /*
... ... @@ -341,18 +341,43 @@
341 341 /*
342 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))
355 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)))
  380 +
356 381 #ifdef __KERNEL__
357 382  
358 383 /*
... ... @@ -503,7 +528,7 @@
503 528 struct xfs_icdinode *);
504 529  
505 530 uint xfs_ip2xflags(struct xfs_inode *);
506   -uint xfs_dic2xflags(struct xfs_dinode_core *);
  531 +uint xfs_dic2xflags(struct xfs_dinode *);
507 532 int xfs_ifree(struct xfs_trans *, xfs_inode_t *,
508 533 struct xfs_bmap_free *);
509 534 int xfs_itruncate_start(xfs_inode_t *, uint, xfs_fsize_t);
... ... @@ -170,7 +170,7 @@
170 170 buf->bs_mtime.tv_nsec = be32_to_cpu(dic->di_mtime.t_nsec);
171 171 buf->bs_ctime.tv_sec = be32_to_cpu(dic->di_ctime.t_sec);
172 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 174 buf->bs_extsize = be32_to_cpu(dic->di_extsize) << mp->m_sb.sb_blocklog;
175 175 buf->bs_extents = be32_to_cpu(dic->di_nextents);
176 176 buf->bs_gen = be32_to_cpu(dic->di_gen);
... ... @@ -307,7 +307,7 @@
307 307 }
308 308 /* BULKSTAT_FG_INLINE: if attr fork is local, or not there, use it */
309 309 aformat = dip->di_core.di_aformat;
310   - if ((XFS_CFORK_Q(&dip->di_core) == 0) ||
  310 + if ((XFS_DFORK_Q(dip) == 0) ||
311 311 (aformat == XFS_DINODE_FMT_LOCAL) ||
312 312 (aformat == XFS_DINODE_FMT_EXTENTS && !dip->di_core.di_anextents)) {
313 313 *dipp = dip;