Commit 81591fe2 authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Niv Sardi

[XFS] kill xfs_dinode_core_t

Now that we have a separate xfs_icdinode_t for the in-core inode which
gets logged there is no need anymore for the xfs_dinode vs xfs_dinode_core
split - the fact that part of the structure gets logged through the inode
log item and a small part not can better be described in a comment.

All sizeof operations on the dinode_core either really wanted the
icdinode and are switched to that one, or had already added the size
of the agi unlinked list pointer.  Later both will be replaced with
helpers once we get the larger CRC-enabled dinode.

Removing the data and attribute fork unions also has the advantage that
xfs_dinode.h doesn't need to pull in every header under the sun.

While we're at it also add some more comments describing the dinode
structure.

(First sent on October 7th)
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
Reviewed-by: default avatarDave Chinner <david@fromorbit.com>
Signed-off-by: default avatarNiv Sardi <xaiki@sgi.com>
parent d42f08f6
...@@ -18,32 +18,32 @@ ...@@ -18,32 +18,32 @@
#ifndef __XFS_DINODE_H__ #ifndef __XFS_DINODE_H__
#define __XFS_DINODE_H__ #define __XFS_DINODE_H__
struct xfs_buf;
struct xfs_mount;
#define XFS_DINODE_VERSION_1 1 #define XFS_DINODE_VERSION_1 1
#define XFS_DINODE_VERSION_2 2 #define XFS_DINODE_VERSION_2 2
#define XFS_DINODE_GOOD_VERSION(v) \ #define XFS_DINODE_GOOD_VERSION(v) \
(((v) == XFS_DINODE_VERSION_1 || (v) == XFS_DINODE_VERSION_2)) (((v) == XFS_DINODE_VERSION_1 || (v) == XFS_DINODE_VERSION_2))
#define XFS_DINODE_MAGIC 0x494e /* 'IN' */ #define XFS_DINODE_MAGIC 0x494e /* 'IN' */
/*
* Disk inode structure.
* This is just the header; the inode is expanded to fill a variable size
* with the last field expanding. It is split into the core and "other"
* because we only need the core part in the in-core inode.
*/
typedef struct xfs_timestamp { typedef struct xfs_timestamp {
__be32 t_sec; /* timestamp seconds */ __be32 t_sec; /* timestamp seconds */
__be32 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 * On-disk inode structure.
* below, the offsets table in xfs_ialloc_log_di() and struct xfs_icdinode *
* in xfs_inode.h. * This is just the header or "dinode core", the inode is expanded to fill a
* variable size the leftover area split into a data and an attribute fork.
* The format of the data and attribute fork depends on the format of the
* inode as indicated by di_format and di_aformat. To access the data and
* attribute use the XFS_DFORK_PTR, XFS_DFORK_DPTR, and XFS_DFORK_PTR macros
* below.
*
* There is a very similar struct icdinode in xfs_inode which matches the
* layout of the first 96 bytes of this structure, but is kept in native
* format instead of big endian.
*/ */
typedef struct xfs_dinode_core { typedef struct xfs_dinode {
__be16 di_magic; /* inode magic # = XFS_DINODE_MAGIC */ __be16 di_magic; /* inode magic # = XFS_DINODE_MAGIC */
__be16 di_mode; /* mode and type of file */ __be16 di_mode; /* mode and type of file */
__u8 di_version; /* inode version */ __u8 di_version; /* inode version */
...@@ -69,33 +69,12 @@ typedef struct xfs_dinode_core { ...@@ -69,33 +69,12 @@ typedef struct xfs_dinode_core {
__be16 di_dmstate; /* DMIG state info */ __be16 di_dmstate; /* DMIG state info */
__be16 di_flags; /* random flags, XFS_DIFLAG_... */ __be16 di_flags; /* random flags, XFS_DIFLAG_... */
__be32 di_gen; /* generation number */ __be32 di_gen; /* generation number */
} xfs_dinode_core_t;
#define DI_MAX_FLUSH 0xffff /* di_next_unlinked is the only non-core field in the old dinode */
typedef struct xfs_dinode
{
xfs_dinode_core_t di_core;
/*
* In adding anything between the core and the union, be
* sure to update the macros like XFS_LITINO below.
*/
__be32 di_next_unlinked;/* agi unlinked list ptr */ __be32 di_next_unlinked;/* agi unlinked list ptr */
union { } __attribute__((packed)) xfs_dinode_t;
xfs_bmdr_block_t di_bmbt; /* btree root block */
xfs_bmbt_rec_32_t di_bmx[1]; /* extent list */ #define DI_MAX_FLUSH 0xffff
xfs_dir2_sf_t di_dir2sf; /* shortform directory v2 */
char di_c[1]; /* local contents */
__be32 di_dev; /* device for S_IFCHR/S_IFBLK */
uuid_t di_muuid; /* mount point value */
char di_symlink[1]; /* local symbolic link */
} di_u;
union {
xfs_bmdr_block_t di_abmbt; /* btree root block */
xfs_bmbt_rec_32_t di_abmx[1]; /* extent list */
xfs_attr_shortform_t di_attrsf; /* shortform attribute list */
} di_a;
} xfs_dinode_t;
/* /*
* The 32 bit link count in the inode theoretically maxes out at UINT_MAX. * The 32 bit link count in the inode theoretically maxes out at UINT_MAX.
...@@ -108,14 +87,12 @@ typedef struct xfs_dinode ...@@ -108,14 +87,12 @@ typedef struct xfs_dinode
/* /*
* Values for di_format * Values for di_format
*/ */
typedef enum xfs_dinode_fmt typedef enum xfs_dinode_fmt {
{ XFS_DINODE_FMT_DEV, /* xfs_dev_t */
XFS_DINODE_FMT_DEV, /* CHR, BLK: di_dev */ XFS_DINODE_FMT_LOCAL, /* bulk data */
XFS_DINODE_FMT_LOCAL, /* DIR, REG: di_c */ XFS_DINODE_FMT_EXTENTS, /* struct xfs_bmbt_rec */
/* LNK: di_symlink */ XFS_DINODE_FMT_BTREE, /* struct xfs_bmdr_block */
XFS_DINODE_FMT_EXTENTS, /* DIR, REG, LNK: di_bmx */ XFS_DINODE_FMT_UUID /* uuid_t */
XFS_DINODE_FMT_BTREE, /* DIR, REG, LNK: di_bmbt */
XFS_DINODE_FMT_UUID /* MNT: di_uuid */
} xfs_dinode_fmt_t; } xfs_dinode_fmt_t;
/* /*
...@@ -136,8 +113,8 @@ typedef enum xfs_dinode_fmt ...@@ -136,8 +113,8 @@ typedef enum xfs_dinode_fmt
/* /*
* Inode data & attribute fork sizes, per inode. * Inode data & attribute fork sizes, per inode.
*/ */
#define XFS_DFORK_Q(dip) ((dip)->di_core.di_forkoff != 0) #define XFS_DFORK_Q(dip) ((dip)->di_forkoff != 0)
#define XFS_DFORK_BOFF(dip) ((int)((dip)->di_core.di_forkoff << 3)) #define XFS_DFORK_BOFF(dip) ((int)((dip)->di_forkoff << 3))
#define XFS_DFORK_DSIZE(dip,mp) \ #define XFS_DFORK_DSIZE(dip,mp) \
(XFS_DFORK_Q(dip) ? \ (XFS_DFORK_Q(dip) ? \
...@@ -152,22 +129,41 @@ typedef enum xfs_dinode_fmt ...@@ -152,22 +129,41 @@ typedef enum xfs_dinode_fmt
XFS_DFORK_DSIZE(dip, mp) : \ XFS_DFORK_DSIZE(dip, mp) : \
XFS_DFORK_ASIZE(dip, mp)) XFS_DFORK_ASIZE(dip, mp))
#define XFS_DFORK_DPTR(dip) ((dip)->di_u.di_c) /*
* Return pointers to the data or attribute forks.
*/
#define XFS_DFORK_DPTR(dip) \
((char *)(dip) + sizeof(struct xfs_dinode))
#define XFS_DFORK_APTR(dip) \ #define XFS_DFORK_APTR(dip) \
((dip)->di_u.di_c + XFS_DFORK_BOFF(dip)) (XFS_DFORK_DPTR(dip) + XFS_DFORK_BOFF(dip))
#define XFS_DFORK_PTR(dip,w) \ #define XFS_DFORK_PTR(dip,w) \
((w) == XFS_DATA_FORK ? XFS_DFORK_DPTR(dip) : XFS_DFORK_APTR(dip)) ((w) == XFS_DATA_FORK ? XFS_DFORK_DPTR(dip) : XFS_DFORK_APTR(dip))
#define XFS_DFORK_FORMAT(dip,w) \ #define XFS_DFORK_FORMAT(dip,w) \
((w) == XFS_DATA_FORK ? \ ((w) == XFS_DATA_FORK ? \
(dip)->di_core.di_format : \ (dip)->di_format : \
(dip)->di_core.di_aformat) (dip)->di_aformat)
#define XFS_DFORK_NEXTENTS(dip,w) \ #define XFS_DFORK_NEXTENTS(dip,w) \
((w) == XFS_DATA_FORK ? \ ((w) == XFS_DATA_FORK ? \
be32_to_cpu((dip)->di_core.di_nextents) : \ be32_to_cpu((dip)->di_nextents) : \
be16_to_cpu((dip)->di_core.di_anextents)) be16_to_cpu((dip)->di_anextents))
#define XFS_BUF_TO_DINODE(bp) ((xfs_dinode_t *)XFS_BUF_PTR(bp)) #define XFS_BUF_TO_DINODE(bp) ((xfs_dinode_t *)XFS_BUF_PTR(bp))
/*
* For block and character special files the 32bit dev_t is stored at the
* beginning of the data fork.
*/
static inline xfs_dev_t xfs_dinode_get_rdev(struct xfs_dinode *dip)
{
return be32_to_cpu(*(__be32 *)XFS_DFORK_DPTR(dip));
}
static inline void xfs_dinode_put_rdev(struct xfs_dinode *dip, xfs_dev_t rdev)
{
*(__be32 *)XFS_DFORK_DPTR(dip) = cpu_to_be32(rdev);
}
/* /*
* Values for di_flags * Values for di_flags
* There should be a one-to-one correspondence between these flags and the * There should be a one-to-one correspondence between these flags and the
......
...@@ -33,13 +33,6 @@ struct xfs_inode; ...@@ -33,13 +33,6 @@ struct xfs_inode;
struct xfs_mount; struct xfs_mount;
struct xfs_trans; struct xfs_trans;
/*
* Maximum size of a shortform directory.
*/
#define XFS_DIR2_SF_MAX_SIZE \
(XFS_DINODE_MAX_SIZE - (uint)sizeof(xfs_dinode_core_t) - \
(uint)sizeof(xfs_agino_t))
/* /*
* Inode number stored as 8 8-bit values. * Inode number stored as 8 8-bit values.
*/ */
......
...@@ -355,12 +355,12 @@ xfs_ialloc_ag_alloc( ...@@ -355,12 +355,12 @@ 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++) {
int ioffset = i << args.mp->m_sb.sb_inodelog; int ioffset = i << args.mp->m_sb.sb_inodelog;
uint isize = sizeof(xfs_dinode_t) + sizeof(__be32); uint isize = sizeof(struct xfs_dinode);
free = XFS_MAKE_IPTR(args.mp, fbuf, i); free = XFS_MAKE_IPTR(args.mp, fbuf, i);
free->di_core.di_magic = cpu_to_be16(XFS_DINODE_MAGIC); free->di_magic = cpu_to_be16(XFS_DINODE_MAGIC);
free->di_core.di_version = version; free->di_version = version;
free->di_core.di_gen = cpu_to_be32(gen); free->di_gen = cpu_to_be32(gen);
free->di_next_unlinked = cpu_to_be32(NULLAGINO); free->di_next_unlinked = cpu_to_be32(NULLAGINO);
xfs_trans_log_buf(tp, fbuf, ioffset, ioffset + isize - 1); xfs_trans_log_buf(tp, fbuf, ioffset, ioffset + isize - 1);
} }
......
...@@ -174,8 +174,8 @@ xfs_imap_to_bp( ...@@ -174,8 +174,8 @@ xfs_imap_to_bp(
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 = be16_to_cpu(dip->di_core.di_magic) == XFS_DINODE_MAGIC && di_ok = be16_to_cpu(dip->di_magic) == XFS_DINODE_MAGIC &&
XFS_DINODE_GOOD_VERSION(dip->di_core.di_version); XFS_DINODE_GOOD_VERSION(dip->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))) {
...@@ -191,7 +191,7 @@ xfs_imap_to_bp( ...@@ -191,7 +191,7 @@ xfs_imap_to_bp(
"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,
be16_to_cpu(dip->di_core.di_magic)); be16_to_cpu(dip->di_magic));
#endif #endif
xfs_trans_brelse(tp, bp); xfs_trans_brelse(tp, bp);
return XFS_ERROR(EFSCORRUPTED); return XFS_ERROR(EFSCORRUPTED);
...@@ -350,26 +350,26 @@ xfs_iformat( ...@@ -350,26 +350,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(be32_to_cpu(dip->di_core.di_nextents) + if (unlikely(be32_to_cpu(dip->di_nextents) +
be16_to_cpu(dip->di_core.di_anextents) > be16_to_cpu(dip->di_anextents) >
be64_to_cpu(dip->di_core.di_nblocks))) { be64_to_cpu(dip->di_nblocks))) {
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)(be32_to_cpu(dip->di_core.di_nextents) + (int)(be32_to_cpu(dip->di_nextents) +
be16_to_cpu(dip->di_core.di_anextents)), be16_to_cpu(dip->di_anextents)),
(unsigned long long) (unsigned long long)
be64_to_cpu(dip->di_core.di_nblocks)); be64_to_cpu(dip->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(dip->di_core.di_forkoff > ip->i_mount->m_sb.sb_inodesize)) { if (unlikely(dip->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,
dip->di_core.di_forkoff); dip->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);
...@@ -380,25 +380,25 @@ xfs_iformat( ...@@ -380,25 +380,25 @@ xfs_iformat(
case S_IFCHR: case S_IFCHR:
case S_IFBLK: case S_IFBLK:
case S_IFSOCK: case S_IFSOCK:
if (unlikely(dip->di_core.di_format != XFS_DINODE_FMT_DEV)) { if (unlikely(dip->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 = be32_to_cpu(dip->di_u.di_dev); ip->i_df.if_u2.if_rdev = xfs_dinode_get_rdev(dip);
break; break;
case S_IFREG: case S_IFREG:
case S_IFLNK: case S_IFLNK:
case S_IFDIR: case S_IFDIR:
switch (dip->di_core.di_format) { switch (dip->di_format) {
case XFS_DINODE_FMT_LOCAL: case XFS_DINODE_FMT_LOCAL:
/* /*
* no local regular files yet * no local regular files yet
*/ */
if (unlikely((be16_to_cpu(dip->di_core.di_mode) & S_IFMT) == S_IFREG)) { if (unlikely((be16_to_cpu(dip->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).",
...@@ -409,7 +409,7 @@ xfs_iformat( ...@@ -409,7 +409,7 @@ xfs_iformat(
return XFS_ERROR(EFSCORRUPTED); return XFS_ERROR(EFSCORRUPTED);
} }
di_size = be64_to_cpu(dip->di_core.di_size); di_size = be64_to_cpu(dip->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 "
...@@ -451,7 +451,7 @@ xfs_iformat( ...@@ -451,7 +451,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 (dip->di_core.di_aformat) { switch (dip->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);
...@@ -663,7 +663,7 @@ xfs_iformat_btree( ...@@ -663,7 +663,7 @@ xfs_iformat_btree(
void void
xfs_dinode_from_disk( xfs_dinode_from_disk(
xfs_icdinode_t *to, xfs_icdinode_t *to,
xfs_dinode_core_t *from) xfs_dinode_t *from)
{ {
to->di_magic = be16_to_cpu(from->di_magic); to->di_magic = be16_to_cpu(from->di_magic);
to->di_mode = be16_to_cpu(from->di_mode); to->di_mode = be16_to_cpu(from->di_mode);
...@@ -697,7 +697,7 @@ xfs_dinode_from_disk( ...@@ -697,7 +697,7 @@ xfs_dinode_from_disk(
void void
xfs_dinode_to_disk( xfs_dinode_to_disk(
xfs_dinode_core_t *to, xfs_dinode_t *to,
xfs_icdinode_t *from) xfs_icdinode_t *from)
{ {
to->di_magic = cpu_to_be16(from->di_magic); to->di_magic = cpu_to_be16(from->di_magic);
...@@ -784,9 +784,7 @@ uint ...@@ -784,9 +784,7 @@ uint
xfs_dic2xflags( xfs_dic2xflags(
xfs_dinode_t *dip) xfs_dinode_t *dip)
{ {
xfs_dinode_core_t *dic = &dip->di_core; return _xfs_dic2xflags(be16_to_cpu(dip->di_flags)) |
return _xfs_dic2xflags(be16_to_cpu(dic->di_flags)) |
(XFS_DFORK_Q(dip) ? XFS_XFLAG_HASATTR : 0); (XFS_DFORK_Q(dip) ? XFS_XFLAG_HASATTR : 0);
} }
...@@ -905,12 +903,12 @@ xfs_iread( ...@@ -905,12 +903,12 @@ 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 (be16_to_cpu(dip->di_core.di_magic) != XFS_DINODE_MAGIC) { if (be16_to_cpu(dip->di_magic) != XFS_DINODE_MAGIC) {
#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_magic (0x%x) != "
"XFS_DINODE_MAGIC (0x%x)", "XFS_DINODE_MAGIC (0x%x)",
be16_to_cpu(dip->di_core.di_magic), be16_to_cpu(dip->di_magic),
XFS_DINODE_MAGIC); XFS_DINODE_MAGIC);
#endif /* DEBUG */ #endif /* DEBUG */
error = XFS_ERROR(EINVAL); error = XFS_ERROR(EINVAL);
...@@ -924,8 +922,8 @@ xfs_iread( ...@@ -924,8 +922,8 @@ xfs_iread(
* specific information. * specific information.
* Otherwise, just get the truly permanent information. * Otherwise, just get the truly permanent information.
*/ */
if (dip->di_core.di_mode) { if (dip->di_mode) {
xfs_dinode_from_disk(&ip->i_d, &dip->di_core); xfs_dinode_from_disk(&ip->i_d, dip);
error = xfs_iformat(ip, dip); error = xfs_iformat(ip, dip);
if (error) { if (error) {
#ifdef DEBUG #ifdef DEBUG
...@@ -936,10 +934,10 @@ xfs_iread( ...@@ -936,10 +934,10 @@ xfs_iread(
goto out_brelse; goto out_brelse;
} }
} else { } else {
ip->i_d.di_magic = be16_to_cpu(dip->di_core.di_magic); ip->i_d.di_magic = be16_to_cpu(dip->di_magic);
ip->i_d.di_version = dip->di_core.di_version; ip->i_d.di_version = dip->di_version;
ip->i_d.di_gen = be32_to_cpu(dip->di_core.di_gen); ip->i_d.di_gen = be32_to_cpu(dip->di_gen);
ip->i_d.di_flushiter = be16_to_cpu(dip->di_core.di_flushiter); ip->i_d.di_flushiter = be16_to_cpu(dip->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.
...@@ -2295,7 +2293,7 @@ xfs_ifree( ...@@ -2295,7 +2293,7 @@ xfs_ifree(
* This is a temporary hack that would require a proper fix * This is a temporary hack that would require a proper fix
* in the future. * in the future.
*/ */
dip->di_core.di_mode = 0; dip->di_mode = 0;
if (delete) { if (delete) {
xfs_ifree_cluster(ip, tp, first_ino); xfs_ifree_cluster(ip, tp, first_ino);
...@@ -2909,14 +2907,15 @@ xfs_iflush_fork( ...@@ -2909,14 +2907,15 @@ 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);
dip->di_u.di_dev = cpu_to_be32(ip->i_df.if_u2.if_rdev); xfs_dinode_put_rdev(dip, ip->i_df.if_u2.if_rdev);
} }
break; break;
case XFS_DINODE_FMT_UUID: case XFS_DINODE_FMT_UUID:
if (iip->ili_format.ilf_fields & XFS_ILOG_UUID) { if (iip->ili_format.ilf_fields & XFS_ILOG_UUID) {
ASSERT(whichfork == XFS_DATA_FORK); ASSERT(whichfork == XFS_DATA_FORK);
memcpy(&dip->di_u.di_muuid, &ip->i_df.if_u2.if_uuid, memcpy(XFS_DFORK_DPTR(dip),
&ip->i_df.if_u2.if_uuid,
sizeof(uuid_t)); sizeof(uuid_t));
} }
break; break;
...@@ -3295,11 +3294,11 @@ xfs_iflush_int( ...@@ -3295,11 +3294,11 @@ xfs_iflush_int(
*/ */
xfs_synchronize_atime(ip); xfs_synchronize_atime(ip);
if (XFS_TEST_ERROR(be16_to_cpu(dip->di_core.di_magic) != XFS_DINODE_MAGIC, if (XFS_TEST_ERROR(be16_to_cpu(dip->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, be16_to_cpu(dip->di_core.di_magic), dip); ip->i_ino, be16_to_cpu(dip->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,
...@@ -3362,7 +3361,7 @@ xfs_iflush_int( ...@@ -3362,7 +3361,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_dinode_to_disk(&dip->di_core, &ip->i_d); xfs_dinode_to_disk(dip, &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)
...@@ -3382,7 +3381,7 @@ xfs_iflush_int( ...@@ -3382,7 +3381,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);
dip->di_core.di_onlink = cpu_to_be16(ip->i_d.di_nlink); dip->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,
...@@ -3390,12 +3389,12 @@ xfs_iflush_int( ...@@ -3390,12 +3389,12 @@ 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;
dip->di_core.di_version = XFS_DINODE_VERSION_2; dip->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_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));
memset(&(dip->di_core.di_pad[0]), 0, memset(&(dip->di_pad[0]), 0,
sizeof(dip->di_core.di_pad)); sizeof(dip->di_pad));
ASSERT(ip->i_d.di_projid == 0); ASSERT(ip->i_d.di_projid == 0);
} }
} }
......
...@@ -19,7 +19,6 @@ ...@@ -19,7 +19,6 @@
#define __XFS_INODE_H__ #define __XFS_INODE_H__
struct xfs_dinode; struct xfs_dinode;
struct xfs_dinode_core;
struct xfs_inode; struct xfs_inode;
/* /*
...@@ -112,7 +111,7 @@ typedef struct xfs_ictimestamp { ...@@ -112,7 +111,7 @@ typedef struct xfs_ictimestamp {
} xfs_ictimestamp_t; } xfs_ictimestamp_t;
/* /*
* NOTE: This structure must be kept identical to struct xfs_dinode_core * NOTE: This structure must be kept identical to struct xfs_dinode
* in xfs_dinode.h except for the endianess annotations. * in xfs_dinode.h except for the endianess annotations.
*/ */
typedef struct xfs_icdinode { typedef struct xfs_icdinode {
...@@ -553,8 +552,8 @@ int xfs_itobp(struct xfs_mount *, struct xfs_trans *, ...@@ -553,8 +552,8 @@ int xfs_itobp(struct xfs_mount *, struct xfs_trans *,
struct xfs_inode *, struct xfs_dinode **, struct xfs_inode *, struct xfs_dinode **,
struct xfs_buf **, xfs_daddr_t, uint, uint); struct xfs_buf **, xfs_daddr_t, uint, uint);
void xfs_dinode_from_disk(struct xfs_icdinode *, void xfs_dinode_from_disk(struct xfs_icdinode *,
struct xfs_dinode_core *); struct xfs_dinode *);
void xfs_dinode_to_disk(struct xfs_dinode_core *, void xfs_dinode_to_disk(struct xfs_dinode *,
struct xfs_icdinode *); struct xfs_icdinode *);
void xfs_idestroy_fork(struct xfs_inode *, int); void xfs_idestroy_fork(struct xfs_inode *, int);
void xfs_idata_realloc(struct xfs_inode *, int, int); void xfs_idata_realloc(struct xfs_inode *, int, int);
......
...@@ -281,7 +281,7 @@ xfs_inode_item_format( ...@@ -281,7 +281,7 @@ xfs_inode_item_format(
xfs_mark_inode_dirty_sync(ip); xfs_mark_inode_dirty_sync(ip);
vecp->i_addr = (xfs_caddr_t)&ip->i_d; vecp->i_addr = (xfs_caddr_t)&ip->i_d;
vecp->i_len = sizeof(xfs_dinode_core_t); vecp->i_len = sizeof(struct xfs_icdinode);
XLOG_VEC_SET_TYPE(vecp, XLOG_REG_TYPE_ICORE); XLOG_VEC_SET_TYPE(vecp, XLOG_REG_TYPE_ICORE);
vecp++; vecp++;
nvecs++; nvecs++;
......
...@@ -125,13 +125,9 @@ STATIC void ...@@ -125,13 +125,9 @@ STATIC void
xfs_bulkstat_one_dinode( xfs_bulkstat_one_dinode(
xfs_mount_t *mp, /* mount point for filesystem */ xfs_mount_t *mp, /* mount point for filesystem */
xfs_ino_t ino, /* inode number to get data for */ xfs_ino_t ino, /* inode number to get data for */
xfs_dinode_t *dip, /* dinode inode pointer */ xfs_dinode_t *dic, /* dinode inode pointer */
xfs_bstat_t *buf) /* return buffer */ xfs_bstat_t *buf) /* return buffer */
{ {
xfs_dinode_core_t *dic; /* dinode core info pointer */
dic = &dip->di_core;
/* /*
* The inode format changed when we moved the link count and * The inode format changed when we moved the link count and
* made it 32 bits long. If this is an old format inode, * made it 32 bits long. If this is an old format inode,
...@@ -162,7 +158,7 @@ xfs_bulkstat_one_dinode( ...@@ -162,7 +158,7 @@ xfs_bulkstat_one_dinode(
buf->bs_mtime.tv_nsec = be32_to_cpu(dic->di_mtime.t_nsec); buf->bs_mtime.tv_nsec = be32_to_cpu(dic->di_mtime.t_nsec);
buf->bs_ctime.tv_sec = be32_to_cpu(dic->di_ctime.t_sec); buf->bs_ctime.tv_sec = be32_to_cpu(dic->di_ctime.t_sec);
buf->bs_ctime.tv_nsec = be32_to_cpu(dic->di_ctime.t_nsec); buf->bs_ctime.tv_nsec = be32_to_cpu(dic->di_ctime.t_nsec);
buf->bs_xflags = xfs_dic2xflags(dip); buf->bs_xflags = xfs_dic2xflags(dic);
buf->bs_extsize = be32_to_cpu(dic->di_extsize) << mp->m_sb.sb_blocklog; buf->bs_extsize = be32_to_cpu(dic->di_extsize) << mp->m_sb.sb_blocklog;
buf->bs_extents = be32_to_cpu(dic->di_nextents); buf->bs_extents = be32_to_cpu(dic->di_nextents);
buf->bs_gen = be32_to_cpu(dic->di_gen); buf->bs_gen = be32_to_cpu(dic->di_gen);
...@@ -173,7 +169,7 @@ xfs_bulkstat_one_dinode( ...@@ -173,7 +169,7 @@ xfs_bulkstat_one_dinode(
switch (dic->di_format) { switch (dic->di_format) {
case XFS_DINODE_FMT_DEV: case XFS_DINODE_FMT_DEV:
buf->bs_rdev = be32_to_cpu(dip->di_u.di_dev); buf->bs_rdev = xfs_dinode_get_rdev(dic);
buf->bs_blksize = BLKDEV_IOSIZE; buf->bs_blksize = BLKDEV_IOSIZE;
buf->bs_blocks = 0; buf->bs_blocks = 0;
break; break;
...@@ -287,19 +283,19 @@ xfs_bulkstat_use_dinode( ...@@ -287,19 +283,19 @@ xfs_bulkstat_use_dinode(
* to disk yet. This is a temporary hack that would require a proper * to disk yet. This is a temporary hack that would require a proper
* fix in the future. * fix in the future.
*/ */
if (be16_to_cpu(dip->di_core.di_magic) != XFS_DINODE_MAGIC || if (be16_to_cpu(dip->di_magic) != XFS_DINODE_MAGIC ||
!XFS_DINODE_GOOD_VERSION(dip->di_core.di_version) || !XFS_DINODE_GOOD_VERSION(dip->di_version) ||
!dip->di_core.di_mode) !dip->di_mode)
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 = dip->di_core.di_aformat; aformat = dip->di_aformat;
if ((XFS_DFORK_Q(dip) == 0) || if ((XFS_DFORK_Q(dip) == 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_anextents)) {
*dipp = dip; *dipp = dip;
return 1; return 1;
} }
......
...@@ -2320,7 +2320,7 @@ xlog_recover_do_inode_trans( ...@@ -2320,7 +2320,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(be16_to_cpu(dip->di_core.di_magic) != XFS_DINODE_MAGIC)) { if (unlikely(be16_to_cpu(dip->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",
...@@ -2343,12 +2343,12 @@ xlog_recover_do_inode_trans( ...@@ -2343,12 +2343,12 @@ 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 < be16_to_cpu(dip->di_core.di_flushiter)) { if (dicp->di_flushiter < be16_to_cpu(dip->di_flushiter)) {
/* /*
* 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 (be16_to_cpu(dip->di_core.di_flushiter) == DI_MAX_FLUSH && if (be16_to_cpu(dip->di_flushiter) == DI_MAX_FLUSH &&
dicp->di_flushiter < (DI_MAX_FLUSH >> 1)) { dicp->di_flushiter < (DI_MAX_FLUSH >> 1)) {
/* do nothing */ /* do nothing */
} else { } else {
...@@ -2408,7 +2408,7 @@ xlog_recover_do_inode_trans( ...@@ -2408,7 +2408,7 @@ xlog_recover_do_inode_trans(
error = EFSCORRUPTED; error = EFSCORRUPTED;
goto error; goto error;
} }
if (unlikely(item->ri_buf[1].i_len > sizeof(xfs_dinode_core_t))) { if (unlikely(item->ri_buf[1].i_len > sizeof(struct xfs_icdinode))) {
XFS_CORRUPTION_ERROR("xlog_recover_do_inode_trans(7)", XFS_CORRUPTION_ERROR("xlog_recover_do_inode_trans(7)",
XFS_ERRLEVEL_LOW, mp, dicp); XFS_ERRLEVEL_LOW, mp, dicp);
xfs_buf_relse(bp); xfs_buf_relse(bp);
...@@ -2420,23 +2420,24 @@ xlog_recover_do_inode_trans( ...@@ -2420,23 +2420,24 @@ xlog_recover_do_inode_trans(
} }
/* The core is in in-core format */ /* The core is in in-core format */
xfs_dinode_to_disk(&dip->di_core, xfs_dinode_to_disk(dip, (xfs_icdinode_t *)item->ri_buf[1].i_addr);
(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(struct xfs_icdinode)) {
memcpy((xfs_caddr_t) dip + sizeof(xfs_dinode_core_t), memcpy((xfs_caddr_t) dip + sizeof(struct xfs_icdinode),
item->ri_buf[1].i_addr + sizeof(xfs_dinode_core_t), item->ri_buf[1].i_addr + sizeof(struct xfs_icdinode),
item->ri_buf[1].i_len - sizeof(xfs_dinode_core_t)); item->ri_buf[1].i_len - sizeof(struct xfs_icdinode));
} }
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:
dip->di_u.di_dev = cpu_to_be32(in_f->ilf_u.ilfu_rdev); xfs_dinode_put_rdev(dip, 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; memcpy(XFS_DFORK_DPTR(dip),
&in_f->ilf_u.ilfu_uuid,
sizeof(uuid_t));
break; break;
} }
...@@ -2452,12 +2453,12 @@ xlog_recover_do_inode_trans( ...@@ -2452,12 +2453,12 @@ xlog_recover_do_inode_trans(
switch (fields & XFS_ILOG_DFORK) { switch (fields & XFS_ILOG_DFORK) {
case XFS_ILOG_DDATA: case XFS_ILOG_DDATA:
case XFS_ILOG_DEXT: case XFS_ILOG_DEXT:
memcpy(&dip->di_u, src, len); memcpy(XFS_DFORK_DPTR(dip), src, len);
break; break;
case XFS_ILOG_DBROOT: case XFS_ILOG_DBROOT:
xfs_bmbt_to_bmdr(mp, (struct xfs_btree_block *)src, len, xfs_bmbt_to_bmdr(mp, (struct xfs_btree_block *)src, len,
&dip->di_u.di_bmbt, (xfs_bmdr_block_t *)XFS_DFORK_DPTR(dip),
XFS_DFORK_DSIZE(dip, mp)); XFS_DFORK_DSIZE(dip, mp));
break; break;
......
...@@ -575,8 +575,7 @@ xfs_mount_common(xfs_mount_t *mp, xfs_sb_t *sbp) ...@@ -575,8 +575,7 @@ xfs_mount_common(xfs_mount_t *mp, xfs_sb_t *sbp)
mp->m_sectbb_log = sbp->sb_sectlog - BBSHIFT; mp->m_sectbb_log = sbp->sb_sectlog - BBSHIFT;
mp->m_agno_log = xfs_highbit32(sbp->sb_agcount - 1) + 1; mp->m_agno_log = xfs_highbit32(sbp->sb_agcount - 1) + 1;
mp->m_agino_log = sbp->sb_inopblog + sbp->sb_agblklog; mp->m_agino_log = sbp->sb_inopblog + sbp->sb_agblklog;
mp->m_litino = sbp->sb_inodesize - mp->m_litino = sbp->sb_inodesize - sizeof(struct xfs_dinode);
((uint)sizeof(xfs_dinode_core_t) + (uint)sizeof(xfs_agino_t));
mp->m_blockmask = sbp->sb_blocksize - 1; mp->m_blockmask = sbp->sb_blocksize - 1;
mp->m_blockwsize = sbp->sb_blocksize >> XFS_WORDLOG; mp->m_blockwsize = sbp->sb_blocksize >> XFS_WORDLOG;
mp->m_blockwmask = mp->m_blockwsize - 1; mp->m_blockwmask = mp->m_blockwsize - 1;
......
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