VirtualBox

Changeset 29330 in vbox for trunk/src/VBox/Devices


Ignore:
Timestamp:
May 11, 2010 10:21:06 AM (15 years ago)
Author:
vboxsync
Message:

SCSI: Create the I/O thread and request queue only if the async I/O interface is not supported

File:
1 edited

Legend:

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

    r29250 r29330  
    335335    PDRVSCSI pThis = (PDRVSCSI)pVScsiDeviceUser;
    336336
     337    ASMAtomicDecU32(&pThis->StatIoDepth);
     338
    337339    pThis->pDevScsiPort->pfnSCSIRequestCompleted(pThis->pDevScsiPort, (PPDMSCSIREQUEST)pVScsiReqUser,
    338340                                                 rcReq);
     341
     342    if (RT_UNLIKELY(pThis->fDummySignal) && !pThis->StatIoDepth)
     343        PDMDrvHlpAsyncNotificationCompleted(pThis->pDrvIns);
    339344}
    340345
     
    492497    PDRVSCSI pThis = PDMINS_2_DATA(pDrvIns, PDRVSCSI);
    493498
    494     if (!pThis->pQueueRequests)
     499    if (!pThis->pDrvBlockAsync)
     500    {
     501        if (!pThis->pQueueRequests)
     502            return;
     503
     504        ASMAtomicWriteBool(&pThis->fDummySignal, true);
     505        if (drvscsiAsyncIOLoopNoPendingDummy(pThis, 0 /*ms*/))
     506        {
     507            if (!RTReqIsBusy(pThis->pQueueRequests))
     508            {
     509                ASMAtomicWriteBool(&pThis->fDummySignal, false);
     510                return;
     511            }
     512
     513            PRTREQ pReq;
     514            int rc = RTReqCall(pThis->pQueueRequests, &pReq, 0 /*ms*/, (PFNRT)drvscsiAsyncIOLoopSyncCallback, 1, pThis);
     515            if (RT_SUCCESS(rc))
     516            {
     517                ASMAtomicWriteBool(&pThis->fDummySignal, false);
     518                RTReqFree(pReq);
     519                return;
     520            }
     521
     522            pThis->pPendingDummyReq = pReq;
     523        }
     524    }
     525    else
     526    {
     527        if (pThis->StatIoDepth > 0)
     528        {
     529            ASMAtomicWriteBool(&pThis->fDummySignal, true);
     530        }
    495531        return;
    496 
    497     ASMAtomicWriteBool(&pThis->fDummySignal, true);
    498     if (drvscsiAsyncIOLoopNoPendingDummy(pThis, 0 /*ms*/))
    499     {
    500         if (!RTReqIsBusy(pThis->pQueueRequests))
    501         {
    502             ASMAtomicWriteBool(&pThis->fDummySignal, false);
    503             return;
    504         }
    505 
    506         PRTREQ pReq;
    507         int rc = RTReqCall(pThis->pQueueRequests, &pReq, 0 /*ms*/, (PFNRT)drvscsiAsyncIOLoopSyncCallback, 1, pThis);
    508         if (RT_SUCCESS(rc))
    509         {
    510             ASMAtomicWriteBool(&pThis->fDummySignal, false);
    511             RTReqFree(pReq);
    512             return;
    513         }
    514 
    515         pThis->pPendingDummyReq = pReq;
    516     }
     532    }
     533
    517534    PDMDrvHlpSetAsyncNotification(pDrvIns, pfnAsyncNotify);
    518535}
     
    528545    PDRVSCSI pThis = PDMINS_2_DATA(pDrvIns, PDRVSCSI);
    529546
    530     if (!drvscsiAsyncIOLoopNoPendingDummy(pThis, 0 /*ms*/))
    531         return false;
    532     ASMAtomicWriteBool(&pThis->fDummySignal, false);
    533     PDMR3ThreadSuspend(pThis->pAsyncIOThread);
    534     return true;
     547    if (pThis->pDrvBlockAsync)
     548    {
     549        if (pThis->StatIoDepth > 0)
     550            return false;
     551        else
     552            return true;
     553    }
     554    else
     555    {
     556        if (!drvscsiAsyncIOLoopNoPendingDummy(pThis, 0 /*ms*/))
     557            return false;
     558        ASMAtomicWriteBool(&pThis->fDummySignal, false);
     559        PDMR3ThreadSuspend(pThis->pAsyncIOThread);
     560        return true;
     561    }
    535562}
    536563
     
    561588    PDRVSCSI pThis = PDMINS_2_DATA(pDrvIns, PDRVSCSI);
    562589
    563     if (!drvscsiAsyncIOLoopNoPendingDummy(pThis, 0 /*ms*/))
    564         return false;
    565     ASMAtomicWriteBool(&pThis->fDummySignal, false);
    566     return true;
     590    if (pThis->pDrvBlockAsync)
     591    {
     592        if (pThis->StatIoDepth > 0)
     593            return false;
     594        else
     595            return true;
     596    }
     597    else
     598    {
     599        if (!drvscsiAsyncIOLoopNoPendingDummy(pThis, 0 /*ms*/))
     600            return false;
     601        ASMAtomicWriteBool(&pThis->fDummySignal, false);
     602        return true;
     603    }
    567604}
    568605
     
    690727    rc = VSCSIDeviceLunAttach(pThis->hVScsiDevice, pThis->hVScsiLun, 0);
    691728    AssertMsgReturn(RT_SUCCESS(rc), ("Failed to attached the LUN to the SCSI device\n"), rc);
    692 
    693     /* Create request queue. */
    694     rc = RTReqCreateQueue(&pThis->pQueueRequests);
    695     AssertMsgReturn(RT_SUCCESS(rc), ("Failed to create request queue rc=%Rrc\n"), rc);
    696729
    697730    /* Register statistics counter. */
     
    709742                            "Number of active tasks.", "/Devices/SCSI0/%d/IoDepth", pDrvIns->iInstance);
    710743
    711 
    712     /* Create I/O thread. */
    713     rc = PDMDrvHlpThreadCreate(pDrvIns, &pThis->pAsyncIOThread, pThis, drvscsiAsyncIOLoop,
    714                                drvscsiAsyncIOLoopWakeup, 0, RTTHREADTYPE_IO, "SCSI async IO");
    715     AssertMsgReturn(RT_SUCCESS(rc), ("Failed to create async I/O thread rc=%Rrc\n"), rc);
     744    if (!pThis->pDrvBlockAsync)
     745    {
     746        /* Create request queue. */
     747        rc = RTReqCreateQueue(&pThis->pQueueRequests);
     748        AssertMsgReturn(RT_SUCCESS(rc), ("Failed to create request queue rc=%Rrc\n"), rc);
     749        /* Create I/O thread. */
     750        rc = PDMDrvHlpThreadCreate(pDrvIns, &pThis->pAsyncIOThread, pThis, drvscsiAsyncIOLoop,
     751                                   drvscsiAsyncIOLoopWakeup, 0, RTTHREADTYPE_IO, "SCSI async IO");
     752        AssertMsgReturn(RT_SUCCESS(rc), ("Failed to create async I/O thread rc=%Rrc\n"), rc);
     753    }
    716754
    717755    return VINF_SUCCESS;
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