VirtualBox

Changeset 64727 in vbox


Ignore:
Timestamp:
Nov 21, 2016 11:43:03 AM (8 years ago)
Author:
vboxsync
Message:

Storage/DrvVD: Don't process I/O requests under a lock but postpone it until it was released

File:
1 edited

Legend:

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

    r64671 r64727  
    32333233        if (cIoReqsWaiting > 0)
    32343234        {
     3235            RTLISTANCHOR LstIoReqProcess;
     3236            RTListInit(&LstIoReqProcess);
     3237
    32353238            /* Try to process as many requests as possible. */
    32363239            RTCritSectEnter(&pThis->CritSectIoReqsIoBufWait);
     
    32553258                    pIoReqCur->ReadWrite.pSgBuf     = &pIoReqCur->ReadWrite.IoBuf.SgBuf;
    32563259
    3257                     bool fXchg = ASMAtomicCmpXchgU32((volatile uint32_t *)&pIoReqCur->enmState, VDIOREQSTATE_ACTIVE, VDIOREQSTATE_ALLOCATED);
    3258                     if (RT_UNLIKELY(!fXchg))
    3259                     {
    3260                         /* Must have been canceled inbetween. */
    3261                         Assert(pIoReqCur->enmState == VDIOREQSTATE_CANCELED);
    3262                         drvvdMediaExIoReqCompleteWorker(pThis, pIoReqCur, VERR_PDM_MEDIAEX_IOREQ_CANCELED, true /* fUpNotify */);
    3263                     }
    3264                     ASMAtomicIncU32(&pThis->cIoReqsActive);
    3265                     rc = drvvdMediaExIoReqReadWriteProcess(pThis, pIoReqCur, true /* fUpNotify */);
     3260                    RTListAppend(&LstIoReqProcess, &pIoReqCur->NdLstWait);
    32663261                }
    32673262                else
     
    32743269
    32753270            ASMAtomicAddU32(&pThis->cIoReqsWaiting, cIoReqsWaiting);
     3271
     3272            /* Process the requests we could allocate memory for outside the lock now. */
     3273            RTListForEachSafe(&LstIoReqProcess, pIoReqCur, pIoReqNext, PDMMEDIAEXIOREQINT, NdLstWait)
     3274            {
     3275                RTListNodeRemove(&pIoReqCur->NdLstWait);
     3276
     3277                bool fXchg = ASMAtomicCmpXchgU32((volatile uint32_t *)&pIoReqCur->enmState, VDIOREQSTATE_ACTIVE, VDIOREQSTATE_ALLOCATED);
     3278                if (RT_UNLIKELY(!fXchg))
     3279                {
     3280                    /* Must have been canceled inbetween. */
     3281                    Assert(pIoReqCur->enmState == VDIOREQSTATE_CANCELED);
     3282                    drvvdMediaExIoReqCompleteWorker(pThis, pIoReqCur, VERR_PDM_MEDIAEX_IOREQ_CANCELED, true /* fUpNotify */);
     3283                }
     3284                ASMAtomicIncU32(&pThis->cIoReqsActive);
     3285                drvvdMediaExIoReqReadWriteProcess(pThis, pIoReqCur, true /* fUpNotify */);
     3286            }
    32763287        }
    32773288    }
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