Changeset 63997 in vbox for trunk/src/VBox/Devices/Storage
- Timestamp:
- Sep 26, 2016 8:58:39 AM (8 years ago)
- Location:
- trunk/src/VBox/Devices/Storage
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Storage/DrvDiskIntegrity.cpp
r63727 r63997 1502 1502 1503 1503 /** 1504 * @interface_method_impl{PDMIMEDIAEXPORT,pfnIoReqQueryDiscardRanges} 1505 */ 1506 static DECLCALLBACK(int) drvdiskintIoReqQueryDiscardRanges(PPDMIMEDIAEXPORT pInterface, PDMMEDIAEXIOREQ hIoReq, 1507 void *pvIoReqAlloc, uint32_t idxRangeStart, 1508 uint32_t cRanges, PRTRANGE paRanges, 1509 uint32_t *pcRanges) 1510 { 1511 PDRVDISKINTEGRITY pThis = RT_FROM_MEMBER(pInterface, DRVDISKINTEGRITY, IMediaExPort); 1512 PDRVDISKAIOREQ pIoReq = (PDRVDISKAIOREQ)pvIoReqAlloc; 1513 1514 return pThis->pDrvMediaExPort->pfnIoReqQueryDiscardRanges(pThis->pDrvMediaExPort, hIoReq, pIoReq + 1, idxRangeStart, 1515 cRanges, paRanges, pcRanges); 1516 } 1517 1518 /** 1504 1519 * @interface_method_impl{PDMIMEDIAEXPORT,pfnIoReqStateChanged} 1505 1520 */ … … 1771 1786 * @interface_method_impl{PDMIMEDIAEX,pfnIoReqDiscard} 1772 1787 */ 1773 static DECLCALLBACK(int) drvdiskintIoReqDiscard(PPDMIMEDIAEX pInterface, PDMMEDIAEXIOREQ hIoReq, PCRTRANGE paRanges, unsigned cRanges)1788 static DECLCALLBACK(int) drvdiskintIoReqDiscard(PPDMIMEDIAEX pInterface, PDMMEDIAEXIOREQ hIoReq, unsigned cRangesMax) 1774 1789 { 1775 1790 PDRVDISKINTEGRITY pThis = RT_FROM_MEMBER(pInterface, DRVDISKINTEGRITY, IMediaEx); 1776 return pThis->pDrvMediaEx->pfnIoReqDiscard(pThis->pDrvMediaEx, hIoReq, paRanges, cRanges);1791 return pThis->pDrvMediaEx->pfnIoReqDiscard(pThis->pDrvMediaEx, hIoReq, cRangesMax); 1777 1792 } 1778 1793 … … 2008 2023 2009 2024 /* IMediaExPort. */ 2010 pThis->IMediaExPort.pfnIoReqCompleteNotify = drvdiskintIoReqCompleteNotify; 2011 pThis->IMediaExPort.pfnIoReqCopyFromBuf = drvdiskintIoReqCopyFromBuf; 2012 pThis->IMediaExPort.pfnIoReqCopyToBuf = drvdiskintIoReqCopyToBuf; 2013 pThis->IMediaExPort.pfnIoReqStateChanged = drvdiskintIoReqStateChanged; 2025 pThis->IMediaExPort.pfnIoReqCompleteNotify = drvdiskintIoReqCompleteNotify; 2026 pThis->IMediaExPort.pfnIoReqCopyFromBuf = drvdiskintIoReqCopyFromBuf; 2027 pThis->IMediaExPort.pfnIoReqCopyToBuf = drvdiskintIoReqCopyToBuf; 2028 pThis->IMediaExPort.pfnIoReqQueryDiscardRanges = drvdiskintIoReqQueryDiscardRanges; 2029 pThis->IMediaExPort.pfnIoReqStateChanged = drvdiskintIoReqStateChanged; 2014 2030 2015 2031 /* Query the media port interface above us. */ -
trunk/src/VBox/Devices/Storage/DrvRamDisk.cpp
r63724 r63997 1524 1524 * @interface_method_impl{PDMIMEDIAEX,pfnIoReqDiscard} 1525 1525 */ 1526 static DECLCALLBACK(int) drvramdiskIoReqDiscard(PPDMIMEDIAEX pInterface, PDMMEDIAEXIOREQ hIoReq, PCRTRANGE paRanges, unsigned cRanges)1526 static DECLCALLBACK(int) drvramdiskIoReqDiscard(PPDMIMEDIAEX pInterface, PDMMEDIAEXIOREQ hIoReq, unsigned cRangesMax) 1527 1527 { 1528 1528 PDRVRAMDISK pThis = RT_FROM_MEMBER(pInterface, DRVRAMDISK, IMediaEx); … … 1536 1536 return VERR_PDM_MEDIAEX_IOREQ_INVALID_STATE; 1537 1537 1538 pIoReq->enmType = PDMMEDIAEXIOREQTYPE_DISCARD; 1539 pIoReq->tsSubmit = RTTimeMilliTS(); 1540 /* Copy the ranges over because they might not be valid anymore when this method returns. */ 1541 pIoReq->Discard.paRanges = (PRTRANGE)RTMemDup(paRanges, cRanges * sizeof(RTRANGE)); 1538 /* Copy the ranges over now, this can be optimized in the future. */ 1539 pIoReq->Discard.paRanges = (PRTRANGE)RTMemAllocZ(cRangesMax * sizeof(RTRANGE)); 1542 1540 if (RT_UNLIKELY(!pIoReq->Discard.paRanges)) 1543 1541 return VERR_NO_MEMORY; 1544 1542 1545 bool fXchg = ASMAtomicCmpXchgU32((volatile uint32_t *)&pIoReq->enmState, VDIOREQSTATE_ACTIVE, VDIOREQSTATE_ALLOCATED); 1546 if (RT_UNLIKELY(!fXchg)) 1547 { 1548 /* Must have been canceled inbetween. */ 1549 Assert(pIoReq->enmState == VDIOREQSTATE_CANCELED); 1550 return VERR_PDM_MEDIAEX_IOREQ_CANCELED; 1551 } 1552 1553 ASMAtomicIncU32(&pThis->cIoReqsActive); 1554 1555 return RTReqQueueCallEx(pThis->hReqQ, NULL, 0, RTREQFLAGS_NO_WAIT, 1556 (PFNRT)drvramdiskIoReqDiscardWorker, 2, pThis, pIoReq); 1543 int rc = pThis->pDrvMediaExPort->pfnIoReqQueryDiscardRanges(pThis->pDrvMediaExPort, pIoReq, &pIoReq->abAlloc[0], 1544 0, cRangesMax, pIoReq->Discard.paRanges, 1545 &pIoReq->Discard.cRanges); 1546 if (RT_SUCCESS(rc)) 1547 { 1548 pIoReq->enmType = PDMMEDIAEXIOREQTYPE_DISCARD; 1549 pIoReq->tsSubmit = RTTimeMilliTS(); 1550 1551 bool fXchg = ASMAtomicCmpXchgU32((volatile uint32_t *)&pIoReq->enmState, VDIOREQSTATE_ACTIVE, VDIOREQSTATE_ALLOCATED); 1552 if (RT_UNLIKELY(!fXchg)) 1553 { 1554 /* Must have been canceled inbetween. */ 1555 Assert(pIoReq->enmState == VDIOREQSTATE_CANCELED); 1556 return VERR_PDM_MEDIAEX_IOREQ_CANCELED; 1557 } 1558 1559 ASMAtomicIncU32(&pThis->cIoReqsActive); 1560 1561 rc = RTReqQueueCallEx(pThis->hReqQ, NULL, 0, RTREQFLAGS_NO_WAIT, 1562 (PFNRT)drvramdiskIoReqDiscardWorker, 2, pThis, pIoReq); 1563 } 1564 1565 return rc; 1557 1566 } 1558 1567 -
trunk/src/VBox/Devices/Storage/DrvSCSI.cpp
r63992 r63997 251 251 252 252 pThis->pLed->Asserted.s.fWriting = pThis->pLed->Actual.s.fWriting = 1; 253 rc = pThis->pDrvMediaEx->pfnIoReqDiscard(pThis->pDrvMediaEx, hIoReq, paRanges,cRanges);253 rc = pThis->pDrvMediaEx->pfnIoReqDiscard(pThis->pDrvMediaEx, hIoReq, cRanges); 254 254 if ( RT_FAILURE(rc) 255 255 && pThis->cErrors++ < MAX_LOG_REL_ERRORS) … … 481 481 482 482 /** 483 * @interface_method_impl{PDMIMEDIAEXPORT,pfnIoReqQueryDiscardRanges} 484 */ 485 static DECLCALLBACK(int) drvscsiIoReqQueryDiscardRanges(PPDMIMEDIAEXPORT pInterface, PDMMEDIAEXIOREQ hIoReq, 486 void *pvIoReqAlloc, uint32_t idxRangeStart, 487 uint32_t cRanges, PRTRANGE paRanges, 488 uint32_t *pcRanges) 489 { 490 RT_NOREF2(pInterface, hIoReq); 491 492 VSCSIIOREQ hVScsiIoReq = DRVSCSI_PDMMEDIAEXIOREQ_2_VSCSIIOREQ(pvIoReqAlloc); 493 PCRTRANGE paRangesVScsi; 494 unsigned cRangesVScsi; 495 496 int rc = VSCSIIoReqUnmapParamsGet(hVScsiIoReq, &paRangesVScsi, &cRangesVScsi); 497 if (RT_SUCCESS(rc)) 498 { 499 uint32_t cRangesCopy = RT_MIN(cRangesVScsi - idxRangeStart, cRanges); 500 Assert( idxRangeStart < cRangesVScsi 501 && (idxRangeStart + cRanges) <= cRangesVScsi); 502 503 memcpy(paRanges, &paRangesVScsi[idxRangeStart], cRangesCopy * sizeof(RTRANGE)); 504 *pcRanges = cRangesCopy; 505 } 506 return rc; 507 } 508 509 /** 483 510 * @interface_method_impl{PDMIMEDIAEXPORT,pfnIoReqStateChanged} 484 511 */ … … 778 805 pThis->IPortEx.pfnIoReqCopyFromBuf = drvscsiIoReqCopyFromBuf; 779 806 pThis->IPortEx.pfnIoReqCopyToBuf = drvscsiIoReqCopyToBuf; 807 pThis->IPortEx.pfnIoReqQueryDiscardRanges = drvscsiIoReqQueryDiscardRanges; 780 808 pThis->IPortEx.pfnIoReqStateChanged = drvscsiIoReqStateChanged; 781 809 -
trunk/src/VBox/Devices/Storage/DrvVD.cpp
r63991 r63997 3718 3718 * @interface_method_impl{PDMIMEDIAEX,pfnIoReqDiscard} 3719 3719 */ 3720 static DECLCALLBACK(int) drvvdIoReqDiscard(PPDMIMEDIAEX pInterface, PDMMEDIAEXIOREQ hIoReq, PCRTRANGE paRanges, unsigned cRanges)3720 static DECLCALLBACK(int) drvvdIoReqDiscard(PPDMIMEDIAEX pInterface, PDMMEDIAEXIOREQ hIoReq, unsigned cRangesMax) 3721 3721 { 3722 3722 PVBOXDISK pThis = RT_FROM_MEMBER(pInterface, VBOXDISK, IMediaEx); … … 3730 3730 return VERR_PDM_MEDIAEX_IOREQ_INVALID_STATE; 3731 3731 3732 pIoReq->enmType = PDMMEDIAEXIOREQTYPE_DISCARD; 3733 pIoReq->tsSubmit = RTTimeMilliTS(); 3734 /* Copy the ranges over because they might not be valid anymore when this method returns. */ 3735 pIoReq->Discard.paRanges = (PRTRANGE)RTMemDup(paRanges, cRanges * sizeof(RTRANGE)); 3732 /* Copy the ranges over now, this can be optimized in the future. */ 3733 pIoReq->Discard.paRanges = (PRTRANGE)RTMemAllocZ(cRangesMax * sizeof(RTRANGE)); 3736 3734 if (RT_UNLIKELY(!pIoReq->Discard.paRanges)) 3737 3735 return VERR_NO_MEMORY; 3738 3736 3739 bool fXchg = ASMAtomicCmpXchgU32((volatile uint32_t *)&pIoReq->enmState, VDIOREQSTATE_ACTIVE, VDIOREQSTATE_ALLOCATED); 3740 if (RT_UNLIKELY(!fXchg)) 3741 { 3742 /* Must have been canceled inbetween. */ 3743 Assert(pIoReq->enmState == VDIOREQSTATE_CANCELED); 3744 return VERR_PDM_MEDIAEX_IOREQ_CANCELED; 3745 } 3746 3747 ASMAtomicIncU32(&pThis->cIoReqsActive); 3748 int rc = drvvdMediaExIoReqDiscardWrapper(pThis, pIoReq); 3749 if (rc == VERR_VD_ASYNC_IO_IN_PROGRESS) 3750 rc = VINF_PDM_MEDIAEX_IOREQ_IN_PROGRESS; 3751 else if (rc == VINF_VD_ASYNC_IO_FINISHED) 3752 rc = VINF_SUCCESS; 3753 3754 if (rc != VINF_PDM_MEDIAEX_IOREQ_IN_PROGRESS) 3755 rc = drvvdMediaExIoReqCompleteWorker(pThis, pIoReq, rc, false /* fUpNotify */); 3737 int rc = pThis->pDrvMediaExPort->pfnIoReqQueryDiscardRanges(pThis->pDrvMediaExPort, pIoReq, &pIoReq->abAlloc[0], 3738 0, cRangesMax, pIoReq->Discard.paRanges, 3739 &pIoReq->Discard.cRanges); 3740 if (RT_SUCCESS(rc)) 3741 { 3742 pIoReq->enmType = PDMMEDIAEXIOREQTYPE_DISCARD; 3743 pIoReq->tsSubmit = RTTimeMilliTS(); 3744 bool fXchg = ASMAtomicCmpXchgU32((volatile uint32_t *)&pIoReq->enmState, VDIOREQSTATE_ACTIVE, VDIOREQSTATE_ALLOCATED); 3745 if (RT_UNLIKELY(!fXchg)) 3746 { 3747 /* Must have been canceled inbetween. */ 3748 Assert(pIoReq->enmState == VDIOREQSTATE_CANCELED); 3749 return VERR_PDM_MEDIAEX_IOREQ_CANCELED; 3750 } 3751 3752 ASMAtomicIncU32(&pThis->cIoReqsActive); 3753 rc = drvvdMediaExIoReqDiscardWrapper(pThis, pIoReq); 3754 if (rc == VERR_VD_ASYNC_IO_IN_PROGRESS) 3755 rc = VINF_PDM_MEDIAEX_IOREQ_IN_PROGRESS; 3756 else if (rc == VINF_VD_ASYNC_IO_FINISHED) 3757 rc = VINF_SUCCESS; 3758 3759 if (rc != VINF_PDM_MEDIAEX_IOREQ_IN_PROGRESS) 3760 rc = drvvdMediaExIoReqCompleteWorker(pThis, pIoReq, rc, false /* fUpNotify */); 3761 } 3756 3762 3757 3763 return rc;
Note:
See TracChangeset
for help on using the changeset viewer.