VirtualBox

Changeset 36001 in vbox


Ignore:
Timestamp:
Feb 16, 2011 9:21:39 PM (14 years ago)
Author:
vboxsync
Message:

AsyncCompletion: Add a new flag to enable the host cache, to make using bandwidth groups possible for buffered I/O

Location:
trunk
Files:
5 edited

Legend:

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

    r35361 r36001  
    228228 * @{ */
    229229/** Open the file in read-only mode. */
    230 #define PDMACEP_FILE_FLAGS_READ_ONLY    RT_BIT_32(0)
     230#define PDMACEP_FILE_FLAGS_READ_ONLY             RT_BIT_32(0)
    231231/** Whether the file should not be write protected.
    232232 * The default is to protect the file against writes by other processes
     
    234234 * concurrent access which can occur if the local writeback cache is enabled.
    235235 */
    236 #define PDMACEP_FILE_FLAGS_DONT_LOCK    RT_BIT_32(2)
     236#define PDMACEP_FILE_FLAGS_DONT_LOCK             RT_BIT_32(2)
     237/** Open the endpoint with the host cache enabled. */
     238#define PDMACEP_FILE_FLAGS_HOST_CACHE_ENABLED    RT_BIT_32(3)
    237239/** @} */
    238240
  • trunk/src/VBox/VMM/VMMR3/PDMAsyncCompletion.cpp

    r35346 r36001  
    11911191
    11921192    /* Check that the flags are valid. */
    1193     AssertReturn(((~(PDMACEP_FILE_FLAGS_READ_ONLY | PDMACEP_FILE_FLAGS_DONT_LOCK) & fFlags) == 0),
     1193    AssertReturn(((~(PDMACEP_FILE_FLAGS_READ_ONLY | PDMACEP_FILE_FLAGS_DONT_LOCK | PDMACEP_FILE_FLAGS_HOST_CACHE_ENABLED) & fFlags) == 0),
    11941194                 VERR_INVALID_PARAMETER);
    11951195
  • trunk/src/VBox/VMM/VMMR3/PDMAsyncCompletionFile.cpp

    r35696 r36001  
    431431        else
    432432            pAioMgrNew->enmMgrType = pEpClass->enmMgrTypeOverride;
     433
     434        pAioMgrNew->msBwLimitExpired = RT_INDEFINITE_WAIT;
    433435
    434436        rc = RTSemEventCreate(&pAioMgrNew->EventSem);
     
    863865    PDMACFILEEPBACKEND enmEpBackend = pEpClassFile->enmEpBackendDefault;
    864866
    865     AssertMsgReturn((fFlags & ~(PDMACEP_FILE_FLAGS_READ_ONLY | PDMACEP_FILE_FLAGS_DONT_LOCK)) == 0,
     867    AssertMsgReturn((fFlags & ~(PDMACEP_FILE_FLAGS_READ_ONLY | PDMACEP_FILE_FLAGS_DONT_LOCK | PDMACEP_FILE_FLAGS_HOST_CACHE_ENABLED)) == 0,
    866868                    ("PDMAsyncCompletion: Invalid flag specified\n"), VERR_INVALID_PARAMETER);
    867869
    868870    unsigned fFileFlags = RTFILE_O_OPEN;
     871
     872    /*
     873     * Revert to the simple manager and the buffered backend if
     874     * the host cache should be enabled.
     875     */
     876    if (fFlags & PDMACEP_FILE_FLAGS_HOST_CACHE_ENABLED)
     877    {
     878        enmMgrType   = PDMACEPFILEMGRTYPE_SIMPLE;
     879        enmEpBackend = PDMACFILEEPBACKEND_BUFFERED;
     880    }
    869881
    870882    if (fFlags & PDMACEP_FILE_FLAGS_READ_ONLY)
  • trunk/src/VBox/VMM/VMMR3/PDMAsyncCompletionFileFailsafe.cpp

    r35333 r36001  
    2727#include "PDMAsyncCompletionFileInternal.h"
    2828
    29 
    30 static int pdmacFileAioMgrFailsafeProcessEndpointTaskList(PPDMASYNCCOMPLETIONENDPOINTFILE pEndpoint,
     29/**
     30 * Put a list of tasks in the pending request list of an endpoint.
     31 */
     32DECLINLINE(void) pdmacFileAioMgrEpAddTaskList(PPDMASYNCCOMPLETIONENDPOINTFILE pEndpoint, PPDMACTASKFILE pTaskHead)
     33{
     34    /* Add the rest of the tasks to the pending list */
     35    if (!pEndpoint->AioMgr.pReqsPendingHead)
     36    {
     37        Assert(!pEndpoint->AioMgr.pReqsPendingTail);
     38        pEndpoint->AioMgr.pReqsPendingHead = pTaskHead;
     39    }
     40    else
     41    {
     42        Assert(pEndpoint->AioMgr.pReqsPendingTail);
     43        pEndpoint->AioMgr.pReqsPendingTail->pNext = pTaskHead;
     44    }
     45
     46    /* Update the tail. */
     47    while (pTaskHead->pNext)
     48        pTaskHead = pTaskHead->pNext;
     49
     50    pEndpoint->AioMgr.pReqsPendingTail = pTaskHead;
     51    pTaskHead->pNext = NULL;
     52}
     53
     54/**
     55 * Processes a given task list for assigned to the given endpoint.
     56 */
     57static int pdmacFileAioMgrFailsafeProcessEndpointTaskList(PPDMACEPFILEMGR pAioMgr,
     58                                                          PPDMASYNCCOMPLETIONENDPOINTFILE pEndpoint,
    3159                                                          PPDMACTASKFILE pTasks)
    3260{
     
    3563    while (pTasks)
    3664    {
     65        RTMSINTERVAL msWhenNext;
    3766        PPDMACTASKFILE pCurr = pTasks;
     67
     68        if (!pdmacEpIsTransferAllowed(&pEndpoint->Core, (uint32_t)pCurr->DataSeg.cbSeg, &msWhenNext))
     69        {
     70            pAioMgr->msBwLimitExpired = RT_MIN(pAioMgr->msBwLimitExpired, msWhenNext);
     71            break;
     72        }
    3873
    3974        pTasks = pTasks->pNext;
     
    80115    }
    81116
     117    if (pTasks)
     118    {
     119        /* Add the rest of the tasks to the pending list */
     120        pdmacFileAioMgrEpAddTaskList(pEndpoint, pTasks);
     121    }
     122
    82123    return VINF_SUCCESS;
    83124}
    84125
    85 static int pdmacFileAioMgrFailsafeProcessEndpoint(PPDMASYNCCOMPLETIONENDPOINTFILE pEndpoint)
     126static int pdmacFileAioMgrFailsafeProcessEndpoint(PPDMACEPFILEMGR pAioMgr,
     127                                                  PPDMASYNCCOMPLETIONENDPOINTFILE pEndpoint)
    86128{
    87129    int rc = VINF_SUCCESS;
     
    93135    /* Process the request pending list first in case the endpoint was migrated due to an error. */
    94136    if (pTasks)
    95         rc = pdmacFileAioMgrFailsafeProcessEndpointTaskList(pEndpoint, pTasks);
     137        rc = pdmacFileAioMgrFailsafeProcessEndpointTaskList(pAioMgr, pEndpoint, pTasks);
    96138
    97139    if (RT_SUCCESS(rc))
     
    100142
    101143        if (pTasks)
    102             rc = pdmacFileAioMgrFailsafeProcessEndpointTaskList(pEndpoint, pTasks);
     144            rc = pdmacFileAioMgrFailsafeProcessEndpointTaskList(pAioMgr, pEndpoint, pTasks);
    103145    }
    104146
     
    120162        ASMAtomicWriteBool(&pAioMgr->fWaitingEventSem, true);
    121163        if (!ASMAtomicReadBool(&pAioMgr->fWokenUp))
    122             rc = RTSemEventWait(pAioMgr->EventSem, RT_INDEFINITE_WAIT);
     164            rc = RTSemEventWait(pAioMgr->EventSem, pAioMgr->msBwLimitExpired);
    123165        ASMAtomicWriteBool(&pAioMgr->fWaitingEventSem, false);
    124         AssertRC(rc);
     166        Assert(RT_SUCCESS(rc) || rc == VERR_TIMEOUT);
    125167
    126168        LogFlow(("Got woken up\n"));
     
    131173        while (pEndpoint)
    132174        {
    133             rc = pdmacFileAioMgrFailsafeProcessEndpoint(pEndpoint);
     175            pAioMgr->msBwLimitExpired = RT_INDEFINITE_WAIT;
     176            rc = pdmacFileAioMgrFailsafeProcessEndpoint(pAioMgr, pEndpoint);
    134177            AssertRC(rc);
    135178            pEndpoint = pEndpoint->AioMgr.pEndpointNext;
     
    160203                     * if the endpoint was migrated from another endpoint.
    161204                     */
    162                     rc = pdmacFileAioMgrFailsafeProcessEndpoint(pEndpointNew);
     205                    rc = pdmacFileAioMgrFailsafeProcessEndpoint(pAioMgr, pEndpointNew);
    163206                    AssertRC(rc);
    164207                    break;
     
    193236
    194237                    /* Make sure all tasks finished. */
    195                     rc = pdmacFileAioMgrFailsafeProcessEndpoint(pEndpointClose);
     238                    rc = pdmacFileAioMgrFailsafeProcessEndpoint(pAioMgr, pEndpointClose);
    196239                    AssertRC(rc);
    197240                    break;
  • trunk/src/VBox/VMM/VMMR3/PDMAsyncCompletionFileNormal.cpp

    r35333 r36001  
    6262        pAioMgr->cReqEntries      = pAioMgr->cRequestsActiveMax;
    6363        pAioMgr->pahReqsFree      = (RTFILEAIOREQ *)RTMemAllocZ(pAioMgr->cReqEntries * sizeof(RTFILEAIOREQ));
    64         pAioMgr->msBwLimitExpired = RT_INDEFINITE_WAIT;
    6564
    6665        if (pAioMgr->pahReqsFree)
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