From: Darrick J. Wong <darrick.wong@xxxxxxxxxx> Refactor this function to use libxfs type checking helpers. Signed-off-by: Darrick J. Wong <darrick.wong@xxxxxxxxxx> Reviewed-by: Christoph Hellwig <hch@xxxxxx> --- libxfs/libxfs_api_defs.h | 1 + repair/dinode.c | 26 +++++++++----------------- 2 files changed, 10 insertions(+), 17 deletions(-) diff --git a/libxfs/libxfs_api_defs.h b/libxfs/libxfs_api_defs.h index c03f0efa..69f79a08 100644 --- a/libxfs/libxfs_api_defs.h +++ b/libxfs/libxfs_api_defs.h @@ -184,6 +184,7 @@ #define xfs_verify_agbno libxfs_verify_agbno #define xfs_verify_cksum libxfs_verify_cksum #define xfs_verify_dir_ino libxfs_verify_dir_ino +#define xfs_verify_fsbno libxfs_verify_fsbno #define xfs_verify_ino libxfs_verify_ino #define xfs_verify_rtbno libxfs_verify_rtbno #define xfs_zero_extent libxfs_zero_extent diff --git a/repair/dinode.c b/repair/dinode.c index b343534c..135703d9 100644 --- a/repair/dinode.c +++ b/repair/dinode.c @@ -228,31 +228,23 @@ verify_dfsbno(xfs_mount_t *mp, #define XR_DFSBNORANGE_OVERFLOW 3 static __inline int -verify_dfsbno_range(xfs_mount_t *mp, - xfs_fsblock_t fsbno, - xfs_filblks_t count) +verify_dfsbno_range( + struct xfs_mount *mp, + xfs_fsblock_t fsbno, + xfs_filblks_t count) { - xfs_agnumber_t agno; - xfs_agblock_t agbno; - xfs_sb_t *sbp = &mp->m_sb;; - /* the start and end blocks better be in the same allocation group */ - agno = XFS_FSB_TO_AGNO(mp, fsbno); - if (agno != XFS_FSB_TO_AGNO(mp, fsbno + count - 1)) { + if (XFS_FSB_TO_AGNO(mp, fsbno) != + XFS_FSB_TO_AGNO(mp, fsbno + count - 1)) { return XR_DFSBNORANGE_OVERFLOW; } - agbno = XFS_FSB_TO_AGBNO(mp, fsbno); - if (verify_ag_bno(sbp, agno, agbno)) { + if (!libxfs_verify_fsbno(mp, fsbno)) return XR_DFSBNORANGE_BADSTART; - } - - agbno = XFS_FSB_TO_AGBNO(mp, fsbno + count - 1); - if (verify_ag_bno(sbp, agno, agbno)) { + if (!libxfs_verify_fsbno(mp, fsbno + count - 1)) return XR_DFSBNORANGE_BADEND; - } - return (XR_DFSBNORANGE_VALID); + return XR_DFSBNORANGE_VALID; } static int