Changeset 38541 in vbox for trunk/src/VBox/Devices/Storage
- Timestamp:
- Aug 25, 2011 10:11:02 PM (14 years ago)
- svn:sync-xref-src-repo-rev:
- 73689
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Storage/DrvDiskIntegrity.cpp
r35353 r38541 22 22 #define LOG_GROUP LOG_GROUP_DRV_DISK_INTEGRITY 23 23 #include <VBox/vmm/pdmdrv.h> 24 #include <VBox/vddbg.h> 24 25 #include <iprt/assert.h> 25 26 #include <iprt/string.h> … … 76 77 /** Completion timestamp. */ 77 78 uint64_t tsComplete; 79 /** I/O log entry if configured. */ 80 VDIOLOGENT hIoLogEntry; 78 81 } DRVDISKAIOREQ, *PDRVDISKAIOREQ; 79 82 … … 180 183 /** Current entry in the array. */ 181 184 unsigned iEntry; 185 186 /** I/O logger to use if enabled. */ 187 VDIOLOGGER hIoLogger; 182 188 } DRVDISKINTEGRITY, *PDRVDISKINTEGRITY; 183 189 … … 201 207 if (RT_LIKELY(pIoReq)) 202 208 { 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; 212 219 } 213 220 … … 556 563 uint64_t off, void *pvBuf, size_t cbRead) 557 564 { 565 int rc = VINF_SUCCESS; 566 VDIOLOGENT hIoLogEntry; 558 567 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 560 591 if (RT_FAILURE(rc)) 561 592 return rc; … … 578 609 size_t cbWrite) 579 610 { 611 int rc = VINF_SUCCESS; 612 VDIOLOGENT hIoLogEntry; 580 613 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 582 637 if (RT_FAILURE(rc)) 583 638 return rc; … … 608 663 drvdiskintIoReqAdd(pThis, pIoReq); 609 664 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 610 672 int rc = pThis->pDrvMediaAsync->pfnStartRead(pThis->pDrvMediaAsync, uOffset, paSeg, cSeg, 611 673 cbRead, pIoReq); … … 616 678 { 617 679 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); 618 690 AssertRC(rc2); 619 691 } … … 643 715 drvdiskintIoReqAdd(pThis, pIoReq); 644 716 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 645 728 int rc = pThis->pDrvMediaAsync->pfnStartWrite(pThis->pDrvMediaAsync, uOffset, paSeg, cSeg, 646 729 cbWrite, pIoReq); 647 730 if (rc == VINF_VD_ASYNC_IO_FINISHED) 648 731 { 649 /* Verify the read now. */732 /* Record the write. */ 650 733 if (pThis->fCheckConsistency) 651 734 { … … 654 737 } 655 738 739 if (pThis->hIoLogger) 740 { 741 int rc2 = VDDbgIoLogComplete(pThis->hIoLogger, pIoReq->hIoLogEntry, VINF_SUCCESS, NULL); 742 AssertRC(rc2); 743 } 744 656 745 if (pThis->fTraceRequests) 657 746 drvdiskintIoReqRemove(pThis, pIoReq); … … 669 758 static DECLCALLBACK(int) drvdiskintStartFlush(PPDMIMEDIAASYNC pInterface, void *pvUser) 670 759 { 760 int rc = VINF_SUCCESS; 671 761 PDRVDISKINTEGRITY pThis = PDMIMEDIAASYNC_2_DRVDISKINTEGRITY(pInterface); 672 762 PDRVDISKAIOREQ pIoReq = drvdiskintIoReqAlloc(DRVDISKAIOTXDIR_FLUSH, 0, NULL, 0, 0, pvUser); … … 676 766 drvdiskintIoReqAdd(pThis, pIoReq); 677 767 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; 679 792 } 680 793 … … 682 795 static DECLCALLBACK(int) drvdiskintFlush(PPDMIMEDIA pInterface) 683 796 { 797 int rc = VINF_SUCCESS; 798 VDIOLOGENT hIoLogEntry; 684 799 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; 686 817 } 687 818 … … 768 899 } 769 900 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 770 912 void *pvUserComplete = pIoReq->pvUser; 771 913 … … 854 996 } 855 997 } 998 999 if (pThis->hIoLogger) 1000 VDDbgIoLogDestroy(pThis->hIoLogger); 856 1001 } 857 1002 … … 876 1021 "ExpireIntervalMs\0" 877 1022 "CheckDoubleCompletions\0" 878 "HistorySize\0")) 1023 "HistorySize\0" 1024 "IoLog\0")) 879 1025 return VERR_PDM_DRVINS_UNKNOWN_CFG_VALUES; 880 1026 … … 892 1038 AssertRC(rc); 893 1039 1040 char *pszIoLogFilename = NULL; 1041 rc = CFGMR3QueryStringAlloc(pCfg, "IoLog", &pszIoLogFilename); 1042 Assert(RT_SUCCESS(rc) || rc == VERR_CFGM_VALUE_NOT_FOUND); 1043 894 1044 /* 895 1045 * Initialize most of the data members. … … 980 1130 pThis->papIoReq = (PDRVDISKAIOREQ *)RTMemAllocZ(pThis->cEntries * sizeof(PDRVDISKAIOREQ)); 981 1131 AssertPtr(pThis->papIoReq); 1132 } 1133 1134 if (pszIoLogFilename) 1135 { 1136 rc = VDDbgIoLogCreate(&pThis->hIoLogger, pszIoLogFilename, VDDBG_IOLOG_LOG_DATA); 1137 RTStrFree(pszIoLogFilename); 982 1138 } 983 1139
Note:
See TracChangeset
for help on using the changeset viewer.