@@ -2723,10 +2723,10 @@ process_inode(
error++;
return;
}
- if (!libxfs_dinode_good_version(&mp->m_sb, xino.i_d.di_version)) {
+ if (!libxfs_dinode_good_version(&mp->m_sb, dip->di_version)) {
if (isfree || v)
dbprintf(_("bad version number %#x for inode %lld\n"),
- xino.i_d.di_version, ino);
+ dip->di_version, ino);
error++;
return;
}
@@ -228,6 +228,7 @@ libxfs_ialloc(
xfs_buf_t **ialloc_context,
xfs_inode_t **ipp)
{
+ struct xfs_mount *mp = tp->t_mountp;
xfs_ino_t ino;
xfs_inode_t *ip;
uint flags;
@@ -259,20 +260,6 @@ libxfs_ialloc(
ip->i_d.di_projid = pip ? 0 : fsx->fsx_projid;
xfs_trans_ichgtime(tp, ip, XFS_ICHGTIME_CHG | XFS_ICHGTIME_MOD);
- /*
- * We only support filesystems that understand v2 format inodes. So if
- * this is currently an old format inode, then change the inode version
- * number now. This way we only do the conversion here rather than here
- * and in the flush/logging code.
- */
- if (ip->i_d.di_version == 1) {
- ip->i_d.di_version = 2;
- /*
- * old link count, projid_lo/hi field, pad field
- * already zeroed
- */
- }
-
if (pip && (VFS_I(pip)->i_mode & S_ISGID)) {
VFS_I(ip)->i_gid = VFS_I(pip)->i_gid;
if ((VFS_I(pip)->i_mode & S_ISGID) && (mode & S_IFMT) == S_IFDIR)
@@ -289,7 +276,7 @@ libxfs_ialloc(
ip->i_d.di_dmstate = 0;
ip->i_d.di_flags = pip ? 0 : xfs_flags2diflags(ip, fsx->fsx_xflags);
- if (ip->i_d.di_version == 3) {
+ if (xfs_sb_version_has_v3inode(&mp->m_sb)) {
ASSERT(ip->i_d.di_ino == ino);
ASSERT(uuid_equal(&ip->i_d.di_uuid, &mp->m_sb.sb_meta_uuid));
VFS_I(ip)->i_version = 1;
@@ -382,7 +369,6 @@ libxfs_iflush_int(xfs_inode_t *ip, xfs_buf_t *bp)
ASSERT(ip->i_d.di_format != XFS_DINODE_FMT_BTREE ||
ip->i_d.di_nextents > ip->i_df.if_ext_max);
- ASSERT(ip->i_d.di_version > 1);
iip = ip->i_itemp;
mp = ip->i_mount;
@@ -403,7 +389,7 @@ libxfs_iflush_int(xfs_inode_t *ip, xfs_buf_t *bp)
ASSERT(ip->i_d.di_forkoff <= mp->m_sb.sb_inodesize);
/* bump the change count on v3 inodes */
- if (ip->i_d.di_version == 3)
+ if (xfs_sb_version_has_v3inode(&mp->m_sb))
VFS_I(ip)->i_version++;
/* Check the inline fork data before we write out. */
@@ -191,16 +191,14 @@ xfs_inode_from_disk(
struct xfs_icdinode *to = &ip->i_d;
struct inode *inode = VFS_I(ip);
-
/*
* Convert v1 inodes immediately to v2 inode format as this is the
* minimum inode version format we support in the rest of the code.
+ * They will also be unconditionally written back to disk as v2 inodes.
*/
- to->di_version = from->di_version;
- if (to->di_version == 1) {
+ if (unlikely(from->di_version == 1)) {
set_nlink(inode, be16_to_cpu(from->di_onlink));
to->di_projid = 0;
- to->di_version = 2;
} else {
set_nlink(inode, be32_to_cpu(from->di_nlink));
to->di_projid = (prid_t)be16_to_cpu(from->di_projid_hi) << 16 |
@@ -238,7 +236,7 @@ xfs_inode_from_disk(
to->di_dmstate = be16_to_cpu(from->di_dmstate);
to->di_flags = be16_to_cpu(from->di_flags);
- if (to->di_version == 3) {
+ if (xfs_sb_version_has_v3inode(&ip->i_mount->m_sb)) {
inode_set_iversion_queried(inode,
be64_to_cpu(from->di_changecount));
to->di_crtime.tv_sec = be32_to_cpu(from->di_crtime.t_sec);
@@ -260,7 +258,6 @@ xfs_inode_to_disk(
to->di_magic = cpu_to_be16(XFS_DINODE_MAGIC);
to->di_onlink = 0;
- to->di_version = from->di_version;
to->di_format = from->di_format;
to->di_uid = cpu_to_be32(i_uid_read(inode));
to->di_gid = cpu_to_be32(i_gid_read(inode));
@@ -289,7 +286,8 @@ xfs_inode_to_disk(
to->di_dmstate = cpu_to_be16(from->di_dmstate);
to->di_flags = cpu_to_be16(from->di_flags);
- if (from->di_version == 3) {
+ if (xfs_sb_version_has_v3inode(&ip->i_mount->m_sb)) {
+ to->di_version = 3;
to->di_changecount = cpu_to_be64(inode_peek_iversion(inode));
to->di_crtime.t_sec = cpu_to_be32(from->di_crtime.tv_sec);
to->di_crtime.t_nsec = cpu_to_be32(from->di_crtime.tv_nsec);
@@ -301,6 +299,7 @@ xfs_inode_to_disk(
uuid_copy(&to->di_uuid, &ip->i_mount->m_sb.sb_meta_uuid);
to->di_flushiter = 0;
} else {
+ to->di_version = 2;
to->di_flushiter = cpu_to_be16(from->di_flushiter);
}
}
@@ -618,7 +617,6 @@ xfs_iread(
xfs_sb_version_has_v3inode(&mp->m_sb) &&
!(mp->m_flags & XFS_MOUNT_IKEEP)) {
VFS_I(ip)->i_generation = prandom_u32();
- ip->i_d.di_version = 3;
return 0;
}
@@ -660,7 +658,6 @@ xfs_iread(
* Partial initialisation of the in-core inode. Just the bits
* that xfs_ialloc won't overwrite or relies on being correct.
*/
- ip->i_d.di_version = dip->di_version;
VFS_I(ip)->i_generation = be32_to_cpu(dip->di_gen);
ip->i_d.di_flushiter = be16_to_cpu(dip->di_flushiter);
@@ -674,7 +671,6 @@ xfs_iread(
VFS_I(ip)->i_mode = 0;
}
- ASSERT(ip->i_d.di_version >= 2);
ip->i_delayed_blks = 0;
/*
@@ -16,7 +16,6 @@ struct xfs_dinode;
* format specific structures at the appropriate time.
*/
struct xfs_icdinode {
- int8_t di_version; /* inode version */
int8_t di_format; /* format of di_c data */
uint16_t di_flushiter; /* incremented on flush */
uint32_t di_projid; /* owner's project id */
@@ -519,7 +519,6 @@ mk_rbmino(xfs_mount_t *mp)
int error;
xfs_fileoff_t bno;
xfs_bmbt_irec_t map[XFS_BMAP_MAX_NMAP];
- int vers;
int times;
uint blocks;
@@ -538,18 +537,16 @@ mk_rbmino(xfs_mount_t *mp)
error);
}
- vers = xfs_sb_version_hascrc(&mp->m_sb) ? 3 : 2;
memset(&ip->i_d, 0, sizeof(ip->i_d));
VFS_I(ip)->i_mode = S_IFREG;
- ip->i_d.di_version = vers;
ip->i_d.di_format = XFS_DINODE_FMT_EXTENTS;
ip->i_d.di_aformat = XFS_DINODE_FMT_EXTENTS;
set_nlink(VFS_I(ip), 1); /* account for sb ptr */
times = XFS_ICHGTIME_CHG | XFS_ICHGTIME_MOD;
- if (ip->i_d.di_version == 3) {
+ if (xfs_sb_version_has_v3inode(&mp->m_sb)) {
VFS_I(ip)->i_version = 1;
ip->i_d.di_flags2 = 0;
times |= XFS_ICHGTIME_CREATE;
@@ -765,7 +762,6 @@ mk_rsumino(xfs_mount_t *mp)
int nsumblocks;
xfs_fileoff_t bno;
xfs_bmbt_irec_t map[XFS_BMAP_MAX_NMAP];
- int vers;
int times;
uint blocks;
@@ -784,18 +780,16 @@ mk_rsumino(xfs_mount_t *mp)
error);
}
- vers = xfs_sb_version_hascrc(&mp->m_sb) ? 3 : 2;
memset(&ip->i_d, 0, sizeof(ip->i_d));
VFS_I(ip)->i_mode = S_IFREG;
- ip->i_d.di_version = vers;
ip->i_d.di_format = XFS_DINODE_FMT_EXTENTS;
ip->i_d.di_aformat = XFS_DINODE_FMT_EXTENTS;
set_nlink(VFS_I(ip), 1); /* account for sb ptr */
times = XFS_ICHGTIME_CHG | XFS_ICHGTIME_MOD;
- if (ip->i_d.di_version == 3) {
+ if (xfs_sb_version_has_v3inode(&mp->m_sb)) {
VFS_I(ip)->i_version = 1;
ip->i_d.di_flags2 = 0;
times |= XFS_ICHGTIME_CREATE;
@@ -870,7 +864,6 @@ mk_root_dir(xfs_mount_t *mp)
int error;
const mode_t mode = 0755;
ino_tree_node_t *irec;
- int vers;
int times;
ip = NULL;
@@ -887,18 +880,16 @@ mk_root_dir(xfs_mount_t *mp)
/*
* take care of the core -- initialization from xfs_ialloc()
*/
- vers = xfs_sb_version_hascrc(&mp->m_sb) ? 3 : 2;
memset(&ip->i_d, 0, sizeof(ip->i_d));
VFS_I(ip)->i_mode = mode|S_IFDIR;
- ip->i_d.di_version = vers;
ip->i_d.di_format = XFS_DINODE_FMT_EXTENTS;
ip->i_d.di_aformat = XFS_DINODE_FMT_EXTENTS;
set_nlink(VFS_I(ip), 2); /* account for . and .. */
times = XFS_ICHGTIME_CHG | XFS_ICHGTIME_MOD;
- if (ip->i_d.di_version == 3) {
+ if (xfs_sb_version_has_v3inode(&mp->m_sb)) {
VFS_I(ip)->i_version = 1;
ip->i_d.di_flags2 = 0;
times |= XFS_ICHGTIME_CREATE;