Changeset 27299 in vbox
- Timestamp:
- Mar 11, 2010 7:19:59 PM (15 years ago)
- Location:
- trunk/src/VBox/VMM
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/VMM/PDMAsyncCompletionFile.cpp
r26812 r27299 387 387 * @param pEpClass Pointer to the endpoint class data. 388 388 * @param ppAioMgr Where to store the pointer to the new async I/O manager on success. 389 * @param fFailsafe Flag to force a failsafe manager even if the global flag is not set.389 * @param enmMgrType Wanted manager type - can be overwritten by the global override. 390 390 */ 391 int pdmacFileAioMgrCreate(PPDMASYNCCOMPLETIONEPCLASSFILE pEpClass, PPPDMACEPFILEMGR ppAioMgr, bool fFailsafe) 391 int pdmacFileAioMgrCreate(PPDMASYNCCOMPLETIONEPCLASSFILE pEpClass, PPPDMACEPFILEMGR ppAioMgr, 392 PDMACEPFILEMGRTYPE enmMgrType) 392 393 { 393 394 int rc = VINF_SUCCESS; … … 399 400 if (RT_SUCCESS(rc)) 400 401 { 401 pAioMgrNew->fFailsafe = fFailsafe || pEpClass->fFailsafe; 402 if (enmMgrType < pEpClass->enmMgrTypeOverride) 403 pAioMgrNew->enmMgrType = enmMgrType; 404 else 405 pAioMgrNew->enmMgrType = pEpClass->enmMgrTypeOverride; 402 406 403 407 rc = RTSemEventCreate(&pAioMgrNew->EventSem); … … 411 415 { 412 416 /* Init the rest of the manager. */ 413 if ( !pAioMgrNew->fFailsafe)417 if (pAioMgrNew->enmMgrType != PDMACEPFILEMGRTYPE_SIMPLE) 414 418 rc = pdmacFileAioMgrNormalInit(pAioMgrNew); 415 419 … … 419 423 420 424 rc = RTThreadCreateF(&pAioMgrNew->Thread, 421 pAioMgrNew-> fFailsafe425 pAioMgrNew->enmMgrType == PDMACEPFILEMGRTYPE_SIMPLE 422 426 ? pdmacFileAioMgrFailsafe 423 427 : pdmacFileAioMgrNormal, … … 427 431 0, 428 432 "AioMgr%d-%s", pEpClass->cAioMgrs, 429 pAioMgrNew-> fFailsafe433 pAioMgrNew->enmMgrType == PDMACEPFILEMGRTYPE_SIMPLE 430 434 ? "F" 431 435 : "N"); … … 495 499 RTCritSectDelete(&pAioMgr->CritSectBlockingEvent); 496 500 RTSemEventDestroy(pAioMgr->EventSem); 497 if ( !pAioMgr->fFailsafe)501 if (pAioMgr->enmMgrType != PDMACEPFILEMGRTYPE_SIMPLE) 498 502 pdmacFileAioMgrNormalDestroy(pAioMgr); 499 503 … … 515 519 rc = CFGMR3QueryU32Def(pCfgNode, "VMTransferPerSecMax", &pBwMgr->cbVMTransferPerSecMax, UINT32_MAX); 516 520 AssertLogRelRCReturn(rc, rc); 517 rc = CFGMR3QueryU32Def(pCfgNode, "VMTransferPerSecStart", &pBwMgr->cbVMTransferPerSecStart, _1M);521 rc = CFGMR3QueryU32Def(pCfgNode, "VMTransferPerSecStart", &pBwMgr->cbVMTransferPerSecStart, 5 * _1M); 518 522 AssertLogRelRCReturn(rc, rc); 519 523 rc = CFGMR3QueryU32Def(pCfgNode, "VMTransferPerSecStep", &pBwMgr->cbVMTransferPerSecStep, _1M); … … 585 589 } 586 590 591 static int pdmacFileMgrTypeFromName(const char *pszVal, PPDMACEPFILEMGRTYPE penmMgrType) 592 { 593 int rc = VINF_SUCCESS; 594 595 if (!RTStrCmp(pszVal, "Simple")) 596 *penmMgrType = PDMACEPFILEMGRTYPE_SIMPLE; 597 else if (!RTStrCmp(pszVal, "Async")) 598 *penmMgrType = PDMACEPFILEMGRTYPE_ASYNC; 599 else 600 rc = VERR_CFGM_CONFIG_UNKNOWN_VALUE; 601 602 return rc; 603 } 604 605 static const char *pdmacFileMgrTypeToName(PDMACEPFILEMGRTYPE enmMgrType) 606 { 607 if (enmMgrType == PDMACEPFILEMGRTYPE_SIMPLE) 608 return "Simple"; 609 if (enmMgrType == PDMACEPFILEMGRTYPE_ASYNC) 610 return "Async"; 611 612 return NULL; 613 } 614 615 static int pdmacFileBackendTypeFromName(const char *pszVal, PPDMACFILEEPBACKEND penmBackendType) 616 { 617 int rc = VINF_SUCCESS; 618 619 if (!RTStrCmp(pszVal, "Buffered")) 620 *penmBackendType = PDMACFILEEPBACKEND_BUFFERED; 621 else if (!RTStrCmp(pszVal, "NonBuffered")) 622 *penmBackendType = PDMACFILEEPBACKEND_NON_BUFFERED; 623 else 624 rc = VERR_CFGM_CONFIG_UNKNOWN_VALUE; 625 626 return rc; 627 } 628 629 static const char *pdmacFileBackendTypeToName(PDMACFILEEPBACKEND enmBackendType) 630 { 631 if (enmBackendType == PDMACFILEEPBACKEND_BUFFERED) 632 return "Buffered"; 633 if (enmBackendType == PDMACFILEEPBACKEND_NON_BUFFERED) 634 return "NonBuffered"; 635 636 return NULL; 637 } 638 587 639 static int pdmacFileInitialize(PPDMASYNCCOMPLETIONEPCLASS pClassGlobals, PCFGMNODE pCfgNode) 588 640 { … … 599 651 if (RT_FAILURE(rc)) 600 652 { 601 LogRel(("AIO: Async I/O manager not supported (rc=%Rrc). Falling back to failsafe manager\n",653 LogRel(("AIO: Async I/O manager not supported (rc=%Rrc). Falling back to simple manager\n", 602 654 rc)); 603 pEpClassFile->fFailsafe = true; 655 pEpClassFile->enmMgrTypeOverride = PDMACEPFILEMGRTYPE_SIMPLE; 656 pEpClassFile->enmEpBackendDefault = PDMACFILEEPBACKEND_BUFFERED; 604 657 } 605 658 else … … 608 661 pEpClassFile->cReqsOutstandingMax = AioLimits.cReqsOutstandingMax; 609 662 610 /* The user can force the failsafe manager. */ 611 rc = CFGMR3QueryBoolDef(pCfgNode, "UseFailsafeIo", &pEpClassFile->fFailsafe, false); 612 AssertLogRelRCReturn(rc, rc); 613 614 if (pEpClassFile->fFailsafe) 615 LogRel(("AIOMgr: Failsafe I/O was requested by user\n")); 663 if (pCfgNode) 664 { 665 /* Query the default manager type */ 666 char *pszVal = NULL; 667 rc = CFGMR3QueryStringAllocDef(pCfgNode, "IoMgr", &pszVal, "Async"); 668 AssertLogRelRCReturn(rc, rc); 669 670 rc = pdmacFileMgrTypeFromName(pszVal, &pEpClassFile->enmMgrTypeOverride); 671 MMR3HeapFree(pszVal); 672 if (RT_FAILURE(rc)) 673 return rc; 674 675 LogRel(("AIOMgr: Default manager type is \"%s\"\n", pdmacFileMgrTypeToName(pEpClassFile->enmMgrTypeOverride))); 676 677 /* Query default backend type */ 678 #ifndef RT_OS_LINUX 679 rc = CFGMR3QueryStringAllocDef(pCfgNode, "FileBackend", &pszVal, "Buffered"); 680 #else /* Linux can't use buffered with async */ 681 rc = CFGMR3QueryStringAllocDef(pCfgNode, "FileBackend", &pszVal, "NonBuffered"); 682 #endif 683 AssertLogRelRCReturn(rc, rc); 684 685 rc = pdmacFileBackendTypeFromName(pszVal, &pEpClassFile->enmEpBackendDefault); 686 MMR3HeapFree(pszVal); 687 if (RT_FAILURE(rc)) 688 return rc; 689 690 LogRel(("AIOMgr: Default file backend is \"%s\"\n", pdmacFileBackendTypeToName(pEpClassFile->enmEpBackendDefault))); 691 692 #ifdef RT_OS_LINUX 693 if ( pEpClassFile->enmMgrTypeOverride == PDMACEPFILEMGRTYPE_ASYNC 694 && pEpClassFile->enmEpBackendDefault == PDMACFILEEPBACKEND_BUFFERED) 695 { 696 LogRel(("AIOMgr: Linux does not support buffered async I/O, changing to non buffered\n")); 697 pEpClassFile->enmEpBackendDefault = PDMACFILEEPBACKEND_NON_BUFFERED; 698 } 699 #endif 700 } 701 else 702 { 703 /* No configuration supplied, set defaults */ 704 pEpClassFile->enmMgrTypeOverride = PDMACEPFILEMGRTYPE_ASYNC; 705 #ifdef RT_OS_LINUX 706 pEpClassFile->enmEpBackendDefault = PDMACFILEEPBACKEND_NON_BUFFERED; 707 #else 708 pEpClassFile->enmEpBackendDefault = PDMACFILEEPBACKEND_BUFFERED; 709 #endif 710 } 616 711 } 617 712 … … 620 715 if (RT_SUCCESS(rc)) 621 716 { 622 /* Check if the host cache should be used too. */623 #ifndef RT_OS_LINUX624 rc = CFGMR3QueryBoolDef(pCfgNode, "HostCacheEnabled", &pEpClassFile->fHostCacheEnabled, false);625 AssertLogRelRCReturn(rc, rc);626 #else627 /*628 * Host cache + async I/O is not supported on Linux. Check if the user enabled the cache,629 * leave a warning and disable it always.630 */631 bool fDummy;632 rc = CFGMR3QueryBool(pCfgNode, "HostCacheEnabled", &fDummy);633 if (RT_SUCCESS(rc))634 LogRel(("AIOMgr: The host cache is not supported with async I/O on Linux\n"));635 636 pEpClassFile->fHostCacheEnabled = false;637 #endif638 639 717 /* Check if the cache was disabled by the user. */ 640 718 rc = CFGMR3QueryBoolDef(pCfgNode, "CacheEnabled", &pEpClassFile->fCacheEnabled, true); … … 687 765 PPDMASYNCCOMPLETIONENDPOINTFILE pEpFile = (PPDMASYNCCOMPLETIONENDPOINTFILE)pEndpoint; 688 766 PPDMASYNCCOMPLETIONEPCLASSFILE pEpClassFile = (PPDMASYNCCOMPLETIONEPCLASSFILE)pEndpoint->pEpClass; 689 bool fUseFailsafeManager = pEpClassFile->fFailsafe; 767 PDMACEPFILEMGRTYPE enmMgrType = pEpClassFile->enmMgrTypeOverride; 768 PDMACFILEEPBACKEND enmEpBackend = pEpClassFile->enmEpBackendDefault; 690 769 691 770 AssertMsgReturn((fFlags & ~(PDMACEP_FILE_FLAGS_READ_ONLY | PDMACEP_FILE_FLAGS_CACHING)) == 0, … … 696 775 : RTFILE_O_READWRITE | RTFILE_O_OPEN | RTFILE_O_DENY_WRITE; 697 776 698 if (!pEpClassFile->fFailsafe) 699 { 700 fFileFlags |= (RTFILE_O_ASYNC_IO | RTFILE_O_WRITE_THROUGH); 701 777 if (enmEpBackend == PDMACFILEEPBACKEND_NON_BUFFERED) 778 { 702 779 /* 703 780 * We only disable the cache if the size of the file is a multiple of 512. … … 717 794 rc = RTFileGetSize(File, &cbSize); 718 795 if (RT_SUCCESS(rc) && ((cbSize % 512) == 0)) 796 fFileFlags |= RTFILE_O_NO_CACHE; 797 else 719 798 { 720 fFileFlags &= ~RTFILE_O_WRITE_THROUGH; 721 722 #if defined(RT_OS_LINUX) 723 AssertMsg(!pEpClassFile->fHostCacheEnabled, ("Host cache + async I/O is not supported on Linux\n")); 724 fFileFlags |= RTFILE_O_NO_CACHE; 725 #else 726 if (!pEpClassFile->fHostCacheEnabled) 727 fFileFlags |= RTFILE_O_NO_CACHE; 728 #endif 799 /* Downgrade to the buffered backend */ 800 enmEpBackend = PDMACFILEEPBACKEND_BUFFERED; 729 801 } 730 731 pEpFile->cbFile = cbSize;732 733 802 RTFileClose(File); 734 803 } … … 753 822 */ 754 823 fFileFlags &= ~RTFILE_O_NO_CACHE; 824 enmEpBackend = PDMACFILEEPBACKEND_BUFFERED; 755 825 756 826 #ifdef RT_OS_LINUX 757 827 fFileFlags &= ~RTFILE_O_ASYNC_IO; 758 fUseFailsafeManager = true;828 enmMgrType = PDMACEPFILEMGRTYPE_SIMPLE; 759 829 #endif 760 830 … … 793 863 pEpFile->cTasksCached = 0; 794 864 pEpFile->pBwMgr = pEpClassFile->pBwMgr; 865 pEpFile->enmBackendType = enmEpBackend; 795 866 pdmacFileBwRef(pEpFile->pBwMgr); 796 867 797 if ( fUseFailsafeManager)868 if (enmMgrType == PDMACEPFILEMGRTYPE_SIMPLE) 798 869 { 799 /* S afe mode. Every file has its own async I/O manager. */800 rc = pdmacFileAioMgrCreate(pEpClassFile, &pAioMgr, true);870 /* Simple mode. Every file has its own async I/O manager. */ 871 rc = pdmacFileAioMgrCreate(pEpClassFile, &pAioMgr, PDMACEPFILEMGRTYPE_SIMPLE); 801 872 AssertRC(rc); 802 873 } … … 817 888 pAioMgr = pEpClassFile->pAioMgrHead; 818 889 819 /* Check for an idling not failsafe one or create new if not found */ 820 while (pAioMgr && pAioMgr->fFailsafe) 890 /* Check for an idling manager of the same type */ 891 while (pAioMgr) 892 { 893 if (pAioMgr->enmMgrType == enmMgrType) 894 break; 821 895 pAioMgr = pAioMgr->pNext; 896 } 822 897 823 898 if (!pAioMgr) 824 899 { 825 rc = pdmacFileAioMgrCreate(pEpClassFile, &pAioMgr, false);900 rc = pdmacFileAioMgrCreate(pEpClassFile, &pAioMgr, enmMgrType); 826 901 AssertRC(rc); 827 902 } … … 888 963 * he processes and thus can be destroyed now. 889 964 */ 890 if (pEpFile->pAioMgr-> fFailsafe)965 if (pEpFile->pAioMgr->enmMgrType == PDMACEPFILEMGRTYPE_SIMPLE) 891 966 pdmacFileAioMgrDestroy(pEpClassFile, pEpFile->pAioMgr); 892 967 -
trunk/src/VBox/VMM/PDMAsyncCompletionFileFailsafe.cpp
r26147 r27299 2 2 /** @file 3 3 * PDM Async I/O - Transport data asynchronous in R3 using EMT. 4 * Failsafe File I/O manager.4 * Simple File I/O manager. 5 5 */ 6 6 -
trunk/src/VBox/VMM/PDMAsyncCompletionFileInternal.h
r27280 r27299 87 87 PDMACEPFILEAIOMGRBLOCKINGEVENT_32BIT_HACK = 0x7fffffff 88 88 } PDMACEPFILEAIOMGRBLOCKINGEVENT; 89 90 /** 91 * I/O manager type. 92 */ 93 typedef enum PDMACEPFILEMGRTYPE 94 { 95 /** Simple aka failsafe */ 96 PDMACEPFILEMGRTYPE_SIMPLE = 0, 97 /** Async I/O with host cache enabled. */ 98 PDMACEPFILEMGRTYPE_ASYNC, 99 /** 32bit hack */ 100 PDMACEPFILEMGRTYPE_32BIT_HACK = 0x7fffffff 101 } PDMACEPFILEMGRTYPE; 102 /** Pointer to a I/O manager type */ 103 typedef PDMACEPFILEMGRTYPE *PPDMACEPFILEMGRTYPE; 89 104 90 105 /** … … 124 139 /** Previous Aio manager in the list. */ 125 140 R3PTRTYPE(struct PDMACEPFILEMGR *) pPrev; 141 /** Manager type */ 142 PDMACEPFILEMGRTYPE enmMgrType; 126 143 /** Current state of the manager. */ 127 144 PDMACEPFILEMGRSTATE enmState; … … 130 147 /** Flag whether the thread waits in the event semaphore. */ 131 148 volatile bool fWaitingEventSem; 132 /** Flag whether this manager uses the failsafe method. */133 bool fFailsafe;134 149 /** Thread data */ 135 150 RTTHREAD Thread; … … 402 417 403 418 /** 419 * Backend type for the endpoint. 420 */ 421 typedef enum PDMACFILEEPBACKEND 422 { 423 /** Non buffered. */ 424 PDMACFILEEPBACKEND_NON_BUFFERED = 0, 425 /** Buffered (i.e host cache enabled) */ 426 PDMACFILEEPBACKEND_BUFFERED, 427 /** 32bit hack */ 428 PDMACFILEEPBACKEND_32BIT_HACK = 0x7fffffff 429 } PDMACFILEEPBACKEND; 430 /** Pointer to a backend type. */ 431 typedef PDMACFILEEPBACKEND *PPDMACFILEEPBACKEND; 432 433 /** 404 434 * Global data for the file endpoint class. 405 435 */ … … 408 438 /** Common data. */ 409 439 PDMASYNCCOMPLETIONEPCLASS Core; 410 /** Flag whether we use the failsafe method. */ 411 bool fFailsafe; 440 /** Override I/O manager type - set to SIMPLE after failure. */ 441 PDMACEPFILEMGRTYPE enmMgrTypeOverride; 442 /** Default backend type for the endpoint. */ 443 PDMACFILEEPBACKEND enmEpBackendDefault; 412 444 /** Flag whether the file data cache is enabled. */ 413 445 bool fCacheEnabled; 414 /** Flag whether the host cache should be used too. */415 bool fHostCacheEnabled;416 446 /** Critical section protecting the list of async I/O managers. */ 417 447 RTCRITSECT CritSect; … … 480 510 /** Current state of the endpoint. */ 481 511 PDMASYNCCOMPLETIONENDPOINTFILESTATE enmState; 512 /** The backend to use for this endpoint. */ 513 PDMACFILEEPBACKEND enmBackendType; 482 514 /** async I/O manager this endpoint is assigned to. */ 483 515 R3PTRTYPE(volatile PPDMACEPFILEMGR) pAioMgr; … … 644 676 void pdmacFileAioMgrNormalDestroy(PPDMACEPFILEMGR pAioMgr); 645 677 646 int pdmacFileAioMgrCreate(PPDMASYNCCOMPLETIONEPCLASSFILE pEpClass, PPPDMACEPFILEMGR ppAioMgr, bool fFailsafe);678 int pdmacFileAioMgrCreate(PPDMASYNCCOMPLETIONEPCLASSFILE pEpClass, PPPDMACEPFILEMGR ppAioMgr, PDMACEPFILEMGRTYPE enmMgrType); 647 679 648 680 int pdmacFileAioMgrAddEndpoint(PPDMACEPFILEMGR pAioMgr, PPDMASYNCCOMPLETIONENDPOINTFILE pEndpoint); -
trunk/src/VBox/VMM/PDMAsyncCompletionFileNormal.cpp
r27280 r27299 248 248 if (pdmacFileAioMgrNormalIsBalancePossible(pAioMgr)) 249 249 { 250 rc = pdmacFileAioMgrCreate((PPDMASYNCCOMPLETIONEPCLASSFILE)pAioMgr->pEndpointsHead->Core.pEpClass, 251 &pAioMgrNew, false); 250 PPDMASYNCCOMPLETIONEPCLASSFILE pEpClassFile = (PPDMASYNCCOMPLETIONEPCLASSFILE)pAioMgr->pEndpointsHead->Core.pEpClass; 251 252 rc = pdmacFileAioMgrCreate(pEpClassFile, &pAioMgrNew, PDMACEPFILEMGRTYPE_ASYNC); 252 253 if (RT_SUCCESS(rc)) 253 254 { … … 326 327 327 328 pAioMgr->enmState = PDMACEPFILEMGRSTATE_FAULT; 328 ASMAtomicWrite Bool(&pEpClassFile->fFailsafe, true);329 ASMAtomicWriteU32((volatile uint32_t *)&pEpClassFile->enmMgrTypeOverride, PDMACEPFILEMGRTYPE_SIMPLE); 329 330 330 331 AssertMsgFailed(("Implement\n")); … … 562 563 } 563 564 564 static int pdmacFileAioMgrNormalTaskPrepare (PPDMACEPFILEMGR pAioMgr,565 PPDMASYNCCOMPLETIONENDPOINTFILE pEndpoint,566 PPDMACTASKFILE pTask, PRTFILEAIOREQ phReq)565 static int pdmacFileAioMgrNormalTaskPrepareBuffered(PPDMACEPFILEMGR pAioMgr, 566 PPDMASYNCCOMPLETIONENDPOINTFILE pEndpoint, 567 PPDMACTASKFILE pTask, PRTFILEAIOREQ phReq) 567 568 { 568 569 int rc = VINF_SUCCESS; … … 571 572 void *pvBuf = pTask->DataSeg.pvSeg; 572 573 573 /* Get a request handle. */ 574 hReq = pdmacFileAioMgrNormalRequestAlloc(pAioMgr); 575 AssertMsg(hReq != NIL_RTFILEAIOREQ, ("Out of request handles\n")); 574 AssertMsg( pTask->enmTransferType == PDMACTASKFILETRANSFER_WRITE 575 || (uint64_t)(pTask->Off + pTask->DataSeg.cbSeg) <= pEndpoint->cbFile, 576 ("Read exceeds file size offStart=%RTfoff cbToTransfer=%d cbFile=%llu\n", 577 pTask->Off, pTask->DataSeg.cbSeg, pEndpoint->cbFile)); 578 579 pTask->fPrefetch = false; 580 pTask->fBounceBuffer = false; 581 582 /* 583 * Before we start to setup the request we have to check whether there is a task 584 * already active which range intersects with ours. We have to defer execution 585 * of this task in two cases: 586 * - The pending task is a write and the current is either read or write 587 * - The pending task is a read and the current task is a write task. 588 * 589 * To check whether a range is currently "locked" we use the AVL tree where every pending task 590 * is stored by its file offset range. The current task will be added to the active task 591 * and will be executed when the active one completes. (The method below 592 * which checks whether a range is already used will add the task) 593 * 594 * This is neccessary because of the requirement to align all requests to a 512 boundary 595 * which is enforced by the host OS (Linux and Windows atm). It is possible that 596 * we have to process unaligned tasks and need to align them using bounce buffers. 597 * While the data is fetched from the file another request might arrive writing to 598 * the same range. This will result in data corruption if both are executed concurrently. 599 */ 600 bool fLocked = pdmacFileAioMgrNormalIsRangeLocked(pEndpoint, pTask->Off, pTask->DataSeg.cbSeg, pTask); 601 602 if (!fLocked) 603 { 604 /* Get a request handle. */ 605 hReq = pdmacFileAioMgrNormalRequestAlloc(pAioMgr); 606 AssertMsg(hReq != NIL_RTFILEAIOREQ, ("Out of request handles\n")); 607 608 if (pTask->enmTransferType == PDMACTASKFILETRANSFER_WRITE) 609 { 610 /* Grow the file if needed. */ 611 if (RT_UNLIKELY((uint64_t)(pTask->Off + pTask->DataSeg.cbSeg) > pEndpoint->cbFile)) 612 { 613 ASMAtomicWriteU64(&pEndpoint->cbFile, pTask->Off + pTask->DataSeg.cbSeg); 614 RTFileSetSize(pEndpoint->File, pTask->Off + pTask->DataSeg.cbSeg); 615 } 616 617 rc = RTFileAioReqPrepareWrite(hReq, pEndpoint->File, 618 pTask->Off, pTask->DataSeg.pvSeg, 619 pTask->DataSeg.cbSeg, pTask); 620 } 621 else 622 rc = RTFileAioReqPrepareRead(hReq, pEndpoint->File, 623 pTask->Off, pTask->DataSeg.pvSeg, 624 pTask->DataSeg.cbSeg, pTask); 625 AssertRC(rc); 626 627 rc = pdmacFileAioMgrNormalRangeLock(pAioMgr, pEndpoint, pTask->Off, 628 pTask->DataSeg.cbSeg, 629 pTask); 630 631 if (RT_SUCCESS(rc)) 632 *phReq = hReq; 633 } 634 else 635 LogFlow(("Task %#p was deferred because the access range is locked\n", pTask)); 636 637 return rc; 638 } 639 640 static int pdmacFileAioMgrNormalTaskPrepareNonBuffered(PPDMACEPFILEMGR pAioMgr, 641 PPDMASYNCCOMPLETIONENDPOINTFILE pEndpoint, 642 PPDMACTASKFILE pTask, PRTFILEAIOREQ phReq) 643 { 644 int rc = VINF_SUCCESS; 645 RTFILEAIOREQ hReq = NIL_RTFILEAIOREQ; 646 PPDMASYNCCOMPLETIONEPCLASSFILE pEpClassFile = (PPDMASYNCCOMPLETIONEPCLASSFILE)pEndpoint->Core.pEpClass; 647 void *pvBuf = pTask->DataSeg.pvSeg; 576 648 577 649 /* … … 585 657 586 658 AssertMsg( pTask->enmTransferType == PDMACTASKFILETRANSFER_WRITE 587 || (uint64_t)(offStart + cbToTransfer) <= pEndpoint->cbFile,588 ("Read exceeds file size offStart=%RTfoff cbToTransfer=%d cbFile=%llu\n",589 offStart, cbToTransfer, pEndpoint->cbFile));659 || (uint64_t)(offStart + cbToTransfer) <= pEndpoint->cbFile, 660 ("Read exceeds file size offStart=%RTfoff cbToTransfer=%d cbFile=%llu\n", 661 offStart, cbToTransfer, pEndpoint->cbFile)); 590 662 591 663 pTask->fPrefetch = false; … … 613 685 if (!fLocked) 614 686 { 687 /* Get a request handle. */ 688 hReq = pdmacFileAioMgrNormalRequestAlloc(pAioMgr); 689 AssertMsg(hReq != NIL_RTFILEAIOREQ, ("Out of request handles\n")); 690 615 691 if ( RT_UNLIKELY(cbToTransfer != pTask->DataSeg.cbSeg) 616 692 || RT_UNLIKELY(offStart != pTask->Off) … … 692 768 } 693 769 else 694 {695 770 LogFlow(("Task %#p was deferred because the access range is locked\n", pTask)); 696 rc = VINF_SUCCESS;697 }698 771 699 772 return rc; … … 755 828 RTFILEAIOREQ hReq = NIL_RTFILEAIOREQ; 756 829 757 rc = pdmacFileAioMgrNormalTaskPrepare(pAioMgr, pEndpoint, pCurr, &hReq); 830 if (pEndpoint->enmBackendType == PDMACFILEEPBACKEND_BUFFERED) 831 rc = pdmacFileAioMgrNormalTaskPrepareBuffered(pAioMgr, pEndpoint, pCurr, &hReq); 832 else if (pEndpoint->enmBackendType == PDMACFILEEPBACKEND_NON_BUFFERED) 833 rc = pdmacFileAioMgrNormalTaskPrepareNonBuffered(pAioMgr, pEndpoint, pCurr, &hReq); 834 else 835 AssertMsgFailed(("Invalid backend type %d\n", pEndpoint->enmBackendType)); 836 758 837 AssertRC(rc); 759 838 … … 1059 1138 1060 1139 rc = pdmacFileAioMgrCreate((PPDMASYNCCOMPLETIONEPCLASSFILE)pEndpoint->Core.pEpClass, 1061 &pAioMgrFailsafe, true);1140 &pAioMgrFailsafe, PDMACEPFILEMGRTYPE_SIMPLE); 1062 1141 AssertRC(rc); 1063 1142
Note:
See TracChangeset
for help on using the changeset viewer.