]> www.infradead.org Git - users/hch/xfsprogs.git/commitdiff
repair: use xfs_validate_rt_geometry
authorChristoph Hellwig <hch@lst.de>
Mon, 29 Jul 2024 23:54:37 +0000 (16:54 -0700)
committerChristoph Hellwig <hch@lst.de>
Tue, 30 Jul 2024 01:07:29 +0000 (18:07 -0700)
Use shared libxfs code with the kernel instead of reimplementing it.

Signed-off-by: Christoph Hellwig <hch@lst.de>
libxfs/libxfs_api_defs.h
repair/sb.c

index 021e60232d2b91e76ea9d349815470303df21daf..e2070849e1670e6769029aca6a42ccf232d80e8b 100644 (file)
 
 #define xfs_update_secondary_sbs       libxfs_update_secondary_sbs
 
+#define xfs_validate_rt_geometry       libxfs_validate_rt_geometry
 #define xfs_validate_stripe_geometry   libxfs_validate_stripe_geometry
 #define xfs_verify_agbno               libxfs_verify_agbno
 #define xfs_verify_agbext              libxfs_verify_agbext
index 243c00e10bc1de9c2c50bc7319cd558fb1c53501..7f27833d697ea9046f61898d1f24f3a3b2993c56 100644 (file)
@@ -450,44 +450,8 @@ verify_sb(char *sb_buf, xfs_sb_t *sb, int is_primary_sb)
                        return(XR_BAD_SECT_SIZE_DATA);
        }
 
-       /*
-        * real-time extent size is always set
-        */
-       if (sb->sb_rextsize * sb->sb_blocksize > XFS_MAX_RTEXTSIZE)
-               return(XR_BAD_RT_GEO_DATA);
-
-       if (sb->sb_rextsize * sb->sb_blocksize < XFS_MIN_RTEXTSIZE)
-                       return(XR_BAD_RT_GEO_DATA);
-
-       if (sb->sb_rblocks == 0)  {
-               if (sb->sb_rextents != 0)
-                       return(XR_BAD_RT_GEO_DATA);
-
-               if (sb->sb_rbmblocks != 0)
-                       return(XR_BAD_RT_GEO_DATA);
-
-               if (sb->sb_rextslog != 0)
-                       return(XR_BAD_RT_GEO_DATA);
-
-               if (sb->sb_frextents != 0)
-                       return(XR_BAD_RT_GEO_DATA);
-       } else  {
-               /*
-                * if we have a real-time partition, sanity-check geometry
-                */
-               if (sb->sb_rblocks / sb->sb_rextsize != sb->sb_rextents)
-                       return(XR_BAD_RT_GEO_DATA);
-
-               if (sb->sb_rextents == 0)
-                       return XR_BAD_RT_GEO_DATA;
-
-               if (sb->sb_rextslog != libxfs_compute_rextslog(sb->sb_rextents))
-                       return(XR_BAD_RT_GEO_DATA);
-
-               if (sb->sb_rbmblocks != (xfs_extlen_t) howmany(sb->sb_rextents,
-                                               NBBY * sb->sb_blocksize))
-                       return(XR_BAD_RT_GEO_DATA);
-       }
+       if (!libxfs_validate_rt_geometry(sb))
+               return XR_BAD_RT_GEO_DATA;
 
        /*
         * verify correctness of inode alignment if it's there