aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@infradead.org>2007-08-27 23:57:51 -0400
committerTim Shimmin <tes@chook.melbourne.sgi.com>2007-10-15 02:48:30 -0400
commit347d1c01956d567c18afef0cc253eb235cafacd8 (patch)
tree55c61ae9390e013978cef21099a65965b2bb0ab5
parentddc6d3b32a8a732c343dc225048fae06c129e48a (diff)
[XFS] dinode endianess annotations
Biggest bit is duplicating the dinode structure so we have one annotated for native endianess and one for disk endianess. The other significant change is that xfs_xlate_dinode_core is split into one helper per direction to allow for proper annotations, everything else is trivial. As a sidenode splitting out the incore dinode means we can move it into xfs_inode.h in a later patch and severely improving on the include hell in xfs. SGI-PV: 968563 SGI-Modid: xfs-linux-melb:xfs-kern:29476a Signed-off-by: Christoph Hellwig <hch@infradead.org> Signed-off-by: David Chinner <dgc@sgi.com> Signed-off-by: Tim Shimmin <tes@sgi.com>
-rw-r--r--fs/xfs/xfs_dinode.h65
-rw-r--r--fs/xfs/xfs_ialloc.c6
-rw-r--r--fs/xfs/xfs_inode.c213
-rw-r--r--fs/xfs/xfs_inode.h52
-rw-r--r--fs/xfs/xfs_itable.c55
-rw-r--r--fs/xfs/xfs_log_recover.c25
6 files changed, 228 insertions, 188 deletions
diff --git a/fs/xfs/xfs_dinode.h b/fs/xfs/xfs_dinode.h
index fefd0116bac9..dedd713574e1 100644
--- a/fs/xfs/xfs_dinode.h
+++ b/fs/xfs/xfs_dinode.h
@@ -34,41 +34,41 @@ struct xfs_mount;
34 * because we only need the core part in the in-core inode. 34 * because we only need the core part in the in-core inode.
35 */ 35 */
36typedef struct xfs_timestamp { 36typedef struct xfs_timestamp {
37 __int32_t t_sec; /* timestamp seconds */ 37 __be32 t_sec; /* timestamp seconds */
38 __int32_t t_nsec; /* timestamp nanoseconds */ 38 __be32 t_nsec; /* timestamp nanoseconds */
39} xfs_timestamp_t; 39} xfs_timestamp_t;
40 40
41/* 41/*
42 * Note: Coordinate changes to this structure with the XFS_DI_* #defines 42 * Note: Coordinate changes to this structure with the XFS_DI_* #defines
43 * below and the offsets table in xfs_ialloc_log_di(). 43 * below, the offsets table in xfs_ialloc_log_di() and struct xfs_icdinode
44 * in xfs_inode.h.
44 */ 45 */
45typedef struct xfs_dinode_core 46typedef struct xfs_dinode_core {
46{ 47 __be16 di_magic; /* inode magic # = XFS_DINODE_MAGIC */
47 __uint16_t di_magic; /* inode magic # = XFS_DINODE_MAGIC */ 48 __be16 di_mode; /* mode and type of file */
48 __uint16_t di_mode; /* mode and type of file */ 49 __u8 di_version; /* inode version */
49 __int8_t di_version; /* inode version */ 50 __u8 di_format; /* format of di_c data */
50 __int8_t di_format; /* format of di_c data */ 51 __be16 di_onlink; /* old number of links to file */
51 __uint16_t di_onlink; /* old number of links to file */ 52 __be32 di_uid; /* owner's user id */
52 __uint32_t di_uid; /* owner's user id */ 53 __be32 di_gid; /* owner's group id */
53 __uint32_t di_gid; /* owner's group id */ 54 __be32 di_nlink; /* number of links to file */
54 __uint32_t di_nlink; /* number of links to file */ 55 __be16 di_projid; /* owner's project id */
55 __uint16_t di_projid; /* owner's project id */ 56 __u8 di_pad[8]; /* unused, zeroed space */
56 __uint8_t di_pad[8]; /* unused, zeroed space */ 57 __be16 di_flushiter; /* incremented on flush */
57 __uint16_t di_flushiter; /* incremented on flush */
58 xfs_timestamp_t di_atime; /* time last accessed */ 58 xfs_timestamp_t di_atime; /* time last accessed */
59 xfs_timestamp_t di_mtime; /* time last modified */ 59 xfs_timestamp_t di_mtime; /* time last modified */
60 xfs_timestamp_t di_ctime; /* time created/inode modified */ 60 xfs_timestamp_t di_ctime; /* time created/inode modified */
61 xfs_fsize_t di_size; /* number of bytes in file */ 61 __be64 di_size; /* number of bytes in file */
62 xfs_drfsbno_t di_nblocks; /* # of direct & btree blocks used */ 62 __be64 di_nblocks; /* # of direct & btree blocks used */
63 xfs_extlen_t di_extsize; /* basic/minimum extent size for file */ 63 __be32 di_extsize; /* basic/minimum extent size for file */
64 xfs_extnum_t di_nextents; /* number of extents in data fork */ 64 __be32 di_nextents; /* number of extents in data fork */
65 xfs_aextnum_t di_anextents; /* number of extents in attribute fork*/ 65 __be16 di_anextents; /* number of extents in attribute fork*/
66 __uint8_t di_forkoff; /* attr fork offs, <<3 for 64b align */ 66 __u8 di_forkoff; /* attr fork offs, <<3 for 64b align */
67 __int8_t di_aformat; /* format of attr fork's data */ 67 __s8 di_aformat; /* format of attr fork's data */
68 __uint32_t di_dmevmask; /* DMIG event mask */ 68 __be32 di_dmevmask; /* DMIG event mask */
69 __uint16_t di_dmstate; /* DMIG state info */ 69 __be16 di_dmstate; /* DMIG state info */
70 __uint16_t di_flags; /* random flags, XFS_DIFLAG_... */ 70 __be16 di_flags; /* random flags, XFS_DIFLAG_... */
71 __uint32_t di_gen; /* generation number */ 71 __be32 di_gen; /* generation number */
72} xfs_dinode_core_t; 72} xfs_dinode_core_t;
73 73
74#define DI_MAX_FLUSH 0xffff 74#define DI_MAX_FLUSH 0xffff
@@ -81,13 +81,13 @@ typedef struct xfs_dinode
81 * sure to update the macros like XFS_LITINO below and 81 * sure to update the macros like XFS_LITINO below and
82 * XFS_BMAP_RBLOCK_DSIZE in xfs_bmap_btree.h. 82 * XFS_BMAP_RBLOCK_DSIZE in xfs_bmap_btree.h.
83 */ 83 */
84 xfs_agino_t di_next_unlinked;/* agi unlinked list ptr */ 84 __be32 di_next_unlinked;/* agi unlinked list ptr */
85 union { 85 union {
86 xfs_bmdr_block_t di_bmbt; /* btree root block */ 86 xfs_bmdr_block_t di_bmbt; /* btree root block */
87 xfs_bmbt_rec_32_t di_bmx[1]; /* extent list */ 87 xfs_bmbt_rec_32_t di_bmx[1]; /* extent list */
88 xfs_dir2_sf_t di_dir2sf; /* shortform directory v2 */ 88 xfs_dir2_sf_t di_dir2sf; /* shortform directory v2 */
89 char di_c[1]; /* local contents */ 89 char di_c[1]; /* local contents */
90 xfs_dev_t di_dev; /* device for S_IFCHR/S_IFBLK */ 90 __be32 di_dev; /* device for S_IFCHR/S_IFBLK */
91 uuid_t di_muuid; /* mount point value */ 91 uuid_t di_muuid; /* mount point value */
92 char di_symlink[1]; /* local symbolic link */ 92 char di_symlink[1]; /* local symbolic link */
93 } di_u; 93 } di_u;
@@ -175,8 +175,7 @@ typedef enum xfs_dinode_fmt
175#define XFS_CFORK_Q_DISK(dcp) ((dcp)->di_forkoff != 0) 175#define XFS_CFORK_Q_DISK(dcp) ((dcp)->di_forkoff != 0)
176 176
177#define XFS_CFORK_BOFF(dcp) ((int)((dcp)->di_forkoff << 3)) 177#define XFS_CFORK_BOFF(dcp) ((int)((dcp)->di_forkoff << 3))
178#define XFS_CFORK_BOFF_DISK(dcp) \ 178#define XFS_CFORK_BOFF_DISK(dcp) ((int)((dcp)->di_forkoff << 3))
179 ((int)(INT_GET((dcp)->di_forkoff, ARCH_CONVERT) << 3))
180 179
181#define XFS_CFORK_DSIZE_DISK(dcp,mp) \ 180#define XFS_CFORK_DSIZE_DISK(dcp,mp) \
182 (XFS_CFORK_Q_DISK(dcp) ? XFS_CFORK_BOFF_DISK(dcp) : XFS_LITINO(mp)) 181 (XFS_CFORK_Q_DISK(dcp) ? XFS_CFORK_BOFF_DISK(dcp) : XFS_LITINO(mp))
@@ -225,8 +224,8 @@ typedef enum xfs_dinode_fmt
225 224
226#define XFS_CFORK_NEXTENTS_DISK(dcp,w) \ 225#define XFS_CFORK_NEXTENTS_DISK(dcp,w) \
227 ((w) == XFS_DATA_FORK ? \ 226 ((w) == XFS_DATA_FORK ? \
228 INT_GET((dcp)->di_nextents, ARCH_CONVERT) : \ 227 be32_to_cpu((dcp)->di_nextents) : \
229 INT_GET((dcp)->di_anextents, ARCH_CONVERT)) 228 be16_to_cpu((dcp)->di_anextents))
230#define XFS_CFORK_NEXTENTS(dcp,w) \ 229#define XFS_CFORK_NEXTENTS(dcp,w) \
231 ((w) == XFS_DATA_FORK ? (dcp)->di_nextents : (dcp)->di_anextents) 230 ((w) == XFS_DATA_FORK ? (dcp)->di_nextents : (dcp)->di_anextents)
232#define XFS_DFORK_NEXTENTS(dip,w) XFS_CFORK_NEXTENTS_DISK(&(dip)->di_core, w) 231#define XFS_DFORK_NEXTENTS(dip,w) XFS_CFORK_NEXTENTS_DISK(&(dip)->di_core, w)
diff --git a/fs/xfs/xfs_ialloc.c b/fs/xfs/xfs_ialloc.c
index f943368c9b93..1409c2d61c11 100644
--- a/fs/xfs/xfs_ialloc.c
+++ b/fs/xfs/xfs_ialloc.c
@@ -293,9 +293,9 @@ xfs_ialloc_ag_alloc(
293 xfs_biozero(fbuf, 0, ninodes << args.mp->m_sb.sb_inodelog); 293 xfs_biozero(fbuf, 0, ninodes << args.mp->m_sb.sb_inodelog);
294 for (i = 0; i < ninodes; i++) { 294 for (i = 0; i < ninodes; i++) {
295 free = XFS_MAKE_IPTR(args.mp, fbuf, i); 295 free = XFS_MAKE_IPTR(args.mp, fbuf, i);
296 INT_SET(free->di_core.di_magic, ARCH_CONVERT, XFS_DINODE_MAGIC); 296 free->di_core.di_magic = cpu_to_be16(XFS_DINODE_MAGIC);
297 INT_SET(free->di_core.di_version, ARCH_CONVERT, version); 297 free->di_core.di_version = version;
298 INT_SET(free->di_next_unlinked, ARCH_CONVERT, NULLAGINO); 298 free->di_next_unlinked = cpu_to_be32(NULLAGINO);
299 xfs_ialloc_log_di(tp, fbuf, i, 299 xfs_ialloc_log_di(tp, fbuf, i,
300 XFS_DI_CORE_BITS | XFS_DI_NEXT_UNLINKED); 300 XFS_DI_CORE_BITS | XFS_DI_NEXT_UNLINKED);
301 } 301 }
diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c
index bc9e7c891809..41a0c73b601a 100644
--- a/fs/xfs/xfs_inode.c
+++ b/fs/xfs/xfs_inode.c
@@ -193,8 +193,8 @@ xfs_inotobp(
193 } 193 }
194 dip = (xfs_dinode_t *)xfs_buf_offset(bp, 0); 194 dip = (xfs_dinode_t *)xfs_buf_offset(bp, 0);
195 di_ok = 195 di_ok =
196 INT_GET(dip->di_core.di_magic, ARCH_CONVERT) == XFS_DINODE_MAGIC && 196 be16_to_cpu(dip->di_core.di_magic) == XFS_DINODE_MAGIC &&
197 XFS_DINODE_GOOD_VERSION(INT_GET(dip->di_core.di_version, ARCH_CONVERT)); 197 XFS_DINODE_GOOD_VERSION(dip->di_core.di_version);
198 if (unlikely(XFS_TEST_ERROR(!di_ok, mp, XFS_ERRTAG_ITOBP_INOTOBP, 198 if (unlikely(XFS_TEST_ERROR(!di_ok, mp, XFS_ERRTAG_ITOBP_INOTOBP,
199 XFS_RANDOM_ITOBP_INOTOBP))) { 199 XFS_RANDOM_ITOBP_INOTOBP))) {
200 XFS_CORRUPTION_ERROR("xfs_inotobp", XFS_ERRLEVEL_LOW, mp, dip); 200 XFS_CORRUPTION_ERROR("xfs_inotobp", XFS_ERRLEVEL_LOW, mp, dip);
@@ -338,8 +338,8 @@ xfs_itobp(
338 338
339 dip = (xfs_dinode_t *)xfs_buf_offset(bp, 339 dip = (xfs_dinode_t *)xfs_buf_offset(bp,
340 (i << mp->m_sb.sb_inodelog)); 340 (i << mp->m_sb.sb_inodelog));
341 di_ok = INT_GET(dip->di_core.di_magic, ARCH_CONVERT) == XFS_DINODE_MAGIC && 341 di_ok = be16_to_cpu(dip->di_core.di_magic) == XFS_DINODE_MAGIC &&
342 XFS_DINODE_GOOD_VERSION(INT_GET(dip->di_core.di_version, ARCH_CONVERT)); 342 XFS_DINODE_GOOD_VERSION(dip->di_core.di_version);
343 if (unlikely(XFS_TEST_ERROR(!di_ok, mp, 343 if (unlikely(XFS_TEST_ERROR(!di_ok, mp,
344 XFS_ERRTAG_ITOBP_INOTOBP, 344 XFS_ERRTAG_ITOBP_INOTOBP,
345 XFS_RANDOM_ITOBP_INOTOBP))) { 345 XFS_RANDOM_ITOBP_INOTOBP))) {
@@ -353,7 +353,7 @@ xfs_itobp(
353 "daddr %lld #%d (magic=%x)", 353 "daddr %lld #%d (magic=%x)",
354 XFS_BUFTARG_NAME(mp->m_ddev_targp), 354 XFS_BUFTARG_NAME(mp->m_ddev_targp),
355 (unsigned long long)imap.im_blkno, i, 355 (unsigned long long)imap.im_blkno, i,
356 INT_GET(dip->di_core.di_magic, ARCH_CONVERT)); 356 be16_to_cpu(dip->di_core.di_magic));
357#endif 357#endif
358 XFS_CORRUPTION_ERROR("xfs_itobp", XFS_ERRLEVEL_HIGH, 358 XFS_CORRUPTION_ERROR("xfs_itobp", XFS_ERRLEVEL_HIGH,
359 mp, dip); 359 mp, dip);
@@ -399,27 +399,26 @@ xfs_iformat(
399 XFS_IFORK_DSIZE(ip) / (uint)sizeof(xfs_bmbt_rec_t); 399 XFS_IFORK_DSIZE(ip) / (uint)sizeof(xfs_bmbt_rec_t);
400 error = 0; 400 error = 0;
401 401
402 if (unlikely( 402 if (unlikely(be32_to_cpu(dip->di_core.di_nextents) +
403 INT_GET(dip->di_core.di_nextents, ARCH_CONVERT) + 403 be16_to_cpu(dip->di_core.di_anextents) >
404 INT_GET(dip->di_core.di_anextents, ARCH_CONVERT) > 404 be64_to_cpu(dip->di_core.di_nblocks))) {
405 INT_GET(dip->di_core.di_nblocks, ARCH_CONVERT))) {
406 xfs_fs_repair_cmn_err(CE_WARN, ip->i_mount, 405 xfs_fs_repair_cmn_err(CE_WARN, ip->i_mount,
407 "corrupt dinode %Lu, extent total = %d, nblocks = %Lu.", 406 "corrupt dinode %Lu, extent total = %d, nblocks = %Lu.",
408 (unsigned long long)ip->i_ino, 407 (unsigned long long)ip->i_ino,
409 (int)(INT_GET(dip->di_core.di_nextents, ARCH_CONVERT) 408 (int)(be32_to_cpu(dip->di_core.di_nextents) +
410 + INT_GET(dip->di_core.di_anextents, ARCH_CONVERT)), 409 be16_to_cpu(dip->di_core.di_anextents)),
411 (unsigned long long) 410 (unsigned long long)
412 INT_GET(dip->di_core.di_nblocks, ARCH_CONVERT)); 411 be64_to_cpu(dip->di_core.di_nblocks));
413 XFS_CORRUPTION_ERROR("xfs_iformat(1)", XFS_ERRLEVEL_LOW, 412 XFS_CORRUPTION_ERROR("xfs_iformat(1)", XFS_ERRLEVEL_LOW,
414 ip->i_mount, dip); 413 ip->i_mount, dip);
415 return XFS_ERROR(EFSCORRUPTED); 414 return XFS_ERROR(EFSCORRUPTED);
416 } 415 }
417 416
418 if (unlikely(INT_GET(dip->di_core.di_forkoff, ARCH_CONVERT) > ip->i_mount->m_sb.sb_inodesize)) { 417 if (unlikely(dip->di_core.di_forkoff > ip->i_mount->m_sb.sb_inodesize)) {
419 xfs_fs_repair_cmn_err(CE_WARN, ip->i_mount, 418 xfs_fs_repair_cmn_err(CE_WARN, ip->i_mount,
420 "corrupt dinode %Lu, forkoff = 0x%x.", 419 "corrupt dinode %Lu, forkoff = 0x%x.",
421 (unsigned long long)ip->i_ino, 420 (unsigned long long)ip->i_ino,
422 (int)(INT_GET(dip->di_core.di_forkoff, ARCH_CONVERT))); 421 dip->di_core.di_forkoff);
423 XFS_CORRUPTION_ERROR("xfs_iformat(2)", XFS_ERRLEVEL_LOW, 422 XFS_CORRUPTION_ERROR("xfs_iformat(2)", XFS_ERRLEVEL_LOW,
424 ip->i_mount, dip); 423 ip->i_mount, dip);
425 return XFS_ERROR(EFSCORRUPTED); 424 return XFS_ERROR(EFSCORRUPTED);
@@ -430,25 +429,25 @@ xfs_iformat(
430 case S_IFCHR: 429 case S_IFCHR:
431 case S_IFBLK: 430 case S_IFBLK:
432 case S_IFSOCK: 431 case S_IFSOCK:
433 if (unlikely(INT_GET(dip->di_core.di_format, ARCH_CONVERT) != XFS_DINODE_FMT_DEV)) { 432 if (unlikely(dip->di_core.di_format != XFS_DINODE_FMT_DEV)) {
434 XFS_CORRUPTION_ERROR("xfs_iformat(3)", XFS_ERRLEVEL_LOW, 433 XFS_CORRUPTION_ERROR("xfs_iformat(3)", XFS_ERRLEVEL_LOW,
435 ip->i_mount, dip); 434 ip->i_mount, dip);
436 return XFS_ERROR(EFSCORRUPTED); 435 return XFS_ERROR(EFSCORRUPTED);
437 } 436 }
438 ip->i_d.di_size = 0; 437 ip->i_d.di_size = 0;
439 ip->i_size = 0; 438 ip->i_size = 0;
440 ip->i_df.if_u2.if_rdev = INT_GET(dip->di_u.di_dev, ARCH_CONVERT); 439 ip->i_df.if_u2.if_rdev = be32_to_cpu(dip->di_u.di_dev);
441 break; 440 break;
442 441
443 case S_IFREG: 442 case S_IFREG:
444 case S_IFLNK: 443 case S_IFLNK:
445 case S_IFDIR: 444 case S_IFDIR:
446 switch (INT_GET(dip->di_core.di_format, ARCH_CONVERT)) { 445 switch (dip->di_core.di_format) {
447 case XFS_DINODE_FMT_LOCAL: 446 case XFS_DINODE_FMT_LOCAL:
448 /* 447 /*
449 * no local regular files yet 448 * no local regular files yet
450 */ 449 */
451 if (unlikely((INT_GET(dip->di_core.di_mode, ARCH_CONVERT) & S_IFMT) == S_IFREG)) { 450 if (unlikely((be16_to_cpu(dip->di_core.di_mode) & S_IFMT) == S_IFREG)) {
452 xfs_fs_repair_cmn_err(CE_WARN, ip->i_mount, 451 xfs_fs_repair_cmn_err(CE_WARN, ip->i_mount,
453 "corrupt inode %Lu " 452 "corrupt inode %Lu "
454 "(local format for regular file).", 453 "(local format for regular file).",
@@ -459,7 +458,7 @@ xfs_iformat(
459 return XFS_ERROR(EFSCORRUPTED); 458 return XFS_ERROR(EFSCORRUPTED);
460 } 459 }
461 460
462 di_size = INT_GET(dip->di_core.di_size, ARCH_CONVERT); 461 di_size = be64_to_cpu(dip->di_core.di_size);
463 if (unlikely(di_size > XFS_DFORK_DSIZE(dip, ip->i_mount))) { 462 if (unlikely(di_size > XFS_DFORK_DSIZE(dip, ip->i_mount))) {
464 xfs_fs_repair_cmn_err(CE_WARN, ip->i_mount, 463 xfs_fs_repair_cmn_err(CE_WARN, ip->i_mount,
465 "corrupt inode %Lu " 464 "corrupt inode %Lu "
@@ -501,7 +500,7 @@ xfs_iformat(
501 ip->i_afp = kmem_zone_zalloc(xfs_ifork_zone, KM_SLEEP); 500 ip->i_afp = kmem_zone_zalloc(xfs_ifork_zone, KM_SLEEP);
502 ip->i_afp->if_ext_max = 501 ip->i_afp->if_ext_max =
503 XFS_IFORK_ASIZE(ip) / (uint)sizeof(xfs_bmbt_rec_t); 502 XFS_IFORK_ASIZE(ip) / (uint)sizeof(xfs_bmbt_rec_t);
504 switch (INT_GET(dip->di_core.di_aformat, ARCH_CONVERT)) { 503 switch (dip->di_core.di_aformat) {
505 case XFS_DINODE_FMT_LOCAL: 504 case XFS_DINODE_FMT_LOCAL:
506 atp = (xfs_attr_shortform_t *)XFS_DFORK_APTR(dip); 505 atp = (xfs_attr_shortform_t *)XFS_DFORK_APTR(dip);
507 size = be16_to_cpu(atp->hdr.totsize); 506 size = be16_to_cpu(atp->hdr.totsize);
@@ -709,70 +708,74 @@ xfs_iformat_btree(
709 return 0; 708 return 0;
710} 709}
711 710
712/*
713 * xfs_xlate_dinode_core - translate an xfs_inode_core_t between ondisk
714 * and native format
715 *
716 * buf = on-disk representation
717 * dip = native representation
718 * dir = direction - +ve -> disk to native
719 * -ve -> native to disk
720 */
721void 711void
722xfs_xlate_dinode_core( 712xfs_dinode_from_disk(
723 xfs_caddr_t buf, 713 xfs_icdinode_t *to,
724 xfs_dinode_core_t *dip, 714 xfs_dinode_core_t *from)
725 int dir)
726{ 715{
727 xfs_dinode_core_t *buf_core = (xfs_dinode_core_t *)buf; 716 to->di_magic = be16_to_cpu(from->di_magic);
728 xfs_dinode_core_t *mem_core = (xfs_dinode_core_t *)dip; 717 to->di_mode = be16_to_cpu(from->di_mode);
729 xfs_arch_t arch = ARCH_CONVERT; 718 to->di_version = from ->di_version;
730 719 to->di_format = from->di_format;
731 ASSERT(dir); 720 to->di_onlink = be16_to_cpu(from->di_onlink);
732 721 to->di_uid = be32_to_cpu(from->di_uid);
733 INT_XLATE(buf_core->di_magic, mem_core->di_magic, dir, arch); 722 to->di_gid = be32_to_cpu(from->di_gid);
734 INT_XLATE(buf_core->di_mode, mem_core->di_mode, dir, arch); 723 to->di_nlink = be32_to_cpu(from->di_nlink);
735 INT_XLATE(buf_core->di_version, mem_core->di_version, dir, arch); 724 to->di_projid = be16_to_cpu(from->di_projid);
736 INT_XLATE(buf_core->di_format, mem_core->di_format, dir, arch); 725 memcpy(to->di_pad, from->di_pad, sizeof(to->di_pad));
737 INT_XLATE(buf_core->di_onlink, mem_core->di_onlink, dir, arch); 726 to->di_flushiter = be16_to_cpu(from->di_flushiter);
738 INT_XLATE(buf_core->di_uid, mem_core->di_uid, dir, arch); 727 to->di_atime.t_sec = be32_to_cpu(from->di_atime.t_sec);
739 INT_XLATE(buf_core->di_gid, mem_core->di_gid, dir, arch); 728 to->di_atime.t_nsec = be32_to_cpu(from->di_atime.t_nsec);
740 INT_XLATE(buf_core->di_nlink, mem_core->di_nlink, dir, arch); 729 to->di_mtime.t_sec = be32_to_cpu(from->di_mtime.t_sec);
741 INT_XLATE(buf_core->di_projid, mem_core->di_projid, dir, arch); 730 to->di_mtime.t_nsec = be32_to_cpu(from->di_mtime.t_nsec);
742 731 to->di_ctime.t_sec = be32_to_cpu(from->di_ctime.t_sec);
743 if (dir > 0) { 732 to->di_ctime.t_nsec = be32_to_cpu(from->di_ctime.t_nsec);
744 memcpy(mem_core->di_pad, buf_core->di_pad, 733 to->di_size = be64_to_cpu(from->di_size);
745 sizeof(buf_core->di_pad)); 734 to->di_nblocks = be64_to_cpu(from->di_nblocks);
746 } else { 735 to->di_extsize = be32_to_cpu(from->di_extsize);
747 memcpy(buf_core->di_pad, mem_core->di_pad, 736 to->di_nextents = be32_to_cpu(from->di_nextents);
748 sizeof(buf_core->di_pad)); 737 to->di_anextents = be16_to_cpu(from->di_anextents);
749 } 738 to->di_forkoff = from->di_forkoff;
750 739 to->di_aformat = from->di_aformat;
751 INT_XLATE(buf_core->di_flushiter, mem_core->di_flushiter, dir, arch); 740 to->di_dmevmask = be32_to_cpu(from->di_dmevmask);
752 741 to->di_dmstate = be16_to_cpu(from->di_dmstate);
753 INT_XLATE(buf_core->di_atime.t_sec, mem_core->di_atime.t_sec, 742 to->di_flags = be16_to_cpu(from->di_flags);
754 dir, arch); 743 to->di_gen = be32_to_cpu(from->di_gen);
755 INT_XLATE(buf_core->di_atime.t_nsec, mem_core->di_atime.t_nsec, 744}
756 dir, arch); 745
757 INT_XLATE(buf_core->di_mtime.t_sec, mem_core->di_mtime.t_sec, 746void
758 dir, arch); 747xfs_dinode_to_disk(
759 INT_XLATE(buf_core->di_mtime.t_nsec, mem_core->di_mtime.t_nsec, 748 xfs_dinode_core_t *to,
760 dir, arch); 749 xfs_icdinode_t *from)
761 INT_XLATE(buf_core->di_ctime.t_sec, mem_core->di_ctime.t_sec, 750{
762 dir, arch); 751 to->di_magic = cpu_to_be16(from->di_magic);
763 INT_XLATE(buf_core->di_ctime.t_nsec, mem_core->di_ctime.t_nsec, 752 to->di_mode = cpu_to_be16(from->di_mode);
764 dir, arch); 753 to->di_version = from ->di_version;
765 INT_XLATE(buf_core->di_size, mem_core->di_size, dir, arch); 754 to->di_format = from->di_format;
766 INT_XLATE(buf_core->di_nblocks, mem_core->di_nblocks, dir, arch); 755 to->di_onlink = cpu_to_be16(from->di_onlink);
767 INT_XLATE(buf_core->di_extsize, mem_core->di_extsize, dir, arch); 756 to->di_uid = cpu_to_be32(from->di_uid);
768 INT_XLATE(buf_core->di_nextents, mem_core->di_nextents, dir, arch); 757 to->di_gid = cpu_to_be32(from->di_gid);
769 INT_XLATE(buf_core->di_anextents, mem_core->di_anextents, dir, arch); 758 to->di_nlink = cpu_to_be32(from->di_nlink);
770 INT_XLATE(buf_core->di_forkoff, mem_core->di_forkoff, dir, arch); 759 to->di_projid = cpu_to_be16(from->di_projid);
771 INT_XLATE(buf_core->di_aformat, mem_core->di_aformat, dir, arch); 760 memcpy(to->di_pad, from->di_pad, sizeof(to->di_pad));
772 INT_XLATE(buf_core->di_dmevmask, mem_core->di_dmevmask, dir, arch); 761 to->di_flushiter = cpu_to_be16(from->di_flushiter);
773 INT_XLATE(buf_core->di_dmstate, mem_core->di_dmstate, dir, arch); 762 to->di_atime.t_sec = cpu_to_be32(from->di_atime.t_sec);
774 INT_XLATE(buf_core->di_flags, mem_core->di_flags, dir, arch); 763 to->di_atime.t_nsec = cpu_to_be32(from->di_atime.t_nsec);
775 INT_XLATE(buf_core->di_gen, mem_core->di_gen, dir, arch); 764 to->di_mtime.t_sec = cpu_to_be32(from->di_mtime.t_sec);
765 to->di_mtime.t_nsec = cpu_to_be32(from->di_mtime.t_nsec);
766 to->di_ctime.t_sec = cpu_to_be32(from->di_ctime.t_sec);
767 to->di_ctime.t_nsec = cpu_to_be32(from->di_ctime.t_nsec);
768 to->di_size = cpu_to_be64(from->di_size);
769 to->di_nblocks = cpu_to_be64(from->di_nblocks);
770 to->di_extsize = cpu_to_be32(from->di_extsize);
771 to->di_nextents = cpu_to_be32(from->di_nextents);
772 to->di_anextents = cpu_to_be16(from->di_anextents);
773 to->di_forkoff = from->di_forkoff;
774 to->di_aformat = from->di_aformat;
775 to->di_dmevmask = cpu_to_be32(from->di_dmevmask);
776 to->di_dmstate = cpu_to_be16(from->di_dmstate);
777 to->di_flags = cpu_to_be16(from->di_flags);
778 to->di_gen = cpu_to_be32(from->di_gen);
776} 779}
777 780
778STATIC uint 781STATIC uint
@@ -819,7 +822,7 @@ uint
819xfs_ip2xflags( 822xfs_ip2xflags(
820 xfs_inode_t *ip) 823 xfs_inode_t *ip)
821{ 824{
822 xfs_dinode_core_t *dic = &ip->i_d; 825 xfs_icdinode_t *dic = &ip->i_d;
823 826
824 return _xfs_dic2xflags(dic->di_flags) | 827 return _xfs_dic2xflags(dic->di_flags) |
825 (XFS_CFORK_Q(dic) ? XFS_XFLAG_HASATTR : 0); 828 (XFS_CFORK_Q(dic) ? XFS_XFLAG_HASATTR : 0);
@@ -829,7 +832,7 @@ uint
829xfs_dic2xflags( 832xfs_dic2xflags(
830 xfs_dinode_core_t *dic) 833 xfs_dinode_core_t *dic)
831{ 834{
832 return _xfs_dic2xflags(INT_GET(dic->di_flags, ARCH_CONVERT)) | 835 return _xfs_dic2xflags(be16_to_cpu(dic->di_flags)) |
833 (XFS_CFORK_Q_DISK(dic) ? XFS_XFLAG_HASATTR : 0); 836 (XFS_CFORK_Q_DISK(dic) ? XFS_XFLAG_HASATTR : 0);
834} 837}
835 838
@@ -899,14 +902,14 @@ xfs_iread(
899 * If we got something that isn't an inode it means someone 902 * If we got something that isn't an inode it means someone
900 * (nfs or dmi) has a stale handle. 903 * (nfs or dmi) has a stale handle.
901 */ 904 */
902 if (INT_GET(dip->di_core.di_magic, ARCH_CONVERT) != XFS_DINODE_MAGIC) { 905 if (be16_to_cpu(dip->di_core.di_magic) != XFS_DINODE_MAGIC) {
903 kmem_zone_free(xfs_inode_zone, ip); 906 kmem_zone_free(xfs_inode_zone, ip);
904 xfs_trans_brelse(tp, bp); 907 xfs_trans_brelse(tp, bp);
905#ifdef DEBUG 908#ifdef DEBUG
906 xfs_fs_cmn_err(CE_ALERT, mp, "xfs_iread: " 909 xfs_fs_cmn_err(CE_ALERT, mp, "xfs_iread: "
907 "dip->di_core.di_magic (0x%x) != " 910 "dip->di_core.di_magic (0x%x) != "
908 "XFS_DINODE_MAGIC (0x%x)", 911 "XFS_DINODE_MAGIC (0x%x)",
909 INT_GET(dip->di_core.di_magic, ARCH_CONVERT), 912 be16_to_cpu(dip->di_core.di_magic),
910 XFS_DINODE_MAGIC); 913 XFS_DINODE_MAGIC);
911#endif /* DEBUG */ 914#endif /* DEBUG */
912 return XFS_ERROR(EINVAL); 915 return XFS_ERROR(EINVAL);
@@ -920,8 +923,7 @@ xfs_iread(
920 * Otherwise, just get the truly permanent information. 923 * Otherwise, just get the truly permanent information.
921 */ 924 */
922 if (dip->di_core.di_mode) { 925 if (dip->di_core.di_mode) {
923 xfs_xlate_dinode_core((xfs_caddr_t)&dip->di_core, 926 xfs_dinode_from_disk(&ip->i_d, &dip->di_core);
924 &(ip->i_d), 1);
925 error = xfs_iformat(ip, dip); 927 error = xfs_iformat(ip, dip);
926 if (error) { 928 if (error) {
927 kmem_zone_free(xfs_inode_zone, ip); 929 kmem_zone_free(xfs_inode_zone, ip);
@@ -934,10 +936,10 @@ xfs_iread(
934 return error; 936 return error;
935 } 937 }
936 } else { 938 } else {
937 ip->i_d.di_magic = INT_GET(dip->di_core.di_magic, ARCH_CONVERT); 939 ip->i_d.di_magic = be16_to_cpu(dip->di_core.di_magic);
938 ip->i_d.di_version = INT_GET(dip->di_core.di_version, ARCH_CONVERT); 940 ip->i_d.di_version = dip->di_core.di_version;
939 ip->i_d.di_gen = INT_GET(dip->di_core.di_gen, ARCH_CONVERT); 941 ip->i_d.di_gen = be32_to_cpu(dip->di_core.di_gen);
940 ip->i_d.di_flushiter = INT_GET(dip->di_core.di_flushiter, ARCH_CONVERT); 942 ip->i_d.di_flushiter = be16_to_cpu(dip->di_core.di_flushiter);
941 /* 943 /*
942 * Make sure to pull in the mode here as well in 944 * Make sure to pull in the mode here as well in
943 * case the inode is released without being used. 945 * case the inode is released without being used.
@@ -1959,8 +1961,7 @@ xfs_iunlink(
1959 if (error) { 1961 if (error) {
1960 return error; 1962 return error;
1961 } 1963 }
1962 ASSERT(INT_GET(dip->di_next_unlinked, ARCH_CONVERT) == NULLAGINO); 1964 ASSERT(be32_to_cpu(dip->di_next_unlinked) == NULLAGINO);
1963 ASSERT(dip->di_next_unlinked);
1964 /* both on-disk, don't endian flip twice */ 1965 /* both on-disk, don't endian flip twice */
1965 dip->di_next_unlinked = agi->agi_unlinked[bucket_index]; 1966 dip->di_next_unlinked = agi->agi_unlinked[bucket_index];
1966 offset = ip->i_boffset + 1967 offset = ip->i_boffset +
@@ -2071,10 +2072,10 @@ xfs_iunlink_remove(
2071 error, mp->m_fsname); 2072 error, mp->m_fsname);
2072 return error; 2073 return error;
2073 } 2074 }
2074 next_agino = INT_GET(dip->di_next_unlinked, ARCH_CONVERT); 2075 next_agino = be32_to_cpu(dip->di_next_unlinked);
2075 ASSERT(next_agino != 0); 2076 ASSERT(next_agino != 0);
2076 if (next_agino != NULLAGINO) { 2077 if (next_agino != NULLAGINO) {
2077 INT_SET(dip->di_next_unlinked, ARCH_CONVERT, NULLAGINO); 2078 dip->di_next_unlinked = cpu_to_be32(NULLAGINO);
2078 offset = ip->i_boffset + 2079 offset = ip->i_boffset +
2079 offsetof(xfs_dinode_t, di_next_unlinked); 2080 offsetof(xfs_dinode_t, di_next_unlinked);
2080 xfs_trans_inode_buf(tp, ibp); 2081 xfs_trans_inode_buf(tp, ibp);
@@ -2118,7 +2119,7 @@ xfs_iunlink_remove(
2118 error, mp->m_fsname); 2119 error, mp->m_fsname);
2119 return error; 2120 return error;
2120 } 2121 }
2121 next_agino = INT_GET(last_dip->di_next_unlinked, ARCH_CONVERT); 2122 next_agino = be32_to_cpu(last_dip->di_next_unlinked);
2122 ASSERT(next_agino != NULLAGINO); 2123 ASSERT(next_agino != NULLAGINO);
2123 ASSERT(next_agino != 0); 2124 ASSERT(next_agino != 0);
2124 } 2125 }
@@ -2133,11 +2134,11 @@ xfs_iunlink_remove(
2133 error, mp->m_fsname); 2134 error, mp->m_fsname);
2134 return error; 2135 return error;
2135 } 2136 }
2136 next_agino = INT_GET(dip->di_next_unlinked, ARCH_CONVERT); 2137 next_agino = be32_to_cpu(dip->di_next_unlinked);
2137 ASSERT(next_agino != 0); 2138 ASSERT(next_agino != 0);
2138 ASSERT(next_agino != agino); 2139 ASSERT(next_agino != agino);
2139 if (next_agino != NULLAGINO) { 2140 if (next_agino != NULLAGINO) {
2140 INT_SET(dip->di_next_unlinked, ARCH_CONVERT, NULLAGINO); 2141 dip->di_next_unlinked = cpu_to_be32(NULLAGINO);
2141 offset = ip->i_boffset + 2142 offset = ip->i_boffset +
2142 offsetof(xfs_dinode_t, di_next_unlinked); 2143 offsetof(xfs_dinode_t, di_next_unlinked);
2143 xfs_trans_inode_buf(tp, ibp); 2144 xfs_trans_inode_buf(tp, ibp);
@@ -2150,7 +2151,7 @@ xfs_iunlink_remove(
2150 /* 2151 /*
2151 * Point the previous inode on the list to the next inode. 2152 * Point the previous inode on the list to the next inode.
2152 */ 2153 */
2153 INT_SET(last_dip->di_next_unlinked, ARCH_CONVERT, next_agino); 2154 last_dip->di_next_unlinked = cpu_to_be32(next_agino);
2154 ASSERT(next_agino != 0); 2155 ASSERT(next_agino != 0);
2155 offset = last_offset + offsetof(xfs_dinode_t, di_next_unlinked); 2156 offset = last_offset + offsetof(xfs_dinode_t, di_next_unlinked);
2156 xfs_trans_inode_buf(tp, last_ibp); 2157 xfs_trans_inode_buf(tp, last_ibp);
@@ -3009,7 +3010,7 @@ xfs_iflush_fork(
3009 case XFS_DINODE_FMT_DEV: 3010 case XFS_DINODE_FMT_DEV:
3010 if (iip->ili_format.ilf_fields & XFS_ILOG_DEV) { 3011 if (iip->ili_format.ilf_fields & XFS_ILOG_DEV) {
3011 ASSERT(whichfork == XFS_DATA_FORK); 3012 ASSERT(whichfork == XFS_DATA_FORK);
3012 INT_SET(dip->di_u.di_dev, ARCH_CONVERT, ip->i_df.if_u2.if_rdev); 3013 dip->di_u.di_dev = cpu_to_be32(ip->i_df.if_u2.if_rdev);
3013 } 3014 }
3014 break; 3015 break;
3015 3016
@@ -3358,11 +3359,11 @@ xfs_iflush_int(
3358 */ 3359 */
3359 xfs_synchronize_atime(ip); 3360 xfs_synchronize_atime(ip);
3360 3361
3361 if (XFS_TEST_ERROR(INT_GET(dip->di_core.di_magic,ARCH_CONVERT) != XFS_DINODE_MAGIC, 3362 if (XFS_TEST_ERROR(be16_to_cpu(dip->di_core.di_magic) != XFS_DINODE_MAGIC,
3362 mp, XFS_ERRTAG_IFLUSH_1, XFS_RANDOM_IFLUSH_1)) { 3363 mp, XFS_ERRTAG_IFLUSH_1, XFS_RANDOM_IFLUSH_1)) {
3363 xfs_cmn_err(XFS_PTAG_IFLUSH, CE_ALERT, mp, 3364 xfs_cmn_err(XFS_PTAG_IFLUSH, CE_ALERT, mp,
3364 "xfs_iflush: Bad inode %Lu magic number 0x%x, ptr 0x%p", 3365 "xfs_iflush: Bad inode %Lu magic number 0x%x, ptr 0x%p",
3365 ip->i_ino, (int) INT_GET(dip->di_core.di_magic, ARCH_CONVERT), dip); 3366 ip->i_ino, be16_to_cpu(dip->di_core.di_magic), dip);
3366 goto corrupt_out; 3367 goto corrupt_out;
3367 } 3368 }
3368 if (XFS_TEST_ERROR(ip->i_d.di_magic != XFS_DINODE_MAGIC, 3369 if (XFS_TEST_ERROR(ip->i_d.di_magic != XFS_DINODE_MAGIC,
@@ -3425,7 +3426,7 @@ xfs_iflush_int(
3425 * because if the inode is dirty at all the core must 3426 * because if the inode is dirty at all the core must
3426 * be. 3427 * be.
3427 */ 3428 */
3428 xfs_xlate_dinode_core((xfs_caddr_t)&(dip->di_core), &(ip->i_d), -1); 3429 xfs_dinode_to_disk(&dip->di_core, &ip->i_d);
3429 3430
3430 /* Wrap, we never let the log put out DI_MAX_FLUSH */ 3431 /* Wrap, we never let the log put out DI_MAX_FLUSH */
3431 if (ip->i_d.di_flushiter == DI_MAX_FLUSH) 3432 if (ip->i_d.di_flushiter == DI_MAX_FLUSH)
@@ -3445,7 +3446,7 @@ xfs_iflush_int(
3445 * Convert it back. 3446 * Convert it back.
3446 */ 3447 */
3447 ASSERT(ip->i_d.di_nlink <= XFS_MAXLINK_1); 3448 ASSERT(ip->i_d.di_nlink <= XFS_MAXLINK_1);
3448 INT_SET(dip->di_core.di_onlink, ARCH_CONVERT, ip->i_d.di_nlink); 3449 dip->di_core.di_onlink = cpu_to_be16(ip->i_d.di_nlink);
3449 } else { 3450 } else {
3450 /* 3451 /*
3451 * The superblock version has already been bumped, 3452 * The superblock version has already been bumped,
@@ -3453,7 +3454,7 @@ xfs_iflush_int(
3453 * format permanent. 3454 * format permanent.
3454 */ 3455 */
3455 ip->i_d.di_version = XFS_DINODE_VERSION_2; 3456 ip->i_d.di_version = XFS_DINODE_VERSION_2;
3456 INT_SET(dip->di_core.di_version, ARCH_CONVERT, XFS_DINODE_VERSION_2); 3457 dip->di_core.di_version = XFS_DINODE_VERSION_2;
3457 ip->i_d.di_onlink = 0; 3458 ip->i_d.di_onlink = 0;
3458 dip->di_core.di_onlink = 0; 3459 dip->di_core.di_onlink = 0;
3459 memset(&(ip->i_d.di_pad[0]), 0, sizeof(ip->i_d.di_pad)); 3460 memset(&(ip->i_d.di_pad[0]), 0, sizeof(ip->i_d.di_pad));
diff --git a/fs/xfs/xfs_inode.h b/fs/xfs/xfs_inode.h
index 6fae71b42922..873b9f783d29 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 */
@@ -227,6 +231,43 @@ typedef struct xfs_chash {
227 * chain off the mount structure by xfs_sync calls. 231 * chain off the mount structure by xfs_sync calls.
228 */ 232 */
229 233
234typedef struct xfs_ictimestamp {
235 __int32_t t_sec; /* timestamp seconds */
236 __int32_t t_nsec; /* timestamp nanoseconds */
237} xfs_ictimestamp_t;
238
239/*
240 * NOTE: This structure must be kept identical to struct xfs_dinode_core
241 * in xfs_dinode.h except for the endianess annotations.
242 */
243typedef struct xfs_icdinode {
244 __uint16_t di_magic; /* inode magic # = XFS_DINODE_MAGIC */
245 __uint16_t di_mode; /* mode and type of file */
246 __int8_t di_version; /* inode version */
247 __int8_t di_format; /* format of di_c data */
248 __uint16_t di_onlink; /* old number of links to file */
249 __uint32_t di_uid; /* owner's user id */
250 __uint32_t di_gid; /* owner's group id */
251 __uint32_t di_nlink; /* number of links to file */
252 __uint16_t di_projid; /* owner's project id */
253 __uint8_t di_pad[8]; /* unused, zeroed space */
254 __uint16_t di_flushiter; /* incremented on flush */
255 xfs_ictimestamp_t di_atime; /* time last accessed */
256 xfs_ictimestamp_t di_mtime; /* time last modified */
257 xfs_ictimestamp_t di_ctime; /* time created/inode modified */
258 xfs_fsize_t di_size; /* number of bytes in file */
259 xfs_drfsbno_t di_nblocks; /* # of direct & btree blocks used */
260 xfs_extlen_t di_extsize; /* basic/minimum extent size for file */
261 xfs_extnum_t di_nextents; /* number of extents in data fork */
262 xfs_aextnum_t di_anextents; /* number of extents in attribute fork*/
263 __uint8_t di_forkoff; /* attr fork offs, <<3 for 64b align */
264 __int8_t di_aformat; /* format of attr fork's data */
265 __uint32_t di_dmevmask; /* DMIG event mask */
266 __uint16_t di_dmstate; /* DMIG state info */
267 __uint16_t di_flags; /* random flags, XFS_DIFLAG_... */
268 __uint32_t di_gen; /* generation number */
269} xfs_icdinode_t;
270
230typedef struct { 271typedef struct {
231 struct xfs_ihash *ip_hash; /* pointer to hash header */ 272 struct xfs_ihash *ip_hash; /* pointer to hash header */
232 struct xfs_inode *ip_next; /* inode hash link forw */ 273 struct xfs_inode *ip_next; /* inode hash link forw */
@@ -282,7 +323,7 @@ typedef struct xfs_inode {
282 unsigned int i_gen; /* generation count */ 323 unsigned int i_gen; /* generation count */
283 unsigned int i_delayed_blks; /* count of delay alloc blks */ 324 unsigned int i_delayed_blks; /* count of delay alloc blks */
284 325
285 xfs_dinode_core_t i_d; /* most of ondisk inode */ 326 xfs_icdinode_t i_d; /* most of ondisk inode */
286 xfs_chashlist_t *i_chash; /* cluster hash list header */ 327 xfs_chashlist_t *i_chash; /* cluster hash list header */
287 struct xfs_inode *i_cnext; /* cluster hash link forward */ 328 struct xfs_inode *i_cnext; /* cluster hash link forward */
288 struct xfs_inode *i_cprev; /* cluster hash link backward */ 329 struct xfs_inode *i_cprev; /* cluster hash link backward */
@@ -506,7 +547,7 @@ int xfs_finish_reclaim_all(struct xfs_mount *, int);
506 * xfs_inode.c prototypes. 547 * xfs_inode.c prototypes.
507 */ 548 */
508int xfs_itobp(struct xfs_mount *, struct xfs_trans *, 549int xfs_itobp(struct xfs_mount *, struct xfs_trans *,
509 xfs_inode_t *, xfs_dinode_t **, struct xfs_buf **, 550 xfs_inode_t *, struct xfs_dinode **, struct xfs_buf **,
510 xfs_daddr_t, uint); 551 xfs_daddr_t, uint);
511int xfs_iread(struct xfs_mount *, struct xfs_trans *, xfs_ino_t, 552int xfs_iread(struct xfs_mount *, struct xfs_trans *, xfs_ino_t,
512 xfs_inode_t **, xfs_daddr_t, uint); 553 xfs_inode_t **, xfs_daddr_t, uint);
@@ -514,8 +555,11 @@ int xfs_iread_extents(struct xfs_trans *, xfs_inode_t *, int);
514int xfs_ialloc(struct xfs_trans *, xfs_inode_t *, mode_t, 555int xfs_ialloc(struct xfs_trans *, xfs_inode_t *, mode_t,
515 xfs_nlink_t, xfs_dev_t, struct cred *, xfs_prid_t, 556 xfs_nlink_t, xfs_dev_t, struct cred *, xfs_prid_t,
516 int, struct xfs_buf **, boolean_t *, xfs_inode_t **); 557 int, struct xfs_buf **, boolean_t *, xfs_inode_t **);
517void xfs_xlate_dinode_core(xfs_caddr_t, struct xfs_dinode_core *, 558void xfs_dinode_from_disk(struct xfs_icdinode *,
518 int); 559 struct xfs_dinode_core *);
560void xfs_dinode_to_disk(struct xfs_dinode_core *,
561 struct xfs_icdinode *);
562
519uint xfs_ip2xflags(struct xfs_inode *); 563uint xfs_ip2xflags(struct xfs_inode *);
520uint xfs_dic2xflags(struct xfs_dinode_core *); 564uint xfs_dic2xflags(struct xfs_dinode_core *);
521int xfs_ifree(struct xfs_trans *, xfs_inode_t *, 565int xfs_ifree(struct xfs_trans *, xfs_inode_t *,
diff --git a/fs/xfs/xfs_itable.c b/fs/xfs/xfs_itable.c
index 4c2454bcc714..efeeafe275b9 100644
--- a/fs/xfs/xfs_itable.c
+++ b/fs/xfs/xfs_itable.c
@@ -57,7 +57,7 @@ xfs_bulkstat_one_iget(
57 xfs_bstat_t *buf, /* return buffer */ 57 xfs_bstat_t *buf, /* return buffer */
58 int *stat) /* BULKSTAT_RV_... */ 58 int *stat) /* BULKSTAT_RV_... */
59{ 59{
60 xfs_dinode_core_t *dic; /* dinode core info pointer */ 60 xfs_icdinode_t *dic; /* dinode core info pointer */
61 xfs_inode_t *ip; /* incore inode pointer */ 61 xfs_inode_t *ip; /* incore inode pointer */
62 bhv_vnode_t *vp; 62 bhv_vnode_t *vp;
63 int error; 63 int error;
@@ -151,37 +151,37 @@ xfs_bulkstat_one_dinode(
151 * the new format. We don't change the version number so that we 151 * the new format. We don't change the version number so that we
152 * can distinguish this from a real new format inode. 152 * can distinguish this from a real new format inode.
153 */ 153 */
154 if (INT_GET(dic->di_version, ARCH_CONVERT) == XFS_DINODE_VERSION_1) { 154 if (dic->di_version == XFS_DINODE_VERSION_1) {
155 buf->bs_nlink = INT_GET(dic->di_onlink, ARCH_CONVERT); 155 buf->bs_nlink = be16_to_cpu(dic->di_onlink);
156 buf->bs_projid = 0; 156 buf->bs_projid = 0;
157 } else { 157 } else {
158 buf->bs_nlink = INT_GET(dic->di_nlink, ARCH_CONVERT); 158 buf->bs_nlink = be32_to_cpu(dic->di_nlink);
159 buf->bs_projid = INT_GET(dic->di_projid, ARCH_CONVERT); 159 buf->bs_projid = be16_to_cpu(dic->di_projid);
160 } 160 }
161 161
162 buf->bs_ino = ino; 162 buf->bs_ino = ino;
163 buf->bs_mode = INT_GET(dic->di_mode, ARCH_CONVERT); 163 buf->bs_mode = be16_to_cpu(dic->di_mode);
164 buf->bs_uid = INT_GET(dic->di_uid, ARCH_CONVERT); 164 buf->bs_uid = be32_to_cpu(dic->di_uid);
165 buf->bs_gid = INT_GET(dic->di_gid, ARCH_CONVERT); 165 buf->bs_gid = be32_to_cpu(dic->di_gid);
166 buf->bs_size = INT_GET(dic->di_size, ARCH_CONVERT); 166 buf->bs_size = be64_to_cpu(dic->di_size);
167 buf->bs_atime.tv_sec = INT_GET(dic->di_atime.t_sec, ARCH_CONVERT); 167 buf->bs_atime.tv_sec = be32_to_cpu(dic->di_atime.t_sec);
168 buf->bs_atime.tv_nsec = INT_GET(dic->di_atime.t_nsec, ARCH_CONVERT); 168 buf->bs_atime.tv_nsec = be32_to_cpu(dic->di_atime.t_nsec);
169 buf->bs_mtime.tv_sec = INT_GET(dic->di_mtime.t_sec, ARCH_CONVERT); 169 buf->bs_mtime.tv_sec = be32_to_cpu(dic->di_mtime.t_sec);
170 buf->bs_mtime.tv_nsec = INT_GET(dic->di_mtime.t_nsec, ARCH_CONVERT); 170 buf->bs_mtime.tv_nsec = be32_to_cpu(dic->di_mtime.t_nsec);
171 buf->bs_ctime.tv_sec = INT_GET(dic->di_ctime.t_sec, ARCH_CONVERT); 171 buf->bs_ctime.tv_sec = be32_to_cpu(dic->di_ctime.t_sec);
172 buf->bs_ctime.tv_nsec = INT_GET(dic->di_ctime.t_nsec, ARCH_CONVERT); 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(dic);
174 buf->bs_extsize = INT_GET(dic->di_extsize, ARCH_CONVERT) << mp->m_sb.sb_blocklog; 174 buf->bs_extsize = be32_to_cpu(dic->di_extsize) << mp->m_sb.sb_blocklog;
175 buf->bs_extents = INT_GET(dic->di_nextents, ARCH_CONVERT); 175 buf->bs_extents = be32_to_cpu(dic->di_nextents);
176 buf->bs_gen = INT_GET(dic->di_gen, ARCH_CONVERT); 176 buf->bs_gen = be32_to_cpu(dic->di_gen);
177 memset(buf->bs_pad, 0, sizeof(buf->bs_pad)); 177 memset(buf->bs_pad, 0, sizeof(buf->bs_pad));
178 buf->bs_dmevmask = INT_GET(dic->di_dmevmask, ARCH_CONVERT); 178 buf->bs_dmevmask = be32_to_cpu(dic->di_dmevmask);
179 buf->bs_dmstate = INT_GET(dic->di_dmstate, ARCH_CONVERT); 179 buf->bs_dmstate = be16_to_cpu(dic->di_dmstate);
180 buf->bs_aextents = INT_GET(dic->di_anextents, ARCH_CONVERT); 180 buf->bs_aextents = be16_to_cpu(dic->di_anextents);
181 181
182 switch (INT_GET(dic->di_format, ARCH_CONVERT)) { 182 switch (dic->di_format) {
183 case XFS_DINODE_FMT_DEV: 183 case XFS_DINODE_FMT_DEV:
184 buf->bs_rdev = INT_GET(dip->di_u.di_dev, ARCH_CONVERT); 184 buf->bs_rdev = be32_to_cpu(dip->di_u.di_dev);
185 buf->bs_blksize = BLKDEV_IOSIZE; 185 buf->bs_blksize = BLKDEV_IOSIZE;
186 buf->bs_blocks = 0; 186 buf->bs_blocks = 0;
187 break; 187 break;
@@ -195,7 +195,7 @@ xfs_bulkstat_one_dinode(
195 case XFS_DINODE_FMT_BTREE: 195 case XFS_DINODE_FMT_BTREE:
196 buf->bs_rdev = 0; 196 buf->bs_rdev = 0;
197 buf->bs_blksize = mp->m_sb.sb_blocksize; 197 buf->bs_blksize = mp->m_sb.sb_blocksize;
198 buf->bs_blocks = INT_GET(dic->di_nblocks, ARCH_CONVERT); 198 buf->bs_blocks = be64_to_cpu(dic->di_nblocks);
199 break; 199 break;
200 } 200 }
201 201
@@ -290,16 +290,15 @@ xfs_bulkstat_use_dinode(
290 return 1; 290 return 1;
291 dip = (xfs_dinode_t *) 291 dip = (xfs_dinode_t *)
292 xfs_buf_offset(bp, clustidx << mp->m_sb.sb_inodelog); 292 xfs_buf_offset(bp, clustidx << mp->m_sb.sb_inodelog);
293 if (INT_GET(dip->di_core.di_magic, ARCH_CONVERT) != XFS_DINODE_MAGIC || 293 if (be16_to_cpu(dip->di_core.di_magic) != XFS_DINODE_MAGIC ||
294 !XFS_DINODE_GOOD_VERSION( 294 !XFS_DINODE_GOOD_VERSION(dip->di_core.di_version))
295 INT_GET(dip->di_core.di_version, ARCH_CONVERT)))
296 return 0; 295 return 0;
297 if (flags & BULKSTAT_FG_QUICK) { 296 if (flags & BULKSTAT_FG_QUICK) {
298 *dipp = dip; 297 *dipp = dip;
299 return 1; 298 return 1;
300 } 299 }
301 /* BULKSTAT_FG_INLINE: if attr fork is local, or not there, use it */ 300 /* BULKSTAT_FG_INLINE: if attr fork is local, or not there, use it */
302 aformat = INT_GET(dip->di_core.di_aformat, ARCH_CONVERT); 301 aformat = dip->di_core.di_aformat;
303 if ((XFS_CFORK_Q(&dip->di_core) == 0) || 302 if ((XFS_CFORK_Q(&dip->di_core) == 0) ||
304 (aformat == XFS_DINODE_FMT_LOCAL) || 303 (aformat == XFS_DINODE_FMT_LOCAL) ||
305 (aformat == XFS_DINODE_FMT_EXTENTS && !dip->di_core.di_anextents)) { 304 (aformat == XFS_DINODE_FMT_EXTENTS && !dip->di_core.di_anextents)) {
diff --git a/fs/xfs/xfs_log_recover.c b/fs/xfs/xfs_log_recover.c
index 8ae6e8e5f3db..758543443b66 100644
--- a/fs/xfs/xfs_log_recover.c
+++ b/fs/xfs/xfs_log_recover.c
@@ -2245,7 +2245,7 @@ xlog_recover_do_inode_trans(
2245 int error; 2245 int error;
2246 int attr_index; 2246 int attr_index;
2247 uint fields; 2247 uint fields;
2248 xfs_dinode_core_t *dicp; 2248 xfs_icdinode_t *dicp;
2249 int need_free = 0; 2249 int need_free = 0;
2250 2250
2251 if (pass == XLOG_RECOVER_PASS1) { 2251 if (pass == XLOG_RECOVER_PASS1) {
@@ -2309,7 +2309,7 @@ xlog_recover_do_inode_trans(
2309 * Make sure the place we're flushing out to really looks 2309 * Make sure the place we're flushing out to really looks
2310 * like an inode! 2310 * like an inode!
2311 */ 2311 */
2312 if (unlikely(INT_GET(dip->di_core.di_magic, ARCH_CONVERT) != XFS_DINODE_MAGIC)) { 2312 if (unlikely(be16_to_cpu(dip->di_core.di_magic) != XFS_DINODE_MAGIC)) {
2313 xfs_buf_relse(bp); 2313 xfs_buf_relse(bp);
2314 xfs_fs_cmn_err(CE_ALERT, mp, 2314 xfs_fs_cmn_err(CE_ALERT, mp,
2315 "xfs_inode_recover: Bad inode magic number, dino ptr = 0x%p, dino bp = 0x%p, ino = %Ld", 2315 "xfs_inode_recover: Bad inode magic number, dino ptr = 0x%p, dino bp = 0x%p, ino = %Ld",
@@ -2319,7 +2319,7 @@ xlog_recover_do_inode_trans(
2319 error = EFSCORRUPTED; 2319 error = EFSCORRUPTED;
2320 goto error; 2320 goto error;
2321 } 2321 }
2322 dicp = (xfs_dinode_core_t*)(item->ri_buf[1].i_addr); 2322 dicp = (xfs_icdinode_t *)(item->ri_buf[1].i_addr);
2323 if (unlikely(dicp->di_magic != XFS_DINODE_MAGIC)) { 2323 if (unlikely(dicp->di_magic != XFS_DINODE_MAGIC)) {
2324 xfs_buf_relse(bp); 2324 xfs_buf_relse(bp);
2325 xfs_fs_cmn_err(CE_ALERT, mp, 2325 xfs_fs_cmn_err(CE_ALERT, mp,
@@ -2332,15 +2332,13 @@ xlog_recover_do_inode_trans(
2332 } 2332 }
2333 2333
2334 /* Skip replay when the on disk inode is newer than the log one */ 2334 /* Skip replay when the on disk inode is newer than the log one */
2335 if (dicp->di_flushiter < 2335 if (dicp->di_flushiter < be16_to_cpu(dip->di_core.di_flushiter)) {
2336 INT_GET(dip->di_core.di_flushiter, ARCH_CONVERT)) {
2337 /* 2336 /*
2338 * Deal with the wrap case, DI_MAX_FLUSH is less 2337 * Deal with the wrap case, DI_MAX_FLUSH is less
2339 * than smaller numbers 2338 * than smaller numbers
2340 */ 2339 */
2341 if ((INT_GET(dip->di_core.di_flushiter, ARCH_CONVERT) 2340 if (be16_to_cpu(dip->di_core.di_flushiter) == DI_MAX_FLUSH &&
2342 == DI_MAX_FLUSH) && 2341 dicp->di_flushiter < (DI_MAX_FLUSH >> 1)) {
2343 (dicp->di_flushiter < (DI_MAX_FLUSH>>1))) {
2344 /* do nothing */ 2342 /* do nothing */
2345 } else { 2343 } else {
2346 xfs_buf_relse(bp); 2344 xfs_buf_relse(bp);
@@ -2411,8 +2409,8 @@ xlog_recover_do_inode_trans(
2411 } 2409 }
2412 2410
2413 /* The core is in in-core format */ 2411 /* The core is in in-core format */
2414 xfs_xlate_dinode_core((xfs_caddr_t)&dip->di_core, 2412 xfs_dinode_to_disk(&dip->di_core,
2415 (xfs_dinode_core_t*)item->ri_buf[1].i_addr, -1); 2413 (xfs_icdinode_t *)item->ri_buf[1].i_addr);
2416 2414
2417 /* the rest is in on-disk format */ 2415 /* the rest is in on-disk format */
2418 if (item->ri_buf[1].i_len > sizeof(xfs_dinode_core_t)) { 2416 if (item->ri_buf[1].i_len > sizeof(xfs_dinode_core_t)) {
@@ -2424,8 +2422,7 @@ xlog_recover_do_inode_trans(
2424 fields = in_f->ilf_fields; 2422 fields = in_f->ilf_fields;
2425 switch (fields & (XFS_ILOG_DEV | XFS_ILOG_UUID)) { 2423 switch (fields & (XFS_ILOG_DEV | XFS_ILOG_UUID)) {
2426 case XFS_ILOG_DEV: 2424 case XFS_ILOG_DEV:
2427 INT_SET(dip->di_u.di_dev, ARCH_CONVERT, in_f->ilf_u.ilfu_rdev); 2425 dip->di_u.di_dev = cpu_to_be32(in_f->ilf_u.ilfu_rdev);
2428
2429 break; 2426 break;
2430 case XFS_ILOG_UUID: 2427 case XFS_ILOG_UUID:
2431 dip->di_u.di_muuid = in_f->ilf_u.ilfu_uuid; 2428 dip->di_u.di_muuid = in_f->ilf_u.ilfu_uuid;
@@ -3234,8 +3231,8 @@ xlog_recover_process_iunlinks(
3234 ASSERT(ip->i_d.di_nlink == 0); 3231 ASSERT(ip->i_d.di_nlink == 0);
3235 3232
3236 /* setup for the next pass */ 3233 /* setup for the next pass */
3237 agino = INT_GET(dip->di_next_unlinked, 3234 agino = be32_to_cpu(
3238 ARCH_CONVERT); 3235 dip->di_next_unlinked);
3239 xfs_buf_relse(ibp); 3236 xfs_buf_relse(ibp);
3240 /* 3237 /*
3241 * Prevent any DMAPI event from 3238 * Prevent any DMAPI event from