]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
xfs: move the di_nblocks field to struct xfs_inode
authorChristoph Hellwig <hch@lst.de>
Wed, 30 Jun 2021 22:32:58 +0000 (18:32 -0400)
committerEric Sandeen <sandeen@sandeen.net>
Wed, 30 Jun 2021 22:32:58 +0000 (18:32 -0400)
Source kernel commit: 6e73a545f91e128d8dd7da1769dca200225f5d82

In preparation of removing the historic icinode struct, move the nblocks
field into the containing xfs_inode structure.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
include/xfs_inode.h
libxfs/util.c
libxfs/xfs_bmap.c
libxfs/xfs_bmap_btree.c
libxfs/xfs_da_btree.c
libxfs/xfs_inode_buf.c
libxfs/xfs_inode_buf.h
libxfs/xfs_inode_fork.c
repair/phase6.c
repair/quotacheck.c

index 477a2972c259665fb9213164045ea075d4204cdb..f2b315d7a860d8fc626fdd704a4fd2945867ace6 100644 (file)
@@ -79,6 +79,7 @@ typedef struct xfs_inode {
        struct xfs_inode_log_item *i_itemp;     /* logging information */
        unsigned int            i_delayed_blks; /* count of delay alloc blks */
        xfs_fsize_t             i_disk_size;    /* number of bytes in file */
+       xfs_rfsblock_t          i_nblocks;      /* # of direct & btree blocks */
        prid_t                  i_projid;       /* owner's project id */
        struct xfs_icdinode     i_d;            /* most of ondisk inode */
 
index 03e66661ca4188c48578ba3e735e17212da5aebf..1af18913f90b165fe19e79c5c1ed5bcb6343359a 100644 (file)
@@ -278,7 +278,7 @@ libxfs_init_new_inode(
 
        ip->i_disk_size = 0;
        ip->i_df.if_nextents = 0;
-       ASSERT(ip->i_d.di_nblocks == 0);
+       ASSERT(ip->i_nblocks == 0);
        ip->i_d.di_extsize = pip ? 0 : fsx->fsx_extsize;
        ip->i_d.di_flags = pip ? 0 : xfs_flags2diflags(ip, fsx->fsx_xflags);
 
@@ -360,7 +360,7 @@ libxfs_iflush_int(
                        (ip->i_df.if_format == XFS_DINODE_FMT_BTREE)   ||
                        (ip->i_df.if_format == XFS_DINODE_FMT_LOCAL) );
        }
-       ASSERT(ip->i_df.if_nextents+ip->i_afp->if_nextents <= ip->i_d.di_nblocks);
+       ASSERT(ip->i_df.if_nextents+ip->i_afp->if_nextents <= ip->i_nblocks);
        ASSERT(ip->i_d.di_forkoff <= mp->m_sb.sb_inodesize);
 
        /* bump the change count on v3 inodes */
index 7d4b8603b62d9dbc6074cd878a1f83407a581010..197c893612e46bf90175837533c92a699e060ad1 100644 (file)
@@ -617,7 +617,7 @@ xfs_bmap_btree_to_extents(
                return error;
        xfs_rmap_ino_bmbt_owner(&oinfo, ip->i_ino, whichfork);
        xfs_bmap_add_free(cur->bc_tp, cbno, 1, &oinfo);
-       ip->i_d.di_nblocks--;
+       ip->i_nblocks--;
        xfs_trans_mod_dquot_byino(tp, ip, XFS_TRANS_DQ_BCOUNT, -1L);
        xfs_trans_binval(tp, cbp);
        if (cur->bc_bufs[0] == cbp)
@@ -719,7 +719,7 @@ xfs_bmap_extents_to_btree(
               args.agno >= XFS_FSB_TO_AGNO(mp, tp->t_firstblock));
        tp->t_firstblock = args.fsbno;
        cur->bc_ino.allocated++;
-       ip->i_d.di_nblocks++;
+       ip->i_nblocks++;
        xfs_trans_mod_dquot_byino(tp, ip, XFS_TRANS_DQ_BCOUNT, 1L);
        error = xfs_trans_get_buf(tp, mp->m_ddev_targp,
                        XFS_FSB_TO_DADDR(mp, args.fsbno),
@@ -901,7 +901,7 @@ xfs_bmap_local_to_extents(
        xfs_iext_insert(ip, &icur, &rec, 0);
 
        ifp->if_nextents = 1;
-       ip->i_d.di_nblocks = 1;
+       ip->i_nblocks = 1;
        xfs_trans_mod_dquot_byino(tp, ip,
                XFS_TRANS_DQ_BCOUNT, 1L);
        flags |= xfs_ilog_fext(whichfork);
@@ -3436,7 +3436,7 @@ xfs_bmap_btalloc_accounting(
        }
 
        /* data/attr fork only */
-       ap->ip->i_d.di_nblocks += args->len;
+       ap->ip->i_nblocks += args->len;
        xfs_trans_log_inode(ap->tp, ap->ip, XFS_ILOG_CORE);
        if (ap->wasdel) {
                ap->ip->i_delayed_blks -= args->len;
@@ -4757,7 +4757,7 @@ xfs_bmapi_remap(
                ASSERT(got.br_startoff - bno >= len);
        }
 
-       ip->i_d.di_nblocks += len;
+       ip->i_nblocks += len;
        xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE);
 
        if (ifp->if_flags & XFS_IFBROOT) {
@@ -5348,7 +5348,7 @@ xfs_bmap_del_extent_real(
         * Adjust inode # blocks in the file.
         */
        if (nblks)
-               ip->i_d.di_nblocks -= nblks;
+               ip->i_nblocks -= nblks;
        /*
         * Adjust quota data.
         */
index a1413980c9999a219f0090a2403dc32a47685d0c..232e58762261a445183afc273af932871e930e1c 100644 (file)
@@ -258,7 +258,7 @@ xfs_bmbt_alloc_block(
        ASSERT(args.len == 1);
        cur->bc_tp->t_firstblock = args.fsbno;
        cur->bc_ino.allocated++;
-       cur->bc_ino.ip->i_d.di_nblocks++;
+       cur->bc_ino.ip->i_nblocks++;
        xfs_trans_log_inode(args.tp, cur->bc_ino.ip, XFS_ILOG_CORE);
        xfs_trans_mod_dquot_byino(args.tp, cur->bc_ino.ip,
                        XFS_TRANS_DQ_BCOUNT, 1L);
@@ -285,7 +285,7 @@ xfs_bmbt_free_block(
 
        xfs_rmap_ino_bmbt_owner(&oinfo, ip->i_ino, cur->bc_ino.whichfork);
        xfs_bmap_add_free(cur->bc_tp, fsbno, 1, &oinfo);
-       ip->i_d.di_nblocks--;
+       ip->i_nblocks--;
 
        xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE);
        xfs_trans_mod_dquot_byino(tp, ip, XFS_TRANS_DQ_BCOUNT, -1L);
index 7448ee6cdf487b878c14f4ec4f70886cf577eb5e..43f090c5106215a20d320e9cce356f37260d8012 100644 (file)
@@ -2142,7 +2142,7 @@ xfs_da_grow_inode_int(
        struct xfs_trans        *tp = args->trans;
        struct xfs_inode        *dp = args->dp;
        int                     w = args->whichfork;
-       xfs_rfsblock_t          nblks = dp->i_d.di_nblocks;
+       xfs_rfsblock_t          nblks = dp->i_nblocks;
        struct xfs_bmbt_irec    map, *mapp;
        int                     nmap, error, got, i, mapi;
 
@@ -2208,7 +2208,7 @@ xfs_da_grow_inode_int(
        }
 
        /* account for newly allocated blocks in reserved blocks total */
-       args->total -= dp->i_d.di_nblocks - nblks;
+       args->total -= dp->i_nblocks - nblks;
 
 out_free_map:
        if (mapp != &map)
index 62b45e128ef207131f41e30623573a956fbd5956..cf0f3e5e121bfb9342b9be84899241396139cac8 100644 (file)
@@ -224,7 +224,7 @@ xfs_inode_from_disk(
        inode->i_ctime = xfs_inode_from_disk_ts(from, from->di_ctime);
 
        ip->i_disk_size = be64_to_cpu(from->di_size);
-       to->di_nblocks = be64_to_cpu(from->di_nblocks);
+       ip->i_nblocks = be64_to_cpu(from->di_nblocks);
        to->di_extsize = be32_to_cpu(from->di_extsize);
        to->di_forkoff = from->di_forkoff;
        to->di_flags    = be16_to_cpu(from->di_flags);
@@ -303,7 +303,7 @@ xfs_inode_to_disk(
        to->di_mode = cpu_to_be16(inode->i_mode);
 
        to->di_size = cpu_to_be64(ip->i_disk_size);
-       to->di_nblocks = cpu_to_be64(from->di_nblocks);
+       to->di_nblocks = cpu_to_be64(ip->i_nblocks);
        to->di_extsize = cpu_to_be32(from->di_extsize);
        to->di_nextents = cpu_to_be32(xfs_ifork_nextents(&ip->i_df));
        to->di_anextents = cpu_to_be16(xfs_ifork_nextents(ip->i_afp));
index c93ed0bc5735e0a403f585e0dc332288a3263398..f4e1a9010b0a47803739b4bf04b7c0f7d207ebd0 100644 (file)
@@ -17,7 +17,6 @@ struct xfs_dinode;
  */
 struct xfs_icdinode {
        uint16_t        di_flushiter;   /* incremented on flush */
-       xfs_rfsblock_t  di_nblocks;     /* # of direct & btree blocks used */
        xfs_extlen_t    di_extsize;     /* basic/minimum extent size for file */
        uint8_t         di_forkoff;     /* attr fork offs, <<3 for 64b align */
        uint16_t        di_flags;       /* random flags, XFS_DIFLAG_... */
index a84fe7a19d140ff6b9c90b6b3059ce3dc4f6773b..55f0deabd701024920564ec1c1f92ce8621516f2 100644 (file)
@@ -192,7 +192,7 @@ xfs_iformat_btree(
                     nrecs == 0 ||
                     XFS_BMDR_SPACE_CALC(nrecs) >
                                        XFS_DFORK_SIZE(dip, mp, whichfork) ||
-                    ifp->if_nextents > ip->i_d.di_nblocks) ||
+                    ifp->if_nextents > ip->i_nblocks) ||
                     level == 0 || level > XFS_BM_MAXLEVELS(mp, whichfork)) {
                xfs_warn(mp, "corrupt inode %Lu (btree).",
                                        (unsigned long long) ip->i_ino);
index 648d3984297666865171d4eaa86dab8d2b3e9a7a..2d0ff7dfeff6dd0afe702e6feb4e086f9b8da597 100644 (file)
@@ -443,6 +443,7 @@ reset_inode_fields(struct xfs_inode *ip)
        memset(&ip->i_d, 0, sizeof(ip->i_d));
        ip->i_projid = 0;
        ip->i_disk_size = 0;
+       ip->i_nblocks = 0;
 }
 
 static void
index 0c4d48406276435da636ef33db92d6603d698ae0..817474ffd2dcd98d7bdc01071ff375a308dbf748 100644 (file)
@@ -222,7 +222,7 @@ quotacheck_adjust(
        /* Count the file's blocks. */
        if (XFS_IS_REALTIME_INODE(ip))
                rtblks = qc_count_rtblocks(ip);
-       blocks = ip->i_d.di_nblocks - rtblks;
+       blocks = ip->i_nblocks - rtblks;
 
        if (user_dquots)
                qc_adjust(user_dquots, i_uid_read(VFS_I(ip)), blocks, rtblks);