VirtualBox

儲存庫 vbox 的更動 65888


忽略:
時間撮記:
2017-2-27 下午02:58:49 (8 年 以前)
作者:
vboxsync
訊息:

DrvVD: Prevent recursion in drvvdMediaExIoReqBufFree() when freeing request memory of canceled requests waiting for memory. Instead, free the memory immediately when the request got canceled to give other requests a chance to allocate the memory

檔案:
修改 1 筆資料

圖例:

未更動
新增
刪除
  • trunk/src/VBox/Devices/Storage/DrvVD.cpp

    r65849 r65888  
    33063306    if (   (   pIoReq->enmType == PDMMEDIAEXIOREQTYPE_READ
    33073307            || pIoReq->enmType == PDMMEDIAEXIOREQTYPE_WRITE)
    3308         && !pIoReq->ReadWrite.fDirectBuf)
     3308        && !pIoReq->ReadWrite.fDirectBuf
     3309        && pIoReq->ReadWrite.cbIoBuf > 0)
    33093310    {
    33103311        IOBUFMgrFreeBuf(&pIoReq->ReadWrite.IoBuf);
     
    33143315        {
    33153316            RTLISTANCHOR LstIoReqProcess;
     3317            RTLISTANCHOR LstIoReqCanceled;
    33163318            RTListInit(&LstIoReqProcess);
     3319            RTListInit(&LstIoReqCanceled);
    33173320
    33183321            /* Try to process as many requests as possible. */
     
    33383341                    pIoReqCur->ReadWrite.pSgBuf     = &pIoReqCur->ReadWrite.IoBuf.SgBuf;
    33393342
    3340                     RTListAppend(&LstIoReqProcess, &pIoReqCur->NdLstWait);
     3343                    bool fXchg = ASMAtomicCmpXchgU32((volatile uint32_t *)&pIoReqCur->enmState,
     3344                                                     VDIOREQSTATE_ACTIVE, VDIOREQSTATE_ALLOCATED);
     3345                    if (RT_UNLIKELY(!fXchg))
     3346                    {
     3347                        /* Must have been canceled inbetween. */
     3348                        Assert(pIoReqCur->enmState == VDIOREQSTATE_CANCELED);
     3349
     3350                        /* Free the buffer here already again to let other requests get a chance to allocate the memory. */
     3351                        IOBUFMgrFreeBuf(&pIoReq->ReadWrite.IoBuf);
     3352                        pIoReqCur->ReadWrite.cbIoBuf = 0;
     3353                        RTListAppend(&LstIoReqCanceled, &pIoReqCur->NdLstWait);
     3354                    }
     3355                    else
     3356                    {
     3357                        ASMAtomicIncU32(&pThis->cIoReqsActive);
     3358                        RTListAppend(&LstIoReqProcess, &pIoReqCur->NdLstWait);
     3359                    }
    33413360                }
    33423361                else
     
    33503369            ASMAtomicAddU32(&pThis->cIoReqsWaiting, cIoReqsWaiting);
    33513370
    3352             /* Process the requests we could allocate memory for outside the lock now. */
     3371            /* Process the requests we could allocate memory for and the ones which got canceled outside the lock now. */
     3372            RTListForEachSafe(&LstIoReqCanceled, pIoReqCur, pIoReqNext, PDMMEDIAEXIOREQINT, NdLstWait)
     3373            {
     3374                RTListNodeRemove(&pIoReqCur->NdLstWait);
     3375                drvvdMediaExIoReqCompleteWorker(pThis, pIoReqCur, VERR_PDM_MEDIAEX_IOREQ_CANCELED, true /* fUpNotify */);
     3376            }
     3377
    33533378            RTListForEachSafe(&LstIoReqProcess, pIoReqCur, pIoReqNext, PDMMEDIAEXIOREQINT, NdLstWait)
    33543379            {
    33553380                RTListNodeRemove(&pIoReqCur->NdLstWait);
    3356 
    3357                 bool fXchg = ASMAtomicCmpXchgU32((volatile uint32_t *)&pIoReqCur->enmState, VDIOREQSTATE_ACTIVE, VDIOREQSTATE_ALLOCATED);
    3358                 if (RT_UNLIKELY(!fXchg))
    3359                 {
    3360                     /* Must have been canceled inbetween. */
    3361                     Assert(pIoReqCur->enmState == VDIOREQSTATE_CANCELED);
    3362                     drvvdMediaExIoReqCompleteWorker(pThis, pIoReqCur, VERR_PDM_MEDIAEX_IOREQ_CANCELED, true /* fUpNotify */);
    3363                 }
    3364                 ASMAtomicIncU32(&pThis->cIoReqsActive);
    33653381                drvvdMediaExIoReqReadWriteProcess(pThis, pIoReqCur, true /* fUpNotify */);
    33663382            }
注意: 瀏覽 TracChangeset 來幫助您使用更動檢視器

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette