VirtualBox

Changeset 64829 in vbox for trunk/src/VBox


Ignore:
Timestamp:
Dec 12, 2016 8:08:31 AM (8 years ago)
Author:
vboxsync
Message:

Storage/QCOW: Remember an L2 table if it was just created so it can be accessed when another read or write happens in the same area at the same time. Fixes assertion in VD layer

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Storage/QCOW.cpp

    r64766 r64829  
    248248    uint32_t            cL2Shift;
    249249
     250    /** Pointer to the L2 table we are currently allocating
     251     * (can be only one at a time). */
     252    PQCOWL2CACHEENTRY   pL2TblAlloc;
     253
    250254} QCOWIMAGE, *PQCOWIMAGE;
    251255
     
    500504static PQCOWL2CACHEENTRY qcowL2TblCacheRetain(PQCOWIMAGE pImage, uint64_t offL2Tbl)
    501505{
     506    if (   pImage->pL2TblAlloc
     507        && pImage->pL2TblAlloc->offL2Tbl == offL2Tbl)
     508    {
     509        pImage->pL2TblAlloc->cRefs++;
     510        return pImage->pL2TblAlloc;
     511    }
     512
    502513    PQCOWL2CACHEENTRY pL2Entry;
    503514    RTListForEach(&pImage->ListSearch, pL2Entry, QCOWL2CACHEENTRY, NodeSearch)
     
    13221333            /* Revert the L1 table entry */
    13231334            pImage->paL1Table[pClusterAlloc->idxL1] = 0;
     1335            pImage->pL2TblAlloc = NULL;
    13241336
    13251337            /* Assumption right now is that the L1 table is not modified on storage if the link fails. */
    13261338            rc = vdIfIoIntFileSetSize(pImage->pIfIo, pImage->pStorage, pClusterAlloc->offNextClusterOld);
    13271339            qcowL2TblCacheEntryRelease(pClusterAlloc->pL2Entry); /* Release L2 cache entry. */
     1340            Assert(!pClusterAlloc->pL2Entry->cRefs);
    13281341            qcowL2TblCacheEntryFree(pImage, pClusterAlloc->pL2Entry); /* Free it, it is not in the cache yet. */
    13291342            break;
     
    13941407            uint64_t offData = qcowClusterAllocate(pImage, 1);
    13951408
     1409            pImage->pL2TblAlloc = NULL;
    13961410            qcowL2TblCacheEntryInsert(pImage, pClusterAlloc->pL2Entry);
    13971411
     
    17631777                        pL2ClusterAlloc->cbToWrite         = cbToWrite;
    17641778                        pL2ClusterAlloc->pL2Entry          = pL2Entry;
     1779
     1780                        pImage->pL2TblAlloc = pL2Entry;
     1781
     1782                        LogFlowFunc(("Allocating new L2 table at cluster offset %llu\n", offL2Tbl));
    17651783
    17661784                        /*
     
    17851803                    else
    17861804                    {
     1805                        LogFlowFunc(("Fetching L2 table at cluster offset %llu\n", pImage->paL1Table[idxL1]));
     1806
    17871807                        rc = qcowL2TblCacheFetch(pImage, pIoCtx, pImage->paL1Table[idxL1],
    17881808                                                 &pL2Entry);
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