VirtualBox

Changeset 23975 in vbox


Ignore:
Timestamp:
Oct 22, 2009 12:54:52 PM (15 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
53806
Message:

AsyncCompletion: Fix possible data corruption

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

Legend:

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

    r23744 r23975  
    490490    pEntry->fFlags &= ~PDMACFILECACHE_ENTRY_IO_IN_PROGRESS;
    491491
     492    /* Process waiting segment list. The data in entry might have changed inbetween. */
     493    PPDMACFILETASKSEG pCurr = pEntry->pWaitingHead;
     494
     495    AssertMsg((pCurr && pEntry->pWaitingTail) || (!pCurr && !pEntry->pWaitingTail),
     496                ("The list tail was not updated correctly\n"));
     497    pEntry->pWaitingTail = NULL;
     498    pEntry->pWaitingHead = NULL;
     499
    492500    if (pTask->enmTransferType == PDMACTASKFILETRANSFER_WRITE)
    493501    {
    494502        pEntry->fFlags &= ~PDMACFILECACHE_ENTRY_IS_DIRTY;
    495 
    496         /* Process waiting segment list. The data in entry might have changed inbetween. */
    497         PPDMACFILETASKSEG pCurr = pEntry->pHead;
    498503
    499504        while (pCurr)
     
    520525        AssertMsg(pTask->enmTransferType == PDMACTASKFILETRANSFER_READ, ("Invalid transfer type\n"));
    521526        AssertMsg(!(pEntry->fFlags & PDMACFILECACHE_ENTRY_IS_DIRTY),("Invalid flags set\n"));
    522 
    523         /* Process waiting segment list. */
    524         PPDMACFILETASKSEG pCurr = pEntry->pHead;
    525527
    526528        while (pCurr)
     
    546548        }
    547549    }
    548 
    549     pEntry->pHead = NULL;
    550550
    551551    if (pEntry->fFlags & PDMACFILECACHE_ENTRY_IS_DIRTY)
     
    844844    pEntryNew->pList        = NULL;
    845845    pEntryNew->cbData       = cbData;
    846     pEntryNew->pHead        = NULL;
     846    pEntryNew->pWaitingHead = NULL;
     847    pEntryNew->pWaitingTail = NULL;
    847848    pEntryNew->pbData       = (uint8_t *)RTMemPageAlloc(cbData);
    848849
     
    854855
    855856    return pEntryNew;
     857}
     858
     859/**
     860 * Adds a segment to the waiting list for a cache entry
     861 * which is currently in progress.
     862 *
     863 * @returns nothing.
     864 * @param   pEntry    The cache entry to add the segment to.
     865 * @param   pSeg      The segment to add.
     866 */
     867static void pdmacFileEpCacheEntryAddWaitingSegment(PPDMACFILECACHEENTRY pEntry, PPDMACFILETASKSEG pSeg)
     868{
     869    pSeg->pNext = NULL;
     870
     871    if (pEntry->pWaitingHead)
     872    {
     873        AssertPtr(pEntry->pWaitingTail);
     874
     875        pEntry->pWaitingTail->pNext = pSeg;
     876        pEntry->pWaitingTail = pSeg;
     877    }
     878    else
     879    {
     880        Assert(!pEntry->pWaitingTail);
     881
     882        pEntry->pWaitingHead = pSeg;
     883        pEntry->pWaitingTail = pSeg;
     884    }
    856885}
    857886
     
    9711000                            ADVANCE_SEGMENT_BUFFER(pSeg->cbTransfer);
    9721001
    973                             pSeg->pNext = pEntry->pHead;
    974                             pEntry->pHead = pSeg;
     1002                            pdmacFileEpCacheEntryAddWaitingSegment(pEntry, pSeg);
    9751003
    9761004                            off      += pSeg->cbTransfer;
     
    10511079                    ADVANCE_SEGMENT_BUFFER(pSeg->cbTransfer);
    10521080
    1053                     pSeg->pNext = pEntry->pHead;
    1054                     pEntry->pHead = pSeg;
     1081                    pdmacFileEpCacheEntryAddWaitingSegment(pEntry, pSeg);
    10551082
    10561083                    off      += pSeg->cbTransfer;
     
    11361163                    ADVANCE_SEGMENT_BUFFER(pSeg->cbTransfer);
    11371164
    1138                     pSeg->pNext = pEntryNew->pHead;
    1139                     pEntryNew->pHead = pSeg;
     1165                    pdmacFileEpCacheEntryAddWaitingSegment(pEntryNew, pSeg);
    11401166
    11411167                    off        += pSeg->cbTransfer;
     
    12741300                            ADVANCE_SEGMENT_BUFFER(pSeg->cbTransfer);
    12751301
    1276                             pSeg->pNext = pEntry->pHead;
    1277                             pEntry->pHead = pSeg;
     1302                            pdmacFileEpCacheEntryAddWaitingSegment(pEntry, pSeg);
    12781303
    12791304                            off       += pSeg->cbTransfer;
     
    13351360                                ADVANCE_SEGMENT_BUFFER(pSeg->cbTransfer);
    13361361
    1337                                 pSeg->pNext = pEntry->pHead;
    1338                                 pEntry->pHead = pSeg;
     1362                                pdmacFileEpCacheEntryAddWaitingSegment(pEntry, pSeg);
    13391363
    13401364                                off       += pSeg->cbTransfer;
     
    14241448                    ADVANCE_SEGMENT_BUFFER(pSeg->cbTransfer);
    14251449
    1426                     pSeg->pNext = pEntry->pHead;
    1427                     pEntry->pHead = pSeg;
     1450                    pdmacFileEpCacheEntryAddWaitingSegment(pEntry, pSeg);
    14281451
    14291452                    off       += pSeg->cbTransfer;
  • trunk/src/VBox/VMM/PDMAsyncCompletionFileInternal.h

    r23956 r23975  
    229229    /** Pointer to the memory containing the data. */
    230230    uint8_t                        *pbData;
    231     /** List of tasks waiting for this one to finish. */
    232     PPDMACFILETASKSEG               pHead;
     231    /** Head of list of tasks waiting for this one to finish. */
     232    PPDMACFILETASKSEG               pWaitingHead;
     233    /** Tail of list of tasks waiting for this one to finish. */
     234    PPDMACFILETASKSEG               pWaitingTail;
    233235} PDMACFILECACHEENTRY, *PPDMACFILECACHEENTRY;
    234236/** I/O is still in progress for this entry. This entry is not evictable. */
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