VirtualBox

Changeset 27557 in vbox for trunk/src/VBox/VMM


Ignore:
Timestamp:
Mar 20, 2010 9:14:43 PM (15 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
59075
Message:

I/O cache: Increase the endpoint size for every appending write, even if it isn't immediately written to the file (delay in the cache). Fixes data corruption when appending data in VMDK images

Location:
trunk/src/VBox/VMM
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/VMM/PDMAsyncCompletionFile.cpp

    r27495 r27557  
    868868                PPDMACEPFILEMGR pAioMgr = NULL;
    869869
     870                pEpFile->cbEndpoint     = pEpFile->cbFile;
    870871                pEpFile->pTasksFreeTail = pEpFile->pTasksFreeHead;
    871872                pEpFile->cTasksCached   = 0;
     
    970971    AssertRC(rc);
    971972
     973    /* endpoint and real file size should better be equal now. */
     974    AssertMsg(pEpFile->cbFile == pEpFile->cbEndpoint,
     975              ("Endpoint and real file size should match now!\n"));
     976
    972977    /*
    973978     * If the async I/O manager is in failsafe mode this is the only endpoint
     
    10511056    STAM_PROFILE_ADV_STOP(&pEpFile->StatWrite, Write);
    10521057
     1058    /* Increase endpoint size. */
     1059    if (   RT_SUCCESS(rc)
     1060        && ((uint64_t)off + cbWrite) > pEpFile->cbEndpoint)
     1061        ASMAtomicWriteU64(&pEpFile->cbEndpoint, (uint64_t)off + cbWrite);
     1062
    10531063    return rc;
    10541064}
     
    10881098    PPDMASYNCCOMPLETIONENDPOINTFILE pEpFile = (PPDMASYNCCOMPLETIONENDPOINTFILE)pEndpoint;
    10891099
    1090     *pcbSize = ASMAtomicReadU64(&pEpFile->cbFile);
     1100    *pcbSize = ASMAtomicReadU64(&pEpFile->cbEndpoint);
    10911101
    10921102    return VINF_SUCCESS;
  • trunk/src/VBox/VMM/PDMAsyncCompletionFileCache.cpp

    r27526 r27557  
    16661666
    16671667            AssertMsg(   (off >= pEntryNew->Core.Key)
    1668                       && (off + (RTFOFF)cb <= pEntryNew->Core.Key + pEntryNew->Core.KeyLast + 1),
     1668                      && (off + (RTFOFF)*pcbData <= pEntryNew->Core.KeyLast + 1),
    16691669                      ("Overflow in calculation off=%RTfoff OffsetAligned=%RTfoff\n",
    16701670                       off, pEntryNew->Core.Key));
     
    21662166            cbWrite -= cbToWrite;
    21672167
    2168             STAM_COUNTER_INC(&pCache->cMisses);
    2169 
    21702168            if (pEntryNew)
    21712169            {
    21722170                RTFOFF offDiff = off - pEntryNew->Core.Key;
     2171
     2172                STAM_COUNTER_INC(&pCache->cHits);
    21732173
    21742174                /*
     
    22092209                LogFlow(("Couldn't evict %u bytes from the cache. Remaining request will be passed through\n", cbToWrite));
    22102210
     2211                STAM_COUNTER_INC(&pCache->cMisses);
     2212
    22112213                pdmacFileEpCacheRequestPassthrough(pEndpoint, pTask,
    22122214                                                   &IoMemCtx, off, cbToWrite,
  • trunk/src/VBox/VMM/PDMAsyncCompletionFileInternal.h

    r27299 r27557  
    518518    /** File handle. */
    519519    RTFILE                                 File;
    520     /** Size of the underlying file.
    521      * Updated while data is appended. */
     520    /** Size of the endpoint.
     521     * Updated while data is appended even if it is
     522     * only in the cache yet and not written to the file.
     523     */
     524    volatile uint64_t                      cbEndpoint;
     525    /**
     526     * Real size of the file. Only updated if
     527     * data is appended.
     528     */
    522529    volatile uint64_t                      cbFile;
    523530    /** Flag whether caching is enabled for this file. */
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