VirtualBox

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


Ignore:
Timestamp:
Jun 27, 2014 8:38:04 PM (10 years ago)
Author:
vboxsync
Message:

Storage/DiskIntegrity: Add an option to record the write before it was actually written to disk, useful when debugging issues with filters enabled in VD because they might modify data in the I/O buffer in place which would result in wrong data written into the ramdisk when the write completes

File:
1 edited

Legend:

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

    r51619 r51749  
    196196    /** Flag whether to do a immediate read after write for verification. */
    197197    bool                    fReadAfterWrite;
     198    /** Flag whether to record the data to write before the write completed successfully.
     199     * Useful in case the data is modified in place later on (encryption for instance). */
     200    bool                    fRecordWriteBeforeCompletion;
    198201
    199202    /** I/O logger to use if enabled. */
     
    819822    }
    820823
     824    if (pThis->fRecordWriteBeforeCompletion)
     825    {
     826        RTSGSEG Seg;
     827        Seg.cbSeg = cbWrite;
     828        Seg.pvSeg = (void *)pvBuf;
     829
     830        rc = drvdiskintWriteRecord(pThis, &Seg, 1, off, cbWrite);
     831        if (RT_FAILURE(rc))
     832            return rc;
     833    }
     834
    821835    rc = pThis->pDrvMedia->pfnWrite(pThis->pDrvMedia, off, pvBuf, cbWrite);
    822836
     
    830844        return rc;
    831845
    832     if (pThis->fCheckConsistency)
     846    if (   pThis->fCheckConsistency
     847        && !pThis->fRecordWriteBeforeCompletion)
    833848    {
    834849        /* Record the write. */
     
    918933    }
    919934
     935    if (pThis->fRecordWriteBeforeCompletion)
     936    {
     937        int rc2 = drvdiskintWriteRecord(pThis, paSeg, cSeg, uOffset, cbWrite);
     938        AssertRC(rc2);
     939    }
     940
    920941    int rc = pThis->pDrvMediaAsync->pfnStartWrite(pThis->pDrvMediaAsync, uOffset, paSeg, cSeg,
    921942                                                  cbWrite, pIoReq);
     
    923944    {
    924945        /* Record the write. */
    925         if  (pThis->fCheckConsistency)
     946        if  (   pThis->fCheckConsistency
     947             && !pThis->fRecordWriteBeforeCompletion)
    926948        {
    927949            int rc2 = drvdiskintWriteRecord(pThis, paSeg, cSeg, uOffset, cbWrite);
     
    11531175        if (pIoReq->enmTxDir == DRVDISKAIOTXDIR_READ)
    11541176            rc = drvdiskintReadVerify(pThis, pIoReq->paSeg, pIoReq->cSeg, pIoReq->off, pIoReq->cbTransfer);
    1155         else if (pIoReq->enmTxDir == DRVDISKAIOTXDIR_WRITE)
     1177        else if (   pIoReq->enmTxDir == DRVDISKAIOTXDIR_WRITE
     1178                 && !pThis->fRecordWriteBeforeCompletion)
    11561179            rc = drvdiskintWriteRecord(pThis, pIoReq->paSeg, pIoReq->cSeg, pIoReq->off, pIoReq->cbTransfer);
    11571180        else if (pIoReq->enmTxDir == DRVDISKAIOTXDIR_DISCARD)
     
    11601183            rc = drvdiskintReadAfterWriteVerify(pThis, pIoReq);
    11611184        else
    1162             AssertMsg(pIoReq->enmTxDir == DRVDISKAIOTXDIR_FLUSH, ("Huh?\n"));
     1185            AssertMsg(   pIoReq->enmTxDir == DRVDISKAIOTXDIR_FLUSH
     1186                      || (   pIoReq->enmTxDir == DRVDISKAIOTXDIR_WRITE
     1187                          && pThis->fRecordWriteBeforeCompletion), ("Huh?\n"));
    11631188
    11641189        AssertRC(rc);
     
    13161341                                    "IoLog\0"
    13171342                                    "PrepopulateRamDisk\0"
    1318                                     "ReadAfterWrite\0"))
     1343                                    "ReadAfterWrite\0"
     1344                                    "RecordWriteBeforeCompletion\0"))
    13191345        return VERR_PDM_DRVINS_UNKNOWN_CFG_VALUES;
    13201346
     
    13341360    AssertRC(rc);
    13351361    rc = CFGMR3QueryBoolDef(pCfg, "ReadAfterWrite", &pThis->fReadAfterWrite, false);
     1362    AssertRC(rc);
     1363    rc = CFGMR3QueryBoolDef(pCfg, "RecordWriteBeforeCompletion", &pThis->fRecordWriteBeforeCompletion, false);
    13361364    AssertRC(rc);
    13371365
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