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);
} }
......
This diff is collapsed.
...@@ -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