VirtualBox

Changeset 21060 in vbox for trunk/src/VBox/Devices


Ignore:
Timestamp:
Jun 30, 2009 9:57:42 AM (15 years ago)
Author:
vboxsync
Message:

VMDK: AsyncIO doesn't work with more than one FLAT extent yet and fix the async read/write code

File:
1 edited

Legend:

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

    r20640 r21060  
    30223022        if (uOpenFlags & VD_OPEN_FLAGS_ASYNC_IO)
    30233023        {
     3024            unsigned cFlatExtents = 0;
     3025
    30243026            for (unsigned i = 0; i < pImage->cExtents; i++)
    30253027            {
    30263028                PVMDKEXTENT pExtent = &pImage->pExtents[i];
    30273029
    3028                 if (    pExtent->enmType != VMDKETYPE_FLAT
    3029                     &&  pExtent->enmType != VMDKETYPE_ZERO
    3030                     &&  pExtent->enmType != VMDKETYPE_VMFS)
     3030                if ((    pExtent->enmType != VMDKETYPE_FLAT
     3031                     &&  pExtent->enmType != VMDKETYPE_ZERO
     3032                     &&  pExtent->enmType != VMDKETYPE_VMFS)
     3033                    || ((pImage->pExtents[i].enmType == VMDKETYPE_FLAT) && (cFlatExtents > 0)))
    30313034                {
    30323035                    /*
     
    30383041                    goto out;
    30393042                }
     3043                if (pExtent->enmType == VMDKETYPE_FLAT)
     3044                    cFlatExtents++;
    30403045            }
    30413046        }
     
    57315736    if (pImage)
    57325737    {
    5733         /* We only support async I/O support if the image only consists of FLAT or ZERO extents. */
     5738        unsigned cFlatExtents = 0;
     5739
     5740        /* We only support async I/O support if the image only consists of FLAT or ZERO extents.
     5741         *
     5742         * @todo: At the moment we only support async I/O if there is at most one FLAT extent
     5743         *        More than one doesn't work yet with the async I/O interface.
     5744         */
    57345745        fAsyncIOSupported = true;
    57355746        for (unsigned i = 0; i < pImage->cExtents; i++)
    57365747        {
    5737             if (    pImage->pExtents[i].enmType != VMDKETYPE_FLAT
    5738                 &&  pImage->pExtents[i].enmType != VMDKETYPE_ZERO
    5739                 &&  pImage->pExtents[i].enmType != VMDKETYPE_VMFS)
     5748            if ((    pImage->pExtents[i].enmType != VMDKETYPE_FLAT
     5749                 &&  pImage->pExtents[i].enmType != VMDKETYPE_ZERO
     5750                 &&  pImage->pExtents[i].enmType != VMDKETYPE_VMFS)
     5751                || ((pImage->pExtents[i].enmType == VMDKETYPE_FLAT) && (cFlatExtents > 0)))
    57405752            {
    57415753                fAsyncIOSupported = false;
    57425754                break; /* Stop search */
    57435755            }
     5756            if (pImage->pExtents[i].enmType == VMDKETYPE_FLAT)
     5757                cFlatExtents++;
    57445758        }
    57455759    }
     
    57525766{
    57535767    PVMDKIMAGE pImage = (PVMDKIMAGE)pvBackendData;
    5754     PVMDKEXTENT pExtent;
     5768    PVMDKEXTENT pExtent = NULL;
    57555769    int rc = VINF_SUCCESS;
    57565770    unsigned cSegments = 0;
     
    57585772    size_t cbLeftInCurrentSegment = paSegCurrent->cbSeg;
    57595773    size_t uOffsetInCurrentSegment = 0;
     5774    size_t cbReadLeft = cbRead;
     5775    uint64_t uOffCurr = uOffset;
    57605776
    57615777    AssertPtr(pImage);
     
    57705786    }
    57715787
    5772     while (cbRead && cSeg)
     5788    while (cbReadLeft && cSeg)
    57735789    {
    57745790        size_t cbToRead;
    57755791        uint64_t uSectorExtentRel;
    57765792
    5777         rc = vmdkFindExtent(pImage, VMDK_BYTE2SECTOR(uOffset),
     5793        rc = vmdkFindExtent(pImage, VMDK_BYTE2SECTOR(uOffCurr),
    57785794                            &pExtent, &uSectorExtentRel);
    57795795        if (RT_FAILURE(rc))
     
    58385854        }
    58395855
    5840         cbRead -= cbToRead;
    5841         uOffset += cbToRead;
     5856        cbReadLeft -= cbToRead;
     5857        uOffCurr  += cbToRead;
    58425858        cbLeftInCurrentSegment -= cbToRead;
    58435859        uOffsetInCurrentSegment += cbToRead;
     
    58525868    }
    58535869
    5854     AssertMsg(cbRead == 0, ("No segment left but there is still data to write\n"));
     5870    AssertMsg(cbReadLeft == 0, ("No segment left but there is still data to write\n"));
    58555871
    58565872    if (cSegments == 0)
     
    58785894{
    58795895    PVMDKIMAGE pImage = (PVMDKIMAGE)pvBackendData;
    5880     PVMDKEXTENT pExtent;
     5896    PVMDKEXTENT pExtent = NULL;
    58815897    int rc = VINF_SUCCESS;
    58825898    unsigned cSegments = 0;
     
    58845900    size_t cbLeftInCurrentSegment = paSegCurrent->cbSeg;
    58855901    size_t uOffsetInCurrentSegment = 0;
     5902    size_t cbWriteLeft = cbWrite;
     5903    uint64_t uOffCurr = uOffset;
    58865904
    58875905    AssertPtr(pImage);
     
    58965914    }
    58975915
    5898     while (cbWrite && cSeg)
     5916    while (cbWriteLeft && cSeg)
    58995917    {
    59005918        size_t cbToWrite;
    59015919        uint64_t uSectorExtentRel;
    59025920
    5903         rc = vmdkFindExtent(pImage, VMDK_BYTE2SECTOR(uOffset),
     5921        rc = vmdkFindExtent(pImage, VMDK_BYTE2SECTOR(uOffCurr),
    59045922                            &pExtent, &uSectorExtentRel);
    59055923        if (RT_FAILURE(rc))
     
    59645982        }
    59655983
    5966         cbWrite -= cbToWrite;
    5967         uOffset += cbToWrite;
     5984        cbWriteLeft -= cbToWrite;
     5985        uOffCurr    += cbToWrite;
    59685986        cbLeftInCurrentSegment -= cbToWrite;
    59695987        uOffsetInCurrentSegment += cbToWrite;
     
    59785996    }
    59795997
    5980     AssertMsg(cbWrite == 0, ("No segment left but there is still data to write\n"));
     5998    AssertMsg(cbWriteLeft == 0, ("No segment left but there is still data to write\n"));
    59815999
    59826000    if (cSegments == 0)
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