Skip to content

Commit

Permalink
xfs: mode di_mode to vfs inode
Browse files Browse the repository at this point in the history
Move the di_mode value from the xfs_icdinode to the VFS inode, reducing
the xfs_icdinode byte another 2 bytes and collapsing another 2 byte hole
in the structure.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Dave Chinner <david@fromorbit.com>
  • Loading branch information
Dave Chinner authored and dchinner committed Feb 9, 2016
1 parent 83e06f2 commit c19b3b0
Show file tree
Hide file tree
Showing 18 changed files with 71 additions and 73 deletions.
6 changes: 3 additions & 3 deletions fs/xfs/libxfs/xfs_bmap.c
Original file line number Diff line number Diff line change
Expand Up @@ -912,7 +912,7 @@ xfs_bmap_local_to_extents(
* We don't want to deal with the case of keeping inode data inline yet.
* So sending the data fork of a regular inode is invalid.
*/
ASSERT(!(S_ISREG(ip->i_d.di_mode) && whichfork == XFS_DATA_FORK));
ASSERT(!(S_ISREG(VFS_I(ip)->i_mode) && whichfork == XFS_DATA_FORK));
ifp = XFS_IFORK_PTR(ip, whichfork);
ASSERT(XFS_IFORK_FORMAT(ip, whichfork) == XFS_DINODE_FMT_LOCAL);

Expand Down Expand Up @@ -1079,7 +1079,7 @@ xfs_bmap_add_attrfork_local(
if (ip->i_df.if_bytes <= XFS_IFORK_DSIZE(ip))
return 0;

if (S_ISDIR(ip->i_d.di_mode)) {
if (S_ISDIR(VFS_I(ip)->i_mode)) {
memset(&dargs, 0, sizeof(dargs));
dargs.geo = ip->i_mount->m_dir_geo;
dargs.dp = ip;
Expand All @@ -1091,7 +1091,7 @@ xfs_bmap_add_attrfork_local(
return xfs_dir2_sf_to_block(&dargs);
}

if (S_ISLNK(ip->i_d.di_mode))
if (S_ISLNK(VFS_I(ip)->i_mode))
return xfs_bmap_local_to_extents(tp, ip, firstblock, 1,
flags, XFS_DATA_FORK,
xfs_symlink_local_to_remote);
Expand Down
12 changes: 6 additions & 6 deletions fs/xfs/libxfs/xfs_dir2.c
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ xfs_dir_isempty(
{
xfs_dir2_sf_hdr_t *sfp;

ASSERT(S_ISDIR(dp->i_d.di_mode));
ASSERT(S_ISDIR(VFS_I(dp)->i_mode));
if (dp->i_d.di_size == 0) /* might happen during shutdown. */
return 1;
if (dp->i_d.di_size > XFS_IFORK_DSIZE(dp))
Expand Down Expand Up @@ -231,7 +231,7 @@ xfs_dir_init(
struct xfs_da_args *args;
int error;

ASSERT(S_ISDIR(dp->i_d.di_mode));
ASSERT(S_ISDIR(VFS_I(dp)->i_mode));
error = xfs_dir_ino_validate(tp->t_mountp, pdp->i_ino);
if (error)
return error;
Expand Down Expand Up @@ -266,7 +266,7 @@ xfs_dir_createname(
int rval;
int v; /* type-checking value */

ASSERT(S_ISDIR(dp->i_d.di_mode));
ASSERT(S_ISDIR(VFS_I(dp)->i_mode));
if (inum) {
rval = xfs_dir_ino_validate(tp->t_mountp, inum);
if (rval)
Expand Down Expand Up @@ -364,7 +364,7 @@ xfs_dir_lookup(
int v; /* type-checking value */
int lock_mode;

ASSERT(S_ISDIR(dp->i_d.di_mode));
ASSERT(S_ISDIR(VFS_I(dp)->i_mode));
XFS_STATS_INC(dp->i_mount, xs_dir_lookup);

/*
Expand Down Expand Up @@ -443,7 +443,7 @@ xfs_dir_removename(
int rval;
int v; /* type-checking value */

ASSERT(S_ISDIR(dp->i_d.di_mode));
ASSERT(S_ISDIR(VFS_I(dp)->i_mode));
XFS_STATS_INC(dp->i_mount, xs_dir_remove);

args = kmem_zalloc(sizeof(*args), KM_SLEEP | KM_NOFS);
Expand Down Expand Up @@ -505,7 +505,7 @@ xfs_dir_replace(
int rval;
int v; /* type-checking value */

ASSERT(S_ISDIR(dp->i_d.di_mode));
ASSERT(S_ISDIR(VFS_I(dp)->i_mode));

rval = xfs_dir_ino_validate(tp->t_mountp, inum);
if (rval)
Expand Down
8 changes: 4 additions & 4 deletions fs/xfs/libxfs/xfs_inode_buf.c
Original file line number Diff line number Diff line change
Expand Up @@ -202,13 +202,12 @@ xfs_inode_from_disk(
struct xfs_icdinode *to = &ip->i_d;
struct inode *inode = VFS_I(ip);

to->di_mode = be16_to_cpu(from->di_mode);
to->di_version = from ->di_version;

/*
* Convert v1 inodes immediately to v2 inode format as this is the
* minimum inode version format we support in the rest of the code.
*/
to->di_version = from->di_version;
if (to->di_version == 1) {
set_nlink(inode, be16_to_cpu(from->di_onlink));
to->di_projid_lo = 0;
Expand Down Expand Up @@ -238,6 +237,7 @@ xfs_inode_from_disk(
inode->i_ctime.tv_sec = (int)be32_to_cpu(from->di_ctime.t_sec);
inode->i_ctime.tv_nsec = (int)be32_to_cpu(from->di_ctime.t_nsec);
inode->i_generation = be32_to_cpu(from->di_gen);
inode->i_mode = be16_to_cpu(from->di_mode);

to->di_size = be64_to_cpu(from->di_size);
to->di_nblocks = be64_to_cpu(from->di_nblocks);
Expand Down Expand Up @@ -270,7 +270,6 @@ xfs_inode_to_disk(
to->di_magic = cpu_to_be16(XFS_DINODE_MAGIC);
to->di_onlink = 0;

to->di_mode = cpu_to_be16(from->di_mode);
to->di_version = from->di_version;
to->di_format = from->di_format;
to->di_uid = cpu_to_be32(from->di_uid);
Expand All @@ -287,6 +286,7 @@ xfs_inode_to_disk(
to->di_ctime.t_nsec = cpu_to_be32(inode->i_ctime.tv_nsec);
to->di_nlink = cpu_to_be32(inode->i_nlink);
to->di_gen = cpu_to_be32(inode->i_generation);
to->di_mode = cpu_to_be16(inode->i_mode);

to->di_size = cpu_to_be64(from->di_size);
to->di_nblocks = cpu_to_be64(from->di_nblocks);
Expand Down Expand Up @@ -501,7 +501,7 @@ xfs_iread(
* the inode is already free and not try to mess
* with the uninitialized part of it.
*/
ip->i_d.di_mode = 0;
VFS_I(ip)->i_mode = 0;
}

ASSERT(ip->i_d.di_version >= 2);
Expand Down
1 change: 0 additions & 1 deletion fs/xfs/libxfs/xfs_inode_buf.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ struct xfs_dinode;
* format specific structures at the appropriate time.
*/
struct xfs_icdinode {
__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_flushiter; /* incremented on flush */
Expand Down
2 changes: 1 addition & 1 deletion fs/xfs/libxfs/xfs_inode_fork.c
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ xfs_iformat_fork(
return -EFSCORRUPTED;
}

switch (ip->i_d.di_mode & S_IFMT) {
switch (VFS_I(ip)->i_mode & S_IFMT) {
case S_IFIFO:
case S_IFCHR:
case S_IFBLK:
Expand Down
4 changes: 2 additions & 2 deletions fs/xfs/xfs_bmap_util.c
Original file line number Diff line number Diff line change
Expand Up @@ -821,7 +821,7 @@ bool
xfs_can_free_eofblocks(struct xfs_inode *ip, bool force)
{
/* prealloc/delalloc exists only on regular files */
if (!S_ISREG(ip->i_d.di_mode))
if (!S_ISREG(VFS_I(ip)->i_mode))
return false;

/*
Expand Down Expand Up @@ -1726,7 +1726,7 @@ xfs_swap_extents(
xfs_lock_two_inodes(ip, tip, XFS_MMAPLOCK_EXCL);

/* Verify that both files have the same format */
if ((ip->i_d.di_mode & S_IFMT) != (tip->i_d.di_mode & S_IFMT)) {
if ((VFS_I(ip)->i_mode & S_IFMT) != (VFS_I(tip)->i_mode & S_IFMT)) {
error = -EINVAL;
goto out_unlock;
}
Expand Down
2 changes: 1 addition & 1 deletion fs/xfs/xfs_dir2_readdir.c
Original file line number Diff line number Diff line change
Expand Up @@ -665,7 +665,7 @@ xfs_readdir(
if (XFS_FORCED_SHUTDOWN(dp->i_mount))
return -EIO;

ASSERT(S_ISDIR(dp->i_d.di_mode));
ASSERT(S_ISDIR(VFS_I(dp)->i_mode));
XFS_STATS_INC(dp->i_mount, xs_dir_getdents);

args.dp = dp;
Expand Down
6 changes: 3 additions & 3 deletions fs/xfs/xfs_file.c
Original file line number Diff line number Diff line change
Expand Up @@ -156,9 +156,9 @@ xfs_update_prealloc_flags(
xfs_trans_ijoin(tp, ip, XFS_ILOCK_EXCL);

if (!(flags & XFS_PREALLOC_INVISIBLE)) {
ip->i_d.di_mode &= ~S_ISUID;
if (ip->i_d.di_mode & S_IXGRP)
ip->i_d.di_mode &= ~S_ISGID;
VFS_I(ip)->i_mode &= ~S_ISUID;
if (VFS_I(ip)->i_mode & S_IXGRP)
VFS_I(ip)->i_mode &= ~S_ISGID;
xfs_trans_ichgtime(tp, ip, XFS_ICHGTIME_MOD | XFS_ICHGTIME_CHG);
}

Expand Down
4 changes: 2 additions & 2 deletions fs/xfs/xfs_filestream.c
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ xfs_filestream_pick_ag(
xfs_agnumber_t ag, max_ag = NULLAGNUMBER;
int err, trylock, nscan;

ASSERT(S_ISDIR(ip->i_d.di_mode));
ASSERT(S_ISDIR(VFS_I(ip)->i_mode));

/* 2% of an AG's blocks must be free for it to be chosen. */
minfree = mp->m_sb.sb_agblocks / 50;
Expand Down Expand Up @@ -319,7 +319,7 @@ xfs_filestream_lookup_ag(
xfs_agnumber_t startag, ag = NULLAGNUMBER;
struct xfs_mru_cache_elem *mru;

ASSERT(S_ISREG(ip->i_d.di_mode));
ASSERT(S_ISREG(VFS_I(ip)->i_mode));

pip = xfs_filestream_get_parent(ip);
if (!pip)
Expand Down
13 changes: 9 additions & 4 deletions fs/xfs/xfs_icache.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ xfs_inode_alloc(
return NULL;
}

/* VFS doesn't initialise i_mode! */
VFS_I(ip)->i_mode = 0;

XFS_STATS_INC(mp, vn_active);
ASSERT(atomic_read(&ip->i_pincount) == 0);
ASSERT(!spin_is_locked(&ip->i_flags_lock));
Expand Down Expand Up @@ -98,7 +101,7 @@ void
xfs_inode_free(
struct xfs_inode *ip)
{
switch (ip->i_d.di_mode & S_IFMT) {
switch (VFS_I(ip)->i_mode & S_IFMT) {
case S_IFREG:
case S_IFDIR:
case S_IFLNK:
Expand Down Expand Up @@ -151,12 +154,14 @@ xfs_reinit_inode(
uint32_t nlink = inode->i_nlink;
uint32_t generation = inode->i_generation;
uint64_t version = inode->i_version;
umode_t mode = inode->i_mode;

error = inode_init_always(mp->m_super, inode);

set_nlink(inode, nlink);
inode->i_generation = generation;
inode->i_version = version;
inode->i_mode = mode;
return error;
}

Expand Down Expand Up @@ -211,7 +216,7 @@ xfs_iget_cache_hit(
/*
* If lookup is racing with unlink return an error immediately.
*/
if (ip->i_d.di_mode == 0 && !(flags & XFS_IGET_CREATE)) {
if (VFS_I(ip)->i_mode == 0 && !(flags & XFS_IGET_CREATE)) {
error = -ENOENT;
goto out_error;
}
Expand Down Expand Up @@ -321,7 +326,7 @@ xfs_iget_cache_miss(

trace_xfs_iget_miss(ip);

if ((ip->i_d.di_mode == 0) && !(flags & XFS_IGET_CREATE)) {
if ((VFS_I(ip)->i_mode == 0) && !(flags & XFS_IGET_CREATE)) {
error = -ENOENT;
goto out_destroy;
}
Expand Down Expand Up @@ -470,7 +475,7 @@ xfs_iget(
* If we have a real type for an on-disk inode, we can setup the inode
* now. If it's a new inode being created, xfs_ialloc will handle it.
*/
if (xfs_iflags_test(ip, XFS_INEW) && ip->i_d.di_mode != 0)
if (xfs_iflags_test(ip, XFS_INEW) && VFS_I(ip)->i_mode != 0)
xfs_setup_existing_inode(ip);
return 0;

Expand Down
Loading

0 comments on commit c19b3b0

Please sign in to comment.