VirtualBox

Changeset 29240 in vbox


Ignore:
Timestamp:
May 8, 2010 4:16:10 PM (15 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
61322
Message:

VBoxHDD: Bring back error reporting for the new async I/O code

File:
1 edited

Legend:

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

    r29048 r29240  
    228228    /** Flag whether the I/O context is blocked because it is in the growing list. */
    229229    bool                         fBlocked;
     230    /** Number of data transfers currently pending. */
     231    volatile uint32_t            cDataTransfersPending;
    230232    /** How many meta data transfers are pending. */
    231233    volatile uint32_t            cMetaTransfersPending;
     
    596598        pIoCtx->uOffset               = uOffset;
    597599        pIoCtx->cbTransfer            = cbTransfer;
     600        pIoCtx->cDataTransfersPending = 0;
    598601        pIoCtx->cMetaTransfersPending = 0;
    599602        pIoCtx->fComplete             = false;
     
    749752    if (   !pIoCtx->cbTransferLeft
    750753        && !pIoCtx->cMetaTransfersPending
     754        && !pIoCtx->cDataTransfersPending
    751755        && !pIoCtx->pfnIoCtxTransfer)
     756        return VINF_VD_ASYNC_IO_FINISHED;
     757
     758    /*
     759     * We complete the I/O context in case of an error
     760     * if there is no I/O task pending.
     761     */
     762    if (   RT_FAILURE(pIoCtx->rcReq)
     763        && !pIoCtx->cMetaTransfersPending
     764        && !pIoCtx->cDataTransfersPending)
    752765        return VINF_VD_ASYNC_IO_FINISHED;
    753766
     
    774787    if (   RT_SUCCESS(rc)
    775788        && !pIoCtx->cbTransferLeft
    776         && !pIoCtx->cMetaTransfersPending)
     789        && !pIoCtx->cMetaTransfersPending
     790        && !pIoCtx->cDataTransfersPending)
    777791        rc = VINF_VD_ASYNC_IO_FINISHED;
    778792    else if (RT_SUCCESS(rc))
    779793        rc = VERR_VD_ASYNC_IO_IN_PROGRESS;
     794    else
     795    {
     796        ASMAtomicCmpXchgS32(&pIoCtx->rcReq, rc, VINF_SUCCESS);
     797        /*
     798         * The I/O context completed if we have an error and there is no data
     799         * or meta data transfer pending.
     800         */
     801        if (   !pIoCtx->cMetaTransfersPending
     802            && !pIoCtx->cDataTransfersPending)
     803            rc = VINF_VD_ASYNC_IO_FINISHED;
     804    }
    780805
    781806    LogFlowFunc(("pIoCtx=%#p rc=%Rrc cbTransferLeft=%u cMetaTransfersPending=%u fComplete=%RTbool\n",
     
    17711796
    17721797    if (!pIoTask->fMeta)
     1798    {
    17731799        ASMAtomicSubU32(&pIoCtx->cbTransferLeft, pIoTask->Type.User.cbTransfer);
     1800        ASMAtomicDecU32(&pIoCtx->cDataTransfersPending);
     1801    }
    17741802    else
    17751803    {
     
    17831811    vdIoTaskFree(pDisk, pIoTask);
    17841812
     1813    if (RT_FAILURE(rcReq))
     1814        ASMAtomicCmpXchgS32(&pIoCtx->rcReq, rcReq, VINF_SUCCESS);
     1815
    17851816    if (!pIoCtx->fBlocked)
    17861817    {
     
    18041835                ASMAtomicSubU32(&pIoCtxParent->cbTransferLeft, pIoCtx->Type.Child.cbTransferParent);
    18051836
     1837                if (RT_FAILURE(pIoCtx->rcReq))
     1838                    ASMAtomicCmpXchgS32(&pIoCtxParent->rcReq, pIoCtx->rcReq, VINF_SUCCESS);
     1839 
    18061840                /*
    18071841                 * A completed child write means that we finsihed growing the image.
     
    20202054            return VERR_NO_MEMORY;
    20212055
     2056        ASMAtomicIncU32(&pIoCtx->cDataTransfersPending);
     2057
    20222058        void *pvTask;
    20232059        int rc2 = pDisk->pInterfaceAsyncIOCallbacks->pfnReadAsync(pDisk->pInterfaceAsyncIO->pvUser,
     
    20302066            AssertMsg(cbTaskRead <= pIoCtx->cbTransferLeft, ("Impossible!\n"));
    20312067            ASMAtomicSubU32(&pIoCtx->cbTransferLeft, cbTaskRead);
     2068            ASMAtomicDecU32(&pIoCtx->cDataTransfersPending);
    20322069            vdIoTaskFree(pDisk, pIoTask);
    20332070        }
     
    20812118        if (!pIoTask)
    20822119            return VERR_NO_MEMORY;
     2120
     2121        ASMAtomicIncU32(&pIoCtx->cDataTransfersPending);
    20832122
    20842123        void *pvTask;
     
    20922131            AssertMsg(cbTaskWrite <= pIoCtx->cbTransferLeft, ("Impossible!\n"));
    20932132            ASMAtomicSubU32(&pIoCtx->cbTransferLeft, cbTaskWrite);
     2133            ASMAtomicDecU32(&pIoCtx->cDataTransfersPending);
    20942134            vdIoTaskFree(pDisk, pIoTask);
    20952135        }
Note: See TracChangeset for help on using the changeset viewer.

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