Changeset 44415 in vbox
- Timestamp:
- Jan 28, 2013 11:28:44 AM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Storage/VD.cpp
r44412 r44415 423 423 } VDIOCTX; 424 424 425 /** Default flags for an I/O context, i.e. unblocked and async. */ 426 #define VDIOCTX_FLAGS_DEFAULT (0) 425 427 /** Flag whether the context is blocked. */ 426 428 #define VDIOCTX_FLAGS_BLOCKED RT_BIT_32(0) … … 1313 1315 void *pvUser1, void *pvUser2, 1314 1316 void *pvAllocation, 1315 PFNVDIOCTXTRANSFER pfnIoCtxTransfer) 1317 PFNVDIOCTXTRANSFER pfnIoCtxTransfer, 1318 uint32_t fFlags) 1316 1319 { 1317 1320 PVDIOCTX pIoCtx = vdIoCtxAlloc(pDisk, enmTxDir, uOffset, cbTransfer, pImageStart, 1318 pcSgBuf, pvAllocation, pfnIoCtxTransfer, 0);1321 pcSgBuf, pvAllocation, pfnIoCtxTransfer, fFlags); 1319 1322 1320 1323 if (RT_LIKELY(pIoCtx)) … … 1762 1765 rc = VERR_VD_ASYNC_IO_IN_PROGRESS; 1763 1766 } 1767 1768 return rc; 1769 } 1770 1771 /** 1772 * Process the I/O context in a synchronous manner, waiting 1773 * for it to complete. 1774 * 1775 * @returns VBox status code of the completed request. 1776 * @param pIoCtx The sync I/O context. 1777 */ 1778 static int vdIoCtxProcessSync(PVDIOCTX pIoCtx) 1779 { 1780 int rc = VINF_SUCCESS; 1781 PVBOXHDD pDisk = pIoCtx->pDisk; 1782 1783 LogFlowFunc(("pIoCtx=%p\n", pIoCtx)); 1784 1785 AssertMsg(pIoCtx->fFlags & VDIOCTX_FLAGS_SYNC, 1786 ("I/O context is not marked as synchronous\n")); 1787 1788 rc = vdIoCtxProcessTryLockDefer(pIoCtx); 1789 if (rc == VINF_VD_ASYNC_IO_FINISHED) 1790 rc = VINF_SUCCESS; 1791 1792 if (rc == VERR_VD_ASYNC_IO_IN_PROGRESS) 1793 { 1794 rc = RTSemEventWait(pDisk->hEventSemSyncIo, RT_INDEFINITE_WAIT); 1795 AssertRC(rc); 1796 1797 rc = pDisk->rcSync; 1798 } 1799 else /* Success or error. */ 1800 vdIoCtxFree(pDisk, pIoCtx); 1764 1801 1765 1802 return rc; … … 2891 2928 vdResetModifiedFlag(pDisk); 2892 2929 rc = pImage->Backend->pfnFlush(pImage->pBackendData, pIoCtx); 2893 if (rc == VERR_VD_ASYNC_IO_IN_PROGRESS) 2894 rc = VINF_SUCCESS; 2895 else if (rc == VINF_VD_ASYNC_IO_FINISHED) 2896 vdIoCtxUnlockDisk(pDisk, pIoCtx, true /* fProcessDeferredReqs */); 2930 if ( ( RT_SUCCESS(rc) 2931 || rc == VERR_VD_ASYNC_IO_IN_PROGRESS) 2932 && pDisk->pCache) 2933 { 2934 rc = pDisk->pCache->Backend->pfnFlush(pDisk->pCache->pBackendData, pIoCtx); 2935 if ( RT_SUCCESS(rc) 2936 || rc == VERR_VD_ASYNC_IO_IN_PROGRESS) 2937 vdIoCtxUnlockDisk(pDisk, pIoCtx, true /* fProcessBlockedReqs */); 2938 } 2939 else 2940 vdIoCtxUnlockDisk(pDisk, pIoCtx, true /* fProcessBlockedReqs */); 2897 2941 } 2898 2942 … … 8199 8243 AssertPtrBreakStmt(pImage, rc = VERR_VD_NOT_OPENED); 8200 8244 8201 vdResetModifiedFlag(pDisk); 8202 8203 VDIOCTX IoCtx; 8204 vdIoCtxInit(&IoCtx, pDisk, VDIOCTXTXDIR_FLUSH, 0, 0, NULL, 8205 NULL, NULL, NULL, VDIOCTX_FLAGS_SYNC); 8206 rc = pImage->Backend->pfnFlush(pImage->pBackendData, &IoCtx); 8207 8208 if ( RT_SUCCESS(rc) 8209 && pDisk->pCache) 8210 rc = pDisk->pCache->Backend->pfnFlush(pDisk->pCache->pBackendData, &IoCtx); 8245 PVDIOCTX pIoCtx = vdIoCtxRootAlloc(pDisk, VDIOCTXTXDIR_FLUSH, 0, 8246 0, pDisk->pLast, NULL, 8247 vdIoCtxSyncComplete, pDisk, NULL, 8248 NULL, vdFlushHelperAsync, 8249 VDIOCTX_FLAGS_SYNC); 8250 8251 if (!pIoCtx) 8252 { 8253 rc = VERR_NO_MEMORY; 8254 break; 8255 } 8256 8257 rc = vdIoCtxProcessSync(pIoCtx); 8211 8258 } while (0); 8212 8259 … … 9532 9579 } 9533 9580 9534 rc = vdIoCtxProcessTryLockDefer(pIoCtx); 9535 if (rc == VINF_VD_ASYNC_IO_FINISHED) 9536 rc = VINF_SUCCESS; 9537 9538 if (rc == VERR_VD_ASYNC_IO_IN_PROGRESS) 9539 { 9540 rc = RTSemEventWait(pDisk->hEventSemSyncIo, RT_INDEFINITE_WAIT); 9541 AssertRC(rc); 9542 9543 rc = pDisk->rcSync; 9544 } 9545 else /* Success or error. */ 9546 vdIoCtxFree(pDisk, pIoCtx); 9581 rc = vdIoCtxProcessSync(pIoCtx); 9547 9582 } while (0); 9548 9583 … … 9598 9633 cbRead, pDisk->pLast, pcSgBuf, 9599 9634 pfnComplete, pvUser1, pvUser2, 9600 NULL, vdReadHelperAsync); 9635 NULL, vdReadHelperAsync, 9636 VDIOCTX_FLAGS_DEFAULT); 9601 9637 if (!pIoCtx) 9602 9638 { … … 9669 9705 cbWrite, pDisk->pLast, pcSgBuf, 9670 9706 pfnComplete, pvUser1, pvUser2, 9671 NULL, vdWriteHelperAsync); 9707 NULL, vdWriteHelperAsync, 9708 VDIOCTX_FLAGS_DEFAULT); 9672 9709 if (!pIoCtx) 9673 9710 { … … 9725 9762 0, pDisk->pLast, NULL, 9726 9763 pfnComplete, pvUser1, pvUser2, 9727 NULL, vdFlushHelperAsync); 9764 NULL, vdFlushHelperAsync, 9765 VDIOCTX_FLAGS_DEFAULT); 9728 9766 if (!pIoCtx) 9729 9767 { … … 9781 9819 pfnComplete, pvUser1, pvUser2, NULL, 9782 9820 vdDiscardHelperAsync, 9783 0 /* fFlags */);9821 VDIOCTX_FLAGS_DEFAULT); 9784 9822 if (!pIoCtx) 9785 9823 {
Note:
See TracChangeset
for help on using the changeset viewer.