Changeset 38878 in vbox for trunk/src/VBox/Devices/Storage/DrvVD.cpp
- Timestamp:
- Sep 27, 2011 9:07:07 AM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Storage/DrvVD.cpp
r38622 r38878 560 560 PDRVVDSTORAGEBACKEND pStorageBackend = (PDRVVDSTORAGEBACKEND)pStorage; 561 561 562 int rc = drvvdAsyncIOFlushSync(pvUser, pStorage); 563 if (RT_SUCCESS(rc)) 564 rc = PDMR3AsyncCompletionEpSetSize(pStorageBackend->pEndpoint, cbSize); 565 566 return rc; 562 return PDMR3AsyncCompletionEpSetSize(pStorageBackend->pEndpoint, cbSize); 567 563 } 568 564 … … 1674 1670 } 1675 1671 1676 static DECLCALLBACK(int) drvvdDiscard(PPDMIMEDIA pInterface, P PDMRANGE paRanges, unsigned cRanges)1672 static DECLCALLBACK(int) drvvdDiscard(PPDMIMEDIA pInterface, PCRTRANGE paRanges, unsigned cRanges) 1677 1673 { 1678 1674 LogFlowFunc(("\n")); 1679 1675 PVBOXDISK pThis = PDMIMEDIA_2_VBOXDISK(pInterface); 1680 1676 1681 /** @todo: Fix the cast properly without allocating temporary memory (maybe move the type to IPRT). */ 1682 int rc = VDDiscardRanges(pThis->pDisk, (PVDRANGE)paRanges, cRanges); 1677 int rc = VDDiscardRanges(pThis->pDisk, paRanges, cRanges); 1683 1678 LogFlowFunc(("returns %Rrc\n", rc)); 1684 1679 return rc; … … 1773 1768 { 1774 1769 rc = PDMR3BlkCacheFlush(pThis->pBlkCache, pvUser); 1770 if (rc == VINF_AIO_TASK_PENDING) 1771 rc = VERR_VD_ASYNC_IO_IN_PROGRESS; 1772 else if (rc == VINF_SUCCESS) 1773 rc = VINF_VD_ASYNC_IO_FINISHED; 1774 } 1775 LogFlowFunc(("returns %Rrc\n", rc)); 1776 return rc; 1777 } 1778 1779 static DECLCALLBACK(int) drvvdStartDiscard(PPDMIMEDIAASYNC pInterface, PCRTRANGE paRanges, 1780 unsigned cRanges, void *pvUser) 1781 { 1782 int rc = VINF_SUCCESS; 1783 PVBOXDISK pThis = PDMIMEDIAASYNC_2_VBOXDISK(pInterface); 1784 1785 LogFlowFunc(("paRanges=%#p cRanges=%u pvUser=%#p\n", 1786 paRanges, cRanges, pvUser)); 1787 1788 if (!pThis->pBlkCache) 1789 rc = VDAsyncDiscardRanges(pThis->pDisk, paRanges, cRanges, drvvdAsyncReqComplete, 1790 pThis, pvUser); 1791 else 1792 { 1793 rc = PDMR3BlkCacheDiscard(pThis->pBlkCache, paRanges, cRanges, pvUser); 1775 1794 if (rc == VINF_AIO_TASK_PENDING) 1776 1795 rc = VERR_VD_ASYNC_IO_IN_PROGRESS; … … 1818 1837 rc = VERR_INVALID_PARAMETER; 1819 1838 } 1839 1840 if (rc == VINF_VD_ASYNC_IO_FINISHED) 1841 PDMR3BlkCacheIoXferComplete(pThis->pBlkCache, hIoXfer, VINF_SUCCESS); 1842 else if (RT_FAILURE(rc) && rc != VERR_VD_ASYNC_IO_IN_PROGRESS) 1843 PDMR3BlkCacheIoXferComplete(pThis->pBlkCache, hIoXfer, rc); 1844 1845 return VINF_SUCCESS; 1846 } 1847 1848 /** @copydoc FNPDMBLKCACHEXFERENQUEUEDISCARDDRV */ 1849 static int drvvdBlkCacheXferEnqueueDiscard(PPDMDRVINS pDrvIns, PCRTRANGE paRanges, 1850 unsigned cRanges, PPDMBLKCACHEIOXFER hIoXfer) 1851 { 1852 int rc = VINF_SUCCESS; 1853 PVBOXDISK pThis = PDMINS_2_DATA(pDrvIns, PVBOXDISK); 1854 1855 rc = VDAsyncDiscardRanges(pThis->pDisk, paRanges, cRanges, 1856 drvvdAsyncReqComplete, pThis, hIoXfer); 1820 1857 1821 1858 if (rc == VINF_VD_ASYNC_IO_FINISHED) … … 2076 2113 pThis->IMediaAsync.pfnStartWrite = drvvdStartWrite; 2077 2114 pThis->IMediaAsync.pfnStartFlush = drvvdStartFlush; 2115 pThis->IMediaAsync.pfnStartDiscard = drvvdStartDiscard; 2078 2116 2079 2117 /* Initialize supported VD interfaces. */ … … 2575 2613 2576 2614 if (!fDiscard) 2615 { 2577 2616 pThis->IMedia.pfnDiscard = NULL; 2617 pThis->IMediaAsync.pfnStartDiscard = NULL; 2618 } 2578 2619 2579 2620 if (RT_SUCCESS(rc)) … … 2666 2707 if ( fUseBlockCache 2667 2708 && !pThis->fShareable 2709 && !fDiscard 2668 2710 && RT_SUCCESS(rc)) 2669 2711 { … … 2695 2737 drvvdBlkCacheXferComplete, 2696 2738 drvvdBlkCacheXferEnqueue, 2739 drvvdBlkCacheXferEnqueueDiscard, 2697 2740 pszId); 2698 2741 if (rc == VERR_NOT_SUPPORTED)
Note:
See TracChangeset
for help on using the changeset viewer.