VirtualBox

Changeset 28947 in vbox


Ignore:
Timestamp:
Apr 30, 2010 9:17:27 PM (15 years ago)
Author:
vboxsync
Message:

AsyncCompletion: Fix an I/O hang after the manager grew. The I/O manager should check for pending requests afterwards

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

Legend:

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

    r28800 r28947  
    2121*******************************************************************************/
    2222#define LOG_GROUP LOG_GROUP_PDM_ASYNC_COMPLETION
    23 //#define DEBUG
    2423#include "PDMInternal.h"
    2524#include <VBox/pdm.h>
     
    259258    PPDMASYNCCOMPLETIONTASKFILE pTaskFile = (PPDMASYNCCOMPLETIONTASKFILE)pvUser;
    260259
     260    LogFlowFunc(("pTask=%#p pvUser=%#p rc=%Rrc\n", pTask, pvUser, rc));
     261
    261262    if (pTask->enmTransferType == PDMACTASKFILETRANSFER_FLUSH)
    262263    {
     
    276277            pdmR3AsyncCompletionCompleteTask(&pTaskFile->Core, pTaskFile->rc, true);
    277278    }
     279}
     280
     281DECLINLINE(void) pdmacFileEpTaskInit(PPDMASYNCCOMPLETIONTASK pTask, size_t cbTransfer)
     282{
     283    PPDMASYNCCOMPLETIONTASKFILE pTaskFile = (PPDMASYNCCOMPLETIONTASKFILE)pTask;
     284
     285    Assert((uint32_t)cbTransfer == cbTransfer && (int32_t)cbTransfer >= 0);
     286    ASMAtomicWriteS32(&pTaskFile->cbTransferLeft, (int32_t)cbTransfer);
     287    ASMAtomicWriteBool(&pTaskFile->fCompleted, false);
     288    ASMAtomicWriteS32(&pTaskFile->rc, VINF_SUCCESS);
    278289}
    279290
     
    290301    Assert(   (enmTransfer == PDMACTASKFILETRANSFER_READ)
    291302           || (enmTransfer == PDMACTASKFILETRANSFER_WRITE));
    292 
    293     Assert((uint32_t)cbTransfer == cbTransfer && (int32_t)cbTransfer >= 0);
    294     ASMAtomicWriteS32(&pTaskFile->cbTransferLeft, (int32_t)cbTransfer);
    295     ASMAtomicWriteBool(&pTaskFile->fCompleted, false);
    296     ASMAtomicWriteS32(&pTaskFile->rc, VINF_SUCCESS);
    297303
    298304    for (unsigned i = 0; i < cSegments; i++)
     
    970976    PPDMASYNCCOMPLETIONENDPOINTFILE pEpFile = (PPDMASYNCCOMPLETIONENDPOINTFILE)pEndpoint;
    971977
     978    LogFlowFunc(("pTask=%#p pEndpoint=%#p off=%RTfoff paSegments=%#p cSegments=%zu cbRead=%zu\n",
     979                 pTask, pEndpoint, off, paSegments, cSegments, cbRead));
     980
    972981    STAM_PROFILE_ADV_START(&pEpFile->StatRead, Read);
     982
     983    pdmacFileEpTaskInit(pTask, cbRead);
    973984
    974985    if (pEpFile->fCaching)
     
    9961007
    9971008    STAM_PROFILE_ADV_START(&pEpFile->StatWrite, Write);
     1009
     1010    pdmacFileEpTaskInit(pTask, cbWrite);
    9981011
    9991012    if (pEpFile->fCaching)
  • trunk/src/VBox/VMM/PDMAsyncCompletionFileCache.cpp

    r28800 r28947  
    17221722                 pEndpoint, pEndpoint->Core.pszUri, pTask, off, paSegments, cSegments, cbRead));
    17231723
    1724     pTask->cbTransferLeft = cbRead;
    1725     pTask->rc             = VINF_SUCCESS;
    17261724    /* Set to completed to make sure that the task is valid while we access it. */
    17271725    ASMAtomicWriteBool(&pTask->fCompleted, true);
     
    19561954                 pEndpoint, pEndpoint->Core.pszUri, pTask, off, paSegments, cSegments, cbWrite));
    19571955
    1958     pTask->cbTransferLeft = cbWrite;
    1959     pTask->rc             = VINF_SUCCESS;
    19601956    /* Set to completed to make sure that the task is valid while we access it. */
    19611957    ASMAtomicWriteBool(&pTask->fCompleted, true);
  • trunk/src/VBox/VMM/PDMAsyncCompletionFileNormal.cpp

    r28884 r28947  
    446446
    447447    pEndpoint->AioMgr.pReqsPendingTail = pTaskHead;
     448    pTaskHead->pNext = NULL;
    448449}
    449450
     
    466467
    467468    pEndpoint->AioMgr.pReqsPendingTail = pTask;
     469    pTask->pNext = NULL;
    468470}
    469471
     
    560562
    561563                    if (pTask->cbBounceBuffer)
    562                         RTMemFree(pTask->pvBounceBuffer);
     564                        RTMemPageFree(pTask->pvBounceBuffer, pTask->cbBounceBuffer);
    563565
    564566                    pTask->fPrefetch = false;
     567                    pTask->cbBounceBuffer = 0;
    565568
    566569                    /* Free the lock and process pending tasks if neccessary */
     
    13911394
    13921395            /* Call completion callback */
     1396            LogFlow(("Task=%#p completed with %Rrc\n", pTask, rcReq));
    13931397            pTask->pfnCompleted(pTask, pTask->pvUser, rcReq);
    13941398            pdmacFileTaskFree(pEndpoint, pTask);
     
    14451449
    14461450    while (   (pAioMgr->enmState == PDMACEPFILEMGRSTATE_RUNNING)
    1447            || (pAioMgr->enmState == PDMACEPFILEMGRSTATE_SUSPENDING))
    1448     {
    1449         ASMAtomicWriteBool(&pAioMgr->fWaitingEventSem, true);
    1450         if (!ASMAtomicReadBool(&pAioMgr->fWokenUp))
    1451             rc = RTSemEventWait(pAioMgr->EventSem, RT_INDEFINITE_WAIT);
    1452         ASMAtomicWriteBool(&pAioMgr->fWaitingEventSem, false);
    1453         AssertRC(rc);
    1454 
    1455         LogFlow(("Got woken up\n"));
    1456         ASMAtomicWriteBool(&pAioMgr->fWokenUp, false);
     1451           || (pAioMgr->enmState == PDMACEPFILEMGRSTATE_SUSPENDING)
     1452           || (pAioMgr->enmState == PDMACEPFILEMGRSTATE_GROWING))
     1453    {
     1454        if (!pAioMgr->cRequestsActive)
     1455        {
     1456            ASMAtomicWriteBool(&pAioMgr->fWaitingEventSem, true);
     1457            if (!ASMAtomicReadBool(&pAioMgr->fWokenUp))
     1458                rc = RTSemEventWait(pAioMgr->EventSem, RT_INDEFINITE_WAIT);
     1459            ASMAtomicWriteBool(&pAioMgr->fWaitingEventSem, false);
     1460            AssertRC(rc);
     1461
     1462            LogFlow(("Got woken up\n"));
     1463            ASMAtomicWriteBool(&pAioMgr->fWokenUp, false);
     1464        }
    14571465
    14581466        /* Check for an external blocking event first. */
     
    14631471        }
    14641472
    1465         if (RT_LIKELY(pAioMgr->enmState == PDMACEPFILEMGRSTATE_RUNNING))
     1473        if (RT_LIKELY(    pAioMgr->enmState == PDMACEPFILEMGRSTATE_RUNNING
     1474                      ||  pAioMgr->enmState == PDMACEPFILEMGRSTATE_GROWING))
    14661475        {
    14671476            /* We got woken up because an endpoint issued new requests. Queue them. */
     
    15461555                AssertRC(rc);
    15471556                Assert(pAioMgr->enmState == PDMACEPFILEMGRSTATE_RUNNING);
     1557
     1558                rc = pdmacFileAioMgrNormalCheckEndpoints(pAioMgr);
     1559                CHECK_RC(pAioMgr, rc);
    15481560            }
    15491561        } /* if still running */
    15501562    } /* while running */
    15511563
     1564    LogFlowFunc(("rc=%Rrc\n", rc));
    15521565    return rc;
    15531566}
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