VirtualBox

Changeset 19202 in vbox for trunk/src/VBox/Devices/Storage


Ignore:
Timestamp:
Apr 27, 2009 9:51:03 AM (16 years ago)
Author:
vboxsync
Message:

Storage/VDI: fix several bugs with compaction, deal with images which have no allocated data blocks, get the same block detection right and terminate the loop searching for a block to move into a bubble

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/Storage/VDIHDDCore.cpp

    r19176 r19202  
    18921892        AssertRCBreak(rc);
    18931893        unsigned cBlocksAllocated = (unsigned)((cbFile - pImage->offStartData - pImage->offStartBlockData) >> pImage->uShiftOffset2Index);
     1894        if (cBlocksAllocated == 0)
     1895        {
     1896            /* No data blocks in this image, no need to compact. */
     1897            rc = VINF_SUCCESS;
     1898            break;
     1899        }
    18941900
    18951901        /* Allocate block array for back resolving. */
     
    19651971                    if (RT_FAILURE(rc))
    19661972                        break;
    1967                     if (memcmp(pvTmp, pvBuf, cbBlock))
     1973                    if (!memcmp(pvTmp, pvBuf, cbBlock))
    19681974                    {
    19691975                        pImage->paBlocks[i] = VDI_IMAGE_BLOCK_FREE;
     
    19982004            if (uBlock == VDI_IMAGE_BLOCK_FREE)
    19992005            {
    2000                 unsigned uBlockData;
    2001                 do {
     2006                unsigned uBlockData = VDI_IMAGE_BLOCK_FREE;
     2007                while (uBlockUsedPos > i && uBlockData == VDI_IMAGE_BLOCK_FREE)
     2008                {
    20022009                    uBlockUsedPos--;
    20032010                    uBlockData = paBlocks2[uBlockUsedPos];
    2004                 } while (uBlockUsedPos > i && uBlockData == VDI_IMAGE_BLOCK_FREE);
     2011                }
    20052012                /* Terminate early if there is no block which needs copying. */
    20062013                if (uBlockUsedPos == i)
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette