VirtualBox

Changeset 29412 in vbox


Ignore:
Timestamp:
May 12, 2010 12:28:02 PM (15 years ago)
Author:
vboxsync
Message:

DiskIntegrity: Pass async flush requests

File:
1 edited

Legend:

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

    r29306 r29412  
    4141
    4242/**
     43 * Transfer direction.
     44 */
     45typedef enum DRVDISKAIOTXDIR
     46{
     47    /** Read */
     48    DRVDISKAIOTXDIR_READ = 0,
     49    /** Write */
     50    DRVDISKAIOTXDIR_WRITE,
     51    /** Flush */
     52    DRVDISKAIOTXDIR_FLUSH
     53} DRVDISKAIOTXDIR;
     54
     55/**
    4356 * async I/O request.
    4457 */
    4558typedef struct DRVDISKAIOREQ
    4659{
    47     /** Flag whether this is a read or write request. */
    48     bool      fRead;
     60    /** Transfer direction. */
     61    DRVDISKAIOTXDIR enmTxDir;
    4962    /** Start offset. */
    5063    uint64_t  off;
     
    156169 *
    157170 * @returns New I/O request.
    158  * @param   fRead         Flag whether this is a read or a write.
     171 * @param   enmTxDir      Transfer direction.
    159172 * @param   off           Start offset.
    160173 * @param   paSeg         Segment array.
     
    163176 * @param   pvUser        User argument.
    164177 */
    165 static PDRVDISKAIOREQ drvdiskintIoReqAlloc(bool fRead, uint64_t off, PCRTSGSEG paSeg,
     178static PDRVDISKAIOREQ drvdiskintIoReqAlloc(DRVDISKAIOTXDIR enmTxDir, uint64_t off, PCRTSGSEG paSeg,
    166179                                           unsigned cSeg, size_t cbTransfer, void *pvUser)
    167180{
     
    170183    if (RT_LIKELY(pIoReq))
    171184    {
    172         pIoReq->fRead      = fRead;
     185        pIoReq->enmTxDir   = enmTxDir;
    173186        pIoReq->off        = off;
    174187        pIoReq->cbTransfer = cbTransfer;
     
    529542             uOffset, paSeg, cSeg, cbRead, pvUser));
    530543    PDRVDISKINTEGRITY pThis = PDMIMEDIAASYNC_2_DRVDISKINTEGRITY(pInterface);
    531     PDRVDISKAIOREQ pIoReq = drvdiskintIoReqAlloc(true, uOffset, paSeg, cSeg, cbRead, pvUser);
     544    PDRVDISKAIOREQ pIoReq = drvdiskintIoReqAlloc(DRVDISKAIOTXDIR_READ, uOffset, paSeg, cSeg, cbRead, pvUser);
    532545    AssertPtr(pIoReq);
    533546
     
    564577             uOffset, paSeg, cSeg, cbWrite, pvUser));
    565578    PDRVDISKINTEGRITY pThis = PDMIMEDIAASYNC_2_DRVDISKINTEGRITY(pInterface);
    566     PDRVDISKAIOREQ pIoReq = drvdiskintIoReqAlloc(false, uOffset, paSeg, cSeg, cbWrite, pvUser);
     579    PDRVDISKAIOREQ pIoReq = drvdiskintIoReqAlloc(DRVDISKAIOTXDIR_WRITE, uOffset, paSeg, cSeg, cbWrite, pvUser);
    567580    AssertPtr(pIoReq);
    568581
     
    593606}
    594607
     608/** @copydoc PDMIMEDIAASYNC::pfnStartFlush */
     609static DECLCALLBACK(int) drvdiskintStartFlush(PPDMIMEDIAASYNC pInterface, void *pvUser)
     610{
     611    PDRVDISKINTEGRITY pThis = PDMIMEDIAASYNC_2_DRVDISKINTEGRITY(pInterface);
     612    PDRVDISKAIOREQ pIoReq = drvdiskintIoReqAlloc(DRVDISKAIOTXDIR_FLUSH, 0, NULL, 0, 0, pvUser);
     613    AssertPtr(pIoReq);
     614
     615    return pThis->pDrvMediaAsync->pfnStartFlush(pThis->pDrvMediaAsync, pIoReq);
     616}
     617
    595618/** @copydoc PDMIMEDIA::pfnFlush */
    596619static DECLCALLBACK(int) drvdiskintFlush(PPDMIMEDIA pInterface)
     
    672695    if (RT_SUCCESS(rcReq) && pThis->fCheckConsistency)
    673696    {
    674         if (pIoReq->fRead)
     697        if (pIoReq->enmTxDir == DRVDISKAIOTXDIR_READ)
    675698            rc = drvdiskintReadVerify(pThis, pIoReq->paSeg, pIoReq->cSeg, pIoReq->off, pIoReq->cbTransfer);
     699        else if (pIoReq->enmTxDir == DRVDISKAIOTXDIR_WRITE)
     700            rc = drvdiskintWriteRecord(pThis, pIoReq->paSeg, pIoReq->cSeg, pIoReq->off, pIoReq->cbTransfer);
    676701        else
    677             rc = drvdiskintWriteRecord(pThis, pIoReq->paSeg, pIoReq->cSeg, pIoReq->off, pIoReq->cbTransfer);
     702            AssertMsg(pIoReq->enmTxDir == DRVDISKAIOTXDIR_FLUSH, ("Huh?\n"));
    678703
    679704        AssertRC(rc);
     
    789814    pThis->IMediaAsync.pfnStartRead      = drvdiskintStartRead;
    790815    pThis->IMediaAsync.pfnStartWrite     = drvdiskintStartWrite;
     816    pThis->IMediaAsync.pfnStartFlush     = drvdiskintStartFlush;
    791817
    792818    /* IMediaAsyncPort. */
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