VirtualBox

Changeset 39414 in vbox


Ignore:
Timestamp:
Nov 24, 2011 9:52:15 PM (13 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
75036
Message:

PDMBlkCache: Clear all entries on reset to prevent that unwritten data is in the cache which can lead to data corruption in case the cache isn't used after the reset

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/VBox/vmm/pdmblkcache.h

    r38877 r39414  
    406406VMMR3DECL(int) PDMR3BlkCacheResume(PPDMBLKCACHE pBlkCache);
    407407
     408/**
     409 * Clears the block cache and removes all entries. The cache waits until all
     410 * I/O transfers completed.
     411 *
     412 * @returns VBox status code.
     413 * @param   pBlkCache       The cache instance.
     414 */
     415VMMR3DECL(int) PDMR3BlkCacheClear(PPDMBLKCACHE pBlkCache);
     416
    408417/** @} */
    409418
  • trunk/src/VBox/Devices/Storage/DrvVD.cpp

    r38878 r39414  
    19991999    LogFlowFunc(("\n"));
    20002000    PVBOXDISK pThis = PDMINS_2_DATA(pDrvIns, PVBOXDISK);
     2001
     2002    if (pThis->pBlkCache)
     2003    {
     2004        int rc = PDMR3BlkCacheClear(pThis->pBlkCache);
     2005        AssertRC(rc);
     2006    }
    20012007
    20022008    if (pThis->fBootAccelEnabled)
  • trunk/src/VBox/VMM/VMMR3/PDMBlkCache.cpp

    r39356 r39414  
    27402740}
    27412741
     2742VMMR3DECL(int) PDMR3BlkCacheClear(PPDMBLKCACHE pBlkCache)
     2743{
     2744    int rc = VINF_SUCCESS;
     2745    PPDMBLKCACHEGLOBAL pCache = pBlkCache->pCache;
     2746
     2747    /*
     2748     * Commit all dirty entries now (they are waited on for completion during the
     2749     * destruction of the AVL tree below).
     2750     * The exception is if the VM was paused because of an I/O error before.
     2751     */
     2752    if (!ASMAtomicReadBool(&pCache->fIoErrorVmSuspended))
     2753        pdmBlkCacheCommit(pBlkCache);
     2754
     2755    /* Make sure nobody is accessing the cache while we delete the tree. */
     2756    pdmBlkCacheLockEnter(pCache);
     2757    RTSemRWRequestWrite(pBlkCache->SemRWEntries, RT_INDEFINITE_WAIT);
     2758    RTAvlrU64Destroy(pBlkCache->pTree, pdmBlkCacheEntryDestroy, pCache);
     2759    RTSemRWReleaseWrite(pBlkCache->SemRWEntries);
     2760
     2761    pdmBlkCacheLockLeave(pCache);
     2762    return rc;
     2763}
     2764
Note: See TracChangeset for help on using the changeset viewer.

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