]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
fix size calculation bug in repairs memory allocation,
authorSteve Lord <lord@sgi.com>
Fri, 4 Oct 2002 15:54:21 +0000 (15:54 +0000)
committerSteve Lord <lord@sgi.com>
Fri, 4 Oct 2002 15:54:21 +0000 (15:54 +0000)
reduces memory by a factor of 4.
change array size calculation

repair/incore.c
repair/phase4.c

index 410b521ebe1ac19b105cf218e5ade1a5a80b5624..3c373f9845ebe87957287ca2e41a4a628f3d8590 100644 (file)
@@ -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;
index 5e341167f513e33f376b26bea6f2c5973b430d7d..3c755c6b3374fd9bf1996303cb614df42d2c3006 100644 (file)
@@ -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);