VirtualBox

Changeset 27280 in vbox


Ignore:
Timestamp:
Mar 11, 2010 12:55:06 PM (15 years ago)
Author:
vboxsync
Message:

AsyncCompletion: Change range locks allocation from RTMemAlloc to RTMemCache

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

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/VMM/PDMAsyncCompletionFileInternal.h

    r26814 r27280  
    3434#include <iprt/list.h>
    3535#include <iprt/spinlock.h>
     36#include <iprt/memcache.h>
    3637
    3738#include "PDMAsyncCompletionInternal.h"
     
    153154    /** Flag whether at least one endpoint reached its bandwidth limit. */
    154155    bool                                   fBwLimitReached;
     156    /** Memory cache for file range locks. */
     157    RTMEMCACHE                             hMemCacheRangeLocks;
    155158    /** Critical section protecting the blocking event handling. */
    156159    RTCRITSECT                             CritSectBlockingEvent;
  • trunk/src/VBox/VMM/PDMAsyncCompletionFileNormal.cpp

    r26689 r27280  
    6262        if (pAioMgr->pahReqsFree)
    6363        {
    64             return VINF_SUCCESS;
     64            /* Create the range lock memcache. */
     65            rc = RTMemCacheCreate(&pAioMgr->hMemCacheRangeLocks, sizeof(PDMACFILERANGELOCK),
     66                                  0, UINT32_MAX, NULL, NULL, NULL, 0);
     67            if (RT_SUCCESS(rc))
     68                return VINF_SUCCESS;
     69
     70            RTMemFree(pAioMgr->pahReqsFree);
    6571        }
    6672        else
     
    8591
    8692    RTMemFree(pAioMgr->pahReqsFree);
     93    RTMemCacheDestroy(pAioMgr->hMemCacheRangeLocks);
    8794}
    8895
     
    511518}
    512519
    513 static int pdmacFileAioMgrNormalRangeLock(PPDMASYNCCOMPLETIONENDPOINTFILE pEndpoint,
     520static int pdmacFileAioMgrNormalRangeLock(PPDMACEPFILEMGR pAioMgr,
     521                                          PPDMASYNCCOMPLETIONENDPOINTFILE pEndpoint,
    514522                                          RTFOFF offStart, size_t cbRange,
    515523                                          PPDMACTASKFILE pTask)
     
    519527               offStart, cbRange));
    520528
    521     PPDMACFILERANGELOCK pRangeLock = (PPDMACFILERANGELOCK)RTMemAllocZ(sizeof(PDMACFILERANGELOCK));
     529    PPDMACFILERANGELOCK pRangeLock = (PPDMACFILERANGELOCK)RTMemCacheAlloc(pAioMgr->hMemCacheRangeLocks);
    522530    if (!pRangeLock)
    523531        return VERR_NO_MEMORY;
     
    549557    RTAvlrFileOffsetRemove(pEndpoint->AioMgr.pTreeRangesLocked, pRangeLock->Core.Key);
    550558    pTasksWaitingHead = pRangeLock->pWaitingTasksHead;
    551     RTMemFree(pRangeLock);
     559    RTMemCacheFree(pAioMgr->hMemCacheRangeLocks, pRangeLock);
    552560
    553561    return pdmacFileAioMgrNormalProcessTaskList(pTasksWaitingHead, pAioMgr, pEndpoint);
     
    595603     * which checks whether a range is already used will add the task)
    596604     *
    597      * This is neccessary because of the requirementto align all requests to a 512 boundary
     605     * This is neccessary because of the requirement to align all requests to a 512 boundary
    598606     * which is enforced by the host OS (Linux and Windows atm). It is possible that
    599607     * we have to process unaligned tasks and need to align them using bounce buffers.
    600      * While the data is feteched from the file another request might arrive writing to
     608     * While the data is fetched from the file another request might arrive writing to
    601609     * the same range. This will result in data corruption if both are executed concurrently.
    602610     */
     
    671679            AssertRC(rc);
    672680
    673             rc = pdmacFileAioMgrNormalRangeLock(pEndpoint, offStart, cbToTransfer, pTask);
     681            rc = pdmacFileAioMgrNormalRangeLock(pAioMgr, pEndpoint, offStart, cbToTransfer, pTask);
    674682
    675683            if (RT_SUCCESS(rc))
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