]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
xfs: mode di_mode to vfs inode
authorDave Chinner <dchinner@redhat.com>
Thu, 18 Feb 2016 01:04:32 +0000 (12:04 +1100)
committerDave Chinner <david@fromorbit.com>
Thu, 18 Feb 2016 01:04:32 +0000 (12:04 +1100)
Source kernel commit c19b3b05ae440de50fffe2ac2a9b27392a7448e9

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>
db/check.c
include/xfs_inode.h
libxfs/rdwr.c
libxfs/util.c
libxfs/xfs_bmap.c
libxfs/xfs_dir2.c
libxfs/xfs_inode_buf.c
libxfs/xfs_inode_buf.h
libxfs/xfs_inode_fork.c
mkfs/proto.c
repair/phase6.c

index 5118e2995075359a2d7d6220cb84f82624870608..c626a5c3c4f8cedb4d33044fb7289f1ffc812e49 100644 (file)
@@ -2636,6 +2636,7 @@ process_inode(
        xfs_qcnt_t              rc = 0;
        xfs_dqid_t              dqprid;
        int                     v = 0;
+       mode_t                  mode;
        static char             okfmts[] = {
                0,                              /* type 0 unused */
                1 << XFS_DINODE_FMT_DEV,        /* FIFO */
@@ -2699,10 +2700,10 @@ process_inode(
                                        be32_to_cpu(dip->di_nlink), ino);
                        error++;
                }
-               if (xino.i_d.di_mode != 0) {
+               if (dip->di_mode != 0) {
                        if (v)
                                dbprintf(_("bad mode %#o for free inode %lld\n"),
-                                       xino.i_d.di_mode, ino);
+                                       be16_to_cpu(dip->di_mode), ino);
                        error++;
                }
                return;
@@ -2717,11 +2718,12 @@ process_inode(
        /*
         * di_mode is a 16-bit uint so no need to check the < 0 case
         */
-       if ((((xino.i_d.di_mode & S_IFMT) >> 12) > 15) ||
-           (!(okfmts[(xino.i_d.di_mode & S_IFMT) >> 12] & (1 << xino.i_d.di_format)))) {
+       mode = be16_to_cpu(dip->di_mode);
+       if ((((mode & S_IFMT) >> 12) > 15) ||
+           (!(okfmts[(mode & S_IFMT) >> 12] & (1 << xino.i_d.di_format)))) {
                if (v)
                        dbprintf(_("bad format %d for inode %lld type %#o\n"),
-                               xino.i_d.di_format, id->ino, xino.i_d.di_mode & S_IFMT);
+                               xino.i_d.di_format, id->ino, mode & S_IFMT);
                error++;
                return;
        }
@@ -2744,7 +2746,7 @@ process_inode(
                dbprintf(_("inode %lld mode %#o fmt %s "
                         "afmt %s "
                         "nex %d anex %d nblk %lld sz %lld%s%s%s%s%s%s%s\n"),
-                       id->ino, xino.i_d.di_mode, fmtnames[(int)xino.i_d.di_format],
+                       id->ino, mode, fmtnames[(int)xino.i_d.di_format],
                        fmtnames[(int)xino.i_d.di_aformat],
                        xino.i_d.di_nextents,
                        xino.i_d.di_anextents,
@@ -2757,7 +2759,7 @@ process_inode(
                        xino.i_d.di_flags & XFS_DIFLAG_NOATIME  ? " noa" : "",
                        xino.i_d.di_flags & XFS_DIFLAG_NODUMP   ? " nod" : "");
        security = 0;
-       switch (xino.i_d.di_mode & S_IFMT) {
+       switch (mode & S_IFMT) {
        case S_IFDIR:
                type = DBM_DIR;
                if (xino.i_d.di_format == XFS_DINODE_FMT_LOCAL)
@@ -2785,7 +2787,7 @@ process_inode(
                }
                else
                        type = DBM_DATA;
-               if (xino.i_d.di_mode & (S_ISUID | S_ISGID))
+               if (mode & (S_ISUID | S_ISGID))
                        security = 1;
                break;
        case S_IFLNK:
index fbc96cf6e2dceff03981b130541f4132230ba408..8141d972553ebdec8adc70c0b4ef79371e839fbc 100644 (file)
@@ -34,6 +34,7 @@ struct xfs_dir_ops;
  * metadata.
  */
 struct inode {
+       mode_t          i_mode;
        uint32_t        i_nlink;
        uint32_t        i_generation;
        uint64_t        i_version;
@@ -64,6 +65,19 @@ static inline struct inode *VFS_I(struct xfs_inode *ip)
        return &ip->i_vnode;
 }
 
+/*
+ * wrappers around the mode checks to simplify code
+ */
+static inline bool XFS_ISREG(struct xfs_inode *ip)
+{
+       return S_ISREG(VFS_I(ip)->i_mode);
+}
+
+static inline bool XFS_ISDIR(struct xfs_inode *ip)
+{
+       return S_ISDIR(VFS_I(ip)->i_mode);
+}
+
 /*
  * For regular files we only update the on-disk filesize when actually
  * writing data back to disk.  Until then only the copy in the VFS inode
@@ -71,7 +85,7 @@ static inline struct inode *VFS_I(struct xfs_inode *ip)
  */
 static inline xfs_fsize_t XFS_ISIZE(struct xfs_inode *ip)
 {
-       if (S_ISREG(ip->i_d.di_mode))
+       if (XFS_ISREG(ip))
                return ip->i_size;
        return ip->i_d.di_size;
 }
index 3522c261f41f4a715ef84965d98f7072729b1d1d..0ec38c58f06070261ab25baa7669a7af64e08c4d 100644 (file)
@@ -1351,7 +1351,7 @@ libxfs_iget(xfs_mount_t *mp, xfs_trans_t *tp, xfs_ino_t ino, uint lock_flags,
        /*
         * set up the inode ops structure that the libxfs code relies on
         */
-       if (S_ISDIR(ip->i_d.di_mode))
+       if (XFS_ISDIR(ip))
                ip->d_ops = mp->m_dir_inode_ops;
        else
                ip->d_ops = mp->m_nondir_inode_ops;
@@ -1363,7 +1363,7 @@ libxfs_iget(xfs_mount_t *mp, xfs_trans_t *tp, xfs_ino_t ino, uint lock_flags,
 static void
 libxfs_idestroy(xfs_inode_t *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:
index 9c2f1d2b007653b74e15f766a75700f810e4de0a..576f9543d8bf1c1be547d58ed7ecbf2ab28c98c0 100644 (file)
@@ -217,7 +217,7 @@ libxfs_ialloc(
                return error;
        ASSERT(ip != NULL);
 
-       ip->i_d.di_mode = (__uint16_t)mode;
+       VFS_I(ip)->i_mode = mode;
        set_nlink(VFS_I(ip), nlink);
        ip->i_d.di_uid = cr->cr_uid;
        ip->i_d.di_gid = cr->cr_gid;
@@ -238,10 +238,10 @@ libxfs_ialloc(
                 */
        }
 
-       if (pip && (pip->i_d.di_mode & S_ISGID)) {
+       if (pip && (VFS_I(pip)->i_mode & S_ISGID)) {
                ip->i_d.di_gid = pip->i_d.di_gid;
-               if ((pip->i_d.di_mode & S_ISGID) && (mode & S_IFMT) == S_IFDIR)
-                       ip->i_d.di_mode |= S_ISGID;
+               if ((VFS_I(pip)->i_mode & S_ISGID) && (mode & S_IFMT) == S_IFDIR)
+                       VFS_I(ip)->i_mode |= S_ISGID;
        }
 
        ip->i_d.di_size = 0;
@@ -316,7 +316,7 @@ libxfs_ialloc(
        /*
         * set up the inode ops structure that the libxfs code relies on
         */
-       if (S_ISDIR(ip->i_d.di_mode))
+       if (XFS_ISDIR(ip))
                ip->d_ops = ip->i_mount->m_dir_inode_ops;
        else
                ip->d_ops = ip->i_mount->m_nondir_inode_ops;
@@ -367,7 +367,7 @@ libxfs_iprint(
 
        dip = &ip->i_d;
        printf("\nOn disk portion\n");
-       printf("    di_mode %o\n", dip->di_mode);
+       printf("    di_mode %o\n", VFS_I(ip)->i_mode);
        printf("    di_version %x\n", (uint)dip->di_version);
        switch (ip->i_d.di_format) {
        case XFS_DINODE_FMT_LOCAL:
@@ -417,11 +417,10 @@ libxfs_iflush_int(xfs_inode_t *ip, xfs_buf_t *bp)
        dip = xfs_buf_offset(bp, ip->i_imap.im_boffset);
 
        ASSERT(ip->i_d.di_magic == XFS_DINODE_MAGIC);
-       if ((ip->i_d.di_mode & S_IFMT) == S_IFREG) {
+       if (XFS_ISREG(ip)) {
                ASSERT( (ip->i_d.di_format == XFS_DINODE_FMT_EXTENTS) ||
                        (ip->i_d.di_format == XFS_DINODE_FMT_BTREE) );
-       }
-       else if ((ip->i_d.di_mode & S_IFMT) == S_IFDIR) {
+       } else if (XFS_ISDIR(ip) == S_IFDIR) {
                ASSERT( (ip->i_d.di_format == XFS_DINODE_FMT_EXTENTS) ||
                        (ip->i_d.di_format == XFS_DINODE_FMT_BTREE)   ||
                        (ip->i_d.di_format == XFS_DINODE_FMT_LOCAL) );
index 8cb89bcfa2f9b9b83bbcec79dd3b33ca00ea7516..40286e4bc7109973b39bc0275a416e1f84ef7fd5 100644 (file)
@@ -904,7 +904,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);
 
@@ -1071,7 +1071,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;
@@ -1083,7 +1083,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);
index 89b4781894bae5df8ca7b7be7808ee442953e437..723b2677e977c5d3762e79f519d4c5a6447de507 100644 (file)
@@ -174,7 +174,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))
@@ -229,7 +229,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;
@@ -264,7 +264,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)
@@ -362,7 +362,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);
 
        /*
@@ -441,7 +441,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);
@@ -503,7 +503,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)
index da9edcda83786f41745b51598de4358ffb972cff..e3d674d30d3ce8322c4bcaeed8d3249725b845a8 100644 (file)
@@ -211,13 +211,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;
@@ -247,6 +246,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);
@@ -279,7 +279,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);
@@ -296,6 +295,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);
@@ -510,7 +510,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);
index ad98fdd65862b547ea6041ef6402a2ed5ca5078c..4ece9bf2f90cfe59d5c183a9cfe3c3d1a469622c 100644 (file)
@@ -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 */
index f40649ec84a5d14de4ec8ed1fcc4b5303771be1e..2af1dbae6df30fd758447708b0407abb1dbd19df 100644 (file)
@@ -117,7 +117,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:
index 9ff855482e78d09a6fd71f1d5bc728fd602cc8de..933924ef21ae2680e8a135fa1c16dec1cc055ad2 100644 (file)
@@ -198,7 +198,7 @@ rsvfile(
 
        libxfs_trans_ijoin(tp, ip, 0);
 
-       ip->i_d.di_mode &= ~S_ISUID;
+       VFS_I(ip)->i_mode &= ~S_ISUID;
 
        /*
         * Note that we don't have to worry about mandatory
@@ -207,8 +207,8 @@ rsvfile(
         * on, but if it was on then mandatory locking wouldn't
         * have been enabled.
         */
-       if (ip->i_d.di_mode & S_IXGRP)
-               ip->i_d.di_mode &= ~S_ISGID;
+       if (VFS_I(ip)->i_mode & S_IXGRP)
+               VFS_I(ip)->i_mode &= ~S_ISGID;
 
        libxfs_trans_ichgtime(tp, ip, XFS_ICHGTIME_MOD | XFS_ICHGTIME_CHG);
 
index 74151994805883cfa31800e3e7f536b8db13274b..0a711640cf08d922df88522b2bdf9c06b729dd39 100644 (file)
@@ -510,7 +510,7 @@ mk_rbmino(xfs_mount_t *mp)
        vers = xfs_sb_version_hascrc(&mp->m_sb) ? 3 : 2;
        memset(&ip->i_d, 0, sizeof(ip->i_d));
 
-       ip->i_d.di_mode = S_IFREG;
+       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;
@@ -763,7 +763,7 @@ mk_rsumino(xfs_mount_t *mp)
        vers = xfs_sb_version_hascrc(&mp->m_sb) ? 3 : 1;
        memset(&ip->i_d, 0, sizeof(ip->i_d));
 
-       ip->i_d.di_mode = S_IFREG;
+       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;
@@ -872,7 +872,7 @@ mk_root_dir(xfs_mount_t *mp)
        vers = xfs_sb_version_hascrc(&mp->m_sb) ? 3 : 2;
        memset(&ip->i_d, 0, sizeof(ip->i_d));
 
-       ip->i_d.di_mode = (__uint16_t) mode|S_IFDIR;
+       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;
@@ -1097,7 +1097,7 @@ mv_orphanage(
        if ((err = -libxfs_iget(mp, NULL, ino, 0, &ino_p, 0)))
                do_error(_("%d - couldn't iget disconnected inode\n"), err);
 
-       xname.type = xfs_mode_to_ftype[(ino_p->i_d.di_mode & S_IFMT)>>S_SHIFT];
+       xname.type = xfs_mode_to_ftype[(VFS_I(ino_p)->i_mode & S_IFMT)>>S_SHIFT];
 
        if (isa_dir)  {
                irec = find_inode_rec(mp, XFS_INO_TO_AGNO(mp, orphanage_ino),