VirtualBox

Changeset 59550 in vbox


Ignore:
Timestamp:
Feb 1, 2016 6:56:09 PM (9 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
105347
Message:

Storage/DrvVD: Log errors and requests taking too long (moved from the NVMe emulation were it will be dropped soon)

File:
1 edited

Legend:

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

    r59539 r59550  
    103103/** Saved state version of an I/O request .*/
    104104#define DRVVD_IOREQ_SAVED_STATE_VERSION UINT32_C(1)
     105/** Maximum number of request errors in the release log before muting. */
     106#define DRVVD_MAX_LOG_REL_ERRORS        100
    105107
    106108/** Forward declaration for the dis kcontainer. */
     
    189191    /** Flags. */
    190192    uint32_t                      fFlags;
     193    /** Timestamp when the request was submitted. */
     194    uint64_t                      tsSubmit;
    191195    /** Type dependent data. */
    192196    union
     
    393397    /** Criticial section protecting the list of waiting requests. */
    394398    RTCRITSECT               CritSectIoReqRedo;
     399    /** Number of errors logged so far. */
     400    unsigned                 cErrors;
    395401    /** @} */
    396402} VBOXDISK;
     
    29082914    ASMAtomicXchgU32((volatile uint32_t *)&pIoReq->enmState, VDIOREQSTATE_COMPLETED);
    29092915
     2916    /*
     2917     * Leave a release log entry if the request was active for more than 25 seconds
     2918     * (30 seconds is the timeout of the guest).
     2919     */
     2920    uint64_t tsNow = RTTimeMilliTS();
     2921    if (tsNow - pIoReq->tsSubmit >= 25 * 1000)
     2922    {
     2923        const char *pcszReq = NULL;
     2924
     2925        switch (pIoReq->enmType)
     2926        {
     2927            case PDMMEDIAEXIOREQTYPE_READ:
     2928                pcszReq = "Read";
     2929                break;
     2930            case PDMMEDIAEXIOREQTYPE_WRITE:
     2931                pcszReq = "Write";
     2932                break;
     2933            case PDMMEDIAEXIOREQTYPE_FLUSH:
     2934                pcszReq = "Flush";
     2935                break;
     2936            case PDMMEDIAEXIOREQTYPE_DISCARD:
     2937                pcszReq = "Discard";
     2938                break;
     2939            default:
     2940                pcszReq = "<Invalid>";
     2941        }
     2942
     2943        LogRel(("VD#%u: %s request was active for %llu seconds\n",
     2944                pThis->pDrvIns->iInstance, pcszReq, (tsNow - pIoReq->tsSubmit) / 1000));
     2945    }
     2946
     2947    if (RT_FAILURE(rcReq))
     2948    {
     2949        /* Log the error. */
     2950        if (pThis->cErrors++ < DRVVD_MAX_LOG_REL_ERRORS)
     2951        {
     2952            if (rcReq == VERR_PDM_MEDIAEX_IOREQ_CANCELED)
     2953            {
     2954                if (pIoReq->enmType == PDMMEDIAEXIOREQTYPE_FLUSH)
     2955                    LogRel(("VD#%u: Aborted flush returned rc=%Rrc\n",
     2956                            pThis->pDrvIns->iInstance, rcReq));
     2957                else
     2958                    LogRel(("VD#%u: Aborted %s (%u bytes left) returned rc=%Rrc\n",
     2959                            pThis->pDrvIns->iInstance,
     2960                            pIoReq->enmType == PDMMEDIAEXIOREQTYPE_READ
     2961                            ? "read"
     2962                            : "write",
     2963                            pIoReq->ReadWrite.cbReqLeft, rcReq));
     2964            }
     2965            else
     2966            {
     2967                if (pIoReq->enmType == PDMMEDIAEXIOREQTYPE_FLUSH)
     2968                    LogRel(("VD#%u: Flush returned rc=%Rrc\n",
     2969                            pThis->pDrvIns->iInstance, rcReq));
     2970                else
     2971                    LogRel(("VD#%u: %s (%u bytes left) returned rc=%Rrc\n",
     2972                            pThis->pDrvIns->iInstance,
     2973                            pIoReq->enmType == PDMMEDIAEXIOREQTYPE_READ
     2974                            ? "Read"
     2975                            : "Write",
     2976                            pIoReq->ReadWrite.cbReqLeft, rcReq));
     2977            }
     2978        }
     2979    }
     2980
    29102981    if (fUpNotify)
    29112982    {
     
    32853356
    32863357    pIoReq->enmType             = PDMMEDIAEXIOREQTYPE_READ;
     3358    pIoReq->tsSubmit            = RTTimeMilliTS();
    32873359    pIoReq->ReadWrite.offStart  = off;
    32883360    pIoReq->ReadWrite.cbReq     = cbRead;
     
    33233395
    33243396    pIoReq->enmType             = PDMMEDIAEXIOREQTYPE_WRITE;
     3397    pIoReq->tsSubmit            = RTTimeMilliTS();
    33253398    pIoReq->ReadWrite.offStart  = off;
    33263399    pIoReq->ReadWrite.cbReq     = cbWrite;
     
    33613434
    33623435    pIoReq->enmType  = PDMMEDIAEXIOREQTYPE_FLUSH;
     3436    pIoReq->tsSubmit = RTTimeMilliTS();
    33633437    bool fXchg = ASMAtomicCmpXchgU32((volatile uint32_t *)&pIoReq->enmState, VDIOREQSTATE_ACTIVE, VDIOREQSTATE_ALLOCATED);
    33643438    if (RT_UNLIKELY(!fXchg))
     
    33973471        return VERR_PDM_MEDIAEX_IOREQ_INVALID_STATE;
    33983472
    3399     pIoReq->enmType = PDMMEDIAEXIOREQTYPE_DISCARD;
     3473    pIoReq->enmType  = PDMMEDIAEXIOREQTYPE_DISCARD;
     3474    pIoReq->tsSubmit = RTTimeMilliTS();
    34003475    /* Copy the ranges over because they might not be valid anymore when this method returns. */
    34013476    pIoReq->Discard.paRanges = (PRTRANGE)RTMemDup(paRanges, cRanges * sizeof(RTRANGE));
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