VirtualBox

Changeset 64839 in vbox for trunk


Ignore:
Timestamp:
Dec 12, 2016 5:32:06 PM (8 years ago)
Author:
vboxsync
Message:

Devices/Storage/DrvHostBase: Statistics for common things (request count, number of bytes read/written, etc.)

Location:
trunk/src/VBox/Devices/Storage
Files:
2 edited

Legend:

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

    r64407 r64839  
    5151    RTCritSectEnter(&pThis->CritSect);
    5252
     53    STAM_REL_COUNTER_INC(&pThis->StatReqsSubmitted);
     54    STAM_REL_COUNTER_INC(&pThis->StatReqsRead);
     55
    5356    /*
    5457     * Check the state.
     
    7477    else
    7578        rc = VERR_MEDIA_NOT_PRESENT;
     79
     80    if (RT_SUCCESS(rc))
     81    {
     82        STAM_REL_COUNTER_INC(&pThis->StatReqsSucceeded);
     83        STAM_REL_COUNTER_ADD(&pThis->StatBytesRead, cbRead);
     84    }
     85    else
     86        STAM_REL_COUNTER_INC(&pThis->StatReqsFailed);
    7687
    7788    RTCritSectLeave(&pThis->CritSect);
     
    91102          pThis->pDrvIns->pReg->szName, pThis->pDrvIns->iInstance, off, cbWrite, cbWrite, pvBuf));
    92103    RTCritSectEnter(&pThis->CritSect);
     104
     105    STAM_REL_COUNTER_INC(&pThis->StatReqsSubmitted);
     106    STAM_REL_COUNTER_INC(&pThis->StatReqsWrite);
    93107
    94108    /*
     
    115129        rc = VERR_WRITE_PROTECT;
    116130
     131    if (RT_SUCCESS(rc))
     132    {
     133        STAM_REL_COUNTER_INC(&pThis->StatReqsSucceeded);
     134        STAM_REL_COUNTER_ADD(&pThis->StatBytesWritten, cbWrite);
     135    }
     136    else
     137        STAM_REL_COUNTER_INC(&pThis->StatReqsFailed);
     138
    117139    RTCritSectLeave(&pThis->CritSect);
    118140    LogFlow(("%s-%d: drvHostBaseWrite: returns %Rrc\n", pThis->pDrvIns->pReg->szName, pThis->pDrvIns->iInstance, rc));
     
    130152    RTCritSectEnter(&pThis->CritSect);
    131153
     154    STAM_REL_COUNTER_INC(&pThis->StatReqsSubmitted);
     155    STAM_REL_COUNTER_INC(&pThis->StatReqsFlush);
     156
    132157    if (pThis->fMediaPresent)
    133158        rc = drvHostBaseFlushOs(pThis);
    134159    else
    135160        rc = VERR_MEDIA_NOT_PRESENT;
     161
     162    if (RT_SUCCESS(rc))
     163        STAM_REL_COUNTER_INC(&pThis->StatReqsSucceeded);
     164    else
     165        STAM_REL_COUNTER_INC(&pThis->StatReqsFailed);
    136166
    137167    RTCritSectLeave(&pThis->CritSect);
     
    460490    pReq->cbReq = cbRead;
    461491    pReq->cbResidual = cbRead;
     492
     493    STAM_REL_COUNTER_INC(&pThis->StatReqsSubmitted);
     494    STAM_REL_COUNTER_INC(&pThis->StatReqsRead);
    462495
    463496    /*
     
    498531        rc = VERR_MEDIA_NOT_PRESENT;
    499532
     533    if (RT_SUCCESS(rc))
     534    {
     535        STAM_REL_COUNTER_INC(&pThis->StatReqsSucceeded);
     536        STAM_REL_COUNTER_INC(&pThis->StatBytesRead);
     537    }
     538    else
     539        STAM_REL_COUNTER_INC(&pThis->StatReqsFailed);
     540
    500541    RTCritSectLeave(&pThis->CritSect);
    501542    LogFlow(("%s-%d: drvHostBaseIoReqRead: returns %Rrc\n", pThis->pDrvIns->pReg->szName, pThis->pDrvIns->iInstance, rc));
     
    514555    pReq->cbReq = cbWrite;
    515556    pReq->cbResidual = cbWrite;
     557
     558    STAM_REL_COUNTER_INC(&pThis->StatReqsSubmitted);
     559    STAM_REL_COUNTER_INC(&pThis->StatReqsWrite);
    516560
    517561    /*
     
    550594        rc = VERR_WRITE_PROTECT;
    551595
     596    if (RT_SUCCESS(rc))
     597    {
     598        STAM_REL_COUNTER_INC(&pThis->StatReqsSucceeded);
     599        STAM_REL_COUNTER_INC(&pThis->StatBytesWritten);
     600    }
     601    else
     602        STAM_REL_COUNTER_INC(&pThis->StatReqsFailed);
     603
    552604    RTCritSectLeave(&pThis->CritSect);
    553605    LogFlow(("%s-%d: drvHostBaseIoReqWrite: returns %Rrc\n", pThis->pDrvIns->pReg->szName, pThis->pDrvIns->iInstance, rc));
     
    566618    RTCritSectEnter(&pThis->CritSect);
    567619
     620    STAM_REL_COUNTER_INC(&pThis->StatReqsSubmitted);
     621    STAM_REL_COUNTER_INC(&pThis->StatReqsFlush);
     622
    568623    if (pThis->fMediaPresent)
    569624        rc = drvHostBaseFlushOs(pThis);
    570625    else
    571626        rc = VERR_MEDIA_NOT_PRESENT;
     627
     628    if (RT_SUCCESS(rc))
     629        STAM_REL_COUNTER_INC(&pThis->StatReqsSucceeded);
     630    else
     631        STAM_REL_COUNTER_INC(&pThis->StatReqsFailed);
    572632
    573633    RTCritSectLeave(&pThis->CritSect);
     
    928988}
    929989
     990/**
     991 * Registers statistics associated with the given media driver.
     992 *
     993 * @returns VBox status code.
     994 * @param   pThis      The media driver instance.
     995 */
     996static int drvHostBaseStatsRegister(PDRVHOSTBASE pThis)
     997{
     998    PPDMDRVINS pDrvIns = pThis->pDrvIns;
     999    uint32_t iInstance, iLUN;
     1000    const char *pcszController;
     1001
     1002    int rc = pThis->pDrvMediaPort->pfnQueryDeviceLocation(pThis->pDrvMediaPort, &pcszController,
     1003                                                          &iInstance, &iLUN);
     1004    if (RT_SUCCESS(rc))
     1005    {
     1006        char *pszCtrlUpper = RTStrDup(pcszController);
     1007        if (pszCtrlUpper)
     1008        {
     1009            RTStrToUpper(pszCtrlUpper);
     1010
     1011            PDMDrvHlpSTAMRegisterF(pDrvIns, &pThis->StatBytesRead, STAMTYPE_COUNTER, STAMVISIBILITY_USED, STAMUNIT_BYTES,
     1012                                   "Amount of data read.", "/Devices/%s%u/Port%u/ReadBytes", pszCtrlUpper, iInstance, iLUN);
     1013            PDMDrvHlpSTAMRegisterF(pDrvIns, &pThis->StatBytesWritten, STAMTYPE_COUNTER, STAMVISIBILITY_USED, STAMUNIT_BYTES,
     1014                                   "Amount of data written.", "/Devices/%s%u/Port%u/WrittenBytes", pszCtrlUpper, iInstance, iLUN);
     1015
     1016            PDMDrvHlpSTAMRegisterF(pDrvIns, &pThis->StatReqsSubmitted, STAMTYPE_COUNTER, STAMVISIBILITY_USED, STAMUNIT_COUNT,
     1017                                   "Number of I/O requests submitted.", "/Devices/%s%u/Port%u/ReqsSubmitted", pszCtrlUpper, iInstance, iLUN);
     1018            PDMDrvHlpSTAMRegisterF(pDrvIns, &pThis->StatReqsFailed, STAMTYPE_COUNTER, STAMVISIBILITY_USED, STAMUNIT_COUNT,
     1019                                   "Number of I/O requests failed.", "/Devices/%s%u/Port%u/ReqsFailed", pszCtrlUpper, iInstance, iLUN);
     1020            PDMDrvHlpSTAMRegisterF(pDrvIns, &pThis->StatReqsSucceeded, STAMTYPE_COUNTER, STAMVISIBILITY_USED, STAMUNIT_COUNT,
     1021                                   "Number of I/O requests succeeded.", "/Devices/%s%u/Port%u/ReqsSucceeded", pszCtrlUpper, iInstance, iLUN);
     1022            PDMDrvHlpSTAMRegisterF(pDrvIns, &pThis->StatReqsFlush, STAMTYPE_COUNTER, STAMVISIBILITY_USED, STAMUNIT_COUNT,
     1023                                   "Number of flush I/O requests submitted.", "/Devices/%s%u/Port%u/ReqsFlush", pszCtrlUpper, iInstance, iLUN);
     1024            PDMDrvHlpSTAMRegisterF(pDrvIns, &pThis->StatReqsWrite, STAMTYPE_COUNTER, STAMVISIBILITY_USED, STAMUNIT_COUNT,
     1025                                   "Number of write I/O requests submitted.", "/Devices/%s%u/Port%u/ReqsWrite", pszCtrlUpper, iInstance, iLUN);
     1026            PDMDrvHlpSTAMRegisterF(pDrvIns, &pThis->StatReqsRead, STAMTYPE_COUNTER, STAMVISIBILITY_USED, STAMUNIT_COUNT,
     1027                                   "Number of read I/O requests submitted.", "/Devices/%s%u/Port%u/ReqsRead", pszCtrlUpper, iInstance, iLUN);
     1028
     1029            RTStrFree(pszCtrlUpper);
     1030        }
     1031        else
     1032            rc = VERR_NO_STR_MEMORY;
     1033    }
     1034
     1035    return rc;
     1036}
     1037
     1038/**
     1039 * Deregisters statistics associated with the given media driver.
     1040 *
     1041 * @returns nothing.
     1042 * @param   pThis      The media driver instance.
     1043 */
     1044static void drvhostBaseStatsDeregister(PDRVHOSTBASE pThis)
     1045{
     1046    PPDMDRVINS pDrvIns = pThis->pDrvIns;
     1047
     1048    PDMDrvHlpSTAMDeregister(pDrvIns, &pThis->StatBytesRead);
     1049    PDMDrvHlpSTAMDeregister(pDrvIns, &pThis->StatBytesWritten);
     1050    PDMDrvHlpSTAMDeregister(pDrvIns, &pThis->StatReqsSubmitted);
     1051    PDMDrvHlpSTAMDeregister(pDrvIns, &pThis->StatReqsFailed);
     1052    PDMDrvHlpSTAMDeregister(pDrvIns, &pThis->StatReqsSucceeded);
     1053    PDMDrvHlpSTAMDeregister(pDrvIns, &pThis->StatReqsFlush);
     1054    PDMDrvHlpSTAMDeregister(pDrvIns, &pThis->StatReqsWrite);
     1055    PDMDrvHlpSTAMDeregister(pDrvIns, &pThis->StatReqsRead);
     1056}
     1057
    9301058/* -=-=-=-=- driver interface -=-=-=-=- */
    9311059
     
    10161144    /* Forget about the notifications. */
    10171145    pThis->pDrvMountNotify = NULL;
     1146
     1147    drvhostBaseStatsDeregister(pThis);
    10181148
    10191149    /* Leave the instance operational if this is just a cleanup of the state
     
    13161446    }
    13171447
     1448    if (RT_SUCCESS(rc))
     1449        drvHostBaseStatsRegister(pThis);
     1450
    13181451    if (RT_FAILURE(rc))
    13191452    {
  • trunk/src/VBox/Devices/Storage/DrvHostBase.h

    r64407 r64839  
    107107    size_t                  cbIoReqAlloc;
    108108
     109    /** Release statistics: number of bytes written. */
     110    STAMCOUNTER              StatBytesWritten;
     111    /** Release statistics: number of bytes read. */
     112    STAMCOUNTER              StatBytesRead;
     113    /** Release statistics: Number of requests submitted. */
     114    STAMCOUNTER              StatReqsSubmitted;
     115    /** Release statistics: Number of requests failed. */
     116    STAMCOUNTER              StatReqsFailed;
     117    /** Release statistics: Number of requests succeeded. */
     118    STAMCOUNTER              StatReqsSucceeded;
     119    /** Release statistics: Number of flush requests. */
     120    STAMCOUNTER              StatReqsFlush;
     121    /** Release statistics: Number of write requests. */
     122    STAMCOUNTER              StatReqsWrite;
     123    /** Release statistics: Number of read requests. */
     124    STAMCOUNTER              StatReqsRead;
     125
    109126    /**
    110127     * Performs the locking / unlocking of the device.
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