From 742c5e97adac6603249787b22f956454b2d0d5de Mon Sep 17 00:00:00 2001 From: "Darrick J. Wong" Date: Mon, 15 Apr 2024 16:07:29 -0700 Subject: [PATCH] xfs_repair: convert helpers for rtbitmap block/wordcount computations Port xfs_repair to use the new helper functions that compute the number of blocks or words necessary to store the rt bitmap. Signed-off-by: Darrick J. Wong Reviewed-by: Christoph Hellwig Reviewed-by: Bill O'Donnell --- libxfs/libxfs_api_defs.h | 2 ++ repair/rt.c | 10 +++++----- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/libxfs/libxfs_api_defs.h b/libxfs/libxfs_api_defs.h index a16efa00..5180da2f 100644 --- a/libxfs/libxfs_api_defs.h +++ b/libxfs/libxfs_api_defs.h @@ -175,6 +175,8 @@ #define xfs_rmap_lookup_le_range libxfs_rmap_lookup_le_range #define xfs_rmap_query_range libxfs_rmap_query_range +#define xfs_rtbitmap_wordcount libxfs_rtbitmap_wordcount + #define xfs_rtfree_extent libxfs_rtfree_extent #define xfs_rtfree_blocks libxfs_rtfree_blocks #define xfs_sb_from_disk libxfs_sb_from_disk diff --git a/repair/rt.c b/repair/rt.c index 8f3b9082..244b59f0 100644 --- a/repair/rt.c +++ b/repair/rt.c @@ -19,6 +19,8 @@ void rtinit(xfs_mount_t *mp) { + unsigned long long wordcnt; + if (mp->m_sb.sb_rblocks == 0) return; @@ -26,11 +28,9 @@ rtinit(xfs_mount_t *mp) * realtime init -- blockmap initialization is * handled by incore_init() */ - /* - sumfile = calloc(mp->m_rsumsize, 1); - */ - if ((btmcompute = calloc(mp->m_sb.sb_rbmblocks * - mp->m_sb.sb_blocksize, 1)) == NULL) + wordcnt = libxfs_rtbitmap_wordcount(mp, mp->m_sb.sb_rextents); + btmcompute = calloc(wordcnt, sizeof(xfs_rtword_t)); + if (!btmcompute) do_error( _("couldn't allocate memory for incore realtime bitmap.\n")); -- 2.47.3