]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
xfs_repair: remove verify_aginum
authorDarrick J. Wong <darrick.wong@oracle.com>
Fri, 10 Jul 2020 19:35:45 +0000 (15:35 -0400)
committerEric Sandeen <sandeen@sandeen.net>
Fri, 10 Jul 2020 19:35:45 +0000 (15:35 -0400)
Replace this homegrown inode pointer verification function with the
libxfs checking helper.  This one is a little tricky because this
function (unlike all of its verify_* siblings) returned 1 for bad and 0
for good, so we must invert the checking logic.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
libxfs/libxfs_api_defs.h
repair/dino_chunks.c
repair/dinode.c
repair/dinode.h
repair/scan.c

index 69f79a0887ef693e4b69cd60c19abdb183cffdd1..be06c763aed57a86ba3e17b20b7e392d02076143 100644 (file)
 #define xfs_trans_roll                 libxfs_trans_roll
 
 #define xfs_verify_agbno               libxfs_verify_agbno
+#define xfs_verify_agino               libxfs_verify_agino
 #define xfs_verify_cksum               libxfs_verify_cksum
 #define xfs_verify_dir_ino             libxfs_verify_dir_ino
 #define xfs_verify_fsbno               libxfs_verify_fsbno
index 6685a4d23b02b3557a7c22917a403ba802143a2e..399d499880a1f6cc797c558641a1a649348cfa99 100644 (file)
@@ -1124,7 +1124,7 @@ check_uncertain_aginodes(xfs_mount_t *mp, xfs_agnumber_t agno)
 
                        agino = i + irec->ino_startnum;
 
-                       if (verify_aginum(mp, agno, agino))
+                       if (!libxfs_verify_agino(mp, agno, agino))
                                continue;
 
                        if (nrec != NULL && nrec->ino_startnum <= agino &&
@@ -1133,7 +1133,7 @@ check_uncertain_aginodes(xfs_mount_t *mp, xfs_agnumber_t agno)
                                continue;
 
                        if ((nrec = find_inode_rec(mp, agno, agino)) == NULL)
-                               if (!verify_aginum(mp, agno, agino))
+                               if (libxfs_verify_agino(mp, agno, agino))
                                        if (verify_aginode_chunk(mp, agno,
                                                        agino, &start))
                                                got_some = 1;
@@ -1215,7 +1215,7 @@ process_uncertain_aginodes(xfs_mount_t *mp, xfs_agnumber_t agno)
                         * good tree), bad inode numbers, and inode numbers
                         * pointing to bogus inodes
                         */
-                       if (verify_aginum(mp, agno, agino))
+                       if (!libxfs_verify_agino(mp, agno, agino))
                                continue;
 
                        if (nrec != NULL && nrec->ino_startnum <= agino &&
index 67adddd705dfa560c8f23c4e64fac3b428e32337..526ecde3fd7ccb5db1c912a88e7f29d77b6e9c6c 100644 (file)
@@ -152,57 +152,6 @@ clear_dinode(xfs_mount_t *mp, xfs_dinode_t *dino, xfs_ino_t ino_num)
  * misc. inode-related utility routines
  */
 
-/*
- * verify_ag_bno is heavily used. In the common case, it
- * performs just two number of compares
- * Returns 1 for bad ag/bno pair or 0 if it's valid.
- */
-static __inline int
-verify_ag_bno(xfs_sb_t *sbp,
-               xfs_agnumber_t agno,
-               xfs_agblock_t agbno)
-{
-       if (agno < (sbp->sb_agcount - 1))
-               return (agbno >= sbp->sb_agblocks);
-       if (agno == (sbp->sb_agcount - 1))
-               return (agbno >= (sbp->sb_dblocks -
-                               ((xfs_rfsblock_t)(sbp->sb_agcount - 1) *
-                                sbp->sb_agblocks)));
-       return 1;
-}
-
-/*
- * have a separate routine to ensure that we don't accidentally
- * lose illegally set bits in the agino by turning it into an FSINO
- * to feed to the above routine
- */
-int
-verify_aginum(xfs_mount_t      *mp,
-               xfs_agnumber_t  agno,
-               xfs_agino_t     agino)
-{
-       xfs_agblock_t   agbno;
-       xfs_sb_t        *sbp = &mp->m_sb;;
-
-       /* range check ag #, ag block.  range-checking offset is pointless */
-
-       if (agino == 0 || agino == NULLAGINO)
-               return(1);
-
-       /*
-        * agino's can't be too close to NULLAGINO because the min blocksize
-        * is 9 bits and at most 1 bit of that gets used for the inode offset
-        * so if the agino gets shifted by the # of offset bits and compared
-        * to the legal agbno values, a bogus agino will be too large.  there
-        * will be extra bits set at the top that shouldn't be set.
-        */
-       agbno = XFS_AGINO_TO_AGBNO(mp, agino);
-       if (agbno == 0)
-               return 1;
-
-       return verify_ag_bno(sbp, agno, agbno);
-}
-
 #define XR_DFSBNORANGE_VALID   0
 #define XR_DFSBNORANGE_BADSTART        1
 #define XR_DFSBNORANGE_BADEND  2
index 4bf7affddde4a703d8b222bcb5a8ca0d0682e6a0..1bd0e0b7225a450dffe3461750b42658122b8666 100644 (file)
@@ -68,11 +68,6 @@ verify_uncertain_dinode(xfs_mount_t *mp,
                xfs_agnumber_t agno,
                xfs_agino_t ino);
 
-int
-verify_aginum(xfs_mount_t      *mp,
-               xfs_agnumber_t  agno,
-               xfs_agino_t     agino);
-
 int
 process_uncertain_aginodes(xfs_mount_t         *mp,
                                xfs_agnumber_t  agno);
index dcd4864d7302f355f5af8102b9302ef4da455ea5..760792477cfb699ebcb6f9573c1974a7041430d8 100644 (file)
@@ -1561,7 +1561,7 @@ verify_single_ino_chunk_align(
         * (NULLAGINO). if it gets closer, the agino number will be illegal as
         * the agbno will be too large.
         */
-       if (verify_aginum(mp, agno, ino)) {
+       if (!libxfs_verify_agino(mp, agno, ino)) {
                do_warn(
 _("bad starting inode # (%" PRIu64 " (0x%x 0x%x)) in %s rec, skipping rec\n"),
                        lino, agno, ino, inobt_name);
@@ -1569,7 +1569,7 @@ _("bad starting inode # (%" PRIu64 " (0x%x 0x%x)) in %s rec, skipping rec\n"),
                return ++suspect;
        }
 
-       if (verify_aginum(mp, agno,
+       if (!libxfs_verify_agino(mp, agno,
                        ino + XFS_INODES_PER_CHUNK - 1)) {
                do_warn(
 _("bad ending inode # (%" PRIu64 " (0x%x 0x%zx)) in %s rec, skipping rec\n"),