]> git.apps.os.sepia.ceph.com Git - xfsprogs-dev.git/commitdiff
xfs_repair: convert utility to use new rt extent helpers and types
authorDarrick J. Wong <djwong@kernel.org>
Mon, 15 Apr 2024 23:07:29 +0000 (16:07 -0700)
committerDarrick J. Wong <djwong@kernel.org>
Wed, 17 Apr 2024 21:06:23 +0000 (14:06 -0700)
Convert the repair program to use the new realtime extent types and
helper functions instead of open-coding them.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Bill O'Donnell <bodonnel@redhat.com>
db/check.c
repair/agheader.h
repair/dinode.c
repair/incore.c
repair/incore.h
repair/incore_ext.c
repair/phase4.c
repair/rt.c
repair/scan.c

index a47a5d9cb5b4a06d6ffe25b397572d2f9bb0a06f..6e06499b9eb34b4a3c91f44a267904785d9f3ecb 100644 (file)
@@ -3594,7 +3594,7 @@ process_rtbitmap(
        int             bitsperblock;
        xfs_fileoff_t   bmbno;
        xfs_fsblock_t   bno;
-       xfs_rtblock_t   extno;
+       xfs_rtxnum_t    extno;
        int             len;
        int             log;
        int             offs;
index a63827c87259fe55ec256c821be7d4b917a7c462..b4f81d5537906de2912e146380875954a4b58d0d 100644 (file)
@@ -11,7 +11,7 @@ typedef struct fs_geometry  {
        uint32_t        sb_blocksize;   /* blocksize (bytes) */
        xfs_rfsblock_t  sb_dblocks;     /* # data blocks */
        xfs_rfsblock_t  sb_rblocks;     /* # realtime blocks */
-       xfs_rtblock_t   sb_rextents;    /* # realtime extents */
+       xfs_rtxnum_t    sb_rextents;    /* # realtime extents */
        xfs_fsblock_t   sb_logstart;    /* starting log block # */
        xfs_agblock_t   sb_rextsize;    /* realtime extent size (blocks )*/
        xfs_agblock_t   sb_agblocks;    /* # of blocks per ag */
index c10dd1fa32251e913cc8fcaa53fa239ee5224432..c1cfadc8833e00f24f8d5b12ca7288b68089efe4 100644 (file)
@@ -193,13 +193,13 @@ process_rt_rec_dups(
        xfs_ino_t               ino,
        struct xfs_bmbt_irec    *irec)
 {
-       xfs_fsblock_t           b;
-       xfs_rtblock_t           ext;
+       xfs_rtblock_t           b;
+       xfs_rtxnum_t            ext;
 
-       for (b = rounddown(irec->br_startblock, mp->m_sb.sb_rextsize);
+       for (b = xfs_rtb_rounddown_rtx(mp, irec->br_startblock);
             b < irec->br_startblock + irec->br_blockcount;
             b += mp->m_sb.sb_rextsize) {
-               ext = (xfs_rtblock_t) b / mp->m_sb.sb_rextsize;
+               ext = xfs_rtb_to_rtx(mp, b);
                if (search_rt_dup_extent(mp, ext))  {
                        do_warn(
 _("data fork in rt ino %" PRIu64 " claims dup rt extent,"
@@ -222,14 +222,17 @@ process_rt_rec_state(
        struct xfs_bmbt_irec    *irec)
 {
        xfs_fsblock_t           b = irec->br_startblock;
-       xfs_rtblock_t           ext;
+       xfs_rtxnum_t            ext;
        int                     state;
 
        do {
-               ext = (xfs_rtblock_t)b / mp->m_sb.sb_rextsize;
+               xfs_extlen_t    mod;
+
+               ext = xfs_rtb_to_rtx(mp, b);
                state = get_rtbmap(ext);
 
-               if ((b % mp->m_sb.sb_rextsize) != 0) {
+               mod = xfs_rtb_to_rtxoff(mp, b);
+               if (mod) {
                        /*
                         * We are midway through a partially written extent.
                         * If we don't find the state that gets set in the
@@ -240,7 +243,7 @@ process_rt_rec_state(
                                do_error(
 _("data fork in rt inode %" PRIu64 " found invalid rt extent %"PRIu64" state %d at rt block %"PRIu64"\n"),
                                        ino, ext, state, b);
-                       b = roundup(b, mp->m_sb.sb_rextsize);
+                       b = xfs_rtb_roundup_rtx(mp, b);
                        continue;
                }
 
@@ -2232,7 +2235,7 @@ validate_extsize(
         */
        if ((flags & XFS_DIFLAG_EXTSZINHERIT) &&
            (flags & XFS_DIFLAG_RTINHERIT) &&
-           value % mp->m_sb.sb_rextsize > 0)
+           xfs_extlen_to_rtxmod(mp, value) > 0)
                misaligned = true;
 
        /*
index bf6ef72fd5ffba3d3c8abd6087f09dcb3c50a74d..2ed37a105ca708f22969846216bb8ec11ec75d0e 100644 (file)
@@ -178,7 +178,7 @@ static size_t               rt_bmap_size;
  */
 int
 get_rtbmap(
-       xfs_rtblock_t   rtx)
+       xfs_rtxnum_t    rtx)
 {
        return (*(rt_bmap + rtx /  XR_BB_NUM) >>
                ((rtx % XR_BB_NUM) * XR_BB)) & XR_BB_MASK;
@@ -186,7 +186,7 @@ get_rtbmap(
 
 void
 set_rtbmap(
-       xfs_rtblock_t   rtx,
+       xfs_rtxnum_t    rtx,
        int             state)
 {
        *(rt_bmap + rtx / XR_BB_NUM) =
index 02031dc17adbdb5ac515be72ed38ac71eff381be..9ad5f1972d3deef5ff4b9711ba9d32635ca1737f 100644 (file)
@@ -28,8 +28,8 @@ void          set_bmap_ext(xfs_agnumber_t agno, xfs_agblock_t agbno,
 int            get_bmap_ext(xfs_agnumber_t agno, xfs_agblock_t agbno,
                             xfs_agblock_t maxbno, xfs_extlen_t *blen);
 
-void           set_rtbmap(xfs_rtblock_t rtx, int state);
-int            get_rtbmap(xfs_rtblock_t rtx);
+void           set_rtbmap(xfs_rtxnum_t rtx, int state);
+int            get_rtbmap(xfs_rtxnum_t rtx);
 
 static inline void
 set_bmap(xfs_agnumber_t agno, xfs_agblock_t agbno, int state)
@@ -70,8 +70,8 @@ typedef struct extent_tree_node  {
 
 typedef struct rt_extent_tree_node  {
        avlnode_t               avl_node;
-       xfs_rtblock_t           rt_startrtx;    /* starting rt extent number */
-       xfs_extlen_t            rt_rtxlen;      /* number of rt extents */
+       xfs_rtxnum_t            rt_startrtx;    /* starting rt extent number */
+       xfs_rtxlen_t            rt_rtxlen;      /* number of rt extents */
        extent_state_t          rt_state;       /* see state flags below */
 
 #if 0
@@ -157,8 +157,8 @@ int         add_dup_extent(xfs_agnumber_t agno, xfs_agblock_t startblock,
                        xfs_extlen_t blockcount);
 int            search_dup_extent(xfs_agnumber_t agno,
                        xfs_agblock_t start_agbno, xfs_agblock_t end_agbno);
-void           add_rt_dup_extent(xfs_rtblock_t startrtx, xfs_extlen_t rtxlen);
-int            search_rt_dup_extent(struct xfs_mount *mp, xfs_rtblock_t rtx);
+void           add_rt_dup_extent(xfs_rtxnum_t startrtx, xfs_rtxlen_t rtxlen);
+int            search_rt_dup_extent(struct xfs_mount *mp, xfs_rtxnum_t rtx);
 
 /*
  * extent/tree recyling and deletion routines
index a8f5370bee1bad6940f99b025401b331dfb89a5c..59c5d6f502c308da5e707a611ae1cca3de48844f 100644 (file)
@@ -533,8 +533,8 @@ static avlops_t avl_extent_tree_ops = {
  */
 static rt_extent_tree_node_t *
 mk_rt_extent_tree_nodes(
-       xfs_rtblock_t                   new_startrtx,
-       xfs_extlen_t                    new_rtxlen,
+       xfs_rtxnum_t                    new_startrtx,
+       xfs_rtxlen_t                    new_rtxlen,
        extent_state_t                  new_state)
 {
        struct rt_extent_tree_node      *new;
@@ -603,12 +603,12 @@ free_rt_dup_extent_tree(xfs_mount_t *mp)
  */
 void
 add_rt_dup_extent(
-       xfs_rtblock_t                   startrtx,
-       xfs_extlen_t                    rtxlen)
+       xfs_rtxnum_t                    startrtx,
+       xfs_rtxlen_t                    rtxlen)
 {
        struct rt_extent_tree_node      *first, *last, *ext, *next_ext;
-       xfs_rtblock_t                   new_startrtx;
-       xfs_extlen_t                    new_rtxlen;
+       xfs_rtxnum_t                    new_startrtx;
+       xfs_rtxlen_t                    new_rtxlen;
 
        pthread_mutex_lock(&rt_ext_tree_lock);
        avl64_findranges(rt_ext_tree_ptr, startrtx - 1,
@@ -692,7 +692,7 @@ add_rt_dup_extent(
 int
 search_rt_dup_extent(
        struct xfs_mount        *mp,
-       xfs_rtblock_t           rtx)
+       xfs_rtxnum_t            rtx)
 {
        int                     ret;
 
index 7b9f20e32a55da80de53ec821ddfba53a6ef9116..e4c0e616ffd0309197ffea76c26ae80fdea97f4e 100644 (file)
@@ -250,9 +250,9 @@ void
 phase4(xfs_mount_t *mp)
 {
        ino_tree_node_t         *irec;
-       xfs_rtblock_t           rtx;
-       xfs_rtblock_t           rt_start;
-       xfs_extlen_t            rt_len;
+       xfs_rtxnum_t            rtx;
+       xfs_rtxnum_t            rt_start;
+       xfs_rtxlen_t            rt_len;
        xfs_agnumber_t          i;
        xfs_agblock_t           j;
        xfs_agblock_t           ag_end;
index 9f3bc8d53ec6002729685c6c73bee8e59a9438c1..8f3b9082a9b8eed615af1867e2ff0f74e7109098 100644 (file)
@@ -48,8 +48,8 @@ generate_rtinfo(xfs_mount_t   *mp,
                xfs_rtword_t    *words,
                xfs_suminfo_t   *sumcompute)
 {
-       xfs_rtblock_t   extno;
-       xfs_rtblock_t   start_ext;
+       xfs_rtxnum_t    extno;
+       xfs_rtxnum_t    start_ext;
        int             bitsperblock;
        int             bmbno;
        xfs_rtword_t    freebit;
index 7a0587615cb91e90673f610c126f71e657fd6e75..0a77dd67913bcfc060e508800854d9867ed68e9d 100644 (file)
@@ -402,7 +402,7 @@ _("bad state %d, inode %" PRIu64 " bmap block 0x%" PRIx64 "\n"),
                                        XFS_FSB_TO_AGBNO(mp, bno) + 1))
                                return(1);
                } else  {
-                       xfs_rtblock_t   ext = bno / mp->m_sb.sb_rextsize;
+                       xfs_rtxnum_t    ext = xfs_rtb_to_rtx(mp, bno);
 
                        if (search_rt_dup_extent(mp, ext))
                                return 1;