- 時間撮記:
- 2009-10-7 下午06:30:27 (15 年 以前)
- 檔案:
-
- 修改 1 筆資料
圖例:
- 未更動
- 新增
- 刪除
-
trunk/src/VBox/VMM/PDMAsyncCompletionFileNormal.cpp
r23404 r23603 232 232 { 233 233 /* Move to other endpoint. */ 234 Log(("Moving endpoint %#p{%s} with %u reqs/s to other manager\n", pCurr ->Core.pszUri, pCurr->AioMgr.cReqsPerSec));234 Log(("Moving endpoint %#p{%s} with %u reqs/s to other manager\n", pCurr, pCurr->Core.pszUri, pCurr->AioMgr.cReqsPerSec)); 235 235 cReqsOther += pCurr->AioMgr.cReqsPerSec; 236 236 … … 343 343 pEndpoint->AioMgr.cRequestsActive += cReqs; 344 344 345 LogFlow(("Enqueuing %d requests. I/O manager has a total of %d active requests now\n", cReqs, pAioMgr->cRequestsActive)); 346 LogFlow(("Endpoint has a total of %d active requests now\n", pEndpoint->AioMgr.cRequestsActive)); 347 345 348 rc = RTFileAioCtxSubmit(pAioMgr->hAioCtx, pahReqs, cReqs); 346 349 if (RT_FAILURE(rc)) … … 382 385 } 383 386 } 387 LogFlow(("Removed requests. I/O manager has a total of %d active requests now\n", pAioMgr->cRequestsActive)); 388 LogFlow(("Endpoint has a total of %d active requests now\n", pEndpoint->AioMgr.cRequestsActive)); 384 389 } 385 390 else … … 404 409 405 410 /* Go through the list and queue the requests until we get a flush request */ 406 while (pTaskHead && !pEndpoint->pFlushReq && (cMaxRequests > 0)) 411 while ( pTaskHead 412 && !pEndpoint->pFlushReq 413 && (cMaxRequests > 0) 414 && RT_SUCCESS(rc)) 407 415 { 408 416 PPDMACTASKFILE pCurr = pTaskHead; … … 428 436 { 429 437 pEndpoint->pFlushReq = pCurr; 430 431 /* Do not process the task list further until the flush finished. */432 pdmacFileAioMgrEpAddTaskList(pEndpoint, pTaskHead);433 438 } 434 439 break; … … 533 538 rc = pdmacFileAioMgrNormalReqsEnqueue(pAioMgr, pEndpoint, apReqs, cRequests); 534 539 cRequests = 0; 535 if (RT_FAILURE(rc)) 536 { 537 AssertMsg(rc == VERR_FILE_AIO_INSUFFICIENT_RESSOURCES, ("Unexpected return code\n")); 538 break; 539 } 540 AssertMsg(RT_SUCCESS(rc) || (rc == VERR_FILE_AIO_INSUFFICIENT_RESSOURCES), 541 ("Unexpected return code\n")); 540 542 } 541 543 break; … … 557 559 /* Add the rest of the tasks to the pending list */ 558 560 pdmacFileAioMgrEpAddTaskList(pEndpoint, pTaskHead); 559 560 561 561 562 if (RT_UNLIKELY(!cMaxRequests && !pEndpoint->pFlushReq)) … … 600 601 if (pEndpoint->AioMgr.pReqsPendingHead) 601 602 { 603 LogFlow(("Queuing pending requests first\n")); 604 602 605 pTasksHead = pEndpoint->AioMgr.pReqsPendingHead; 603 606 /* … … 630 633 bool fNotifyWaiter = false; 631 634 635 LogFlowFunc((": Enter\n")); 636 632 637 Assert(pAioMgr->fBlockingEventPending); 633 638 … … 667 672 AssertMsg(VALID_PTR(pEndpointClose), ("Close endpoint event without a endpoint to close\n")); 668 673 674 LogFlowFunc((": Closing endpoint %#p{%s}\n", pEndpointClose, pEndpointClose->Core.pszUri)); 675 669 676 /* Make sure all tasks finished. Process the queues a last time first. */ 670 677 rc = pdmacFileAioMgrNormalQueueReqs(pAioMgr, pEndpointClose); … … 706 713 rc = RTSemEventSignal(pAioMgr->EventSemBlock); 707 714 AssertRC(rc); 715 } 716 717 LogFlowFunc((": Leave\n")); 718 return rc; 719 } 720 721 /** 722 * Checks all endpoints for pending events or new requests. 723 * 724 * @returns VBox status code. 725 * @param pAioMgr The I/O manager handle. 726 */ 727 static int pdmacFileAioMgrNormalCheckEndpoints(PPDMACEPFILEMGR pAioMgr) 728 { 729 /* Check the assigned endpoints for new tasks if there isn't a flush request active at the moment. */ 730 int rc = VINF_SUCCESS; 731 PPDMASYNCCOMPLETIONENDPOINTFILE pEndpoint = pAioMgr->pEndpointsHead; 732 733 while (pEndpoint) 734 { 735 if (!pEndpoint->pFlushReq && (pEndpoint->enmState == PDMASYNCCOMPLETIONENDPOINTFILESTATE_ACTIVE)) 736 { 737 rc = pdmacFileAioMgrNormalQueueReqs(pAioMgr, pEndpoint); 738 if (RT_FAILURE(rc)) 739 return rc; 740 } 741 else if (!pEndpoint->AioMgr.cRequestsActive) 742 { 743 /* Reopen the file so that the new endpoint can reassociate with the file */ 744 RTFileClose(pEndpoint->File); 745 rc = RTFileOpen(&pEndpoint->File, pEndpoint->Core.pszUri, pEndpoint->fFlags); 746 AssertRC(rc); 747 748 if (pEndpoint->AioMgr.fMoving) 749 { 750 pEndpoint->AioMgr.fMoving = false; 751 pdmacFileAioMgrAddEndpoint(pEndpoint->AioMgr.pAioMgrDst, pEndpoint); 752 } 753 else 754 { 755 Assert(pAioMgr->fBlockingEventPending); 756 ASMAtomicWriteBool(&pAioMgr->fBlockingEventPending, false); 757 758 /* Release the waiting thread. */ 759 LogFlow(("Signalling waiter\n")); 760 rc = RTSemEventSignal(pAioMgr->EventSemBlock); 761 AssertRC(rc); 762 } 763 } 764 765 pEndpoint = pEndpoint->AioMgr.pEndpointNext; 708 766 } 709 767 … … 753 811 if (RT_LIKELY(pAioMgr->enmState == PDMACEPFILEMGRSTATE_RUNNING)) 754 812 { 755 /* Check the assigned endpoints for new tasks if there isn't a flush request active at the moment. */ 756 PPDMASYNCCOMPLETIONENDPOINTFILE pEndpoint = pAioMgr->pEndpointsHead; 757 758 while (pEndpoint) 759 { 760 if (!pEndpoint->pFlushReq && (pEndpoint->enmState == PDMASYNCCOMPLETIONENDPOINTFILESTATE_ACTIVE)) 761 { 762 rc = pdmacFileAioMgrNormalQueueReqs(pAioMgr, pEndpoint); 763 CHECK_RC(pAioMgr, rc); 764 } 765 766 pEndpoint = pEndpoint->AioMgr.pEndpointNext; 767 } 813 /* We got woken up because an endpoint issued new requests. Queue them. */ 814 rc = pdmacFileAioMgrNormalCheckEndpoints(pAioMgr); 815 CHECK_RC(pAioMgr, rc); 768 816 769 817 while (pAioMgr->cRequestsActive) … … 777 825 else 778 826 cReqsWait = pAioMgr->cRequestsActive; 827 828 LogFlow(("Waiting for %d of %d tasks to complete\n", pAioMgr->cRequestsActive, cReqsWait)); 779 829 780 830 rc = RTFileAioCtxWait(pAioMgr->hAioCtx, … … 785 835 CHECK_RC(pAioMgr, rc); 786 836 837 LogFlow(("%d tasks completed\n", cReqsCompleted)); 838 787 839 for (uint32_t i = 0; i < cReqsCompleted; i++) 788 840 { 841 PPDMASYNCCOMPLETIONENDPOINTFILE pEndpoint; 789 842 size_t cbTransfered = 0; 790 843 int rcReq = RTFileAioReqGetRC(apReqs[i], &cbTransfered); … … 866 919 } 867 920 } 868 869 if (pEndpoint->enmState == PDMASYNCCOMPLETIONENDPOINTFILESTATE_ACTIVE)870 {871 if (!pEndpoint->pFlushReq)872 {873 /* Check if there are events on the endpoint. */874 rc = pdmacFileAioMgrNormalQueueReqs(pAioMgr, pEndpoint);875 CHECK_RC(pAioMgr, rc);876 }877 }878 else if (!pEndpoint->AioMgr.cRequestsActive)879 {880 /* Reopen the file so that the new endpoint can reassociate with the file */881 RTFileClose(pEndpoint->File);882 rc = RTFileOpen(&pEndpoint->File, pEndpoint->Core.pszUri, pEndpoint->fFlags);883 AssertRC(rc);884 885 if (pEndpoint->AioMgr.fMoving)886 {887 pEndpoint->AioMgr.fMoving = false;888 pdmacFileAioMgrAddEndpoint(pEndpoint->AioMgr.pAioMgrDst, pEndpoint);889 }890 else891 {892 Assert(pAioMgr->fBlockingEventPending);893 ASMAtomicWriteBool(&pAioMgr->fBlockingEventPending, false);894 895 /* Release the waiting thread. */896 LogFlow(("Signalling waiter\n"));897 rc = RTSemEventSignal(pAioMgr->EventSemBlock);898 AssertRC(rc);899 }900 }901 921 } 902 922 … … 927 947 uMillisEnd = RTTimeMilliTS() + PDMACEPFILEMGR_LOAD_UPDATE_PERIOD; 928 948 } 929 } 930 } 931 } 949 950 /* Check endpoints for new requests. */ 951 rc = pdmacFileAioMgrNormalCheckEndpoints(pAioMgr); 952 CHECK_RC(pAioMgr, rc); 953 } /* while requests are active. */ 954 } /* if still running */ 955 } /* while running */ 932 956 933 957 return rc;
注意:
瀏覽 TracChangeset
來幫助您使用更動檢視器