Commit 347d1c01 authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Tim Shimmin

[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: default avatarChristoph Hellwig <hch@infradead.org>
Signed-off-by: default avatarDavid Chinner <dgc@sgi.com>
Signed-off-by: default avatarTim Shimmin <tes@sgi.com>
parent ddc6d3b3
...@@ -34,41 +34,41 @@ struct xfs_mount; ...@@ -34,41 +34,41 @@ struct xfs_mount;
* because we only need the core part in the in-core inode. * because we only need the core part in the in-core inode.
*/ */
typedef struct xfs_timestamp { typedef struct xfs_timestamp {
__int32_t t_sec; /* timestamp seconds */ __be32 t_sec; /* timestamp seconds */
__int32_t t_nsec; /* timestamp nanoseconds */ __be32 t_nsec; /* timestamp nanoseconds */
} xfs_timestamp_t; } xfs_timestamp_t;
/* /*
* Note: Coordinate changes to this structure with the XFS_DI_* #defines * Note: Coordinate changes to this structure with the XFS_DI_* #defines
* below and the offsets table in xfs_ialloc_log_di(). * below, the offsets table in xfs_ialloc_log_di() and struct xfs_icdinode
* in xfs_inode.h.
*/ */
typedef struct xfs_dinode_core typedef struct xfs_dinode_core {
{ __be16 di_magic; /* inode magic # = XFS_DINODE_MAGIC */
__uint16_t di_magic; /* inode magic # = XFS_DINODE_MAGIC */ __be16 di_mode; /* mode and type of file */
__uint16_t di_mode; /* mode and type of file */ __u8 di_version; /* inode version */
__int8_t di_version; /* inode version */ __u8 di_format; /* format of di_c data */
__int8_t di_format; /* format of di_c data */ __be16 di_onlink; /* old number of links to file */
__uint16_t di_onlink; /* old number of links to file */ __be32 di_uid; /* owner's user id */
__uint32_t di_uid; /* owner's user id */ __be32 di_gid; /* owner's group id */
__uint32_t di_gid; /* owner's group id */ __be32 di_nlink; /* number of links to file */
__uint32_t di_nlink; /* number of links to file */ __be16 di_projid; /* owner's project id */
__uint16_t di_projid; /* owner's project id */ __u8 di_pad[8]; /* unused, zeroed space */
__uint8_t di_pad[8]; /* unused, zeroed space */ __be16 di_flushiter; /* incremented on flush */
__uint16_t di_flushiter; /* incremented on flush */
xfs_timestamp_t di_atime; /* time last accessed */ xfs_timestamp_t di_atime; /* time last accessed */
xfs_timestamp_t di_mtime; /* time last modified */ xfs_timestamp_t di_mtime; /* time last modified */
xfs_timestamp_t di_ctime; /* time created/inode modified */ xfs_timestamp_t di_ctime; /* time created/inode modified */
xfs_fsize_t di_size; /* number of bytes in file */ __be64 di_size; /* number of bytes in file */
xfs_drfsbno_t di_nblocks; /* # of direct & btree blocks used */ __be64 di_nblocks; /* # of direct & btree blocks used */
xfs_extlen_t di_extsize; /* basic/minimum extent size for file */ __be32 di_extsize; /* basic/minimum extent size for file */
xfs_extnum_t di_nextents; /* number of extents in data fork */ __be32 di_nextents; /* number of extents in data fork */
xfs_aextnum_t di_anextents; /* number of extents in attribute fork*/ __be16 di_anextents; /* number of extents in attribute fork*/
__uint8_t di_forkoff; /* attr fork offs, <<3 for 64b align */ __u8 di_forkoff; /* attr fork offs, <<3 for 64b align */
__int8_t di_aformat; /* format of attr fork's data */ __s8 di_aformat; /* format of attr fork's data */
__uint32_t di_dmevmask; /* DMIG event mask */ __be32 di_dmevmask; /* DMIG event mask */
__uint16_t di_dmstate; /* DMIG state info */ __be16 di_dmstate; /* DMIG state info */
__uint16_t di_flags; /* random flags, XFS_DIFLAG_... */ __be16 di_flags; /* random flags, XFS_DIFLAG_... */
__uint32_t di_gen; /* generation number */ __be32 di_gen; /* generation number */
} xfs_dinode_core_t; } xfs_dinode_core_t;
#define DI_MAX_FLUSH 0xffff #define DI_MAX_FLUSH 0xffff
...@@ -81,13 +81,13 @@ typedef struct xfs_dinode ...@@ -81,13 +81,13 @@ typedef struct xfs_dinode
* sure to update the macros like XFS_LITINO below and * sure to update the macros like XFS_LITINO below and
* XFS_BMAP_RBLOCK_DSIZE in xfs_bmap_btree.h. * XFS_BMAP_RBLOCK_DSIZE in xfs_bmap_btree.h.
*/ */
xfs_agino_t di_next_unlinked;/* agi unlinked list ptr */ __be32 di_next_unlinked;/* agi unlinked list ptr */
union { union {
xfs_bmdr_block_t di_bmbt; /* btree root block */ xfs_bmdr_block_t di_bmbt; /* btree root block */
xfs_bmbt_rec_32_t di_bmx[1]; /* extent list */ xfs_bmbt_rec_32_t di_bmx[1]; /* extent list */
xfs_dir2_sf_t di_dir2sf; /* shortform directory v2 */ xfs_dir2_sf_t di_dir2sf; /* shortform directory v2 */
char di_c[1]; /* local contents */ char di_c[1]; /* local contents */
xfs_dev_t di_dev; /* device for S_IFCHR/S_IFBLK */ __be32 di_dev; /* device for S_IFCHR/S_IFBLK */
uuid_t di_muuid; /* mount point value */ uuid_t di_muuid; /* mount point value */
char di_symlink[1]; /* local symbolic link */ char di_symlink[1]; /* local symbolic link */
} di_u; } di_u;
...@@ -175,8 +175,7 @@ typedef enum xfs_dinode_fmt ...@@ -175,8 +175,7 @@ typedef enum xfs_dinode_fmt
#define XFS_CFORK_Q_DISK(dcp) ((dcp)->di_forkoff != 0) #define XFS_CFORK_Q_DISK(dcp) ((dcp)->di_forkoff != 0)
#define XFS_CFORK_BOFF(dcp) ((int)((dcp)->di_forkoff << 3)) #define XFS_CFORK_BOFF(dcp) ((int)((dcp)->di_forkoff << 3))
#define XFS_CFORK_BOFF_DISK(dcp) \ #define XFS_CFORK_BOFF_DISK(dcp) ((int)((dcp)->di_forkoff << 3))
((int)(INT_GET((dcp)->di_forkoff, ARCH_CONVERT) << 3))
#define XFS_CFORK_DSIZE_DISK(dcp,mp) \ #define XFS_CFORK_DSIZE_DISK(dcp,mp) \
(XFS_CFORK_Q_DISK(dcp) ? XFS_CFORK_BOFF_DISK(dcp) : XFS_LITINO(mp)) (XFS_CFORK_Q_DISK(dcp) ? XFS_CFORK_BOFF_DISK(dcp) : XFS_LITINO(mp))
...@@ -225,8 +224,8 @@ typedef enum xfs_dinode_fmt ...@@ -225,8 +224,8 @@ typedef enum xfs_dinode_fmt
#define XFS_CFORK_NEXTENTS_DISK(dcp,w) \ #define XFS_CFORK_NEXTENTS_DISK(dcp,w) \
((w) == XFS_DATA_FORK ? \ ((w) == XFS_DATA_FORK ? \
INT_GET((dcp)->di_nextents, ARCH_CONVERT) : \ be32_to_cpu((dcp)->di_nextents) : \
INT_GET((dcp)->di_anextents, ARCH_CONVERT)) be16_to_cpu((dcp)->di_anextents))
#define XFS_CFORK_NEXTENTS(dcp,w) \ #define XFS_CFORK_NEXTENTS(dcp,w) \
((w) == XFS_DATA_FORK ? (dcp)->di_nextents : (dcp)->di_anextents) ((w) == XFS_DATA_FORK ? (dcp)->di_nextents : (dcp)->di_anextents)
#define XFS_DFORK_NEXTENTS(dip,w) XFS_CFORK_NEXTENTS_DISK(&(dip)->di_core, w) #define XFS_DFORK_NEXTENTS(dip,w) XFS_CFORK_NEXTENTS_DISK(&(dip)->di_core, w)
......
...@@ -293,9 +293,9 @@ xfs_ialloc_ag_alloc( ...@@ -293,9 +293,9 @@ xfs_ialloc_ag_alloc(
xfs_biozero(fbuf, 0, ninodes << args.mp->m_sb.sb_inodelog); xfs_biozero(fbuf, 0, ninodes << args.mp->m_sb.sb_inodelog);
for (i = 0; i < ninodes; i++) { for (i = 0; i < ninodes; i++) {
free = XFS_MAKE_IPTR(args.mp, fbuf, i); free = XFS_MAKE_IPTR(args.mp, fbuf, i);
INT_SET(free->di_core.di_magic, ARCH_CONVERT, XFS_DINODE_MAGIC); free->di_core.di_magic = cpu_to_be16(XFS_DINODE_MAGIC);
INT_SET(free->di_core.di_version, ARCH_CONVERT, version); free->di_core.di_version = version;
INT_SET(free->di_next_unlinked, ARCH_CONVERT, NULLAGINO); free->di_next_unlinked = cpu_to_be32(NULLAGINO);
xfs_ialloc_log_di(tp, fbuf, i, xfs_ialloc_log_di(tp, fbuf, i,
XFS_DI_CORE_BITS | XFS_DI_NEXT_UNLINKED); XFS_DI_CORE_BITS | XFS_DI_NEXT_UNLINKED);
} }
......
...@@ -193,8 +193,8 @@ xfs_inotobp( ...@@ -193,8 +193,8 @@ xfs_inotobp(
} }
dip = (xfs_dinode_t *)xfs_buf_offset(bp, 0); dip = (xfs_dinode_t *)xfs_buf_offset(bp, 0);
di_ok = di_ok =
INT_GET(dip->di_core.di_magic, ARCH_CONVERT) == XFS_DINODE_MAGIC && be16_to_cpu(dip->di_core.di_magic) == XFS_DINODE_MAGIC &&
XFS_DINODE_GOOD_VERSION(INT_GET(dip->di_core.di_version, ARCH_CONVERT)); XFS_DINODE_GOOD_VERSION(dip->di_core.di_version);
if (unlikely(XFS_TEST_ERROR(!di_ok, mp, XFS_ERRTAG_ITOBP_INOTOBP, if (unlikely(XFS_TEST_ERROR(!di_ok, mp, XFS_ERRTAG_ITOBP_INOTOBP,
XFS_RANDOM_ITOBP_INOTOBP))) { XFS_RANDOM_ITOBP_INOTOBP))) {
XFS_CORRUPTION_ERROR("xfs_inotobp", XFS_ERRLEVEL_LOW, mp, dip); XFS_CORRUPTION_ERROR("xfs_inotobp", XFS_ERRLEVEL_LOW, mp, dip);
...@@ -338,8 +338,8 @@ xfs_itobp( ...@@ -338,8 +338,8 @@ xfs_itobp(
dip = (xfs_dinode_t *)xfs_buf_offset(bp, dip = (xfs_dinode_t *)xfs_buf_offset(bp,
(i << mp->m_sb.sb_inodelog)); (i << mp->m_sb.sb_inodelog));
di_ok = INT_GET(dip->di_core.di_magic, ARCH_CONVERT) == XFS_DINODE_MAGIC && di_ok = be16_to_cpu(dip->di_core.di_magic) == XFS_DINODE_MAGIC &&
XFS_DINODE_GOOD_VERSION(INT_GET(dip->di_core.di_version, ARCH_CONVERT)); XFS_DINODE_GOOD_VERSION(dip->di_core.di_version);
if (unlikely(XFS_TEST_ERROR(!di_ok, mp, if (unlikely(XFS_TEST_ERROR(!di_ok, mp,
XFS_ERRTAG_ITOBP_INOTOBP, XFS_ERRTAG_ITOBP_INOTOBP,
XFS_RANDOM_ITOBP_INOTOBP))) { XFS_RANDOM_ITOBP_INOTOBP))) {
...@@ -353,7 +353,7 @@ xfs_itobp( ...@@ -353,7 +353,7 @@ xfs_itobp(
"daddr %lld #%d (magic=%x)", "daddr %lld #%d (magic=%x)",
XFS_BUFTARG_NAME(mp->m_ddev_targp), XFS_BUFTARG_NAME(mp->m_ddev_targp),
(unsigned long long)imap.im_blkno, i, (unsigned long long)imap.im_blkno, i,
INT_GET(dip->di_core.di_magic, ARCH_CONVERT)); be16_to_cpu(dip->di_core.di_magic));
#endif #endif
XFS_CORRUPTION_ERROR("xfs_itobp", XFS_ERRLEVEL_HIGH, XFS_CORRUPTION_ERROR("xfs_itobp", XFS_ERRLEVEL_HIGH,
mp, dip); mp, dip);
...@@ -399,27 +399,26 @@ xfs_iformat( ...@@ -399,27 +399,26 @@ xfs_iformat(
XFS_IFORK_DSIZE(ip) / (uint)sizeof(xfs_bmbt_rec_t); XFS_IFORK_DSIZE(ip) / (uint)sizeof(xfs_bmbt_rec_t);
error = 0; error = 0;
if (unlikely( if (unlikely(be32_to_cpu(dip->di_core.di_nextents) +
INT_GET(dip->di_core.di_nextents, ARCH_CONVERT) + be16_to_cpu(dip->di_core.di_anextents) >
INT_GET(dip->di_core.di_anextents, ARCH_CONVERT) > be64_to_cpu(dip->di_core.di_nblocks))) {
INT_GET(dip->di_core.di_nblocks, ARCH_CONVERT))) {
xfs_fs_repair_cmn_err(CE_WARN, ip->i_mount, xfs_fs_repair_cmn_err(CE_WARN, ip->i_mount,
"corrupt dinode %Lu, extent total = %d, nblocks = %Lu.", "corrupt dinode %Lu, extent total = %d, nblocks = %Lu.",
(unsigned long long)ip->i_ino, (unsigned long long)ip->i_ino,
(int)(INT_GET(dip->di_core.di_nextents, ARCH_CONVERT) (int)(be32_to_cpu(dip->di_core.di_nextents) +
+ INT_GET(dip->di_core.di_anextents, ARCH_CONVERT)), be16_to_cpu(dip->di_core.di_anextents)),
(unsigned long long) (unsigned long long)
INT_GET(dip->di_core.di_nblocks, ARCH_CONVERT)); be64_to_cpu(dip->di_core.di_nblocks));
XFS_CORRUPTION_ERROR("xfs_iformat(1)", XFS_ERRLEVEL_LOW, XFS_CORRUPTION_ERROR("xfs_iformat(1)", XFS_ERRLEVEL_LOW,
ip->i_mount, dip); ip->i_mount, dip);
return XFS_ERROR(EFSCORRUPTED); return XFS_ERROR(EFSCORRUPTED);
} }
if (unlikely(INT_GET(dip->di_core.di_forkoff, ARCH_CONVERT) > ip->i_mount->m_sb.sb_inodesize)) { if (unlikely(dip->di_core.di_forkoff > ip->i_mount->m_sb.sb_inodesize)) {
xfs_fs_repair_cmn_err(CE_WARN, ip->i_mount, xfs_fs_repair_cmn_err(CE_WARN, ip->i_mount,
"corrupt dinode %Lu, forkoff = 0x%x.", "corrupt dinode %Lu, forkoff = 0x%x.",
(unsigned long long)ip->i_ino, (unsigned long long)ip->i_ino,
(int)(INT_GET(dip->di_core.di_forkoff, ARCH_CONVERT))); dip->di_core.di_forkoff);
XFS_CORRUPTION_ERROR("xfs_iformat(2)", XFS_ERRLEVEL_LOW, XFS_CORRUPTION_ERROR("xfs_iformat(2)", XFS_ERRLEVEL_LOW,
ip->i_mount, dip); ip->i_mount, dip);
return XFS_ERROR(EFSCORRUPTED); return XFS_ERROR(EFSCORRUPTED);
...@@ -430,25 +429,25 @@ xfs_iformat( ...@@ -430,25 +429,25 @@ xfs_iformat(
case S_IFCHR: case S_IFCHR:
case S_IFBLK: case S_IFBLK:
case S_IFSOCK: case S_IFSOCK:
if (unlikely(INT_GET(dip->di_core.di_format, ARCH_CONVERT) != XFS_DINODE_FMT_DEV)) { if (unlikely(dip->di_core.di_format != XFS_DINODE_FMT_DEV)) {
XFS_CORRUPTION_ERROR("xfs_iformat(3)", XFS_ERRLEVEL_LOW, XFS_CORRUPTION_ERROR("xfs_iformat(3)", XFS_ERRLEVEL_LOW,
ip->i_mount, dip); ip->i_mount, dip);
return XFS_ERROR(EFSCORRUPTED); return XFS_ERROR(EFSCORRUPTED);
} }
ip->i_d.di_size = 0; ip->i_d.di_size = 0;
ip->i_size = 0; ip->i_size = 0;
ip->i_df.if_u2.if_rdev = INT_GET(dip->di_u.di_dev, ARCH_CONVERT); ip->i_df.if_u2.if_rdev = be32_to_cpu(dip->di_u.di_dev);
break; break;
case S_IFREG: case S_IFREG:
case S_IFLNK: case S_IFLNK:
case S_IFDIR: case S_IFDIR:
switch (INT_GET(dip->di_core.di_format, ARCH_CONVERT)) { switch (dip->di_core.di_format) {
case XFS_DINODE_FMT_LOCAL: case XFS_DINODE_FMT_LOCAL:
/* /*
* no local regular files yet * no local regular files yet
*/ */
if (unlikely((INT_GET(dip->di_core.di_mode, ARCH_CONVERT) & S_IFMT) == S_IFREG)) { if (unlikely((be16_to_cpu(dip->di_core.di_mode) & S_IFMT) == S_IFREG)) {
xfs_fs_repair_cmn_err(CE_WARN, ip->i_mount, xfs_fs_repair_cmn_err(CE_WARN, ip->i_mount,
"corrupt inode %Lu " "corrupt inode %Lu "
"(local format for regular file).", "(local format for regular file).",
...@@ -459,7 +458,7 @@ xfs_iformat( ...@@ -459,7 +458,7 @@ xfs_iformat(
return XFS_ERROR(EFSCORRUPTED); return XFS_ERROR(EFSCORRUPTED);
} }
di_size = INT_GET(dip->di_core.di_size, ARCH_CONVERT); di_size = be64_to_cpu(dip->di_core.di_size);
if (unlikely(di_size > XFS_DFORK_DSIZE(dip, ip->i_mount))) { if (unlikely(di_size > XFS_DFORK_DSIZE(dip, ip->i_mount))) {
xfs_fs_repair_cmn_err(CE_WARN, ip->i_mount, xfs_fs_repair_cmn_err(CE_WARN, ip->i_mount,
"corrupt inode %Lu " "corrupt inode %Lu "
...@@ -501,7 +500,7 @@ xfs_iformat( ...@@ -501,7 +500,7 @@ xfs_iformat(
ip->i_afp = kmem_zone_zalloc(xfs_ifork_zone, KM_SLEEP); ip->i_afp = kmem_zone_zalloc(xfs_ifork_zone, KM_SLEEP);
ip->i_afp->if_ext_max = ip->i_afp->if_ext_max =
XFS_IFORK_ASIZE(ip) / (uint)sizeof(xfs_bmbt_rec_t); XFS_IFORK_ASIZE(ip) / (uint)sizeof(xfs_bmbt_rec_t);
switch (INT_GET(dip->di_core.di_aformat, ARCH_CONVERT)) { switch (dip->di_core.di_aformat) {
case XFS_DINODE_FMT_LOCAL: case XFS_DINODE_FMT_LOCAL:
atp = (xfs_attr_shortform_t *)XFS_DFORK_APTR(dip); atp = (xfs_attr_shortform_t *)XFS_DFORK_APTR(dip);
size = be16_to_cpu(atp->hdr.totsize); size = be16_to_cpu(atp->hdr.totsize);
...@@ -709,70 +708,74 @@ xfs_iformat_btree( ...@@ -709,70 +708,74 @@ xfs_iformat_btree(
return 0; return 0;
} }
/*
* xfs_xlate_dinode_core - translate an xfs_inode_core_t between ondisk
* and native format
*
* buf = on-disk representation
* dip = native representation
* dir = direction - +ve -> disk to native
* -ve -> native to disk
*/
void void
xfs_xlate_dinode_core( xfs_dinode_from_disk(
xfs_caddr_t buf, xfs_icdinode_t *to,
xfs_dinode_core_t *dip, xfs_dinode_core_t *from)
int dir)
{ {
xfs_dinode_core_t *buf_core = (xfs_dinode_core_t *)buf; to->di_magic = be16_to_cpu(from->di_magic);
xfs_dinode_core_t *mem_core = (xfs_dinode_core_t *)dip; to->di_mode = be16_to_cpu(from->di_mode);
xfs_arch_t arch = ARCH_CONVERT; to->di_version = from ->di_version;
to->di_format = from->di_format;
ASSERT(dir); to->di_onlink = be16_to_cpu(from->di_onlink);
to->di_uid = be32_to_cpu(from->di_uid);
INT_XLATE(buf_core->di_magic, mem_core->di_magic, dir, arch); to->di_gid = be32_to_cpu(from->di_gid);
INT_XLATE(buf_core->di_mode, mem_core->di_mode, dir, arch); to->di_nlink = be32_to_cpu(from->di_nlink);
INT_XLATE(buf_core->di_version, mem_core->di_version, dir, arch); to->di_projid = be16_to_cpu(from->di_projid);
INT_XLATE(buf_core->di_format, mem_core->di_format, dir, arch); memcpy(to->di_pad, from->di_pad, sizeof(to->di_pad));
INT_XLATE(buf_core->di_onlink, mem_core->di_onlink, dir, arch); to->di_flushiter = be16_to_cpu(from->di_flushiter);
INT_XLATE(buf_core->di_uid, mem_core->di_uid, dir, arch); to->di_atime.t_sec = be32_to_cpu(from->di_atime.t_sec);
INT_XLATE(buf_core->di_gid, mem_core->di_gid, dir, arch); to->di_atime.t_nsec = be32_to_cpu(from->di_atime.t_nsec);
INT_XLATE(buf_core->di_nlink, mem_core->di_nlink, dir, arch); to->di_mtime.t_sec = be32_to_cpu(from->di_mtime.t_sec);
INT_XLATE(buf_core->di_projid, mem_core->di_projid, dir, arch); to->di_mtime.t_nsec = be32_to_cpu(from->di_mtime.t_nsec);
to->di_ctime.t_sec = be32_to_cpu(from->di_ctime.t_sec);
if (dir > 0) { to->di_ctime.t_nsec = be32_to_cpu(from->di_ctime.t_nsec);
memcpy(mem_core->di_pad, buf_core->di_pad, to->di_size = be64_to_cpu(from->di_size);
sizeof(buf_core->di_pad)); to->di_nblocks = be64_to_cpu(from->di_nblocks);
} else { to->di_extsize = be32_to_cpu(from->di_extsize);
memcpy(buf_core->di_pad, mem_core->di_pad, to->di_nextents = be32_to_cpu(from->di_nextents);
sizeof(buf_core->di_pad)); to->di_anextents = be16_to_cpu(from->di_anextents);
} to->di_forkoff = from->di_forkoff;
to->di_aformat = from->di_aformat;
INT_XLATE(buf_core->di_flushiter, mem_core->di_flushiter, dir, arch); to->di_dmevmask = be32_to_cpu(from->di_dmevmask);
to->di_dmstate = be16_to_cpu(from->di_dmstate);
INT_XLATE(buf_core->di_atime.t_sec, mem_core->di_atime.t_sec, to->di_flags = be16_to_cpu(from->di_flags);
dir, arch); to->di_gen = be32_to_cpu(from->di_gen);
INT_XLATE(buf_core->di_atime.t_nsec, mem_core->di_atime.t_nsec, }
dir, arch);
INT_XLATE(buf_core->di_mtime.t_sec, mem_core->di_mtime.t_sec, void
dir, arch); xfs_dinode_to_disk(
INT_XLATE(buf_core->di_mtime.t_nsec, mem_core->di_mtime.t_nsec, xfs_dinode_core_t *to,
dir, arch); xfs_icdinode_t *from)
INT_XLATE(buf_core->di_ctime.t_sec, mem_core->di_ctime.t_sec, {
dir, arch); to->di_magic = cpu_to_be16(from->di_magic);
INT_XLATE(buf_core->di_ctime.t_nsec, mem_core->di_ctime.t_nsec, to->di_mode = cpu_to_be16(from->di_mode);
dir, arch); to->di_version = from ->di_version;
INT_XLATE(buf_core->di_size, mem_core->di_size, dir, arch); to->di_format = from->di_format;
INT_XLATE(buf_core->di_nblocks, mem_core->di_nblocks, dir, arch); to->di_onlink = cpu_to_be16(from->di_onlink);
INT_XLATE(buf_core->di_extsize, mem_core->di_extsize, dir, arch); to->di_uid = cpu_to_be32(from->di_uid);
INT_XLATE(buf_core->di_nextents, mem_core->di_nextents, dir, arch); to->di_gid = cpu_to_be32(from->di_gid);
INT_XLATE(buf_core->di_anextents, mem_core->di_anextents, dir, arch); to->di_nlink = cpu_to_be32(from->di_nlink);
INT_XLATE(buf_core->di_forkoff, mem_core->di_forkoff, dir, arch); to->di_projid = cpu_to_be16(from->di_projid);
INT_XLATE(buf_core->di_aformat, mem_core->di_aformat, dir, arch); memcpy(to->di_pad, from->di_pad, sizeof(to->di_pad));
INT_XLATE(buf_core->di_dmevmask, mem_core->di_dmevmask, dir, arch); to->di_flushiter = cpu_to_be16(from->di_flushiter);
INT_XLATE(buf_core->di_dmstate, mem_core->di_dmstate, dir, arch); to->di_atime.t_sec = cpu_to_be32(from->di_atime.t_sec);
INT_XLATE(buf_core->di_flags, mem_core->di_flags, dir, arch); to->di_atime.t_nsec = cpu_to_be32(from->di_atime.t_nsec);
INT_XLATE(buf_core->di_gen, mem_core->di_gen, dir, arch); to->di_mtime.t_sec = cpu_to_be32(from->di_mtime.t_sec);
to->di_mtime.t_nsec = cpu_to_be32(from->di_mtime.t_nsec);
to->di_ctime.t_sec = cpu_to_be32(from->di_ctime.t_sec);
to->di_ctime.t_nsec = cpu_to_be32(from->di_ctime.t_nsec);
to->di_size = cpu_to_be64(from->di_size);
to->di_nblocks = cpu_to_be64(from->di_nblocks);
to->di_extsize = cpu_to_be32(from->di_extsize);
to->di_nextents = cpu_to_be32(from->di_nextents);
to->di_anextents = cpu_to_be16(from->di_anextents);
to->di_forkoff = from->di_forkoff;
to->di_aformat = from->di_aformat;
to->di_dmevmask = cpu_to_be32(from->di_dmevmask);
to->di_dmstate = cpu_to_be16(from->di_dmstate);
to->di_flags = cpu_to_be16(from->di_flags);
to->di_gen = cpu_to_be32(from->di_gen);
} }
STATIC uint STATIC uint
...@@ -819,7 +822,7 @@ uint ...@@ -819,7 +822,7 @@ uint
xfs_ip2xflags( xfs_ip2xflags(
xfs_inode_t *ip) xfs_inode_t *ip)
{ {
xfs_dinode_core_t *dic = &ip->i_d; xfs_icdinode_t *dic = &ip->i_d;
return _xfs_dic2xflags(dic->di_flags) | return _xfs_dic2xflags(dic->di_flags) |
(XFS_CFORK_Q(dic) ? XFS_XFLAG_HASATTR : 0); (XFS_CFORK_Q(dic) ? XFS_XFLAG_HASATTR : 0);
...@@ -829,7 +832,7 @@ uint ...@@ -829,7 +832,7 @@ uint
xfs_dic2xflags( xfs_dic2xflags(
xfs_dinode_core_t *dic) xfs_dinode_core_t *dic)
{ {
return _xfs_dic2xflags(INT_GET(dic->di_flags, ARCH_CONVERT)) | return _xfs_dic2xflags(be16_to_cpu(dic->di_flags)) |
(XFS_CFORK_Q_DISK(dic) ? XFS_XFLAG_HASATTR : 0); (XFS_CFORK_Q_DISK(dic) ? XFS_XFLAG_HASATTR : 0);
} }
...@@ -899,14 +902,14 @@ xfs_iread( ...@@ -899,14 +902,14 @@ xfs_iread(
* If we got something that isn't an inode it means someone * If we got something that isn't an inode it means someone
* (nfs or dmi) has a stale handle. * (nfs or dmi) has a stale handle.
*/ */
if (INT_GET(dip->di_core.di_magic, ARCH_CONVERT) != XFS_DINODE_MAGIC) { if (be16_to_cpu(dip->di_core.di_magic) != XFS_DINODE_MAGIC) {
kmem_zone_free(xfs_inode_zone, ip); kmem_zone_free(xfs_inode_zone, ip);
xfs_trans_brelse(tp, bp); xfs_trans_brelse(tp, bp);
#ifdef DEBUG #ifdef DEBUG
xfs_fs_cmn_err(CE_ALERT, mp, "xfs_iread: " xfs_fs_cmn_err(CE_ALERT, mp, "xfs_iread: "
"dip->di_core.di_magic (0x%x) != " "dip->di_core.di_magic (0x%x) != "
"XFS_DINODE_MAGIC (0x%x)", "XFS_DINODE_MAGIC (0x%x)",
INT_GET(dip->di_core.di_magic, ARCH_CONVERT), be16_to_cpu(dip->di_core.di_magic),
XFS_DINODE_MAGIC); XFS_DINODE_MAGIC);
#endif /* DEBUG */ #endif /* DEBUG */
return XFS_ERROR(EINVAL); return XFS_ERROR(EINVAL);
...@@ -920,8 +923,7 @@ xfs_iread( ...@@ -920,8 +923,7 @@ xfs_iread(
* Otherwise, just get the truly permanent information. * Otherwise, just get the truly permanent information.
*/ */
if (dip->di_core.di_mode) { if (dip->di_core.di_mode) {
xfs_xlate_dinode_core((xfs_caddr_t)&dip->di_core, xfs_dinode_from_disk(&ip->i_d, &dip->di_core);
&(ip->i_d), 1);
error = xfs_iformat(ip, dip); error = xfs_iformat(ip, dip);
if (error) { if (error) {
kmem_zone_free(xfs_inode_zone, ip); kmem_zone_free(xfs_inode_zone, ip);
...@@ -934,10 +936,10 @@ xfs_iread( ...@@ -934,10 +936,10 @@ xfs_iread(
return error; return error;
} }
} else { } else {
ip->i_d.di_magic = INT_GET(dip->di_core.di_magic, ARCH_CONVERT); ip->i_d.di_magic = be16_to_cpu(dip->di_core.di_magic);
ip->i_d.di_version = INT_GET(dip->di_core.di_version, ARCH_CONVERT); ip->i_d.di_version = dip->di_core.di_version;
ip->i_d.di_gen = INT_GET(dip->di_core.di_gen, ARCH_CONVERT); ip->i_d.di_gen = be32_to_cpu(dip->di_core.di_gen);
ip->i_d.di_flushiter = INT_GET(dip->di_core.di_flushiter, ARCH_CONVERT); ip->i_d.di_flushiter = be16_to_cpu(dip->di_core.di_flushiter);
/* /*
* Make sure to pull in the mode here as well in * Make sure to pull in the mode here as well in
* case the inode is released without being used. * case the inode is released without being used.
...@@ -1959,8 +1961,7 @@ xfs_iunlink( ...@@ -1959,8 +1961,7 @@ xfs_iunlink(
if (error) { if (error) {
return error; return error;
} }
ASSERT(INT_GET(dip->di_next_unlinked, ARCH_CONVERT) == NULLAGINO); ASSERT(be32_to_cpu(dip->di_next_unlinked) == NULLAGINO);
ASSERT(dip->di_next_unlinked);
/* both on-disk, don't endian flip twice */ /* both on-disk, don't endian flip twice */
dip->di_next_unlinked = agi->agi_unlinked[bucket_index]; dip->di_next_unlinked = agi->agi_unlinked[bucket_index];
offset = ip->i_boffset + offset = ip->i_boffset +
...@@ -2071,10 +2072,10 @@ xfs_iunlink_remove( ...@@ -2071,10 +2072,10 @@ xfs_iunlink_remove(
error, mp->m_fsname); error, mp->m_fsname);
return error; return error;
} }
next_agino = INT_GET(dip->di_next_unlinked, ARCH_CONVERT); next_agino = be32_to_cpu(dip->di_next_unlinked);
ASSERT(next_agino != 0); ASSERT(next_agino != 0);
if (next_agino != NULLAGINO) { if (next_agino != NULLAGINO) {
INT_SET(dip->di_next_unlinked, ARCH_CONVERT, NULLAGINO); dip->di_next_unlinked = cpu_to_be32(NULLAGINO);
offset = ip->i_boffset + offset = ip->i_boffset +
offsetof(xfs_dinode_t, di_next_unlinked); offsetof(xfs_dinode_t, di_next_unlinked);
xfs_trans_inode_buf(tp, ibp); xfs_trans_inode_buf(tp, ibp);
...@@ -2118,7 +2119,7 @@ xfs_iunlink_remove( ...@@ -2118,7 +2119,7 @@ xfs_iunlink_remove(
error, mp->m_fsname); error, mp->m_fsname);
return error; return error;
} }
next_agino = INT_GET(last_dip->di_next_unlinked, ARCH_CONVERT); next_agino = be32_to_cpu(last_dip->di_next_unlinked);
ASSERT(next_agino != NULLAGINO); ASSERT(next_agino != NULLAGINO);
ASSERT(next_agino != 0); ASSERT(next_agino != 0);
} }
...@@ -2133,11 +2134,11 @@ xfs_iunlink_remove( ...@@ -2133,11 +2134,11 @@ xfs_iunlink_remove(
error, mp->m_fsname); error, mp->m_fsname);
return error; return error;
} }
next_agino = INT_GET(dip->di_next_unlinked, ARCH_CONVERT); next_agino = be32_to_cpu(dip->di_next_unlinked);
ASSERT(next_agino != 0); ASSERT(next_agino != 0);
ASSERT(next_agino != agino); ASSERT(next_agino != agino);
if (next_agino != NULLAGINO) { if (next_agino != NULLAGINO) {
INT_SET(dip->di_next_unlinked, ARCH_CONVERT, NULLAGINO); dip->di_next_unlinked = cpu_to_be32(NULLAGINO);
offset = ip->i_boffset + offset = ip->i_boffset +
offsetof(xfs_dinode_t, di_next_unlinked); offsetof(xfs_dinode_t, di_next_unlinked);
xfs_trans_inode_buf(tp, ibp); xfs_trans_inode_buf(tp, ibp);
...@@ -2150,7 +2151,7 @@ xfs_iunlink_remove( ...@@ -2150,7 +2151,7 @@ xfs_iunlink_remove(
/* /*
* Point the previous inode on the list to the next inode. * Point the previous inode on the list to the next inode.
*/ */
INT_SET(last_dip->di_next_unlinked, ARCH_CONVERT, next_agino); last_dip->di_next_unlinked = cpu_to_be32(next_agino);
ASSERT(next_agino != 0); ASSERT(next_agino != 0);
offset = last_offset + offsetof(xfs_dinode_t, di_next_unlinked); offset = last_offset + offsetof(xfs_dinode_t, di_next_unlinked);
xfs_trans_inode_buf(tp, last_ibp); xfs_trans_inode_buf(tp, last_ibp);
...@@ -3009,7 +3010,7 @@ xfs_iflush_fork( ...@@ -3009,7 +3010,7 @@ xfs_iflush_fork(
case XFS_DINODE_FMT_DEV: case XFS_DINODE_FMT_DEV:
if (iip->ili_format.ilf_fields & XFS_ILOG_DEV) { if (iip->ili_format.ilf_fields & XFS_ILOG_DEV) {
ASSERT(whichfork == XFS_DATA_FORK); ASSERT(whichfork == XFS_DATA_FORK);
INT_SET(dip->di_u.di_dev, ARCH_CONVERT, ip->i_df.if_u2.if_rdev); dip->di_u.di_dev = cpu_to_be32(ip->i_df.if_u2.if_rdev);
} }
break; break;
...@@ -3358,11 +3359,11 @@ xfs_iflush_int( ...@@ -3358,11 +3359,11 @@ xfs_iflush_int(
*/ */
xfs_synchronize_atime(ip); xfs_synchronize_atime(ip);
if (XFS_TEST_ERROR(INT_GET(dip->di_core.di_magic,ARCH_CONVERT) != XFS_DINODE_MAGIC, if (XFS_TEST_ERROR(be16_to_cpu(dip->di_core.di_magic) != XFS_DINODE_MAGIC,
mp, XFS_ERRTAG_IFLUSH_1, XFS_RANDOM_IFLUSH_1)) { mp, XFS_ERRTAG_IFLUSH_1, XFS_RANDOM_IFLUSH_1)) {
xfs_cmn_err(XFS_PTAG_IFLUSH, CE_ALERT, mp, xfs_cmn_err(XFS_PTAG_IFLUSH, CE_ALERT, mp,
"xfs_iflush: Bad inode %Lu magic number 0x%x, ptr 0x%p", "xfs_iflush: Bad inode %Lu magic number 0x%x, ptr 0x%p",
ip->i_ino, (int) INT_GET(dip->di_core.di_magic, ARCH_CONVERT), dip); ip->i_ino, be16_to_cpu(dip->di_core.di_magic), dip);
goto corrupt_out; goto corrupt_out;
} }
if (XFS_TEST_ERROR(ip->i_d.di_magic != XFS_DINODE_MAGIC, if (XFS_TEST_ERROR(ip->i_d.di_magic != XFS_DINODE_MAGIC,
...@@ -3425,7 +3426,7 @@ xfs_iflush_int( ...@@ -3425,7 +3426,7 @@ xfs_iflush_int(
* because if the inode is dirty at all the core must * because if the inode is dirty at all the core must
* be. * be.
*/ */
xfs_xlate_dinode_core((xfs_caddr_t)&(dip->di_core), &(ip->i_d), -1); xfs_dinode_to_disk(&dip->di_core, &ip->i_d);
/* Wrap, we never let the log put out DI_MAX_FLUSH */ /* Wrap, we never let the log put out DI_MAX_FLUSH */
if (ip->i_d.di_flushiter == DI_MAX_FLUSH) if (ip->i_d.di_flushiter == DI_MAX_FLUSH)
...@@ -3445,7 +3446,7 @@ xfs_iflush_int( ...@@ -3445,7 +3446,7 @@ xfs_iflush_int(
* Convert it back. * Convert it back.
*/ */
ASSERT(ip->i_d.di_nlink <= XFS_MAXLINK_1); ASSERT(ip->i_d.di_nlink <= XFS_MAXLINK_1);
INT_SET(dip->di_core.di_onlink, ARCH_CONVERT, ip->i_d.di_nlink); dip->di_core.di_onlink = cpu_to_be16(ip->i_d.di_nlink);
} else { } else {
/* /*
* The superblock version has already been bumped, * The superblock version has already been bumped,
...@@ -3453,7 +3454,7 @@ xfs_iflush_int( ...@@ -3453,7 +3454,7 @@ xfs_iflush_int(
* format permanent. * format permanent.
*/ */
ip->i_d.di_version = XFS_DINODE_VERSION_2; ip->i_d.di_version = XFS_DINODE_VERSION_2;
INT_SET(dip->di_core.di_version, ARCH_CONVERT, XFS_DINODE_VERSION_2); dip->di_core.di_version = XFS_DINODE_VERSION_2;
ip->i_d.di_onlink = 0; ip->i_d.di_onlink = 0;
dip->di_core.di_onlink = 0; dip->di_core.di_onlink = 0;
memset(&(ip->i_d.di_pad[0]), 0, sizeof(ip->i_d.di_pad)); memset(&(ip->i_d.di_pad[0]), 0, sizeof(ip->i_d.di_pad));
......
...@@ -18,6 +18,10 @@ ...@@ -18,6 +18,10 @@
#ifndef __XFS_INODE_H__ #ifndef __XFS_INODE_H__
#define __XFS_INODE_H__ #define __XFS_INODE_H__
struct xfs_dinode;
struct xfs_dinode_core;
/* /*
* Fork identifiers. * Fork identifiers.
*/ */
...@@ -227,6 +231,43 @@ typedef struct xfs_chash { ...@@ -227,6 +231,43 @@ typedef struct xfs_chash {
* chain off the mount structure by xfs_sync calls. * chain off the mount structure by xfs_sync calls.
*/ */
typedef struct xfs_ictimestamp {
__int32_t t_sec; /* timestamp seconds */
__int32_t t_nsec; /* timestamp nanoseconds */
} xfs_ictimestamp_t;
/*
* NOTE: This structure must be kept identical to struct xfs_dinode_core
* in xfs_dinode.h except for the endianess annotations.
*/
typedef struct xfs_icdinode {
__uint16_t di_magic; /* inode magic # = XFS_DINODE_MAGIC */
__uint16_t di_mode; /* mode and type of file */
__int8_t di_version; /* inode version */
__int8_t di_format; /* format of di_c data */
__uint16_t di_onlink; /* old number of links to file */
__uint32_t di_uid; /* owner's user id */
__uint32_t di_gid; /* owner's group id */
__uint32_t di_nlink; /* number of links to file */
__uint16_t di_projid; /* owner's project id */
__uint8_t di_pad[8]; /* unused, zeroed space */
__uint16_t di_flushiter; /* incremented on flush */
xfs_ictimestamp_t di_atime; /* time last accessed */
xfs_ictimestamp_t di_mtime; /* time last modified */
xfs_ictimestamp_t di_ctime; /* time created/inode modified */
xfs_fsize_t di_size; /* number of bytes in file */
xfs_drfsbno_t di_nblocks; /* # of direct & btree blocks used */
xfs_extlen_t di_extsize; /* basic/minimum extent size for file */
xfs_extnum_t di_nextents; /* number of extents in data fork */
xfs_aextnum_t di_anextents; /* number of extents in attribute fork*/
__uint8_t di_forkoff; /* attr fork offs, <<3 for 64b align */
__int8_t di_aformat; /* format of attr fork's data */
__uint32_t di_dmevmask; /* DMIG event mask */
__uint16_t di_dmstate; /* DMIG state info */
__uint16_t di_flags; /* random flags, XFS_DIFLAG_... */
__uint32_t di_gen; /* generation number */
} xfs_icdinode_t;
typedef struct { typedef struct {
struct xfs_ihash *ip_hash; /* pointer to hash header */ struct xfs_ihash *ip_hash; /* pointer to hash header */
struct xfs_inode *ip_next; /* inode hash link forw */ struct xfs_inode *ip_next; /* inode hash link forw */
...@@ -282,7 +323,7 @@ typedef struct xfs_inode { ...@@ -282,7 +323,7 @@ typedef struct xfs_inode {
unsigned int i_gen; /* generation count */ unsigned int i_gen; /* generation count */
unsigned int i_delayed_blks; /* count of delay alloc blks */ unsigned int i_delayed_blks; /* count of delay alloc blks */
xfs_dinode_core_t i_d; /* most of ondisk inode */ xfs_icdinode_t i_d; /* most of ondisk inode */
xfs_chashlist_t *i_chash; /* cluster hash list header */ xfs_chashlist_t *i_chash; /* cluster hash list header */
struct xfs_inode *i_cnext; /* cluster hash link forward */ struct xfs_inode *i_cnext; /* cluster hash link forward */
struct xfs_inode *i_cprev; /* cluster hash link backward */ struct xfs_inode *i_cprev; /* cluster hash link backward */
...@@ -506,7 +547,7 @@ int xfs_finish_reclaim_all(struct xfs_mount *, int); ...@@ -506,7 +547,7 @@ int xfs_finish_reclaim_all(struct xfs_mount *, int);
* xfs_inode.c prototypes. * xfs_inode.c prototypes.
*/ */
int xfs_itobp(struct xfs_mount *, struct xfs_trans *, int xfs_itobp(struct xfs_mount *, struct xfs_trans *,
xfs_inode_t *, xfs_dinode_t **, struct xfs_buf **, xfs_inode_t *, struct xfs_dinode **, struct xfs_buf **,
xfs_daddr_t, uint); xfs_daddr_t, uint);
int xfs_iread(struct xfs_mount *, struct xfs_trans *, xfs_ino_t, int xfs_iread(struct xfs_mount *, struct xfs_trans *, xfs_ino_t,
xfs_inode_t **, xfs_daddr_t, uint); xfs_inode_t **, xfs_daddr_t, uint);
...@@ -514,8 +555,11 @@ int xfs_iread_extents(struct xfs_trans *, xfs_inode_t *, int); ...@@ -514,8 +555,11 @@ int xfs_iread_extents(struct xfs_trans *, xfs_inode_t *, int);
int xfs_ialloc(struct xfs_trans *, xfs_inode_t *, mode_t, int xfs_ialloc(struct xfs_trans *, xfs_inode_t *, mode_t,
xfs_nlink_t, xfs_dev_t, struct cred *, xfs_prid_t, xfs_nlink_t, xfs_dev_t, struct cred *, xfs_prid_t,
int, struct xfs_buf **, boolean_t *, xfs_inode_t **); int, struct xfs_buf **, boolean_t *, xfs_inode_t **);
void xfs_xlate_dinode_core(xfs_caddr_t, struct xfs_dinode_core *, void xfs_dinode_from_disk(struct xfs_icdinode *,
int); struct xfs_dinode_core *);
void xfs_dinode_to_disk(struct xfs_dinode_core *,
struct xfs_icdinode *);
uint xfs_ip2xflags(struct xfs_inode *); uint xfs_ip2xflags(struct xfs_inode *);
uint xfs_dic2xflags(struct xfs_dinode_core *); uint xfs_dic2xflags(struct xfs_dinode_core *);
int xfs_ifree(struct xfs_trans *, xfs_inode_t *, int xfs_ifree(struct xfs_trans *, xfs_inode_t *,
......
...@@ -57,7 +57,7 @@ xfs_bulkstat_one_iget( ...@@ -57,7 +57,7 @@ xfs_bulkstat_one_iget(
xfs_bstat_t *buf, /* return buffer */ xfs_bstat_t *buf, /* return buffer */
int *stat) /* BULKSTAT_RV_... */ int *stat) /* BULKSTAT_RV_... */
{ {
xfs_dinode_core_t *dic; /* dinode core info pointer */ xfs_icdinode_t *dic; /* dinode core info pointer */
xfs_inode_t *ip; /* incore inode pointer */ xfs_inode_t *ip; /* incore inode pointer */
bhv_vnode_t *vp; bhv_vnode_t *vp;
int error; int error;
...@@ -151,37 +151,37 @@ xfs_bulkstat_one_dinode( ...@@ -151,37 +151,37 @@ xfs_bulkstat_one_dinode(
* the new format. We don't change the version number so that we * the new format. We don't change the version number so that we
* can distinguish this from a real new format inode. * can distinguish this from a real new format inode.
*/ */
if (INT_GET(dic->di_version, ARCH_CONVERT) == XFS_DINODE_VERSION_1) { if (dic->di_version == XFS_DINODE_VERSION_1) {
buf->bs_nlink = INT_GET(dic->di_onlink, ARCH_CONVERT); buf->bs_nlink = be16_to_cpu(dic->di_onlink);
buf->bs_projid = 0; buf->bs_projid = 0;
} else { } else {
buf->bs_nlink = INT_GET(dic->di_nlink, ARCH_CONVERT); buf->bs_nlink = be32_to_cpu(dic->di_nlink);
buf->bs_projid = INT_GET(dic->di_projid, ARCH_CONVERT); buf->bs_projid = be16_to_cpu(dic->di_projid);
} }
buf->bs_ino = ino; buf->bs_ino = ino;
buf->bs_mode = INT_GET(dic->di_mode, ARCH_CONVERT); buf->bs_mode = be16_to_cpu(dic->di_mode);
buf->bs_uid = INT_GET(dic->di_uid, ARCH_CONVERT); buf->bs_uid = be32_to_cpu(dic->di_uid);
buf->bs_gid = INT_GET(dic->di_gid, ARCH_CONVERT); buf->bs_gid = be32_to_cpu(dic->di_gid);
buf->bs_size = INT_GET(dic->di_size, ARCH_CONVERT); buf->bs_size = be64_to_cpu(dic->di_size);
buf->bs_atime.tv_sec = INT_GET(dic->di_atime.t_sec, ARCH_CONVERT); buf->bs_atime.tv_sec = be32_to_cpu(dic->di_atime.t_sec);
buf->bs_atime.tv_nsec = INT_GET(dic->di_atime.t_nsec, ARCH_CONVERT); buf->bs_atime.tv_nsec = be32_to_cpu(dic->di_atime.t_nsec);
buf->bs_mtime.tv_sec = INT_GET(dic->di_mtime.t_sec, ARCH_CONVERT); buf->bs_mtime.tv_sec = be32_to_cpu(dic->di_mtime.t_sec);
buf->bs_mtime.tv_nsec = INT_GET(dic->di_mtime.t_nsec, ARCH_CONVERT); buf->bs_mtime.tv_nsec = be32_to_cpu(dic->di_mtime.t_nsec);
buf->bs_ctime.tv_sec = INT_GET(dic->di_ctime.t_sec, ARCH_CONVERT); buf->bs_ctime.tv_sec = be32_to_cpu(dic->di_ctime.t_sec);
buf->bs_ctime.tv_nsec = INT_GET(dic->di_ctime.t_nsec, ARCH_CONVERT); buf->bs_ctime.tv_nsec = be32_to_cpu(dic->di_ctime.t_nsec);
buf->bs_xflags = xfs_dic2xflags(dic); buf->bs_xflags = xfs_dic2xflags(dic);
buf->bs_extsize = INT_GET(dic->di_extsize, ARCH_CONVERT) << mp->m_sb.sb_blocklog; buf->bs_extsize = be32_to_cpu(dic->di_extsize) << mp->m_sb.sb_blocklog;
buf->bs_extents = INT_GET(dic->di_nextents, ARCH_CONVERT); buf->bs_extents = be32_to_cpu(dic->di_nextents);
buf->bs_gen = INT_GET(dic->di_gen, ARCH_CONVERT); buf->bs_gen = be32_to_cpu(dic->di_gen);
memset(buf->bs_pad, 0, sizeof(buf->bs_pad)); memset(buf->bs_pad, 0, sizeof(buf->bs_pad));
buf->bs_dmevmask = INT_GET(dic->di_dmevmask, ARCH_CONVERT); buf->bs_dmevmask = be32_to_cpu(dic->di_dmevmask);
buf->bs_dmstate = INT_GET(dic->di_dmstate, ARCH_CONVERT); buf->bs_dmstate = be16_to_cpu(dic->di_dmstate);
buf->bs_aextents = INT_GET(dic->di_anextents, ARCH_CONVERT); buf->bs_aextents = be16_to_cpu(dic->di_anextents);
switch (INT_GET(dic->di_format, ARCH_CONVERT)) { switch (dic->di_format) {
case XFS_DINODE_FMT_DEV: case XFS_DINODE_FMT_DEV:
buf->bs_rdev = INT_GET(dip->di_u.di_dev, ARCH_CONVERT); buf->bs_rdev = be32_to_cpu(dip->di_u.di_dev);
buf->bs_blksize = BLKDEV_IOSIZE; buf->bs_blksize = BLKDEV_IOSIZE;
buf->bs_blocks = 0; buf->bs_blocks = 0;
break; break;
...@@ -195,7 +195,7 @@ xfs_bulkstat_one_dinode( ...@@ -195,7 +195,7 @@ xfs_bulkstat_one_dinode(
case XFS_DINODE_FMT_BTREE: case XFS_DINODE_FMT_BTREE:
buf->bs_rdev = 0; buf->bs_rdev = 0;
buf->bs_blksize = mp->m_sb.sb_blocksize; buf->bs_blksize = mp->m_sb.sb_blocksize;
buf->bs_blocks = INT_GET(dic->di_nblocks, ARCH_CONVERT); buf->bs_blocks = be64_to_cpu(dic->di_nblocks);
break; break;
} }
...@@ -290,16 +290,15 @@ xfs_bulkstat_use_dinode( ...@@ -290,16 +290,15 @@ xfs_bulkstat_use_dinode(
return 1; return 1;
dip = (xfs_dinode_t *) dip = (xfs_dinode_t *)
xfs_buf_offset(bp, clustidx << mp->m_sb.sb_inodelog); xfs_buf_offset(bp, clustidx << mp->m_sb.sb_inodelog);
if (INT_GET(dip->di_core.di_magic, ARCH_CONVERT) != XFS_DINODE_MAGIC || if (be16_to_cpu(dip->di_core.di_magic) != XFS_DINODE_MAGIC ||
!XFS_DINODE_GOOD_VERSION( !XFS_DINODE_GOOD_VERSION(dip->di_core.di_version))
INT_GET(dip->di_core.di_version, ARCH_CONVERT)))
return 0; return 0;
if (flags & BULKSTAT_FG_QUICK) { if (flags & BULKSTAT_FG_QUICK) {
*dipp = dip; *dipp = dip;
return 1; return 1;
} }
/* BULKSTAT_FG_INLINE: if attr fork is local, or not there, use it */ /* BULKSTAT_FG_INLINE: if attr fork is local, or not there, use it */
aformat = INT_GET(dip->di_core.di_aformat, ARCH_CONVERT); aformat = dip->di_core.di_aformat;
if ((XFS_CFORK_Q(&dip->di_core) == 0) || if ((XFS_CFORK_Q(&dip->di_core) == 0) ||
(aformat == XFS_DINODE_FMT_LOCAL) || (aformat == XFS_DINODE_FMT_LOCAL) ||
(aformat == XFS_DINODE_FMT_EXTENTS && !dip->di_core.di_anextents)) { (aformat == XFS_DINODE_FMT_EXTENTS && !dip->di_core.di_anextents)) {
......
...@@ -2245,7 +2245,7 @@ xlog_recover_do_inode_trans( ...@@ -2245,7 +2245,7 @@ xlog_recover_do_inode_trans(
int error; int error;
int attr_index; int attr_index;
uint fields; uint fields;
xfs_dinode_core_t *dicp; xfs_icdinode_t *dicp;
int need_free = 0; int need_free = 0;
if (pass == XLOG_RECOVER_PASS1) { if (pass == XLOG_RECOVER_PASS1) {
...@@ -2309,7 +2309,7 @@ xlog_recover_do_inode_trans( ...@@ -2309,7 +2309,7 @@ xlog_recover_do_inode_trans(
* Make sure the place we're flushing out to really looks * Make sure the place we're flushing out to really looks
* like an inode! * like an inode!
*/ */
if (unlikely(INT_GET(dip->di_core.di_magic, ARCH_CONVERT) != XFS_DINODE_MAGIC)) { if (unlikely(be16_to_cpu(dip->di_core.di_magic) != XFS_DINODE_MAGIC)) {
xfs_buf_relse(bp); xfs_buf_relse(bp);
xfs_fs_cmn_err(CE_ALERT, mp, xfs_fs_cmn_err(CE_ALERT, mp,
"xfs_inode_recover: Bad inode magic number, dino ptr = 0x%p, dino bp = 0x%p, ino = %Ld", "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,7 +2319,7 @@ xlog_recover_do_inode_trans(
error = EFSCORRUPTED; error = EFSCORRUPTED;
goto error; goto error;
} }
dicp = (xfs_dinode_core_t*)(item->ri_buf[1].i_addr); dicp = (xfs_icdinode_t *)(item->ri_buf[1].i_addr);
if (unlikely(dicp->di_magic != XFS_DINODE_MAGIC)) { if (unlikely(dicp->di_magic != XFS_DINODE_MAGIC)) {
xfs_buf_relse(bp); xfs_buf_relse(bp);
xfs_fs_cmn_err(CE_ALERT, mp, xfs_fs_cmn_err(CE_ALERT, mp,
...@@ -2332,15 +2332,13 @@ xlog_recover_do_inode_trans( ...@@ -2332,15 +2332,13 @@ xlog_recover_do_inode_trans(
} }
/* Skip replay when the on disk inode is newer than the log one */ /* Skip replay when the on disk inode is newer than the log one */
if (dicp->di_flushiter < if (dicp->di_flushiter < be16_to_cpu(dip->di_core.di_flushiter)) {
INT_GET(dip->di_core.di_flushiter, ARCH_CONVERT)) {
/* /*
* Deal with the wrap case, DI_MAX_FLUSH is less * Deal with the wrap case, DI_MAX_FLUSH is less
* than smaller numbers * than smaller numbers
*/ */
if ((INT_GET(dip->di_core.di_flushiter, ARCH_CONVERT) if (be16_to_cpu(dip->di_core.di_flushiter) == DI_MAX_FLUSH &&
== DI_MAX_FLUSH) && dicp->di_flushiter < (DI_MAX_FLUSH >> 1)) {
(dicp->di_flushiter < (DI_MAX_FLUSH>>1))) {
/* do nothing */ /* do nothing */
} else { } else {
xfs_buf_relse(bp); xfs_buf_relse(bp);
...@@ -2411,8 +2409,8 @@ xlog_recover_do_inode_trans( ...@@ -2411,8 +2409,8 @@ xlog_recover_do_inode_trans(
} }
/* The core is in in-core format */ /* The core is in in-core format */
xfs_xlate_dinode_core((xfs_caddr_t)&dip->di_core, xfs_dinode_to_disk(&dip->di_core,
(xfs_dinode_core_t*)item->ri_buf[1].i_addr, -1); (xfs_icdinode_t *)item->ri_buf[1].i_addr);
/* the rest is in on-disk format */ /* the rest is in on-disk format */
if (item->ri_buf[1].i_len > sizeof(xfs_dinode_core_t)) { if (item->ri_buf[1].i_len > sizeof(xfs_dinode_core_t)) {
...@@ -2424,8 +2422,7 @@ xlog_recover_do_inode_trans( ...@@ -2424,8 +2422,7 @@ xlog_recover_do_inode_trans(
fields = in_f->ilf_fields; fields = in_f->ilf_fields;
switch (fields & (XFS_ILOG_DEV | XFS_ILOG_UUID)) { switch (fields & (XFS_ILOG_DEV | XFS_ILOG_UUID)) {
case XFS_ILOG_DEV: case XFS_ILOG_DEV:
INT_SET(dip->di_u.di_dev, ARCH_CONVERT, in_f->ilf_u.ilfu_rdev); dip->di_u.di_dev = cpu_to_be32(in_f->ilf_u.ilfu_rdev);
break; break;
case XFS_ILOG_UUID: case XFS_ILOG_UUID:
dip->di_u.di_muuid = in_f->ilf_u.ilfu_uuid; dip->di_u.di_muuid = in_f->ilf_u.ilfu_uuid;
...@@ -3234,8 +3231,8 @@ xlog_recover_process_iunlinks( ...@@ -3234,8 +3231,8 @@ xlog_recover_process_iunlinks(
ASSERT(ip->i_d.di_nlink == 0); ASSERT(ip->i_d.di_nlink == 0);
/* setup for the next pass */ /* setup for the next pass */
agino = INT_GET(dip->di_next_unlinked, agino = be32_to_cpu(
ARCH_CONVERT); dip->di_next_unlinked);
xfs_buf_relse(ibp); xfs_buf_relse(ibp);
/* /*
* Prevent any DMAPI event from * Prevent any DMAPI event from
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment