Commit 347d1c01956d567c18afef0cc253eb235cafacd8
Committed by
Tim Shimmin
1 parent
ddc6d3b32a
Exists in
master
and in
7 other branches
[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>
Showing 6 changed files with 228 additions and 188 deletions Side-by-side Diff
fs/xfs/xfs_dinode.h
... | ... | @@ -34,41 +34,41 @@ |
34 | 34 | * because we only need the core part in the in-core inode. |
35 | 35 | */ |
36 | 36 | typedef struct xfs_timestamp { |
37 | - __int32_t t_sec; /* timestamp seconds */ | |
38 | - __int32_t t_nsec; /* timestamp nanoseconds */ | |
37 | + __be32 t_sec; /* timestamp seconds */ | |
38 | + __be32 t_nsec; /* timestamp nanoseconds */ | |
39 | 39 | } xfs_timestamp_t; |
40 | 40 | |
41 | 41 | /* |
42 | 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 | */ |
45 | -typedef struct xfs_dinode_core | |
46 | -{ | |
47 | - __uint16_t di_magic; /* inode magic # = XFS_DINODE_MAGIC */ | |
48 | - __uint16_t di_mode; /* mode and type of file */ | |
49 | - __int8_t di_version; /* inode version */ | |
50 | - __int8_t di_format; /* format of di_c data */ | |
51 | - __uint16_t di_onlink; /* old number of links to file */ | |
52 | - __uint32_t di_uid; /* owner's user id */ | |
53 | - __uint32_t di_gid; /* owner's group id */ | |
54 | - __uint32_t di_nlink; /* number of links to file */ | |
55 | - __uint16_t di_projid; /* owner's project id */ | |
56 | - __uint8_t di_pad[8]; /* unused, zeroed space */ | |
57 | - __uint16_t di_flushiter; /* incremented on flush */ | |
46 | +typedef struct xfs_dinode_core { | |
47 | + __be16 di_magic; /* inode magic # = XFS_DINODE_MAGIC */ | |
48 | + __be16 di_mode; /* mode and type of file */ | |
49 | + __u8 di_version; /* inode version */ | |
50 | + __u8 di_format; /* format of di_c data */ | |
51 | + __be16 di_onlink; /* old number of links to file */ | |
52 | + __be32 di_uid; /* owner's user id */ | |
53 | + __be32 di_gid; /* owner's group id */ | |
54 | + __be32 di_nlink; /* number of links to file */ | |
55 | + __be16 di_projid; /* owner's project id */ | |
56 | + __u8 di_pad[8]; /* unused, zeroed space */ | |
57 | + __be16 di_flushiter; /* incremented on flush */ | |
58 | 58 | xfs_timestamp_t di_atime; /* time last accessed */ |
59 | 59 | xfs_timestamp_t di_mtime; /* time last modified */ |
60 | 60 | xfs_timestamp_t di_ctime; /* time created/inode modified */ |
61 | - xfs_fsize_t di_size; /* number of bytes in file */ | |
62 | - xfs_drfsbno_t di_nblocks; /* # of direct & btree blocks used */ | |
63 | - xfs_extlen_t di_extsize; /* basic/minimum extent size for file */ | |
64 | - xfs_extnum_t di_nextents; /* number of extents in data fork */ | |
65 | - xfs_aextnum_t di_anextents; /* number of extents in attribute fork*/ | |
66 | - __uint8_t di_forkoff; /* attr fork offs, <<3 for 64b align */ | |
67 | - __int8_t di_aformat; /* format of attr fork's data */ | |
68 | - __uint32_t di_dmevmask; /* DMIG event mask */ | |
69 | - __uint16_t di_dmstate; /* DMIG state info */ | |
70 | - __uint16_t di_flags; /* random flags, XFS_DIFLAG_... */ | |
71 | - __uint32_t di_gen; /* generation number */ | |
61 | + __be64 di_size; /* number of bytes in file */ | |
62 | + __be64 di_nblocks; /* # of direct & btree blocks used */ | |
63 | + __be32 di_extsize; /* basic/minimum extent size for file */ | |
64 | + __be32 di_nextents; /* number of extents in data fork */ | |
65 | + __be16 di_anextents; /* number of extents in attribute fork*/ | |
66 | + __u8 di_forkoff; /* attr fork offs, <<3 for 64b align */ | |
67 | + __s8 di_aformat; /* format of attr fork's data */ | |
68 | + __be32 di_dmevmask; /* DMIG event mask */ | |
69 | + __be16 di_dmstate; /* DMIG state info */ | |
70 | + __be16 di_flags; /* random flags, XFS_DIFLAG_... */ | |
71 | + __be32 di_gen; /* generation number */ | |
72 | 72 | } xfs_dinode_core_t; |
73 | 73 | |
74 | 74 | #define DI_MAX_FLUSH 0xffff |
75 | 75 | |
... | ... | @@ -81,13 +81,13 @@ |
81 | 81 | * sure to update the macros like XFS_LITINO below and |
82 | 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 | 85 | union { |
86 | 86 | xfs_bmdr_block_t di_bmbt; /* btree root block */ |
87 | 87 | xfs_bmbt_rec_32_t di_bmx[1]; /* extent list */ |
88 | 88 | xfs_dir2_sf_t di_dir2sf; /* shortform directory v2 */ |
89 | 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 | 91 | uuid_t di_muuid; /* mount point value */ |
92 | 92 | char di_symlink[1]; /* local symbolic link */ |
93 | 93 | } di_u; |
... | ... | @@ -175,8 +175,7 @@ |
175 | 175 | #define XFS_CFORK_Q_DISK(dcp) ((dcp)->di_forkoff != 0) |
176 | 176 | |
177 | 177 | #define XFS_CFORK_BOFF(dcp) ((int)((dcp)->di_forkoff << 3)) |
178 | -#define XFS_CFORK_BOFF_DISK(dcp) \ | |
179 | - ((int)(INT_GET((dcp)->di_forkoff, ARCH_CONVERT) << 3)) | |
178 | +#define XFS_CFORK_BOFF_DISK(dcp) ((int)((dcp)->di_forkoff << 3)) | |
180 | 179 | |
181 | 180 | #define XFS_CFORK_DSIZE_DISK(dcp,mp) \ |
182 | 181 | (XFS_CFORK_Q_DISK(dcp) ? XFS_CFORK_BOFF_DISK(dcp) : XFS_LITINO(mp)) |
... | ... | @@ -225,8 +224,8 @@ |
225 | 224 | |
226 | 225 | #define XFS_CFORK_NEXTENTS_DISK(dcp,w) \ |
227 | 226 | ((w) == XFS_DATA_FORK ? \ |
228 | - INT_GET((dcp)->di_nextents, ARCH_CONVERT) : \ | |
229 | - INT_GET((dcp)->di_anextents, ARCH_CONVERT)) | |
227 | + be32_to_cpu((dcp)->di_nextents) : \ | |
228 | + be16_to_cpu((dcp)->di_anextents)) | |
230 | 229 | #define XFS_CFORK_NEXTENTS(dcp,w) \ |
231 | 230 | ((w) == XFS_DATA_FORK ? (dcp)->di_nextents : (dcp)->di_anextents) |
232 | 231 | #define XFS_DFORK_NEXTENTS(dip,w) XFS_CFORK_NEXTENTS_DISK(&(dip)->di_core, w) |
fs/xfs/xfs_ialloc.c
... | ... | @@ -293,9 +293,9 @@ |
293 | 293 | xfs_biozero(fbuf, 0, ninodes << args.mp->m_sb.sb_inodelog); |
294 | 294 | for (i = 0; i < ninodes; i++) { |
295 | 295 | free = XFS_MAKE_IPTR(args.mp, fbuf, i); |
296 | - INT_SET(free->di_core.di_magic, ARCH_CONVERT, XFS_DINODE_MAGIC); | |
297 | - INT_SET(free->di_core.di_version, ARCH_CONVERT, version); | |
298 | - INT_SET(free->di_next_unlinked, ARCH_CONVERT, NULLAGINO); | |
296 | + free->di_core.di_magic = cpu_to_be16(XFS_DINODE_MAGIC); | |
297 | + free->di_core.di_version = version; | |
298 | + free->di_next_unlinked = cpu_to_be32(NULLAGINO); | |
299 | 299 | xfs_ialloc_log_di(tp, fbuf, i, |
300 | 300 | XFS_DI_CORE_BITS | XFS_DI_NEXT_UNLINKED); |
301 | 301 | } |
fs/xfs/xfs_inode.c
... | ... | @@ -193,8 +193,8 @@ |
193 | 193 | } |
194 | 194 | dip = (xfs_dinode_t *)xfs_buf_offset(bp, 0); |
195 | 195 | di_ok = |
196 | - INT_GET(dip->di_core.di_magic, ARCH_CONVERT) == XFS_DINODE_MAGIC && | |
197 | - XFS_DINODE_GOOD_VERSION(INT_GET(dip->di_core.di_version, ARCH_CONVERT)); | |
196 | + be16_to_cpu(dip->di_core.di_magic) == XFS_DINODE_MAGIC && | |
197 | + XFS_DINODE_GOOD_VERSION(dip->di_core.di_version); | |
198 | 198 | if (unlikely(XFS_TEST_ERROR(!di_ok, mp, XFS_ERRTAG_ITOBP_INOTOBP, |
199 | 199 | XFS_RANDOM_ITOBP_INOTOBP))) { |
200 | 200 | XFS_CORRUPTION_ERROR("xfs_inotobp", XFS_ERRLEVEL_LOW, mp, dip); |
... | ... | @@ -338,8 +338,8 @@ |
338 | 338 | |
339 | 339 | dip = (xfs_dinode_t *)xfs_buf_offset(bp, |
340 | 340 | (i << mp->m_sb.sb_inodelog)); |
341 | - di_ok = INT_GET(dip->di_core.di_magic, ARCH_CONVERT) == XFS_DINODE_MAGIC && | |
342 | - XFS_DINODE_GOOD_VERSION(INT_GET(dip->di_core.di_version, ARCH_CONVERT)); | |
341 | + di_ok = be16_to_cpu(dip->di_core.di_magic) == XFS_DINODE_MAGIC && | |
342 | + XFS_DINODE_GOOD_VERSION(dip->di_core.di_version); | |
343 | 343 | if (unlikely(XFS_TEST_ERROR(!di_ok, mp, |
344 | 344 | XFS_ERRTAG_ITOBP_INOTOBP, |
345 | 345 | XFS_RANDOM_ITOBP_INOTOBP))) { |
... | ... | @@ -353,7 +353,7 @@ |
353 | 353 | "daddr %lld #%d (magic=%x)", |
354 | 354 | XFS_BUFTARG_NAME(mp->m_ddev_targp), |
355 | 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 | 357 | #endif |
358 | 358 | XFS_CORRUPTION_ERROR("xfs_itobp", XFS_ERRLEVEL_HIGH, |
359 | 359 | mp, dip); |
360 | 360 | |
361 | 361 | |
362 | 362 | |
363 | 363 | |
... | ... | @@ -399,27 +399,26 @@ |
399 | 399 | XFS_IFORK_DSIZE(ip) / (uint)sizeof(xfs_bmbt_rec_t); |
400 | 400 | error = 0; |
401 | 401 | |
402 | - if (unlikely( | |
403 | - INT_GET(dip->di_core.di_nextents, ARCH_CONVERT) + | |
404 | - INT_GET(dip->di_core.di_anextents, ARCH_CONVERT) > | |
405 | - INT_GET(dip->di_core.di_nblocks, ARCH_CONVERT))) { | |
402 | + if (unlikely(be32_to_cpu(dip->di_core.di_nextents) + | |
403 | + be16_to_cpu(dip->di_core.di_anextents) > | |
404 | + be64_to_cpu(dip->di_core.di_nblocks))) { | |
406 | 405 | xfs_fs_repair_cmn_err(CE_WARN, ip->i_mount, |
407 | 406 | "corrupt dinode %Lu, extent total = %d, nblocks = %Lu.", |
408 | 407 | (unsigned long long)ip->i_ino, |
409 | - (int)(INT_GET(dip->di_core.di_nextents, ARCH_CONVERT) | |
410 | - + INT_GET(dip->di_core.di_anextents, ARCH_CONVERT)), | |
408 | + (int)(be32_to_cpu(dip->di_core.di_nextents) + | |
409 | + be16_to_cpu(dip->di_core.di_anextents)), | |
411 | 410 | (unsigned long long) |
412 | - INT_GET(dip->di_core.di_nblocks, ARCH_CONVERT)); | |
411 | + be64_to_cpu(dip->di_core.di_nblocks)); | |
413 | 412 | XFS_CORRUPTION_ERROR("xfs_iformat(1)", XFS_ERRLEVEL_LOW, |
414 | 413 | ip->i_mount, dip); |
415 | 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 | 418 | xfs_fs_repair_cmn_err(CE_WARN, ip->i_mount, |
420 | 419 | "corrupt dinode %Lu, forkoff = 0x%x.", |
421 | 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 | 422 | XFS_CORRUPTION_ERROR("xfs_iformat(2)", XFS_ERRLEVEL_LOW, |
424 | 423 | ip->i_mount, dip); |
425 | 424 | return XFS_ERROR(EFSCORRUPTED); |
426 | 425 | |
427 | 426 | |
428 | 427 | |
... | ... | @@ -430,25 +429,25 @@ |
430 | 429 | case S_IFCHR: |
431 | 430 | case S_IFBLK: |
432 | 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 | 433 | XFS_CORRUPTION_ERROR("xfs_iformat(3)", XFS_ERRLEVEL_LOW, |
435 | 434 | ip->i_mount, dip); |
436 | 435 | return XFS_ERROR(EFSCORRUPTED); |
437 | 436 | } |
438 | 437 | ip->i_d.di_size = 0; |
439 | 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 | 440 | break; |
442 | 441 | |
443 | 442 | case S_IFREG: |
444 | 443 | case S_IFLNK: |
445 | 444 | case S_IFDIR: |
446 | - switch (INT_GET(dip->di_core.di_format, ARCH_CONVERT)) { | |
445 | + switch (dip->di_core.di_format) { | |
447 | 446 | case XFS_DINODE_FMT_LOCAL: |
448 | 447 | /* |
449 | 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 | 451 | xfs_fs_repair_cmn_err(CE_WARN, ip->i_mount, |
453 | 452 | "corrupt inode %Lu " |
454 | 453 | "(local format for regular file).", |
... | ... | @@ -459,7 +458,7 @@ |
459 | 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 | 462 | if (unlikely(di_size > XFS_DFORK_DSIZE(dip, ip->i_mount))) { |
464 | 463 | xfs_fs_repair_cmn_err(CE_WARN, ip->i_mount, |
465 | 464 | "corrupt inode %Lu " |
... | ... | @@ -501,7 +500,7 @@ |
501 | 500 | ip->i_afp = kmem_zone_zalloc(xfs_ifork_zone, KM_SLEEP); |
502 | 501 | ip->i_afp->if_ext_max = |
503 | 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 | 504 | case XFS_DINODE_FMT_LOCAL: |
506 | 505 | atp = (xfs_attr_shortform_t *)XFS_DFORK_APTR(dip); |
507 | 506 | size = be16_to_cpu(atp->hdr.totsize); |
508 | 507 | |
509 | 508 | |
510 | 509 | |
... | ... | @@ -709,70 +708,74 @@ |
709 | 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 | - */ | |
721 | 711 | void |
722 | -xfs_xlate_dinode_core( | |
723 | - xfs_caddr_t buf, | |
724 | - xfs_dinode_core_t *dip, | |
725 | - int dir) | |
712 | +xfs_dinode_from_disk( | |
713 | + xfs_icdinode_t *to, | |
714 | + xfs_dinode_core_t *from) | |
726 | 715 | { |
727 | - xfs_dinode_core_t *buf_core = (xfs_dinode_core_t *)buf; | |
728 | - xfs_dinode_core_t *mem_core = (xfs_dinode_core_t *)dip; | |
729 | - xfs_arch_t arch = ARCH_CONVERT; | |
716 | + to->di_magic = be16_to_cpu(from->di_magic); | |
717 | + to->di_mode = be16_to_cpu(from->di_mode); | |
718 | + to->di_version = from ->di_version; | |
719 | + to->di_format = from->di_format; | |
720 | + to->di_onlink = be16_to_cpu(from->di_onlink); | |
721 | + to->di_uid = be32_to_cpu(from->di_uid); | |
722 | + to->di_gid = be32_to_cpu(from->di_gid); | |
723 | + to->di_nlink = be32_to_cpu(from->di_nlink); | |
724 | + to->di_projid = be16_to_cpu(from->di_projid); | |
725 | + memcpy(to->di_pad, from->di_pad, sizeof(to->di_pad)); | |
726 | + to->di_flushiter = be16_to_cpu(from->di_flushiter); | |
727 | + to->di_atime.t_sec = be32_to_cpu(from->di_atime.t_sec); | |
728 | + to->di_atime.t_nsec = be32_to_cpu(from->di_atime.t_nsec); | |
729 | + to->di_mtime.t_sec = be32_to_cpu(from->di_mtime.t_sec); | |
730 | + to->di_mtime.t_nsec = be32_to_cpu(from->di_mtime.t_nsec); | |
731 | + to->di_ctime.t_sec = be32_to_cpu(from->di_ctime.t_sec); | |
732 | + to->di_ctime.t_nsec = be32_to_cpu(from->di_ctime.t_nsec); | |
733 | + to->di_size = be64_to_cpu(from->di_size); | |
734 | + to->di_nblocks = be64_to_cpu(from->di_nblocks); | |
735 | + to->di_extsize = be32_to_cpu(from->di_extsize); | |
736 | + to->di_nextents = be32_to_cpu(from->di_nextents); | |
737 | + to->di_anextents = be16_to_cpu(from->di_anextents); | |
738 | + to->di_forkoff = from->di_forkoff; | |
739 | + to->di_aformat = from->di_aformat; | |
740 | + to->di_dmevmask = be32_to_cpu(from->di_dmevmask); | |
741 | + to->di_dmstate = be16_to_cpu(from->di_dmstate); | |
742 | + to->di_flags = be16_to_cpu(from->di_flags); | |
743 | + to->di_gen = be32_to_cpu(from->di_gen); | |
744 | +} | |
730 | 745 | |
731 | - ASSERT(dir); | |
732 | - | |
733 | - INT_XLATE(buf_core->di_magic, mem_core->di_magic, dir, arch); | |
734 | - INT_XLATE(buf_core->di_mode, mem_core->di_mode, dir, arch); | |
735 | - INT_XLATE(buf_core->di_version, mem_core->di_version, dir, arch); | |
736 | - INT_XLATE(buf_core->di_format, mem_core->di_format, dir, arch); | |
737 | - INT_XLATE(buf_core->di_onlink, mem_core->di_onlink, dir, arch); | |
738 | - INT_XLATE(buf_core->di_uid, mem_core->di_uid, dir, arch); | |
739 | - INT_XLATE(buf_core->di_gid, mem_core->di_gid, dir, arch); | |
740 | - INT_XLATE(buf_core->di_nlink, mem_core->di_nlink, dir, arch); | |
741 | - INT_XLATE(buf_core->di_projid, mem_core->di_projid, dir, arch); | |
742 | - | |
743 | - if (dir > 0) { | |
744 | - memcpy(mem_core->di_pad, buf_core->di_pad, | |
745 | - sizeof(buf_core->di_pad)); | |
746 | - } else { | |
747 | - memcpy(buf_core->di_pad, mem_core->di_pad, | |
748 | - sizeof(buf_core->di_pad)); | |
749 | - } | |
750 | - | |
751 | - INT_XLATE(buf_core->di_flushiter, mem_core->di_flushiter, dir, arch); | |
752 | - | |
753 | - INT_XLATE(buf_core->di_atime.t_sec, mem_core->di_atime.t_sec, | |
754 | - dir, arch); | |
755 | - INT_XLATE(buf_core->di_atime.t_nsec, mem_core->di_atime.t_nsec, | |
756 | - dir, arch); | |
757 | - INT_XLATE(buf_core->di_mtime.t_sec, mem_core->di_mtime.t_sec, | |
758 | - dir, arch); | |
759 | - INT_XLATE(buf_core->di_mtime.t_nsec, mem_core->di_mtime.t_nsec, | |
760 | - dir, arch); | |
761 | - INT_XLATE(buf_core->di_ctime.t_sec, mem_core->di_ctime.t_sec, | |
762 | - dir, arch); | |
763 | - INT_XLATE(buf_core->di_ctime.t_nsec, mem_core->di_ctime.t_nsec, | |
764 | - dir, arch); | |
765 | - INT_XLATE(buf_core->di_size, mem_core->di_size, dir, arch); | |
766 | - INT_XLATE(buf_core->di_nblocks, mem_core->di_nblocks, dir, arch); | |
767 | - INT_XLATE(buf_core->di_extsize, mem_core->di_extsize, dir, arch); | |
768 | - INT_XLATE(buf_core->di_nextents, mem_core->di_nextents, dir, arch); | |
769 | - INT_XLATE(buf_core->di_anextents, mem_core->di_anextents, dir, arch); | |
770 | - INT_XLATE(buf_core->di_forkoff, mem_core->di_forkoff, dir, arch); | |
771 | - INT_XLATE(buf_core->di_aformat, mem_core->di_aformat, dir, arch); | |
772 | - INT_XLATE(buf_core->di_dmevmask, mem_core->di_dmevmask, dir, arch); | |
773 | - INT_XLATE(buf_core->di_dmstate, mem_core->di_dmstate, dir, arch); | |
774 | - INT_XLATE(buf_core->di_flags, mem_core->di_flags, dir, arch); | |
775 | - INT_XLATE(buf_core->di_gen, mem_core->di_gen, dir, arch); | |
746 | +void | |
747 | +xfs_dinode_to_disk( | |
748 | + xfs_dinode_core_t *to, | |
749 | + xfs_icdinode_t *from) | |
750 | +{ | |
751 | + to->di_magic = cpu_to_be16(from->di_magic); | |
752 | + to->di_mode = cpu_to_be16(from->di_mode); | |
753 | + to->di_version = from ->di_version; | |
754 | + to->di_format = from->di_format; | |
755 | + to->di_onlink = cpu_to_be16(from->di_onlink); | |
756 | + to->di_uid = cpu_to_be32(from->di_uid); | |
757 | + to->di_gid = cpu_to_be32(from->di_gid); | |
758 | + to->di_nlink = cpu_to_be32(from->di_nlink); | |
759 | + to->di_projid = cpu_to_be16(from->di_projid); | |
760 | + memcpy(to->di_pad, from->di_pad, sizeof(to->di_pad)); | |
761 | + to->di_flushiter = cpu_to_be16(from->di_flushiter); | |
762 | + to->di_atime.t_sec = cpu_to_be32(from->di_atime.t_sec); | |
763 | + to->di_atime.t_nsec = cpu_to_be32(from->di_atime.t_nsec); | |
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 | |
778 | 781 | STATIC uint |
... | ... | @@ -819,7 +822,7 @@ |
819 | 822 | xfs_ip2xflags( |
820 | 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 | 827 | return _xfs_dic2xflags(dic->di_flags) | |
825 | 828 | (XFS_CFORK_Q(dic) ? XFS_XFLAG_HASATTR : 0); |
... | ... | @@ -829,7 +832,7 @@ |
829 | 832 | xfs_dic2xflags( |
830 | 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 | 836 | (XFS_CFORK_Q_DISK(dic) ? XFS_XFLAG_HASATTR : 0); |
834 | 837 | } |
835 | 838 | |
836 | 839 | |
... | ... | @@ -899,14 +902,14 @@ |
899 | 902 | * If we got something that isn't an inode it means someone |
900 | 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 | 906 | kmem_zone_free(xfs_inode_zone, ip); |
904 | 907 | xfs_trans_brelse(tp, bp); |
905 | 908 | #ifdef DEBUG |
906 | 909 | xfs_fs_cmn_err(CE_ALERT, mp, "xfs_iread: " |
907 | 910 | "dip->di_core.di_magic (0x%x) != " |
908 | 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 | 913 | XFS_DINODE_MAGIC); |
911 | 914 | #endif /* DEBUG */ |
912 | 915 | return XFS_ERROR(EINVAL); |
... | ... | @@ -920,8 +923,7 @@ |
920 | 923 | * Otherwise, just get the truly permanent information. |
921 | 924 | */ |
922 | 925 | if (dip->di_core.di_mode) { |
923 | - xfs_xlate_dinode_core((xfs_caddr_t)&dip->di_core, | |
924 | - &(ip->i_d), 1); | |
926 | + xfs_dinode_from_disk(&ip->i_d, &dip->di_core); | |
925 | 927 | error = xfs_iformat(ip, dip); |
926 | 928 | if (error) { |
927 | 929 | kmem_zone_free(xfs_inode_zone, ip); |
... | ... | @@ -934,10 +936,10 @@ |
934 | 936 | return error; |
935 | 937 | } |
936 | 938 | } else { |
937 | - ip->i_d.di_magic = INT_GET(dip->di_core.di_magic, ARCH_CONVERT); | |
938 | - ip->i_d.di_version = INT_GET(dip->di_core.di_version, ARCH_CONVERT); | |
939 | - ip->i_d.di_gen = INT_GET(dip->di_core.di_gen, ARCH_CONVERT); | |
940 | - ip->i_d.di_flushiter = INT_GET(dip->di_core.di_flushiter, ARCH_CONVERT); | |
939 | + ip->i_d.di_magic = be16_to_cpu(dip->di_core.di_magic); | |
940 | + ip->i_d.di_version = dip->di_core.di_version; | |
941 | + ip->i_d.di_gen = be32_to_cpu(dip->di_core.di_gen); | |
942 | + ip->i_d.di_flushiter = be16_to_cpu(dip->di_core.di_flushiter); | |
941 | 943 | /* |
942 | 944 | * Make sure to pull in the mode here as well in |
943 | 945 | * case the inode is released without being used. |
... | ... | @@ -1959,8 +1961,7 @@ |
1959 | 1961 | if (error) { |
1960 | 1962 | return error; |
1961 | 1963 | } |
1962 | - ASSERT(INT_GET(dip->di_next_unlinked, ARCH_CONVERT) == NULLAGINO); | |
1963 | - ASSERT(dip->di_next_unlinked); | |
1964 | + ASSERT(be32_to_cpu(dip->di_next_unlinked) == NULLAGINO); | |
1964 | 1965 | /* both on-disk, don't endian flip twice */ |
1965 | 1966 | dip->di_next_unlinked = agi->agi_unlinked[bucket_index]; |
1966 | 1967 | offset = ip->i_boffset + |
1967 | 1968 | |
... | ... | @@ -2071,10 +2072,10 @@ |
2071 | 2072 | error, mp->m_fsname); |
2072 | 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 | 2076 | ASSERT(next_agino != 0); |
2076 | 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 | 2079 | offset = ip->i_boffset + |
2079 | 2080 | offsetof(xfs_dinode_t, di_next_unlinked); |
2080 | 2081 | xfs_trans_inode_buf(tp, ibp); |
... | ... | @@ -2118,7 +2119,7 @@ |
2118 | 2119 | error, mp->m_fsname); |
2119 | 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 | 2123 | ASSERT(next_agino != NULLAGINO); |
2123 | 2124 | ASSERT(next_agino != 0); |
2124 | 2125 | } |
2125 | 2126 | |
... | ... | @@ -2133,11 +2134,11 @@ |
2133 | 2134 | error, mp->m_fsname); |
2134 | 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 | 2138 | ASSERT(next_agino != 0); |
2138 | 2139 | ASSERT(next_agino != agino); |
2139 | 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 | 2142 | offset = ip->i_boffset + |
2142 | 2143 | offsetof(xfs_dinode_t, di_next_unlinked); |
2143 | 2144 | xfs_trans_inode_buf(tp, ibp); |
... | ... | @@ -2150,7 +2151,7 @@ |
2150 | 2151 | /* |
2151 | 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 | 2155 | ASSERT(next_agino != 0); |
2155 | 2156 | offset = last_offset + offsetof(xfs_dinode_t, di_next_unlinked); |
2156 | 2157 | xfs_trans_inode_buf(tp, last_ibp); |
... | ... | @@ -3009,7 +3010,7 @@ |
3009 | 3010 | case XFS_DINODE_FMT_DEV: |
3010 | 3011 | if (iip->ili_format.ilf_fields & XFS_ILOG_DEV) { |
3011 | 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 | 3015 | break; |
3015 | 3016 | |
3016 | 3017 | |
... | ... | @@ -3358,11 +3359,11 @@ |
3358 | 3359 | */ |
3359 | 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 | 3363 | mp, XFS_ERRTAG_IFLUSH_1, XFS_RANDOM_IFLUSH_1)) { |
3363 | 3364 | xfs_cmn_err(XFS_PTAG_IFLUSH, CE_ALERT, mp, |
3364 | 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 | 3367 | goto corrupt_out; |
3367 | 3368 | } |
3368 | 3369 | if (XFS_TEST_ERROR(ip->i_d.di_magic != XFS_DINODE_MAGIC, |
... | ... | @@ -3425,7 +3426,7 @@ |
3425 | 3426 | * because if the inode is dirty at all the core must |
3426 | 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 | 3431 | /* Wrap, we never let the log put out DI_MAX_FLUSH */ |
3431 | 3432 | if (ip->i_d.di_flushiter == DI_MAX_FLUSH) |
... | ... | @@ -3445,7 +3446,7 @@ |
3445 | 3446 | * Convert it back. |
3446 | 3447 | */ |
3447 | 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 | 3450 | } else { |
3450 | 3451 | /* |
3451 | 3452 | * The superblock version has already been bumped, |
... | ... | @@ -3453,7 +3454,7 @@ |
3453 | 3454 | * format permanent. |
3454 | 3455 | */ |
3455 | 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 | 3458 | ip->i_d.di_onlink = 0; |
3458 | 3459 | dip->di_core.di_onlink = 0; |
3459 | 3460 | memset(&(ip->i_d.di_pad[0]), 0, sizeof(ip->i_d.di_pad)); |
fs/xfs/xfs_inode.h
... | ... | @@ -18,6 +18,10 @@ |
18 | 18 | #ifndef __XFS_INODE_H__ |
19 | 19 | #define __XFS_INODE_H__ |
20 | 20 | |
21 | +struct xfs_dinode; | |
22 | +struct xfs_dinode_core; | |
23 | + | |
24 | + | |
21 | 25 | /* |
22 | 26 | * Fork identifiers. |
23 | 27 | */ |
... | ... | @@ -227,6 +231,43 @@ |
227 | 231 | * chain off the mount structure by xfs_sync calls. |
228 | 232 | */ |
229 | 233 | |
234 | +typedef 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 | + */ | |
243 | +typedef 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 | + | |
230 | 271 | typedef struct { |
231 | 272 | struct xfs_ihash *ip_hash; /* pointer to hash header */ |
232 | 273 | struct xfs_inode *ip_next; /* inode hash link forw */ |
... | ... | @@ -282,7 +323,7 @@ |
282 | 323 | unsigned int i_gen; /* generation count */ |
283 | 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 | 327 | xfs_chashlist_t *i_chash; /* cluster hash list header */ |
287 | 328 | struct xfs_inode *i_cnext; /* cluster hash link forward */ |
288 | 329 | struct xfs_inode *i_cprev; /* cluster hash link backward */ |
... | ... | @@ -506,7 +547,7 @@ |
506 | 547 | * xfs_inode.c prototypes. |
507 | 548 | */ |
508 | 549 | int 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 | 551 | xfs_daddr_t, uint); |
511 | 552 | int xfs_iread(struct xfs_mount *, struct xfs_trans *, xfs_ino_t, |
512 | 553 | xfs_inode_t **, xfs_daddr_t, uint); |
... | ... | @@ -514,8 +555,11 @@ |
514 | 555 | int xfs_ialloc(struct xfs_trans *, xfs_inode_t *, mode_t, |
515 | 556 | xfs_nlink_t, xfs_dev_t, struct cred *, xfs_prid_t, |
516 | 557 | int, struct xfs_buf **, boolean_t *, xfs_inode_t **); |
517 | -void xfs_xlate_dinode_core(xfs_caddr_t, struct xfs_dinode_core *, | |
518 | - int); | |
558 | +void xfs_dinode_from_disk(struct xfs_icdinode *, | |
559 | + struct xfs_dinode_core *); | |
560 | +void xfs_dinode_to_disk(struct xfs_dinode_core *, | |
561 | + struct xfs_icdinode *); | |
562 | + | |
519 | 563 | uint xfs_ip2xflags(struct xfs_inode *); |
520 | 564 | uint xfs_dic2xflags(struct xfs_dinode_core *); |
521 | 565 | int xfs_ifree(struct xfs_trans *, xfs_inode_t *, |
fs/xfs/xfs_itable.c
... | ... | @@ -57,7 +57,7 @@ |
57 | 57 | xfs_bstat_t *buf, /* return buffer */ |
58 | 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 | 61 | xfs_inode_t *ip; /* incore inode pointer */ |
62 | 62 | bhv_vnode_t *vp; |
63 | 63 | int error; |
64 | 64 | |
65 | 65 | |
66 | 66 | |
67 | 67 | |
68 | 68 | |
69 | 69 | |
... | ... | @@ -151,37 +151,37 @@ |
151 | 151 | * the new format. We don't change the version number so that we |
152 | 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) { | |
155 | - buf->bs_nlink = INT_GET(dic->di_onlink, ARCH_CONVERT); | |
154 | + if (dic->di_version == XFS_DINODE_VERSION_1) { | |
155 | + buf->bs_nlink = be16_to_cpu(dic->di_onlink); | |
156 | 156 | buf->bs_projid = 0; |
157 | 157 | } else { |
158 | - buf->bs_nlink = INT_GET(dic->di_nlink, ARCH_CONVERT); | |
159 | - buf->bs_projid = INT_GET(dic->di_projid, ARCH_CONVERT); | |
158 | + buf->bs_nlink = be32_to_cpu(dic->di_nlink); | |
159 | + buf->bs_projid = be16_to_cpu(dic->di_projid); | |
160 | 160 | } |
161 | 161 | |
162 | 162 | buf->bs_ino = ino; |
163 | - buf->bs_mode = INT_GET(dic->di_mode, ARCH_CONVERT); | |
164 | - buf->bs_uid = INT_GET(dic->di_uid, ARCH_CONVERT); | |
165 | - buf->bs_gid = INT_GET(dic->di_gid, ARCH_CONVERT); | |
166 | - buf->bs_size = INT_GET(dic->di_size, ARCH_CONVERT); | |
167 | - buf->bs_atime.tv_sec = INT_GET(dic->di_atime.t_sec, ARCH_CONVERT); | |
168 | - buf->bs_atime.tv_nsec = INT_GET(dic->di_atime.t_nsec, ARCH_CONVERT); | |
169 | - buf->bs_mtime.tv_sec = INT_GET(dic->di_mtime.t_sec, ARCH_CONVERT); | |
170 | - buf->bs_mtime.tv_nsec = INT_GET(dic->di_mtime.t_nsec, ARCH_CONVERT); | |
171 | - buf->bs_ctime.tv_sec = INT_GET(dic->di_ctime.t_sec, ARCH_CONVERT); | |
172 | - buf->bs_ctime.tv_nsec = INT_GET(dic->di_ctime.t_nsec, ARCH_CONVERT); | |
163 | + buf->bs_mode = be16_to_cpu(dic->di_mode); | |
164 | + buf->bs_uid = be32_to_cpu(dic->di_uid); | |
165 | + buf->bs_gid = be32_to_cpu(dic->di_gid); | |
166 | + buf->bs_size = be64_to_cpu(dic->di_size); | |
167 | + buf->bs_atime.tv_sec = be32_to_cpu(dic->di_atime.t_sec); | |
168 | + buf->bs_atime.tv_nsec = be32_to_cpu(dic->di_atime.t_nsec); | |
169 | + buf->bs_mtime.tv_sec = be32_to_cpu(dic->di_mtime.t_sec); | |
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); | |
172 | + buf->bs_ctime.tv_nsec = be32_to_cpu(dic->di_ctime.t_nsec); | |
173 | 173 | buf->bs_xflags = xfs_dic2xflags(dic); |
174 | - buf->bs_extsize = INT_GET(dic->di_extsize, ARCH_CONVERT) << mp->m_sb.sb_blocklog; | |
175 | - buf->bs_extents = INT_GET(dic->di_nextents, ARCH_CONVERT); | |
176 | - buf->bs_gen = INT_GET(dic->di_gen, ARCH_CONVERT); | |
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); | |
176 | + buf->bs_gen = be32_to_cpu(dic->di_gen); | |
177 | 177 | memset(buf->bs_pad, 0, sizeof(buf->bs_pad)); |
178 | - buf->bs_dmevmask = INT_GET(dic->di_dmevmask, ARCH_CONVERT); | |
179 | - buf->bs_dmstate = INT_GET(dic->di_dmstate, ARCH_CONVERT); | |
180 | - buf->bs_aextents = INT_GET(dic->di_anextents, ARCH_CONVERT); | |
178 | + buf->bs_dmevmask = be32_to_cpu(dic->di_dmevmask); | |
179 | + buf->bs_dmstate = be16_to_cpu(dic->di_dmstate); | |
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 | 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 | 185 | buf->bs_blksize = BLKDEV_IOSIZE; |
186 | 186 | buf->bs_blocks = 0; |
187 | 187 | break; |
... | ... | @@ -195,7 +195,7 @@ |
195 | 195 | case XFS_DINODE_FMT_BTREE: |
196 | 196 | buf->bs_rdev = 0; |
197 | 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 | 199 | break; |
200 | 200 | } |
201 | 201 | |
202 | 202 | |
... | ... | @@ -290,16 +290,15 @@ |
290 | 290 | return 1; |
291 | 291 | dip = (xfs_dinode_t *) |
292 | 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 || | |
294 | - !XFS_DINODE_GOOD_VERSION( | |
295 | - INT_GET(dip->di_core.di_version, ARCH_CONVERT))) | |
293 | + if (be16_to_cpu(dip->di_core.di_magic) != XFS_DINODE_MAGIC || | |
294 | + !XFS_DINODE_GOOD_VERSION(dip->di_core.di_version)) | |
296 | 295 | return 0; |
297 | 296 | if (flags & BULKSTAT_FG_QUICK) { |
298 | 297 | *dipp = dip; |
299 | 298 | return 1; |
300 | 299 | } |
301 | 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 | 302 | if ((XFS_CFORK_Q(&dip->di_core) == 0) || |
304 | 303 | (aformat == XFS_DINODE_FMT_LOCAL) || |
305 | 304 | (aformat == XFS_DINODE_FMT_EXTENTS && !dip->di_core.di_anextents)) { |
fs/xfs/xfs_log_recover.c
... | ... | @@ -2245,7 +2245,7 @@ |
2245 | 2245 | int error; |
2246 | 2246 | int attr_index; |
2247 | 2247 | uint fields; |
2248 | - xfs_dinode_core_t *dicp; | |
2248 | + xfs_icdinode_t *dicp; | |
2249 | 2249 | int need_free = 0; |
2250 | 2250 | |
2251 | 2251 | if (pass == XLOG_RECOVER_PASS1) { |
... | ... | @@ -2309,7 +2309,7 @@ |
2309 | 2309 | * Make sure the place we're flushing out to really looks |
2310 | 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 | 2313 | xfs_buf_relse(bp); |
2314 | 2314 | xfs_fs_cmn_err(CE_ALERT, mp, |
2315 | 2315 | "xfs_inode_recover: Bad inode magic number, dino ptr = 0x%p, dino bp = 0x%p, ino = %Ld", |
... | ... | @@ -2319,7 +2319,7 @@ |
2319 | 2319 | error = EFSCORRUPTED; |
2320 | 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 | 2323 | if (unlikely(dicp->di_magic != XFS_DINODE_MAGIC)) { |
2324 | 2324 | xfs_buf_relse(bp); |
2325 | 2325 | xfs_fs_cmn_err(CE_ALERT, mp, |
2326 | 2326 | |
... | ... | @@ -2332,15 +2332,13 @@ |
2332 | 2332 | } |
2333 | 2333 | |
2334 | 2334 | /* Skip replay when the on disk inode is newer than the log one */ |
2335 | - if (dicp->di_flushiter < | |
2336 | - INT_GET(dip->di_core.di_flushiter, ARCH_CONVERT)) { | |
2335 | + if (dicp->di_flushiter < be16_to_cpu(dip->di_core.di_flushiter)) { | |
2337 | 2336 | /* |
2338 | 2337 | * Deal with the wrap case, DI_MAX_FLUSH is less |
2339 | 2338 | * than smaller numbers |
2340 | 2339 | */ |
2341 | - if ((INT_GET(dip->di_core.di_flushiter, ARCH_CONVERT) | |
2342 | - == DI_MAX_FLUSH) && | |
2343 | - (dicp->di_flushiter < (DI_MAX_FLUSH>>1))) { | |
2340 | + if (be16_to_cpu(dip->di_core.di_flushiter) == DI_MAX_FLUSH && | |
2341 | + dicp->di_flushiter < (DI_MAX_FLUSH >> 1)) { | |
2344 | 2342 | /* do nothing */ |
2345 | 2343 | } else { |
2346 | 2344 | xfs_buf_relse(bp); |
... | ... | @@ -2411,8 +2409,8 @@ |
2411 | 2409 | } |
2412 | 2410 | |
2413 | 2411 | /* The core is in in-core format */ |
2414 | - xfs_xlate_dinode_core((xfs_caddr_t)&dip->di_core, | |
2415 | - (xfs_dinode_core_t*)item->ri_buf[1].i_addr, -1); | |
2412 | + xfs_dinode_to_disk(&dip->di_core, | |
2413 | + (xfs_icdinode_t *)item->ri_buf[1].i_addr); | |
2416 | 2414 | |
2417 | 2415 | /* the rest is in on-disk format */ |
2418 | 2416 | if (item->ri_buf[1].i_len > sizeof(xfs_dinode_core_t)) { |
... | ... | @@ -2424,8 +2422,7 @@ |
2424 | 2422 | fields = in_f->ilf_fields; |
2425 | 2423 | switch (fields & (XFS_ILOG_DEV | XFS_ILOG_UUID)) { |
2426 | 2424 | case XFS_ILOG_DEV: |
2427 | - INT_SET(dip->di_u.di_dev, ARCH_CONVERT, in_f->ilf_u.ilfu_rdev); | |
2428 | - | |
2425 | + dip->di_u.di_dev = cpu_to_be32(in_f->ilf_u.ilfu_rdev); | |
2429 | 2426 | break; |
2430 | 2427 | case XFS_ILOG_UUID: |
2431 | 2428 | dip->di_u.di_muuid = in_f->ilf_u.ilfu_uuid; |
... | ... | @@ -3234,8 +3231,8 @@ |
3234 | 3231 | ASSERT(ip->i_d.di_nlink == 0); |
3235 | 3232 | |
3236 | 3233 | /* setup for the next pass */ |
3237 | - agino = INT_GET(dip->di_next_unlinked, | |
3238 | - ARCH_CONVERT); | |
3234 | + agino = be32_to_cpu( | |
3235 | + dip->di_next_unlinked); | |
3239 | 3236 | xfs_buf_relse(ibp); |
3240 | 3237 | /* |
3241 | 3238 | * Prevent any DMAPI event from |