Changeset 29449 in vbox
- Timestamp:
- May 13, 2010 3:32:07 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/r3/posix/fileaio-posix.cpp
r29129 r29449 68 68 /** Invalid entry in the waiting array. */ 69 69 #define RTFILEAIOCTX_WAIT_ENTRY_INVALID (~0U) 70 71 /** No-op replacement for rtFileAioCtxDump for non debug builds */ 72 #ifndef LOG_ENABLED 73 # define rtFileAioCtxDump(pCtxInt) do {} while (0) 74 #endif 70 75 71 76 /******************************************************************************* … … 199 204 && pReqHead) 200 205 { 206 RTFIELAIOREQ_ASSERT_STATE(pReqHead, SUBMITTED); 201 207 pCtxInt->apReqs[pCtxInt->iFirstFree] = pReqHead; 202 208 pReqHead->iWaitingList = pCtxInt->iFirstFree; … … 215 221 if (pReqHead) 216 222 { 223 RTFIELAIOREQ_ASSERT_STATE(pReqHead, SUBMITTED); 217 224 if (!pCtxInt->pReqsWaitHead) 218 225 { … … 231 238 /* Update tail. */ 232 239 while (pReqHead->pNext) 240 { 241 RTFIELAIOREQ_ASSERT_STATE(pReqHead->pNext, SUBMITTED); 233 242 pReqHead = pReqHead->pNext; 243 } 234 244 235 245 pCtxInt->pReqsWaitTail = pReqHead; … … 579 589 } 580 590 591 #ifdef LOG_ENABLED 592 /** 593 * Dumps the state of a async I/O context. 594 */ 595 static void rtFileAioCtxDump(PRTFILEAIOCTXINTERNAL pCtxInt) 596 { 597 LogFlow(("cRequests=%d\n", pCtxInt->cRequests)); 598 LogFlow(("cMaxRequests=%u\n", pCtxInt->cMaxRequests)); 599 LogFlow(("hThreadWait=%#p\n", pCtxInt->hThreadWait)); 600 LogFlow(("fWokenUp=%RTbool\n", pCtxInt->fWokenUp)); 601 LogFlow(("fWaiting=%RTbool\n", pCtxInt->fWaiting)); 602 LogFlow(("fWokenUpInternal=%RTbool\n", pCtxInt->fWokenUpInternal)); 603 for (unsigned i = 0; i < RT_ELEMENTS(pCtxInt->apReqsNewHead); i++) 604 LogFlow(("apReqsNewHead[%u]=%#p\n", i, pCtxInt->apReqsNewHead[i])); 605 LogFlow(("pReqToCancel=%#p\n", pCtxInt->pReqToCancel)); 606 LogFlow(("pReqsWaitHead=%#p\n", pCtxInt->pReqsWaitHead)); 607 LogFlow(("pReqsWaitTail=%#p\n", pCtxInt->pReqsWaitTail)); 608 LogFlow(("cReqsWaitMax=%u\n", pCtxInt->cReqsWaitMax)); 609 LogFlow(("iFirstFree=%u\n", pCtxInt->iFirstFree)); 610 for (unsigned i = 0; i < pCtxInt->cReqsWaitMax; i++) 611 LogFlow(("apReqs[%u]=%#p\n", i, pCtxInt->apReqs[i])); 612 } 613 #endif 614 581 615 RTDECL(int) RTFileAioCtxSubmit(RTFILEAIOCTX hAioCtx, PRTFILEAIOREQ pahReqs, size_t cReqs) 582 616 { … … 588 622 AssertReturn(cReqs != 0, VERR_INVALID_POINTER); 589 623 AssertPtrReturn(pahReqs, VERR_INVALID_PARAMETER); 624 625 rtFileAioCtxDump(pCtxInt); 590 626 591 627 /* Check that we don't exceed the limit */ … … 632 668 pReqInt->pCtxInt = pCtxInt; 633 669 670 if (pReqInt->fFlush) 671 break; 672 634 673 /* Link them together. */ 635 674 pReqInt->pNext = pHead; … … 639 678 pHead = pReqInt; 640 679 RTFILEAIOREQ_SET_STATE(pReqInt, SUBMITTED); 641 642 if (pReqInt->fFlush)643 break;644 680 645 681 cReqsSubmit++; … … 732 768 { 733 769 pReqInt = pahReqs[0]; 734 RTFILEAIOREQ_VALID_RETURN(pReqInt);735 770 736 771 if (pReqInt->fFlush) … … 743 778 if (RT_UNLIKELY(rcPosix < 0)) 744 779 { 745 rc = RTErrConvertFromErrno(errno); 746 RTFILEAIOREQ_SET_STATE(pReqInt, COMPLETED); 747 pReqInt->Rc = rc; 780 if (errno == EAGAIN) 781 { 782 rc = VERR_FILE_AIO_INSUFFICIENT_RESSOURCES; 783 RTFILEAIOREQ_SET_STATE(pReqInt, PREPARED); 784 } 785 else 786 { 787 rc = RTErrConvertFromErrno(errno); 788 RTFILEAIOREQ_SET_STATE(pReqInt, COMPLETED); 789 pReqInt->Rc = rc; 790 } 748 791 pReqInt->cbTransfered = 0; 749 750 /* Unlink from the list. */751 PRTFILEAIOREQINTERNAL pNext, pPrev;752 pNext = pReqInt->pNext;753 pPrev = pReqInt->pPrev;754 if (pNext)755 pNext->pPrev = pPrev;756 if (pPrev)757 pPrev->pNext = pNext;758 else759 pHead = pNext;760 792 break; 761 793 } 794 795 /* Link them together. */ 796 pReqInt->pNext = pHead; 797 if (pHead) 798 pHead->pPrev = pReqInt; 799 pReqInt->pPrev = NULL; 800 pHead = pReqInt; 801 RTFILEAIOREQ_SET_STATE(pReqInt, SUBMITTED); 762 802 763 803 ASMAtomicIncS32(&pCtxInt->cRequests); … … 804 844 } 805 845 846 rtFileAioCtxDump(pCtxInt); 847 806 848 return rc; 807 849 } … … 818 860 uint64_t StartNanoTS = 0; 819 861 862 LogFlowFunc(("hAioCtx=%#p cMinReqs=%zu cMillies=%u pahReqs=%#p cReqs=%zu pcbReqs=%#p\n", 863 hAioCtx, cMinReqs, cMillies, pahReqs, cReqs, pcReqs)); 864 820 865 /* Check parameters. */ 821 866 AssertPtrReturn(pCtxInt, VERR_INVALID_HANDLE); … … 824 869 AssertReturn(cReqs != 0, VERR_INVALID_PARAMETER); 825 870 AssertReturn(cReqs >= cMinReqs, VERR_OUT_OF_RANGE); 871 872 rtFileAioCtxDump(pCtxInt); 826 873 827 874 int32_t cRequestsWaiting = ASMAtomicReadS32(&pCtxInt->cRequests); … … 866 913 #endif 867 914 915 LogFlow(("Waiting for %d requests to complete\n", pCtxInt->iFirstFree)); 916 rtFileAioCtxDump(pCtxInt); 917 868 918 ASMAtomicXchgBool(&pCtxInt->fWaiting, true); 869 919 int rcPosix = aio_suspend((const struct aiocb * const *)pCtxInt->apReqs, … … 872 922 if (rcPosix < 0) 873 923 { 924 LogFlow(("aio_suspend failed %d nent=%u\n", errno, pCtxInt->iFirstFree)); 874 925 /* Check that this is an external wakeup event. */ 875 926 if (errno == EINTR) … … 984 1035 ASMAtomicWriteHandle(&pCtxInt->hThreadWait, NIL_RTTHREAD); 985 1036 1037 rtFileAioCtxDump(pCtxInt); 1038 986 1039 return rc; 987 1040 }
Note:
See TracChangeset
for help on using the changeset viewer.