Changeset 44397 in vbox for trunk/src/VBox/VMM/VMMR3/PDMAsyncCompletionFileNormal.cpp
- Timestamp:
- Jan 27, 2013 8:23:39 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/VMM/VMMR3/PDMAsyncCompletionFileNormal.cpp
r44235 r44397 638 638 static bool pdmacFileAioMgrNormalIsRangeLocked(PPDMASYNCCOMPLETIONENDPOINTFILE pEndpoint, 639 639 RTFOFF offStart, size_t cbRange, 640 PPDMACTASKFILE pTask )640 PPDMACTASKFILE pTask, bool fAlignedReq) 641 641 { 642 642 AssertMsg( pTask->enmTransferType == PDMACTASKFILETRANSFER_WRITE 643 643 || pTask->enmTransferType == PDMACTASKFILETRANSFER_READ, 644 644 ("Invalid task type %d\n", pTask->enmTransferType)); 645 646 /* 647 * If there is no unaligned request active and the current one is aligned 648 * just pass it through. 649 */ 650 if (!pEndpoint->AioMgr.cLockedReqsActive && fAlignedReq) 651 return false; 645 652 646 653 PPDMACFILERANGELOCK pRangeLock; … … 659 666 660 667 /* Check whether we have one of the situations explained below */ 661 if ( pRangeLock 662 #if 0 /** @todo later. For now we will just block all requests if they interfere */ 663 && ( (pRangeLock->fReadLock && pTask->enmTransferType == PDMACTASKFILETRANSFER_WRITE) 664 || (!pRangeLock->fReadLock) 665 #endif 666 ) 668 if (pRangeLock) 667 669 { 668 670 /* Add to the list. */ … … 690 692 PPDMASYNCCOMPLETIONENDPOINTFILE pEndpoint, 691 693 RTFOFF offStart, size_t cbRange, 692 PPDMACTASKFILE pTask )694 PPDMACTASKFILE pTask, bool fAlignedReq) 693 695 { 694 696 LogFlowFunc(("pAioMgr=%#p pEndpoint=%#p offStart=%RTfoff cbRange=%zu pTask=%#p\n", 695 697 pAioMgr, pEndpoint, offStart, cbRange, pTask)); 696 698 697 AssertMsg(!pdmacFileAioMgrNormalIsRangeLocked(pEndpoint, offStart, cbRange, pTask ),699 AssertMsg(!pdmacFileAioMgrNormalIsRangeLocked(pEndpoint, offStart, cbRange, pTask, fAlignedReq), 698 700 ("Range is already locked offStart=%RTfoff cbRange=%u\n", 699 701 offStart, cbRange)); 702 703 /* 704 * If there is no unaligned request active and the current one is aligned 705 * just don't use the lock. 706 */ 707 if (!pEndpoint->AioMgr.cLockedReqsActive && fAlignedReq) 708 { 709 pTask->pRangeLock = NULL; 710 return VINF_SUCCESS; 711 } 700 712 701 713 PPDMACFILERANGELOCK pRangeLock = (PPDMACFILERANGELOCK)RTMemCacheAlloc(pAioMgr->hMemCacheRangeLocks); … … 716 728 /* Let the task point to its lock. */ 717 729 pTask->pRangeLock = pRangeLock; 730 pEndpoint->AioMgr.cLockedReqsActive++; 718 731 719 732 return VINF_SUCCESS; … … 729 742 pAioMgr, pEndpoint, pRangeLock)); 730 743 731 AssertPtr(pRangeLock); 744 /* pRangeLock can be NULL if there was no lock assigned with the task. */ 745 if (!pRangeLock) 746 return NULL; 747 732 748 Assert(pRangeLock->cRefs == 1); 733 749 … … 737 753 pRangeLock->pWaitingTasksTail = NULL; 738 754 RTMemCacheFree(pAioMgr->hMemCacheRangeLocks, pRangeLock); 755 pEndpoint->AioMgr.cLockedReqsActive--; 739 756 740 757 return pTasksWaitingHead; … … 772 789 */ 773 790 int rc = VINF_SUCCESS; 774 bool fLocked = pdmacFileAioMgrNormalIsRangeLocked(pEndpoint, pTask->Off, pTask->DataSeg.cbSeg, pTask); 791 bool fLocked = pdmacFileAioMgrNormalIsRangeLocked(pEndpoint, pTask->Off, pTask->DataSeg.cbSeg, pTask, 792 true /* fAlignedReq */); 775 793 if (!fLocked) 776 794 { … … 800 818 rc = pdmacFileAioMgrNormalRangeLock(pAioMgr, pEndpoint, pTask->Off, 801 819 pTask->DataSeg.cbSeg, 802 pTask );820 pTask, true /* fAlignedReq */); 803 821 804 822 if (RT_SUCCESS(rc)) … … 826 844 size_t cbToTransfer = RT_ALIGN_Z(pTask->DataSeg.cbSeg + (pTask->Off - offStart), 512); 827 845 PDMACTASKFILETRANSFER enmTransferType = pTask->enmTransferType; 846 bool fAlignedReq = cbToTransfer == pTask->DataSeg.cbSeg 847 && offStart == pTask->Off; 828 848 829 849 AssertMsg( pTask->enmTransferType == PDMACTASKFILETRANSFER_WRITE … … 853 873 */ 854 874 int rc = VINF_SUCCESS; 855 bool fLocked = pdmacFileAioMgrNormalIsRangeLocked(pEndpoint, offStart, cbToTransfer, pTask );875 bool fLocked = pdmacFileAioMgrNormalIsRangeLocked(pEndpoint, offStart, cbToTransfer, pTask, fAlignedReq); 856 876 if (!fLocked) 857 877 { … … 863 883 AssertMsg(hReq != NIL_RTFILEAIOREQ, ("Out of request handles\n")); 864 884 865 if ( RT_UNLIKELY(cbToTransfer != pTask->DataSeg.cbSeg) 866 || RT_UNLIKELY(offStart != pTask->Off) 885 if ( !fAlignedReq 867 886 || ((pEpClassFile->uBitmaskAlignment & (RTR3UINTPTR)pvBuf) != (RTR3UINTPTR)pvBuf)) 868 887 { … … 929 948 AssertRC(rc); 930 949 931 rc = pdmacFileAioMgrNormalRangeLock(pAioMgr, pEndpoint, offStart, cbToTransfer, pTask); 932 950 rc = pdmacFileAioMgrNormalRangeLock(pAioMgr, pEndpoint, offStart, cbToTransfer, pTask, fAlignedReq); 933 951 if (RT_SUCCESS(rc)) 934 952 {
Note:
See TracChangeset
for help on using the changeset viewer.