VirtualBox

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


Ignore:
Timestamp:
May 19, 2009 2:06:34 PM (16 years ago)
Author:
vboxsync
Message:

Storage/VHD: cooperate with VBoxHDD to suppress redundant writes

File:
1 edited

Legend:

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

    r19737 r19824  
    10461046
    10471047        /*
     1048         * Clip write range.
     1049         */
     1050        cbToWrite = RT_MIN(cbToWrite, (pImage->cbDataBlock - (cBATEntryIndex * VHD_SECTOR_SIZE)));
     1051
     1052        /*
    10481053         * If the block is not allocated the content of the entry is ~0
    10491054         * and we need to allocate a new block. Note that while blocks are
     
    10511056         * own bitmap entry, indicating whether it has been written or not.
    10521057         * So that means for the purposes of the higher level that the
    1053          * granularity is invisible.
     1058         * granularity is invisible. This means there's no need to return
     1059         * VERR_VD_BLOCK_FREE unless the block hasn't been allocated yet.
    10541060         */
    10551061        if (pImage->pBlockAllocationTable[cBlockAllocationTableEntry] == ~0U)
    10561062        {
     1063            /* Check if the block allocation should be suppressed. */
     1064            if (fWrite & VD_WRITE_NO_ALLOC)
     1065            {
     1066                *pcbPreRead = cBATEntryIndex * VHD_SECTOR_SIZE;
     1067                *pcbPostRead = pImage->cSectorsPerDataBlock * VHD_SECTOR_SIZE - cbToWrite - *pcbPreRead;
     1068                return VERR_VD_BLOCK_FREE;
     1069            }
     1070
    10571071            size_t  cbNewBlock = (pImage->cbDataBlock + pImage->cbDataBlockBitmap) * sizeof(uint8_t);
    10581072            uint8_t *pNewBlock = (uint8_t *)RTMemAllocZ(cbNewBlock);
     
    10791093        uVhdOffset = ((uint64_t)pImage->pBlockAllocationTable[cBlockAllocationTableEntry] + pImage->cDataBlockBitmapSectors + cBATEntryIndex) * VHD_SECTOR_SIZE;
    10801094
    1081         /*
    1082          * Clip write range.
    1083          */
    1084         cbToWrite = RT_MIN(cbToWrite, (pImage->cbDataBlock - (cBATEntryIndex * VHD_SECTOR_SIZE)));
     1095        /* Write data. */
    10851096        RTFileWriteAt(pImage->File, uVhdOffset, pvBuf, cbToWrite, NULL);
    10861097
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