From df10f12a1e7299cebf9f0d94a0eef4077e507a0f Mon Sep 17 00:00:00 2001 From: Steve Lord Date: Fri, 4 Oct 2002 15:54:21 +0000 Subject: [PATCH] fix size calculation bug in repairs memory allocation, reduces memory by a factor of 4. change array size calculation --- repair/incore.c | 10 ++++------ repair/phase4.c | 2 +- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/repair/incore.c b/repair/incore.c index 410b521eb..3c373f984 100644 --- a/repair/incore.c +++ b/repair/incore.c @@ -72,7 +72,7 @@ void setup_bmap(xfs_agnumber_t agno, xfs_agblock_t numblocks, xfs_drtbno_t rtblocks) { int i; - xfs_drfsbno_t size; + size_t size = 0; ba_bmap = (__uint64_t**)malloc(agno*sizeof(__uint64_t *)); if (!ba_bmap) { @@ -80,9 +80,7 @@ setup_bmap(xfs_agnumber_t agno, xfs_agblock_t numblocks, xfs_drtbno_t rtblocks) return; } for (i = 0; i < agno; i++) { - int size; - - size = roundup(numblocks * (NBBY/XR_BB),sizeof(__uint64_t)); + size = roundup(numblocks / (NBBY/XR_BB),sizeof(__uint64_t)); ba_bmap[i] = (__uint64_t*)memalign(sizeof(__uint64_t), size); if (!ba_bmap[i]) { @@ -98,7 +96,7 @@ setup_bmap(xfs_agnumber_t agno, xfs_agblock_t numblocks, xfs_drtbno_t rtblocks) return; } - size = roundup(rtblocks * (NBBY/XR_BB), sizeof(__uint64_t)); + size = roundup(rtblocks / (NBBY/XR_BB), sizeof(__uint64_t)); rt_ba_bmap=(__uint64_t*)memalign(sizeof(__uint64_t), size); if (!rt_ba_bmap) { @@ -178,7 +176,7 @@ set_bmap_rt(xfs_drtbno_t num) * for now, initialize all realtime blocks to be free * (state == XR_E_FREE) */ - size = howmany(num * (NBBY/XR_BB), sizeof(__uint64_t)); + size = howmany(num / (NBBY/XR_BB), sizeof(__uint64_t)); for (j = 0; j < size; j++) rt_ba_bmap[j] = 0x2222222222222222LL; diff --git a/repair/phase4.c b/repair/phase4.c index 5e341167f..3c755c6b3 100644 --- a/repair/phase4.c +++ b/repair/phase4.c @@ -1294,7 +1294,7 @@ block %d\n", /* * now reset the bitmap for all ags */ - bzero(ba_bmap[i], roundup(mp->m_sb.sb_agblocks*(NBBY/XR_BB), + bzero(ba_bmap[i], roundup(mp->m_sb.sb_agblocks/(NBBY/XR_BB), sizeof(__uint64_t))); for (j = 0; j < ag_hdr_block; j++) set_agbno_state(mp, i, j, XR_E_INUSE_FS); -- 2.47.2