VirtualBox

Changeset 38541 in vbox for trunk/src/VBox/Devices/Storage


Ignore:
Timestamp:
Aug 25, 2011 10:11:02 PM (14 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
73689
Message:

DrvDiskIntegrity: Add support for the I/O logger from the storage debug library

File:
1 edited

Legend:

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

    r35353 r38541  
    2222#define LOG_GROUP LOG_GROUP_DRV_DISK_INTEGRITY
    2323#include <VBox/vmm/pdmdrv.h>
     24#include <VBox/vddbg.h>
    2425#include <iprt/assert.h>
    2526#include <iprt/string.h>
     
    7677    /** Completion timestamp. */
    7778    uint64_t        tsComplete;
     79    /** I/O log entry if configured. */
     80    VDIOLOGENT      hIoLogEntry;
    7881} DRVDISKAIOREQ, *PDRVDISKAIOREQ;
    7982
     
    180183    /** Current entry in the array. */
    181184    unsigned                iEntry;
     185
     186    /** I/O logger to use if enabled. */
     187    VDIOLOGGER              hIoLogger;
    182188} DRVDISKINTEGRITY, *PDRVDISKINTEGRITY;
    183189
     
    201207    if (RT_LIKELY(pIoReq))
    202208    {
    203         pIoReq->enmTxDir   = enmTxDir;
    204         pIoReq->off        = off;
    205         pIoReq->cbTransfer = cbTransfer;
    206         pIoReq->paSeg      = paSeg;
    207         pIoReq->cSeg       = cSeg;
    208         pIoReq->pvUser     = pvUser;
    209         pIoReq->iSlot      = 0;
    210         pIoReq->tsStart    = RTTimeSystemMilliTS();
    211         pIoReq->tsComplete = 0;
     209        pIoReq->enmTxDir    = enmTxDir;
     210        pIoReq->off         = off;
     211        pIoReq->cbTransfer  = cbTransfer;
     212        pIoReq->paSeg       = paSeg;
     213        pIoReq->cSeg        = cSeg;
     214        pIoReq->pvUser      = pvUser;
     215        pIoReq->iSlot       = 0;
     216        pIoReq->tsStart     = RTTimeSystemMilliTS();
     217        pIoReq->tsComplete  = 0;
     218        pIoReq->hIoLogEntry = NULL;
    212219    }
    213220
     
    556563                                        uint64_t off, void *pvBuf, size_t cbRead)
    557564{
     565    int rc = VINF_SUCCESS;
     566    VDIOLOGENT hIoLogEntry;
    558567    PDRVDISKINTEGRITY pThis = PDMIMEDIA_2_DRVDISKINTEGRITY(pInterface);
    559     int rc = pThis->pDrvMedia->pfnRead(pThis->pDrvMedia, off, pvBuf, cbRead);
     568
     569    if (pThis->hIoLogger)
     570    {
     571        rc = VDDbgIoLogStart(pThis->hIoLogger, false, VDDBGIOLOGTXDIR_READ, off,
     572                             cbRead, NULL, &hIoLogEntry);
     573        AssertRC(rc);
     574    }
     575
     576    rc = pThis->pDrvMedia->pfnRead(pThis->pDrvMedia, off, pvBuf, cbRead);
     577
     578    if (pThis->hIoLogger)
     579    {
     580        RTSGSEG Seg;
     581        RTSGBUF SgBuf;
     582
     583        Seg.pvSeg = pvBuf;
     584        Seg.cbSeg = cbRead;
     585        RTSgBufInit(&SgBuf, &Seg, 1);
     586
     587        int rc2 = VDDbgIoLogComplete(pThis->hIoLogger, hIoLogEntry, rc, &SgBuf);
     588        AssertRC(rc2);
     589    }
     590
    560591    if (RT_FAILURE(rc))
    561592        return rc;
     
    578609                                         size_t cbWrite)
    579610{
     611    int rc = VINF_SUCCESS;
     612    VDIOLOGENT hIoLogEntry;
    580613    PDRVDISKINTEGRITY pThis = PDMIMEDIA_2_DRVDISKINTEGRITY(pInterface);
    581     int rc = pThis->pDrvMedia->pfnWrite(pThis->pDrvMedia, off, pvBuf, cbWrite);
     614
     615    if (pThis->hIoLogger)
     616    {
     617        RTSGSEG Seg;
     618        RTSGBUF SgBuf;
     619
     620        Seg.pvSeg = (void *)pvBuf;
     621        Seg.cbSeg = cbWrite;
     622        RTSgBufInit(&SgBuf, &Seg, 1);
     623
     624        rc = VDDbgIoLogStart(pThis->hIoLogger, false, VDDBGIOLOGTXDIR_WRITE, off,
     625                             cbWrite, &SgBuf, &hIoLogEntry);
     626        AssertRC(rc);
     627    }
     628
     629    rc = pThis->pDrvMedia->pfnWrite(pThis->pDrvMedia, off, pvBuf, cbWrite);
     630
     631    if (pThis->hIoLogger)
     632    {
     633        int rc2 = VDDbgIoLogComplete(pThis->hIoLogger, hIoLogEntry, rc, NULL);
     634        AssertRC(rc2);
     635    }
     636
    582637    if (RT_FAILURE(rc))
    583638        return rc;
     
    608663        drvdiskintIoReqAdd(pThis, pIoReq);
    609664
     665    if (pThis->hIoLogger)
     666    {
     667        int rc2 = VDDbgIoLogStart(pThis->hIoLogger, true, VDDBGIOLOGTXDIR_READ, uOffset,
     668                                  cbRead, NULL, &pIoReq->hIoLogEntry);
     669        AssertRC(rc2);
     670    }
     671
    610672    int rc = pThis->pDrvMediaAsync->pfnStartRead(pThis->pDrvMediaAsync, uOffset, paSeg, cSeg,
    611673                                                 cbRead, pIoReq);
     
    616678        {
    617679            int rc2 = drvdiskintReadVerify(pThis, paSeg, cSeg, uOffset, cbRead);
     680            AssertRC(rc2);
     681        }
     682
     683        if (pThis->hIoLogger)
     684        {
     685            RTSGBUF SgBuf;
     686
     687            RTSgBufInit(&SgBuf, paSeg, cSeg);
     688
     689            int rc2 = VDDbgIoLogComplete(pThis->hIoLogger, pIoReq->hIoLogEntry, VINF_SUCCESS, &SgBuf);
    618690            AssertRC(rc2);
    619691        }
     
    643715        drvdiskintIoReqAdd(pThis, pIoReq);
    644716
     717    if (pThis->hIoLogger)
     718    {
     719        RTSGBUF SgBuf;
     720
     721        RTSgBufInit(&SgBuf, paSeg, cSeg);
     722
     723        int rc2 = VDDbgIoLogStart(pThis->hIoLogger, true, VDDBGIOLOGTXDIR_WRITE, uOffset,
     724                                  cbWrite, &SgBuf, &pIoReq->hIoLogEntry);
     725        AssertRC(rc2);
     726    }
     727
    645728    int rc = pThis->pDrvMediaAsync->pfnStartWrite(pThis->pDrvMediaAsync, uOffset, paSeg, cSeg,
    646729                                                  cbWrite, pIoReq);
    647730    if (rc == VINF_VD_ASYNC_IO_FINISHED)
    648731    {
    649         /* Verify the read now. */
     732        /* Record the write. */
    650733        if  (pThis->fCheckConsistency)
    651734        {
     
    654737        }
    655738
     739        if (pThis->hIoLogger)
     740        {
     741            int rc2 = VDDbgIoLogComplete(pThis->hIoLogger, pIoReq->hIoLogEntry, VINF_SUCCESS, NULL);
     742            AssertRC(rc2);
     743        }
     744
    656745        if (pThis->fTraceRequests)
    657746            drvdiskintIoReqRemove(pThis, pIoReq);
     
    669758static DECLCALLBACK(int) drvdiskintStartFlush(PPDMIMEDIAASYNC pInterface, void *pvUser)
    670759{
     760    int rc = VINF_SUCCESS;
    671761    PDRVDISKINTEGRITY pThis = PDMIMEDIAASYNC_2_DRVDISKINTEGRITY(pInterface);
    672762    PDRVDISKAIOREQ pIoReq = drvdiskintIoReqAlloc(DRVDISKAIOTXDIR_FLUSH, 0, NULL, 0, 0, pvUser);
     
    676766        drvdiskintIoReqAdd(pThis, pIoReq);
    677767
    678     return pThis->pDrvMediaAsync->pfnStartFlush(pThis->pDrvMediaAsync, pIoReq);
     768    if (pThis->hIoLogger)
     769    {
     770        rc = VDDbgIoLogStart(pThis->hIoLogger, true, VDDBGIOLOGTXDIR_FLUSH, 0,
     771                             0, NULL, &pIoReq->hIoLogEntry);
     772        AssertRC(rc);
     773    }
     774
     775    rc = pThis->pDrvMediaAsync->pfnStartFlush(pThis->pDrvMediaAsync, pIoReq);
     776
     777    if (rc == VINF_VD_ASYNC_IO_FINISHED)
     778    {
     779        if (pThis->hIoLogger)
     780        {
     781            int rc2 = VDDbgIoLogComplete(pThis->hIoLogger, pIoReq->hIoLogEntry, VINF_SUCCESS, NULL);
     782            AssertRC(rc2);
     783        }
     784
     785        RTMemFree(pIoReq);
     786    }
     787    else if (RT_FAILURE(rc) && rc != VERR_VD_ASYNC_IO_IN_PROGRESS)
     788        RTMemFree(pIoReq);
     789
     790    LogFlow(("%s: returns %Rrc\n", __FUNCTION__, rc));
     791    return rc;
    679792}
    680793
     
    682795static DECLCALLBACK(int) drvdiskintFlush(PPDMIMEDIA pInterface)
    683796{
     797    int rc = VINF_SUCCESS;
     798    VDIOLOGENT hIoLogEntry;
    684799    PDRVDISKINTEGRITY pThis = PDMIMEDIA_2_DRVDISKINTEGRITY(pInterface);
    685     return pThis->pDrvMedia->pfnFlush(pThis->pDrvMedia);
     800
     801    if (pThis->hIoLogger)
     802    {
     803        rc = VDDbgIoLogStart(pThis->hIoLogger, false, VDDBGIOLOGTXDIR_FLUSH, 0,
     804                             0, NULL, &hIoLogEntry);
     805        AssertRC(rc);
     806    }
     807
     808    rc = pThis->pDrvMedia->pfnFlush(pThis->pDrvMedia);
     809
     810    if (pThis->hIoLogger)
     811    {
     812        int rc2 = VDDbgIoLogComplete(pThis->hIoLogger, hIoLogEntry, rc, NULL);
     813        AssertRC(rc2);
     814    }
     815
     816    return rc;
    686817}
    687818
     
    768899    }
    769900
     901    if (pThis->hIoLogger)
     902    {
     903        RTSGBUF SgBuf;
     904
     905        if (pIoReq->enmTxDir == DRVDISKAIOTXDIR_READ)
     906            RTSgBufInit(&SgBuf, pIoReq->paSeg, pIoReq->cSeg);
     907
     908        int rc2 = VDDbgIoLogComplete(pThis->hIoLogger, pIoReq->hIoLogEntry, rc, &SgBuf);
     909        AssertRC(rc2);
     910    }
     911
    770912    void *pvUserComplete = pIoReq->pvUser;
    771913
     
    854996        }
    855997    }
     998
     999    if (pThis->hIoLogger)
     1000        VDDbgIoLogDestroy(pThis->hIoLogger);
    8561001}
    8571002
     
    8761021                                    "ExpireIntervalMs\0"
    8771022                                    "CheckDoubleCompletions\0"
    878                                     "HistorySize\0"))
     1023                                    "HistorySize\0"
     1024                                    "IoLog\0"))
    8791025        return VERR_PDM_DRVINS_UNKNOWN_CFG_VALUES;
    8801026
     
    8921038    AssertRC(rc);
    8931039
     1040    char *pszIoLogFilename = NULL;
     1041    rc = CFGMR3QueryStringAlloc(pCfg, "IoLog", &pszIoLogFilename);
     1042    Assert(RT_SUCCESS(rc) || rc == VERR_CFGM_VALUE_NOT_FOUND);
     1043
    8941044    /*
    8951045     * Initialize most of the data members.
     
    9801130        pThis->papIoReq = (PDRVDISKAIOREQ *)RTMemAllocZ(pThis->cEntries * sizeof(PDRVDISKAIOREQ));
    9811131        AssertPtr(pThis->papIoReq);
     1132    }
     1133
     1134    if (pszIoLogFilename)
     1135    {
     1136        rc = VDDbgIoLogCreate(&pThis->hIoLogger, pszIoLogFilename, VDDBG_IOLOG_LOG_DATA);
     1137        RTStrFree(pszIoLogFilename);
    9821138    }
    9831139
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