VirtualBox

Changeset 64029 in vbox


Ignore:
Timestamp:
Sep 26, 2016 9:22:02 PM (8 years ago)
Author:
vboxsync
Message:

Storage/DrvVD: Don't recurse into trying to allocate I/O buffers again for waiting requests from drvvdMediaExIoReqBufFree() or we might see stale list data

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/Storage/DrvVD.cpp

    r64025 r64029  
    27082708static void drvvdMediaExIoReqRetire(PVBOXDISK pThis, PPDMMEDIAEXIOREQINT pIoReq, int rcReq, bool fUpNotify)
    27092709{
    2710     int rc;
     2710    LogFlowFunc(("pThis=%#p pIoReq=%#p rcReq=%Rrc fUpNotify=%RTbool\n",
     2711                 pThis, pIoReq, rcReq, fUpNotify));
     2712
    27112713    bool fXchg = ASMAtomicCmpXchgU32((volatile uint32_t *)&pIoReq->enmState, VDIOREQSTATE_COMPLETING, VDIOREQSTATE_ACTIVE);
    27122714    if (fXchg)
     
    27192721
    27202722    ASMAtomicXchgU32((volatile uint32_t *)&pIoReq->enmState, VDIOREQSTATE_COMPLETED);
    2721     drvvdMediaExIoReqBufFree(pThis, pIoReq);
     2723    //drvvdMediaExIoReqBufFree(pThis, pIoReq);
    27222724
    27232725    /*
     
    27942796    if (fUpNotify)
    27952797    {
    2796         rc = pThis->pDrvMediaExPort->pfnIoReqCompleteNotify(pThis->pDrvMediaExPort,
    2797                                                             pIoReq, &pIoReq->abAlloc[0], rcReq);
     2798        int rc = pThis->pDrvMediaExPort->pfnIoReqCompleteNotify(pThis->pDrvMediaExPort,
     2799                                                                pIoReq, &pIoReq->abAlloc[0], rcReq);
    27982800        AssertRC(rc);
    27992801    }
     2802
     2803    LogFlowFunc(("returns\n"));
    28002804}
    28012805
     
    28112815static int drvvdMediaExIoReqCompleteWorker(PVBOXDISK pThis, PPDMMEDIAEXIOREQINT pIoReq, int rcReq, bool fUpNotify)
    28122816{
     2817    LogFlowFunc(("pThis=%#p pIoReq=%#p rcReq=%Rrc fUpNotify=%RTbool\n",
     2818                 pThis, pIoReq, rcReq, fUpNotify));
     2819
    28132820    /*
    28142821     * For a read we need to sync the memory before continuing to process
     
    28652872    }
    28662873
     2874    LogFlowFunc(("returns %Rrc\n", rcReq));
    28672875    return rcReq;
    28682876}
     
    28812889DECLINLINE(int) drvvdMediaExIoReqBufAlloc(PVBOXDISK pThis, PPDMMEDIAEXIOREQINT pIoReq, size_t cb)
    28822890{
     2891    LogFlowFunc(("pThis=%#p pIoReq=%#p cb=%zu\n", pThis, pIoReq, cb));
     2892
    28832893    int rc = IOBUFMgrAllocBuf(pThis->hIoBufMgr, &pIoReq->ReadWrite.IoBuf, cb, &pIoReq->ReadWrite.cbIoBuf);
    28842894    if (rc == VERR_NO_MEMORY)
    28852895    {
     2896        LogFlowFunc(("Could not allocate memory for request, deferring\n"));
    28862897        RTCritSectEnter(&pThis->CritSectIoReqsIoBufWait);
    28872898        RTListAppend(&pThis->LstIoReqIoBufWait, &pIoReq->NdLstWait);
     
    28912902    }
    28922903    else
     2904    {
     2905        LogFlowFunc(("Allocated %zu bytes of memory\n", pIoReq->ReadWrite.cbIoBuf));
    28932906        Assert(pIoReq->ReadWrite.cbIoBuf > 0);
    2894 
     2907    }
     2908
     2909    LogFlowFunc(("returns %Rrc\n", rc));
    28952910    return rc;
    28962911}
     
    29092924    int rc = VINF_SUCCESS;
    29102925
     2926    LogFlowFunc(("pThis=%#p pIoReq=%#p cbReqIo=%zu pcbReqIo=%#p\n", pThis, pIoReq, cbReqIo, pcbReqIo));
     2927
    29112928    Assert(cbReqIo > 0);
    29122929
     
    29392956    *pcbReqIo = cbReqIo;
    29402957
     2958    LogFlowFunc(("returns %Rrc *pcbReqIo=%zu\n", rc, *pcbReqIo));
    29412959    return rc;
    29422960}
     
    29572975    Assert(cbReqIo > 0);
    29582976
     2977    LogFlowFunc(("pThis=%#p pIoReq=%#p cbReqIo=%zu pcbReqIo=%#p\n", pThis, pIoReq, cbReqIo, pcbReqIo));
     2978
    29592979    if (   pThis->fAsyncIOSupported
    29602980        && !(pIoReq->fFlags & PDMIMEDIAEX_F_SYNC))
     
    29853005    *pcbReqIo = cbReqIo;
    29863006
     3007    LogFlowFunc(("returns %Rrc *pcbReqIo=%zu\n", rc, *pcbReqIo));
    29873008    return rc;
    29883009}
     
    29993020    int rc = VINF_SUCCESS;
    30003021
     3022    LogFlowFunc(("pThis=%#p pIoReq=%#p\n", pThis, pIoReq));
     3023
    30013024    if (   pThis->fAsyncIOSupported
    30023025        && !(pIoReq->fFlags & PDMIMEDIAEX_F_SYNC))
     
    30203043    }
    30213044
     3045    LogFlowFunc(("returns %Rrc\n", rc));
    30223046    return rc;
    30233047}
     
    30343058    int rc = VINF_SUCCESS;
    30353059
     3060    LogFlowFunc(("pThis=%#p pIoReq=%#p\n", pThis, pIoReq));
     3061
    30363062    if (   pThis->fAsyncIOSupported
    30373063        && !(pIoReq->fFlags & PDMIMEDIAEX_F_SYNC))
     
    30563082    }
    30573083
     3084    LogFlowFunc(("returns %Rrc\n", rc));
    30583085    return rc;
    30593086}
     
    30713098    int rc = VINF_SUCCESS;
    30723099
     3100    LogFlowFunc(("pThis=%#p pIoReq=%#p fUpNotify=%RTbool\n", pThis, pIoReq, fUpNotify));
     3101
    30733102    Assert(pIoReq->enmType == PDMMEDIAEXIOREQTYPE_READ || pIoReq->enmType == PDMMEDIAEXIOREQTYPE_WRITE);
    30743103
     
    31113140    }
    31123141
     3142    LogFlowFunc(("returns %Rrc\n", rc));
    31133143    return rc;
    31143144}
     
    31243154DECLINLINE(void) drvvdMediaExIoReqBufFree(PVBOXDISK pThis, PPDMMEDIAEXIOREQINT pIoReq)
    31253155{
     3156    LogFlowFunc(("pThis=%#p pIoReq=%#p{.cbIoBuf=%zu}\n", pThis, pIoReq, pIoReq->ReadWrite.cbIoBuf));
     3157
    31263158    if (   pIoReq->enmType == PDMMEDIAEXIOREQTYPE_READ
    31273159        || pIoReq->enmType == PDMMEDIAEXIOREQTYPE_WRITE)
     
    31293161        IOBUFMgrFreeBuf(&pIoReq->ReadWrite.IoBuf);
    31303162
    3131         if (ASMAtomicReadU32(&pThis->cIoReqsWaiting) > 0)
     3163        uint32_t cIoReqsWaiting = ASMAtomicXchgU32(&pThis->cIoReqsWaiting, 0);
     3164        if (cIoReqsWaiting > 0)
    31323165        {
    31333166            /* Try to process as many requests as possible. */
     
    31373170            RTListForEachSafe(&pThis->LstIoReqIoBufWait, pIoReqCur, pIoReqNext, PDMMEDIAEXIOREQINT, NdLstWait)
    31383171            {
     3172                LogFlowFunc(("Found I/O request %#p on waiting list, trying to allocate buffer of size %zu bytes\n",
     3173                             pIoReqCur, pIoReqCur->ReadWrite.cbReq));
     3174
    31393175                /* Allocate a suitable I/O buffer for this request. */
    31403176                int rc = IOBUFMgrAllocBuf(pThis->hIoBufMgr, &pIoReqCur->ReadWrite.IoBuf, pIoReqCur->ReadWrite.cbReq,
     
    31443180                    Assert(pIoReq->ReadWrite.cbIoBuf > 0);
    31453181
    3146                     ASMAtomicDecU32(&pThis->cIoReqsWaiting);
     3182                    cIoReqsWaiting--;
    31473183                    RTListNodeRemove(&pIoReqCur->NdLstWait);
    31483184
     
    31643200            }
    31653201            RTCritSectLeave(&pThis->CritSectIoReqsIoBufWait);
    3166         }
    3167     }
     3202
     3203            ASMAtomicAddU32(&pThis->cIoReqsWaiting, cIoReqsWaiting);
     3204        }
     3205    }
     3206
     3207    LogFlowFunc(("returns\n"));
    31683208}
    31693209
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