]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/blobdiff - db/check.c
xfs: Introduce xfs_dfork_nextents() helper
[thirdparty/xfsprogs-dev.git] / db / check.c
index d09e33a48172e212aa5534413bf9f84bc2a5e993..fb28994d050435829223460f84afb1cce7ba8c2a 100644 (file)
@@ -2713,7 +2713,7 @@ process_exinode(
        xfs_bmbt_rec_t          *rp;
 
        rp = (xfs_bmbt_rec_t *)XFS_DFORK_PTR(dip, whichfork);
-       *nex = XFS_DFORK_NEXTENTS(dip, whichfork);
+       *nex = xfs_dfork_nextents(dip, whichfork);
        if (*nex < 0 || *nex > XFS_DFORK_SIZE(dip, mp, whichfork) /
                                                sizeof(xfs_bmbt_rec_t)) {
                if (!sflag || id->ilist)
@@ -2737,12 +2737,14 @@ process_inode(
        inodata_t               *id = NULL;
        xfs_ino_t               ino;
        xfs_extnum_t            nextents = 0;
+       xfs_extnum_t            dnextents;
        int                     security;
        xfs_rfsblock_t          totblocks;
        xfs_rfsblock_t          totdblocks = 0;
        xfs_rfsblock_t          totiblocks = 0;
        dbm_t                   type;
        xfs_extnum_t            anextents = 0;
+       xfs_extnum_t            danextents;
        xfs_rfsblock_t          atotdblocks = 0;
        xfs_rfsblock_t          atotiblocks = 0;
        xfs_qcnt_t              bc = 0;
@@ -2871,14 +2873,17 @@ process_inode(
                error++;
                return;
        }
+
+       dnextents = xfs_dfork_data_extents(dip);
+       danextents = xfs_dfork_attr_extents(dip);
+
        if (verbose || (id && id->ilist) || CHECK_BLIST(bno))
                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, mode, fmtnames[(int)dip->di_format],
                        fmtnames[(int)dip->di_aformat],
-                       be32_to_cpu(dip->di_nextents),
-                       be16_to_cpu(dip->di_anextents),
+                       dnextents, danextents,
                        be64_to_cpu(dip->di_nblocks), be64_to_cpu(dip->di_size),
                        diflags & XFS_DIFLAG_REALTIME ? " rt" : "",
                        diflags & XFS_DIFLAG_PREALLOC ? " pre" : "",
@@ -2893,25 +2898,25 @@ process_inode(
                type = DBM_DIR;
                if (dip->di_format == XFS_DINODE_FMT_LOCAL)
                        break;
-               blkmap = blkmap_alloc(be32_to_cpu(dip->di_nextents));
+               blkmap = blkmap_alloc(dnextents);
                break;
        case S_IFREG:
                if (diflags & XFS_DIFLAG_REALTIME)
                        type = DBM_RTDATA;
                else if (id->ino == mp->m_sb.sb_rbmino) {
                        type = DBM_RTBITMAP;
-                       blkmap = blkmap_alloc(be32_to_cpu(dip->di_nextents));
+                       blkmap = blkmap_alloc(dnextents);
                        addlink_inode(id);
                } else if (id->ino == mp->m_sb.sb_rsumino) {
                        type = DBM_RTSUM;
-                       blkmap = blkmap_alloc(be32_to_cpu(dip->di_nextents));
+                       blkmap = blkmap_alloc(dnextents);
                        addlink_inode(id);
                }
                else if (id->ino == mp->m_sb.sb_uquotino ||
                         id->ino == mp->m_sb.sb_gquotino ||
                         id->ino == mp->m_sb.sb_pquotino) {
                        type = DBM_QUOTA;
-                       blkmap = blkmap_alloc(be32_to_cpu(dip->di_nextents));
+                       blkmap = blkmap_alloc(dnextents);
                        addlink_inode(id);
                }
                else
@@ -2993,17 +2998,17 @@ process_inode(
                                be64_to_cpu(dip->di_nblocks), id->ino, totblocks);
                error++;
        }
-       if (nextents != be32_to_cpu(dip->di_nextents)) {
+       if (nextents != dnextents) {
                if (v)
                        dbprintf(_("bad nextents %d for inode %lld, counted %d\n"),
-                               be32_to_cpu(dip->di_nextents), id->ino, nextents);
+                               dnextents, id->ino, nextents);
                error++;
        }
-       if (anextents != be16_to_cpu(dip->di_anextents)) {
+       if (anextents != danextents) {
                if (v)
                        dbprintf(_("bad anextents %d for inode %lld, counted "
                                 "%d\n"),
-                               be16_to_cpu(dip->di_anextents), id->ino, anextents);
+                               danextents, id->ino, anextents);
                error++;
        }
        if (type == DBM_DIR)