]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/blobdiff - db/check.c
progs: clean up libxfs.h includes
[thirdparty/xfsprogs-dev.git] / db / check.c
index d66dc686df4b56f20dd8f599b9de10b2211cd6b4..ce98360f43eb1e5c683e560c51c9b6fe38390965 100644 (file)
@@ -16,7 +16,7 @@
  * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  */
 
-#include <xfs/libxfs.h>
+#include "xfs/libxfs.h"
 #include <math.h>
 #include <sys/time.h>
 #include "bmap.h"
@@ -183,8 +183,8 @@ typedef void        (*scan_lbtree_f_t)(struct xfs_btree_block *block,
                                   dbm_t                type,
                                   xfs_fsblock_t        bno,
                                   inodata_t            *id,
-                                  xfs_drfsbno_t        *totd,
-                                  xfs_drfsbno_t        *toti,
+                                  xfs_rfsblock_t       *totd,
+                                  xfs_rfsblock_t       *toti,
                                   xfs_extnum_t         *nex,
                                   blkmap_t             **blkmapp,
                                   int                  isroot,
@@ -233,23 +233,23 @@ static int                check_inomap(xfs_agnumber_t agno, xfs_agblock_t agbno,
 static void            check_linkcounts(xfs_agnumber_t agno);
 static int             check_range(xfs_agnumber_t agno, xfs_agblock_t agbno,
                                    xfs_extlen_t len);
-static void            check_rdbmap(xfs_drfsbno_t bno, xfs_extlen_t len,
+static void            check_rdbmap(xfs_rfsblock_t bno, xfs_extlen_t len,
                                     dbm_t type);
-static int             check_rinomap(xfs_drfsbno_t bno, xfs_extlen_t len,
+static int             check_rinomap(xfs_rfsblock_t bno, xfs_extlen_t len,
                                      xfs_ino_t c_ino);
 static void            check_rootdir(void);
-static int             check_rrange(xfs_drfsbno_t bno, xfs_extlen_t len);
+static int             check_rrange(xfs_rfsblock_t bno, xfs_extlen_t len);
 static void            check_set_dbmap(xfs_agnumber_t agno,
                                        xfs_agblock_t agbno, xfs_extlen_t len,
                                        dbm_t type1, dbm_t type2,
                                        xfs_agnumber_t c_agno,
                                        xfs_agblock_t c_agbno);
-static void            check_set_rdbmap(xfs_drfsbno_t bno, xfs_extlen_t len,
+static void            check_set_rdbmap(xfs_rfsblock_t bno, xfs_extlen_t len,
                                         dbm_t type1, dbm_t type2);
 static void            check_summary(void);
 static void            checknot_dbmap(xfs_agnumber_t agno, xfs_agblock_t agbno,
                                       xfs_extlen_t len, int typemask);
-static void            checknot_rdbmap(xfs_drfsbno_t bno, xfs_extlen_t len,
+static void            checknot_rdbmap(xfs_rfsblock_t bno, xfs_extlen_t len,
                                        int typemask);
 static void            dir_hash_add(xfs_dahash_t hash,
                                     xfs_dir2_dataptr_t addr);
@@ -268,11 +268,11 @@ static xfs_ino_t  process_block_dir_v2(blkmap_t *blkmap, int *dot,
                                             int *dotdot, inodata_t *id);
 static void            process_bmbt_reclist(xfs_bmbt_rec_t *rp, int numrecs,
                                             dbm_t type, inodata_t *id,
-                                            xfs_drfsbno_t *tot,
+                                            xfs_rfsblock_t *tot,
                                             blkmap_t **blkmapp);
 static void            process_btinode(inodata_t *id, xfs_dinode_t *dip,
-                                       dbm_t type, xfs_drfsbno_t *totd,
-                                       xfs_drfsbno_t *toti, xfs_extnum_t *nex,
+                                       dbm_t type, xfs_rfsblock_t *totd,
+                                       xfs_rfsblock_t *toti, xfs_extnum_t *nex,
                                        blkmap_t **blkmapp, int whichfork);
 static xfs_ino_t       process_data_dir_v2(int *dot, int *dotdot,
                                            inodata_t *id, int v,
@@ -287,14 +287,14 @@ static int                process_dir_v2(xfs_dinode_t *dip, blkmap_t *blkmap,
                                       int *dot, int *dotdot, inodata_t *id,
                                       xfs_ino_t *parent);
 static void            process_exinode(inodata_t *id, xfs_dinode_t *dip,
-                                       dbm_t type, xfs_drfsbno_t *totd,
-                                       xfs_drfsbno_t *toti, xfs_extnum_t *nex,
+                                       dbm_t type, xfs_rfsblock_t *totd,
+                                       xfs_rfsblock_t *toti, xfs_extnum_t *nex,
                                        blkmap_t **blkmapp, int whichfork);
 static void            process_inode(xfs_agf_t *agf, xfs_agino_t agino,
                                      xfs_dinode_t *dip, int isfree);
 static void            process_lclinode(inodata_t *id, xfs_dinode_t *dip,
-                                        dbm_t type, xfs_drfsbno_t *totd,
-                                        xfs_drfsbno_t *toti, xfs_extnum_t *nex,
+                                        dbm_t type, xfs_rfsblock_t *totd,
+                                        xfs_rfsblock_t *toti, xfs_extnum_t *nex,
                                         blkmap_t **blkmapp, int whichfork);
 static xfs_ino_t       process_leaf_node_dir_v2(blkmap_t *blkmap, int *dot,
                                                 int *dotdot, inodata_t *id,
@@ -323,8 +323,8 @@ static void         scan_ag(xfs_agnumber_t agno);
 static void            scan_freelist(xfs_agf_t *agf);
 static void            scan_lbtree(xfs_fsblock_t root, int nlevels,
                                    scan_lbtree_f_t func, dbm_t type,
-                                   inodata_t *id, xfs_drfsbno_t *totd,
-                                   xfs_drfsbno_t *toti, xfs_extnum_t *nex,
+                                   inodata_t *id, xfs_rfsblock_t *totd,
+                                   xfs_rfsblock_t *toti, xfs_extnum_t *nex,
                                    blkmap_t **blkmapp, int isroot,
                                    typnm_t btype);
 static void            scan_sbtree(xfs_agf_t *agf, xfs_agblock_t root,
@@ -332,8 +332,8 @@ static void         scan_sbtree(xfs_agf_t *agf, xfs_agblock_t root,
                                    scan_sbtree_f_t func, typnm_t btype);
 static void            scanfunc_bmap(struct xfs_btree_block *block,
                                      int level, dbm_t type, xfs_fsblock_t bno,
-                                     inodata_t *id, xfs_drfsbno_t *totd,
-                                     xfs_drfsbno_t *toti, xfs_extnum_t *nex,
+                                     inodata_t *id, xfs_rfsblock_t *totd,
+                                     xfs_rfsblock_t *toti, xfs_extnum_t *nex,
                                      blkmap_t **blkmapp, int isroot,
                                      typnm_t btype);
 static void            scanfunc_bno(struct xfs_btree_block *block, int level,
@@ -350,9 +350,9 @@ static void         set_dbmap(xfs_agnumber_t agno, xfs_agblock_t agbno,
                                  xfs_agnumber_t c_agno, xfs_agblock_t c_agbno);
 static void            set_inomap(xfs_agnumber_t agno, xfs_agblock_t agbno,
                                   xfs_extlen_t len, inodata_t *id);
-static void            set_rdbmap(xfs_drfsbno_t bno, xfs_extlen_t len,
+static void            set_rdbmap(xfs_rfsblock_t bno, xfs_extlen_t len,
                                   dbm_t type);
-static void            set_rinomap(xfs_drfsbno_t bno, xfs_extlen_t len,
+static void            set_rinomap(xfs_rfsblock_t bno, xfs_extlen_t len,
                                    inodata_t *id);
 static void            setlink_inode(inodata_t *id, nlink_t nlink, int isdir,
                                       int security);
@@ -895,13 +895,6 @@ blockget_f(
                                XFS_SB_VERSION_ATTRBIT);
                error++;
        }
-       if ((sbversion & XFS_SB_VERSION_NLINKBIT) &&
-                                       !xfs_sb_version_hasnlink(&mp->m_sb)) {
-               if (!sflag)
-                       dbprintf(_("sb versionnum missing nlink bit %x\n"),
-                               XFS_SB_VERSION_NLINKBIT);
-               error++;
-       }
        if ((sbversion & XFS_SB_VERSION_QUOTABIT) &&
                                        !xfs_sb_version_hasquota(&mp->m_sb)) {
                if (!sflag)
@@ -1004,8 +997,8 @@ blocktrash_f(
 {
        xfs_agblock_t   agbno;
        xfs_agnumber_t  agno;
-       xfs_drfsbno_t   bi;
-       xfs_drfsbno_t   blocks;
+       xfs_rfsblock_t  bi;
+       xfs_rfsblock_t  blocks;
        int             c;
        int             count;
        int             done;
@@ -1018,7 +1011,7 @@ blocktrash_f(
        int             mode;
        struct timeval  now;
        char            *p;
-       xfs_drfsbno_t   randb;
+       xfs_rfsblock_t  randb;
        uint            seed;
        int             sopt;
        int             tmask;
@@ -1136,13 +1129,13 @@ blocktrash_f(
        }
        if (blocks == 0) {
                dbprintf(_("blocktrash: no matching blocks\n"));
-               return 0;
+               goto out;
        }
        if (!sopt)
                dbprintf(_("blocktrash: seed %u\n"), seed);
        srandom(seed);
        for (i = 0; i < count; i++) {
-               randb = (xfs_drfsbno_t)((((__int64_t)random() << 32) |
+               randb = (xfs_rfsblock_t)((((__int64_t)random() << 32) |
                                         random()) % blocks);
                for (bi = 0, agno = 0, done = 0;
                     !done && agno < mp->m_sb.sb_agcount;
@@ -1161,6 +1154,7 @@ blocktrash_f(
                        }
                }
        }
+out:
        xfree(lentab);
        return 0;
 }
@@ -1185,7 +1179,6 @@ blockuse_f(
                return 0;
        }
        optind = 0;
-       count = 1;
        shownames = 0;
        fsb = XFS_DADDR_TO_FSB(mp, iocur_top->off >> BBSHIFT);
        agno = XFS_FSB_TO_AGNO(mp, fsb);
@@ -1217,7 +1210,7 @@ blockuse_f(
                p = &dbmap[agno][agbno];
                i = inomap[agno][agbno];
                dbprintf(_("block %llu (%u/%u) type %s"),
-                       (xfs_dfsbno_t)XFS_AGB_TO_FSB(mp, agno, agbno),
+                       (xfs_fsblock_t)XFS_AGB_TO_FSB(mp, agno, agbno),
                        agno, agbno, typename[(dbm_t)*p]);
                if (i) {
                        dbprintf(_(" inode %lld"), i->ino);
@@ -1414,7 +1407,7 @@ check_range(
 
 static void
 check_rdbmap(
-       xfs_drfsbno_t   bno,
+       xfs_rfsblock_t  bno,
        xfs_extlen_t    len,
        dbm_t           type)
 {
@@ -1435,7 +1428,7 @@ check_rdbmap(
 
 static int
 check_rinomap(
-       xfs_drfsbno_t   bno,
+       xfs_rfsblock_t  bno,
        xfs_extlen_t    len,
        xfs_ino_t       c_ino)
 {
@@ -1484,7 +1477,7 @@ check_rootdir(void)
 
 static int
 check_rrange(
-       xfs_drfsbno_t   bno,
+       xfs_rfsblock_t  bno,
        xfs_extlen_t    len)
 {
        xfs_extlen_t    i;
@@ -1532,7 +1525,7 @@ check_set_dbmap(
 
 static void
 check_set_rdbmap(
-       xfs_drfsbno_t   bno,
+       xfs_rfsblock_t  bno,
        xfs_extlen_t    len,
        dbm_t           type1,
        dbm_t           type2)
@@ -1556,7 +1549,7 @@ check_set_rdbmap(
 static void
 check_summary(void)
 {
-       xfs_drfsbno_t   bno;
+       xfs_rfsblock_t  bno;
        xfs_suminfo_t   *csp;
        xfs_suminfo_t   *fsp;
        int             log;
@@ -1603,7 +1596,7 @@ checknot_dbmap(
 
 static void
 checknot_rdbmap(
-       xfs_drfsbno_t   bno,
+       xfs_rfsblock_t  bno,
        xfs_extlen_t    len,
        int             typemask)
 {
@@ -1832,10 +1825,17 @@ init(
        error = sbver_err = serious_error = 0;
        fdblocks = frextents = icount = ifree = 0;
        sbversion = XFS_SB_VERSION_4;
-       if (mp->m_sb.sb_inoalignmt)
+       /*
+        * Note that inoalignmt == 0 is valid when fsb size is large enough for
+        * at least one full inode record per block. Check this case explicitly.
+        */
+       if (mp->m_sb.sb_inoalignmt ||
+           (xfs_sb_version_hasalign(&mp->m_sb) &&
+            mp->m_sb.sb_inopblock >= XFS_INODES_PER_CHUNK))
                sbversion |= XFS_SB_VERSION_ALIGNBIT;
        if ((mp->m_sb.sb_uquotino && mp->m_sb.sb_uquotino != NULLFSINO) ||
-           (mp->m_sb.sb_gquotino && mp->m_sb.sb_gquotino != NULLFSINO))
+           (mp->m_sb.sb_gquotino && mp->m_sb.sb_gquotino != NULLFSINO) ||
+           (mp->m_sb.sb_pquotino && mp->m_sb.sb_pquotino != NULLFSINO))
                sbversion |= XFS_SB_VERSION_QUOTABIT;
        quota_init();
        return 1;
@@ -1906,6 +1906,7 @@ ncheck_f(
                        break;
                default:
                        dbprintf(_("bad option -%c for ncheck command\n"), c);
+                       xfree(ilist);
                        return 0;
                }
        }
@@ -1974,7 +1975,7 @@ process_block_dir_v2(
        int             v;
        int             x;
 
-       nex = blkmap_getn(blkmap, 0, mp->m_dirblkfsbs, &bmp);
+       nex = blkmap_getn(blkmap, 0, mp->m_dir_geo->fsbcount, &bmp);
        v = id->ilist || verbose;
        if (nex == 0) {
                if (!sflag || v)
@@ -1988,7 +1989,7 @@ process_block_dir_v2(
        if (nex > 1)
                make_bbmap(&bbmap, nex, bmp);
        set_cur(&typtab[TYP_DIR2], XFS_FSB_TO_DADDR(mp, bmp->startblock),
-               mp->m_dirblkfsbs * blkbb, DB_RING_IGN, nex > 1 ? &bbmap : NULL);
+               mp->m_dir_geo->fsbcount * blkbb, DB_RING_IGN, nex > 1 ? &bbmap : NULL);
        for (x = 0; !v && x < nex; x++) {
                for (b = bmp[x].startblock;
                     !v && b < bmp[x].startblock + bmp[x].blockcount;
@@ -2006,7 +2007,7 @@ process_block_dir_v2(
                return 0;
        }
        dir_hash_init();
-       parent = process_data_dir_v2(dot, dotdot, id, v, mp->m_dirdatablk,
+       parent = process_data_dir_v2(dot, dotdot, id, v, mp->m_dir_geo->datablk,
                NULL);
        dir_hash_check(id, v);
        dir_hash_done();
@@ -2020,21 +2021,21 @@ process_bmbt_reclist(
        int                     numrecs,
        dbm_t                   type,
        inodata_t               *id,
-       xfs_drfsbno_t           *tot,
+       xfs_rfsblock_t          *tot,
        blkmap_t                **blkmapp)
 {
        xfs_agblock_t           agbno;
        xfs_agnumber_t          agno;
        xfs_fsblock_t           b;
-       xfs_dfilblks_t          c;
-       xfs_dfilblks_t          cp;
+       xfs_filblks_t           c;
+       xfs_filblks_t           cp;
        int                     f;
        int                     i;
        xfs_agblock_t           iagbno;
        xfs_agnumber_t          iagno;
-       xfs_dfiloff_t           o;
-       xfs_dfiloff_t           op;
-       xfs_dfsbno_t            s;
+       xfs_fileoff_t           o;
+       xfs_fileoff_t           op;
+       xfs_fsblock_t           s;
        int                     v;
 
        cp = op = 0;
@@ -2089,7 +2090,7 @@ process_bmbt_reclist(
                                if (CHECK_BLIST(b))
                                        dbprintf(_("inode %lld block %lld at "
                                                 "offset %lld\n"),
-                                               id->ino, (xfs_dfsbno_t)b, o);
+                                               id->ino, (xfs_fsblock_t)b, o);
                        }
                } else {
                        agno = XFS_FSB_TO_AGNO(mp, (xfs_fsblock_t)s);
@@ -2103,7 +2104,7 @@ process_bmbt_reclist(
                                if (CHECK_BLIST(b))
                                        dbprintf(_("inode %lld block %lld at "
                                                 "offset %lld\n"),
-                                               id->ino, (xfs_dfsbno_t)b, o);
+                                               id->ino, (xfs_fsblock_t)b, o);
                        }
                }
                *tot += c;
@@ -2115,8 +2116,8 @@ process_btinode(
        inodata_t               *id,
        xfs_dinode_t            *dip,
        dbm_t                   type,
-       xfs_drfsbno_t           *totd,
-       xfs_drfsbno_t           *toti,
+       xfs_rfsblock_t          *totd,
+       xfs_rfsblock_t          *toti,
        xfs_extnum_t            *nex,
        blkmap_t                **blkmapp,
        int                     whichfork)
@@ -2137,7 +2138,7 @@ process_btinode(
                return;
        }
        if (be16_to_cpu(dib->bb_numrecs) >
-                       xfs_bmdr_maxrecs(mp, XFS_DFORK_SIZE(dip, mp, whichfork),
+                       xfs_bmdr_maxrecs(XFS_DFORK_SIZE(dip, mp, whichfork),
                        be16_to_cpu(dib->bb_level) == 0)) {
                if (!sflag || id->ilist)
                        dbprintf(_("numrecs for ino %lld %s fork bmap root too "
@@ -2155,7 +2156,7 @@ process_btinode(
                *nex += be16_to_cpu(dib->bb_numrecs);
                return;
        } else {
-               pp = XFS_BMDR_PTR_ADDR(dib, 1, xfs_bmdr_maxrecs(mp,
+               pp = XFS_BMDR_PTR_ADDR(dib, 1, xfs_bmdr_maxrecs(
                                XFS_DFORK_SIZE(dip, mp, whichfork), 0));
                for (i = 0; i < be16_to_cpu(dib->bb_numrecs); i++)
                        scan_lbtree(be64_to_cpu(pp[i]), 
@@ -2223,15 +2224,15 @@ process_data_dir_v2(
                error++;
                return NULLFSINO;
        }
-       db = xfs_dir2_da_to_db(mp, dabno);
-       bf = xfs_dir3_data_bestfree_p(data);
-       ptr = (char *)xfs_dir3_data_unused_p(data);
+       db = xfs_dir2_da_to_db(mp->m_dir_geo, dabno);
+       bf = M_DIROPS(mp)->data_bestfree_p(data);
+       ptr = (char *)M_DIROPS(mp)->data_unused_p(data);
        if (be32_to_cpu(block->magic) == XFS_DIR2_BLOCK_MAGIC) {
-               btp = xfs_dir2_block_tail_p(mp, block);
+               btp = xfs_dir2_block_tail_p(mp->m_dir_geo, block);
                lep = xfs_dir2_block_leaf_p(btp);
                endptr = (char *)lep;
                if (endptr <= ptr || endptr > (char *)btp) {
-                       endptr = (char *)data + mp->m_dirblksize;
+                       endptr = (char *)data + mp->m_dir_geo->blksize;
                        lep = NULL;
                        if (!sflag || v)
                                dbprintf(_("bad block directory tail for dir ino "
@@ -2240,7 +2241,7 @@ process_data_dir_v2(
                        error++;
                }
        } else
-               endptr = (char *)data + mp->m_dirblksize;
+               endptr = (char *)data + mp->m_dir_geo->blksize;
        bf_err = lastfree_err = tag_err = 0;
        count = lastfree = freeseen = 0;
        if (be16_to_cpu(bf[0].length) == 0) {
@@ -2309,7 +2310,7 @@ process_data_dir_v2(
                                        (int)((char *)dep - (char *)data));
                        error++;
                }
-               tagp = xfs_dir2_data_entry_tag_p(dep);
+               tagp = M_DIROPS(mp)->data_entry_tag_p(dep);
                if ((char *)tagp >= endptr) {
                        if (!sflag || v)
                                dbprintf(_("dir %lld block %d bad entry at %d\n"),
@@ -2319,12 +2320,12 @@ process_data_dir_v2(
                        break;
                }
                tag_err += be16_to_cpu(*tagp) != (char *)dep - (char *)data;
-               addr = xfs_dir2_db_off_to_dataptr(mp, db,
+               addr = xfs_dir2_db_off_to_dataptr(mp->m_dir_geo, db,
                        (char *)dep - (char *)data);
                xname.name = dep->name;
                xname.len = dep->namelen;
                dir_hash_add(mp->m_dirnameops->hashname(&xname), addr);
-               ptr += xfs_dir2_data_entsize(dep->namelen);
+               ptr += M_DIROPS(mp)->data_entsize(dep->namelen);
                count++;
                lastfree = 0;
                lino = be64_to_cpu(dep->inumber);
@@ -2373,7 +2374,7 @@ process_data_dir_v2(
                }
        }
        if (be32_to_cpu(data->magic) == XFS_DIR2_BLOCK_MAGIC) {
-               endptr = (char *)data + mp->m_dirblksize;
+               endptr = (char *)data + mp->m_dir_geo->blksize;
                for (i = stale = 0; lep && i < be32_to_cpu(btp->count); i++) {
                        if ((char *)&lep[i] >= endptr) {
                                if (!sflag || v)
@@ -2446,7 +2447,7 @@ process_data_dir_v2_freefind(
        xfs_dir2_data_aoff_t    off;
 
        off = (xfs_dir2_data_aoff_t)((char *)dup - (char *)data);
-       bf = xfs_dir3_data_bestfree_p(data);
+       bf = M_DIROPS(mp)->data_bestfree_p(data);
        if (be16_to_cpu(dup->length) <
                        be16_to_cpu(bf[XFS_DIR2_DATA_FD_COUNT - 1].length))
                return NULL;
@@ -2515,11 +2516,11 @@ process_dir_v2(
        if (size <= XFS_DFORK_DSIZE(dip, mp) &&
                                dip->di_format == XFS_DINODE_FMT_LOCAL)
                *parent = process_sf_dir_v2(dip, dot, dotdot, id);
-       else if (last == mp->m_dirblkfsbs &&
+       else if (last == mp->m_dir_geo->fsbcount &&
                        (dip->di_format == XFS_DINODE_FMT_EXTENTS ||
                        dip->di_format == XFS_DINODE_FMT_BTREE))
                *parent = process_block_dir_v2(blkmap, dot, dotdot, id);
-       else if (last >= mp->m_dirleafblk + mp->m_dirblkfsbs &&
+       else if (last >= mp->m_dir_geo->leafblk + mp->m_dir_geo->fsbcount &&
                        (dip->di_format == XFS_DINODE_FMT_EXTENTS ||
                        dip->di_format == XFS_DINODE_FMT_BTREE))
                *parent = process_leaf_node_dir_v2(blkmap, dot, dotdot, id, size);
@@ -2539,8 +2540,8 @@ process_exinode(
        inodata_t               *id,
        xfs_dinode_t            *dip,
        dbm_t                   type,
-       xfs_drfsbno_t           *totd,
-       xfs_drfsbno_t           *toti,
+       xfs_rfsblock_t          *totd,
+       xfs_rfsblock_t          *toti,
        xfs_extnum_t            *nex,
        blkmap_t                **blkmapp,
        int                     whichfork)
@@ -2575,13 +2576,13 @@ process_inode(
        xfs_extnum_t            nextents = 0;
        int                     nlink;
        int                     security;
-       xfs_drfsbno_t           totblocks;
-       xfs_drfsbno_t           totdblocks = 0;
-       xfs_drfsbno_t           totiblocks = 0;
+       xfs_rfsblock_t          totblocks;
+       xfs_rfsblock_t          totdblocks = 0;
+       xfs_rfsblock_t          totiblocks = 0;
        dbm_t                   type;
        xfs_extnum_t            anextents = 0;
-       xfs_drfsbno_t           atotdblocks = 0;
-       xfs_drfsbno_t           atotiblocks = 0;
+       xfs_rfsblock_t          atotdblocks = 0;
+       xfs_rfsblock_t          atotiblocks = 0;
        xfs_qcnt_t              bc = 0;
        xfs_qcnt_t              ic = 0;
        xfs_qcnt_t              rc = 0;
@@ -2732,7 +2733,8 @@ process_inode(
                        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_gquotino ||
+                        id->ino == mp->m_sb.sb_pquotino) {
                        type = DBM_QUOTA;
                        blkmap = blkmap_alloc(idic.di_nextents);
                        addlink_inode(id);
@@ -2853,7 +2855,7 @@ process_inode(
                         (mp->m_sb.sb_qflags & XFS_GQUOTA_ACCT) &&
                         (mp->m_sb.sb_qflags & XFS_GQUOTA_CHKD))
                        process_quota(IS_GROUP_QUOTA, id, blkmap);
-               else if (id->ino == mp->m_sb.sb_gquotino &&
+               else if (id->ino == mp->m_sb.sb_pquotino &&
                         (mp->m_sb.sb_qflags & XFS_PQUOTA_ACCT) &&
                         (mp->m_sb.sb_qflags & XFS_PQUOTA_CHKD))
                        process_quota(IS_PROJECT_QUOTA, id, blkmap);
@@ -2868,8 +2870,8 @@ process_lclinode(
        inodata_t               *id,
        xfs_dinode_t            *dip,
        dbm_t                   type,
-       xfs_drfsbno_t           *totd,
-       xfs_drfsbno_t           *toti,
+       xfs_rfsblock_t          *totd,
+       xfs_rfsblock_t          *toti,
        xfs_extnum_t            *nex,
        blkmap_t                **blkmapp,
        int                     whichfork)
@@ -2923,14 +2925,14 @@ process_leaf_node_dir_v2(
        v2 = verbose || id->ilist;
        v = parent = 0;
        dbno = NULLFILEOFF;
-       freetab = malloc(FREETAB_SIZE(dirsize / mp->m_dirblksize));
-       freetab->naents = (int)(dirsize / mp->m_dirblksize);
+       freetab = malloc(FREETAB_SIZE(dirsize / mp->m_dir_geo->blksize));
+       freetab->naents = (int)(dirsize / mp->m_dir_geo->blksize);
        freetab->nents = 0;
        for (i = 0; i < freetab->naents; i++)
                freetab->ents[i] = NULLDATAOFF;
        dir_hash_init();
        while ((dbno = blkmap_next_off(blkmap, dbno, &t)) != NULLFILEOFF) {
-               nex = blkmap_getn(blkmap, dbno, mp->m_dirblkfsbs, &bmp);
+               nex = blkmap_getn(blkmap, dbno, mp->m_dir_geo->fsbcount, &bmp);
                ASSERT(nex > 0);
                for (v = v2, x = 0; !v && x < nex; x++) {
                        for (b = bmp[x].startblock;
@@ -2941,12 +2943,12 @@ process_leaf_node_dir_v2(
                if (v)
                        dbprintf(_("dir inode %lld block %u=%llu\n"), id->ino,
                                (__uint32_t)dbno,
-                               (xfs_dfsbno_t)bmp->startblock);
+                               (xfs_fsblock_t)bmp->startblock);
                push_cur();
                if (nex > 1)
                        make_bbmap(&bbmap, nex, bmp);
                set_cur(&typtab[TYP_DIR2], XFS_FSB_TO_DADDR(mp, bmp->startblock),
-                       mp->m_dirblkfsbs * blkbb, DB_RING_IGN,
+                       mp->m_dir_geo->fsbcount * blkbb, DB_RING_IGN,
                        nex > 1 ? &bbmap : NULL);
                free(bmp);
                if (iocur_top->data == NULL) {
@@ -2956,10 +2958,10 @@ process_leaf_node_dir_v2(
                                        (__uint32_t)dbno, id->ino);
                        error++;
                        pop_cur();
-                       dbno += mp->m_dirblkfsbs - 1;
+                       dbno += mp->m_dir_geo->fsbcount - 1;
                        continue;
                }
-               if (dbno < mp->m_dirleafblk) {
+               if (dbno < mp->m_dir_geo->leafblk) {
                        lino = process_data_dir_v2(dot, dotdot, id, v,
                                (xfs_dablk_t)dbno, &freetab);
                        if (lino) {
@@ -2972,7 +2974,7 @@ process_leaf_node_dir_v2(
                                } else
                                        parent = lino;
                        }
-               } else if (dbno < mp->m_dirfreeblk) {
+               } else if (dbno < mp->m_dir_geo->freeblk) {
                        process_leaf_node_dir_v2_int(id, v, (xfs_dablk_t)dbno,
                                freetab);
                } else {
@@ -2980,7 +2982,7 @@ process_leaf_node_dir_v2(
                                freetab);
                }
                pop_cur();
-               dbno += mp->m_dirblkfsbs - 1;
+               dbno += mp->m_dir_geo->fsbcount - 1;
        }
        dir_hash_check(id, v);
        dir_hash_done();
@@ -2989,7 +2991,7 @@ process_leaf_node_dir_v2(
                        if (!sflag || v)
                                dbprintf(_("missing free index for data block %d "
                                         "in dir ino %lld\n"),
-                                       xfs_dir2_db_to_da(mp, i), id->ino);
+                                       xfs_dir2_db_to_da(mp->m_dir_geo, i), id->ino);
                        error++;
                }
        }
@@ -3019,9 +3021,9 @@ process_leaf_node_dir_v2_free(
                error++;
                return;
        }
-       maxent = xfs_dir3_free_max_bests(mp);
-       if (be32_to_cpu(free->hdr.firstdb) != xfs_dir2_da_to_db(mp, 
-                                       dabno - mp->m_dirfreeblk) * maxent) {
+       maxent = M_DIROPS(mp)->free_max_bests(mp->m_dir_geo);
+       if (be32_to_cpu(free->hdr.firstdb) != xfs_dir2_da_to_db(mp->m_dir_geo
+                                       dabno - mp->m_dir_geo->freeblk) * maxent) {
                if (!sflag || v)
                        dbprintf(_("bad free block firstdb %d for dir ino %lld "
                                 "block %d\n"),
@@ -3101,15 +3103,15 @@ process_leaf_node_dir_v2_int(
                                        id->ino, dabno);
                        error++;
                }
-               if (dabno != mp->m_dirleafblk) {
+               if (dabno != mp->m_dir_geo->leafblk) {
                        if (!sflag || v)
                                dbprintf(_("single leaf block for dir ino %lld "
                                         "block %d should be at block %d\n"),
                                        id->ino, dabno,
-                                       (xfs_dablk_t)mp->m_dirleafblk);
+                                       (xfs_dablk_t)mp->m_dir_geo->leafblk);
                        error++;
                }
-               ltp = xfs_dir2_leaf_tail_p(mp, leaf);
+               ltp = xfs_dir2_leaf_tail_p(mp->m_dir_geo, leaf);
                lbp = xfs_dir2_leaf_bests_p(ltp);
                for (i = 0; i < be32_to_cpu(ltp->bestcount); i++) {
                        if (freetab->nents <= i || freetab->ents[i] != 
@@ -3122,7 +3124,7 @@ process_leaf_node_dir_v2_int(
                                                        NULLDATAOFF :
                                                        freetab->ents[i],
                                                id->ino,
-                                               xfs_dir2_db_to_da(mp, i),
+                                               xfs_dir2_db_to_da(mp->m_dir_geo, i),
                                                be16_to_cpu(lbp[i]));
                        }
                        if (freetab->nents > i)
@@ -3135,7 +3137,7 @@ process_leaf_node_dir_v2_int(
                break;
        case XFS_DA_NODE_MAGIC:
                node = iocur_top->data;
-               xfs_da3_node_hdr_from_disk(&nodehdr, node);
+               M_DIROPS(mp)->node_hdr_from_disk(&nodehdr, node);
                if (nodehdr.level < 1 || nodehdr.level > XFS_DA_NODE_MAXDEPTH) {
                        if (!sflag || v)
                                dbprintf(_("bad node block level %d for dir ino "
@@ -3154,7 +3156,7 @@ process_leaf_node_dir_v2_int(
                error++;
                return;
        }
-       lep = xfs_dir3_leaf_ents_p(leaf);
+       lep = M_DIROPS(mp)->leaf_ents_p(leaf);
        for (i = stale = 0; i < be16_to_cpu(leaf->hdr.count); i++) {
                if (be32_to_cpu(lep[i].address) == XFS_DIR2_NULL_DATAPTR)
                        stale++;
@@ -3228,8 +3230,8 @@ process_quota(
                        if (scicb)
                                dbprintf(_("can't read block %lld for %s quota "
                                         "inode (fsblock %lld)\n"),
-                                       (xfs_dfiloff_t)qbno, s,
-                                       (xfs_dfsbno_t)bno);
+                                       (xfs_fileoff_t)qbno, s,
+                                       (xfs_fsblock_t)bno);
                        error++;
                        pop_cur();
                        continue;
@@ -3238,7 +3240,7 @@ process_quota(
                        if (verbose || id->ilist || cb)
                                dbprintf(_("%s dqblk %lld entry %d id %u bc "
                                         "%lld ic %lld rc %lld\n"),
-                                       s, (xfs_dfiloff_t)qbno, i, dqid,
+                                       s, (xfs_fileoff_t)qbno, i, dqid,
                                        be64_to_cpu(dqb->dd_diskdq.d_bcount),
                                        be64_to_cpu(dqb->dd_diskdq.d_icount),
                                        be64_to_cpu(dqb->dd_diskdq.d_rtbcount));
@@ -3247,7 +3249,7 @@ process_quota(
                                        dbprintf(_("bad magic number %#x for %s "
                                                 "dqblk %lld entry %d id %u\n"),
                                                be16_to_cpu(dqb->dd_diskdq.d_magic), s,
-                                               (xfs_dfiloff_t)qbno, i, dqid);
+                                               (xfs_fileoff_t)qbno, i, dqid);
                                error++;
                                continue;
                        }
@@ -3257,7 +3259,7 @@ process_quota(
                                                 "%s dqblk %lld entry %d id "
                                                 "%u\n"),
                                                dqb->dd_diskdq.d_version, s,
-                                               (xfs_dfiloff_t)qbno, i, dqid);
+                                               (xfs_fileoff_t)qbno, i, dqid);
                                error++;
                                continue;
                        }
@@ -3266,7 +3268,7 @@ process_quota(
                                        dbprintf(_("bad flags %#x for %s dqblk "
                                                 "%lld entry %d id %u\n"),
                                                dqb->dd_diskdq.d_flags, s,
-                                               (xfs_dfiloff_t)qbno, i, dqid);
+                                               (xfs_fileoff_t)qbno, i, dqid);
                                error++;
                                continue;
                        }
@@ -3275,7 +3277,7 @@ process_quota(
                                        dbprintf(_("bad id %u for %s dqblk %lld "
                                                 "entry %d id %u\n"),
                                                be32_to_cpu(dqb->dd_diskdq.d_id), s,
-                                               (xfs_dfiloff_t)qbno, i, dqid);
+                                               (xfs_fileoff_t)qbno, i, dqid);
                                error++;
                                continue;
                        }
@@ -3299,12 +3301,12 @@ process_rtbitmap(
        int             bitsperblock;
        xfs_fileoff_t   bmbno;
        xfs_fsblock_t   bno;
-       xfs_drtbno_t    extno;
+       xfs_rtblock_t   extno;
        int             len;
        int             log;
        int             offs;
        int             prevbit;
-       xfs_drfsbno_t   rtbno;
+       xfs_rfsblock_t  rtbno;
        int             start_bmbno;
        int             start_bit;
        int             t;
@@ -3320,7 +3322,7 @@ process_rtbitmap(
                        if (!sflag)
                                dbprintf(_("block %lld for rtbitmap inode is "
                                         "missing\n"),
-                                       (xfs_dfiloff_t)bmbno);
+                                       (xfs_fileoff_t)bmbno);
                        error++;
                        continue;
                }
@@ -3331,7 +3333,7 @@ process_rtbitmap(
                        if (!sflag)
                                dbprintf(_("can't read block %lld for rtbitmap "
                                         "inode\n"),
-                                       (xfs_dfiloff_t)bmbno);
+                                       (xfs_fileoff_t)bmbno);
                        error++;
                        pop_cur();
                        continue;
@@ -3387,7 +3389,7 @@ process_rtsummary(
                        if (!sflag)
                                dbprintf(_("block %lld for rtsummary inode is "
                                         "missing\n"),
-                                       (xfs_dfiloff_t)sumbno);
+                                       (xfs_fileoff_t)sumbno);
                        error++;
                        continue;
                }
@@ -3398,7 +3400,7 @@ process_rtsummary(
                        if (!sflag)
                                dbprintf(_("can't read block %lld for rtsummary "
                                         "inode\n"),
-                                       (xfs_dfiloff_t)sumbno);
+                                       (xfs_fileoff_t)sumbno);
                        error++;
                        pop_cur();
                        continue;
@@ -3432,9 +3434,9 @@ process_sf_dir_v2(
                dbprintf(_("dir %lld entry . %lld\n"), id->ino, id->ino);
        (*dot)++;
        sfe = xfs_dir2_sf_firstentry(sf);
-       offset = XFS_DIR3_DATA_FIRST_OFFSET(mp);
+       offset = M_DIROPS(mp)->data_first_offset;
        for (i = sf->count - 1, i8 = 0; i >= 0; i--) {
-               if ((__psint_t)sfe + xfs_dir2_sf_entsize(sf, sfe->namelen) -
+               if ((__psint_t)sfe + M_DIROPS(mp)->sf_entsize(sf, sfe->namelen) -
                    (__psint_t)sf > be64_to_cpu(dip->di_size)) {
                        if (!sflag)
                                dbprintf(_("dir %llu bad size in entry at %d\n"),
@@ -3443,7 +3445,7 @@ process_sf_dir_v2(
                        error++;
                        break;
                }
-               lino = xfs_dir2_sfe_get_ino(sf, sfe);
+               lino = M_DIROPS(mp)->sf_get_ino(sf, sfe);
                if (lino > XFS_DIR2_MAX_SHORT_INUM)
                        i8++;
                cid = find_inode(lino, 1);
@@ -3473,8 +3475,8 @@ process_sf_dir_v2(
                }
                offset =
                        xfs_dir2_sf_get_offset(sfe) +
-                       xfs_dir2_sf_entsize(sf, sfe->namelen);
-               sfe = xfs_dir2_sf_nextentry(sf, sfe);
+                       M_DIROPS(mp)->sf_entsize(sf, sfe->namelen);
+               sfe = M_DIROPS(mp)->sf_nextentry(sf, sfe);
        }
        if (i < 0 && (__psint_t)sfe - (__psint_t)sf != 
                                        be64_to_cpu(dip->di_size)) {
@@ -3485,12 +3487,12 @@ process_sf_dir_v2(
                error++;
        }
        if (offset + (sf->count + 2) * sizeof(xfs_dir2_leaf_entry_t) +
-           sizeof(xfs_dir2_block_tail_t) > mp->m_dirblksize) {
+           sizeof(xfs_dir2_block_tail_t) > mp->m_dir_geo->blksize) {
                if (!sflag)
                        dbprintf(_("dir %llu offsets too high\n"), id->ino);
                error++;
        }
-       lino = xfs_dir2_sf_get_parent_ino(sf);
+       lino = M_DIROPS(mp)->sf_get_parent_ino(sf);
        if (lino > XFS_DIR2_MAX_SHORT_INUM)
                i8++;
        cid = find_inode(lino, 1);
@@ -3624,8 +3626,8 @@ quota_init(void)
               mp->m_sb.sb_gquotino != NULLFSINO &&
               (mp->m_sb.sb_qflags & XFS_GQUOTA_ACCT) &&
               (mp->m_sb.sb_qflags & XFS_GQUOTA_CHKD);
-       qpdo = mp->m_sb.sb_gquotino != 0 &&
-              mp->m_sb.sb_gquotino != NULLFSINO &&
+       qpdo = mp->m_sb.sb_pquotino != 0 &&
+              mp->m_sb.sb_pquotino != NULLFSINO &&
               (mp->m_sb.sb_qflags & XFS_PQUOTA_ACCT) &&
               (mp->m_sb.sb_qflags & XFS_PQUOTA_CHKD);
        if (qudo)
@@ -3883,8 +3885,8 @@ scan_lbtree(
        scan_lbtree_f_t func,
        dbm_t           type,
        inodata_t       *id,
-       xfs_drfsbno_t   *totd,
-       xfs_drfsbno_t   *toti,
+       xfs_rfsblock_t  *totd,
+       xfs_rfsblock_t  *toti,
        xfs_extnum_t    *nex,
        blkmap_t        **blkmapp,
        int             isroot,
@@ -3939,8 +3941,8 @@ scanfunc_bmap(
        dbm_t                   type,
        xfs_fsblock_t           bno,
        inodata_t               *id,
-       xfs_drfsbno_t           *totd,
-       xfs_drfsbno_t           *toti,
+       xfs_rfsblock_t          *totd,
+       xfs_rfsblock_t          *toti,
        xfs_extnum_t            *nex,
        blkmap_t                **blkmapp,
        int                     isroot,
@@ -3979,7 +3981,7 @@ scanfunc_bmap(
                                         "in inode %lld bmap block %lld\n"),
                                        be16_to_cpu(block->bb_numrecs), mp->m_bmap_dmnr[0],
                                        mp->m_bmap_dmxr[0], id->ino,
-                                       (xfs_dfsbno_t)bno);
+                                       (xfs_fsblock_t)bno);
                        error++;
                        return;
                }
@@ -3995,7 +3997,7 @@ scanfunc_bmap(
                        dbprintf(_("bad btree nrecs (%u, min=%u, max=%u) in "
                                 "inode %lld bmap block %lld\n"),
                                be16_to_cpu(block->bb_numrecs), mp->m_bmap_dmnr[1],
-                               mp->m_bmap_dmxr[1], id->ino, (xfs_dfsbno_t)bno);
+                               mp->m_bmap_dmxr[1], id->ino, (xfs_fsblock_t)bno);
                error++;
                return;
        }
@@ -4220,7 +4222,7 @@ scanfunc_ino(
                        set_cur(&typtab[TYP_INODE],
                                XFS_AGB_TO_DADDR(mp, seqno,
                                                 XFS_AGINO_TO_AGBNO(mp, agino)),
-                               (int)XFS_FSB_TO_BB(mp, XFS_IALLOC_BLOCKS(mp)),
+                               (int)XFS_FSB_TO_BB(mp, mp->m_ialloc_blks),
                                DB_RING_IGN, NULL);
                        if (iocur_top->data == NULL) {
                                if (!sflag)
@@ -4304,7 +4306,7 @@ set_inomap(
 
 static void
 set_rdbmap(
-       xfs_drfsbno_t   bno,
+       xfs_rfsblock_t  bno,
        xfs_extlen_t    len,
        dbm_t           type)
 {
@@ -4313,7 +4315,7 @@ set_rdbmap(
 
 static void
 set_rinomap(
-       xfs_drfsbno_t   bno,
+       xfs_rfsblock_t  bno,
        xfs_extlen_t    len,
        inodata_t       *id)
 {