Changeset 21060 in vbox for trunk/src/VBox/Devices
- Timestamp:
- Jun 30, 2009 9:57:42 AM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Storage/VmdkHDDCore.cpp
r20640 r21060 3022 3022 if (uOpenFlags & VD_OPEN_FLAGS_ASYNC_IO) 3023 3023 { 3024 unsigned cFlatExtents = 0; 3025 3024 3026 for (unsigned i = 0; i < pImage->cExtents; i++) 3025 3027 { 3026 3028 PVMDKEXTENT pExtent = &pImage->pExtents[i]; 3027 3029 3028 if ( pExtent->enmType != VMDKETYPE_FLAT 3029 && pExtent->enmType != VMDKETYPE_ZERO 3030 && pExtent->enmType != VMDKETYPE_VMFS) 3030 if (( pExtent->enmType != VMDKETYPE_FLAT 3031 && pExtent->enmType != VMDKETYPE_ZERO 3032 && pExtent->enmType != VMDKETYPE_VMFS) 3033 || ((pImage->pExtents[i].enmType == VMDKETYPE_FLAT) && (cFlatExtents > 0))) 3031 3034 { 3032 3035 /* … … 3038 3041 goto out; 3039 3042 } 3043 if (pExtent->enmType == VMDKETYPE_FLAT) 3044 cFlatExtents++; 3040 3045 } 3041 3046 } … … 5731 5736 if (pImage) 5732 5737 { 5733 /* We only support async I/O support if the image only consists of FLAT or ZERO extents. */ 5738 unsigned cFlatExtents = 0; 5739 5740 /* We only support async I/O support if the image only consists of FLAT or ZERO extents. 5741 * 5742 * @todo: At the moment we only support async I/O if there is at most one FLAT extent 5743 * More than one doesn't work yet with the async I/O interface. 5744 */ 5734 5745 fAsyncIOSupported = true; 5735 5746 for (unsigned i = 0; i < pImage->cExtents; i++) 5736 5747 { 5737 if ( pImage->pExtents[i].enmType != VMDKETYPE_FLAT 5738 && pImage->pExtents[i].enmType != VMDKETYPE_ZERO 5739 && pImage->pExtents[i].enmType != VMDKETYPE_VMFS) 5748 if (( pImage->pExtents[i].enmType != VMDKETYPE_FLAT 5749 && pImage->pExtents[i].enmType != VMDKETYPE_ZERO 5750 && pImage->pExtents[i].enmType != VMDKETYPE_VMFS) 5751 || ((pImage->pExtents[i].enmType == VMDKETYPE_FLAT) && (cFlatExtents > 0))) 5740 5752 { 5741 5753 fAsyncIOSupported = false; 5742 5754 break; /* Stop search */ 5743 5755 } 5756 if (pImage->pExtents[i].enmType == VMDKETYPE_FLAT) 5757 cFlatExtents++; 5744 5758 } 5745 5759 } … … 5752 5766 { 5753 5767 PVMDKIMAGE pImage = (PVMDKIMAGE)pvBackendData; 5754 PVMDKEXTENT pExtent ;5768 PVMDKEXTENT pExtent = NULL; 5755 5769 int rc = VINF_SUCCESS; 5756 5770 unsigned cSegments = 0; … … 5758 5772 size_t cbLeftInCurrentSegment = paSegCurrent->cbSeg; 5759 5773 size_t uOffsetInCurrentSegment = 0; 5774 size_t cbReadLeft = cbRead; 5775 uint64_t uOffCurr = uOffset; 5760 5776 5761 5777 AssertPtr(pImage); … … 5770 5786 } 5771 5787 5772 while (cbRead && cSeg)5788 while (cbReadLeft && cSeg) 5773 5789 { 5774 5790 size_t cbToRead; 5775 5791 uint64_t uSectorExtentRel; 5776 5792 5777 rc = vmdkFindExtent(pImage, VMDK_BYTE2SECTOR(uOff set),5793 rc = vmdkFindExtent(pImage, VMDK_BYTE2SECTOR(uOffCurr), 5778 5794 &pExtent, &uSectorExtentRel); 5779 5795 if (RT_FAILURE(rc)) … … 5838 5854 } 5839 5855 5840 cbRead -= cbToRead;5841 uOff set+= cbToRead;5856 cbReadLeft -= cbToRead; 5857 uOffCurr += cbToRead; 5842 5858 cbLeftInCurrentSegment -= cbToRead; 5843 5859 uOffsetInCurrentSegment += cbToRead; … … 5852 5868 } 5853 5869 5854 AssertMsg(cbRead == 0, ("No segment left but there is still data to write\n"));5870 AssertMsg(cbReadLeft == 0, ("No segment left but there is still data to write\n")); 5855 5871 5856 5872 if (cSegments == 0) … … 5878 5894 { 5879 5895 PVMDKIMAGE pImage = (PVMDKIMAGE)pvBackendData; 5880 PVMDKEXTENT pExtent ;5896 PVMDKEXTENT pExtent = NULL; 5881 5897 int rc = VINF_SUCCESS; 5882 5898 unsigned cSegments = 0; … … 5884 5900 size_t cbLeftInCurrentSegment = paSegCurrent->cbSeg; 5885 5901 size_t uOffsetInCurrentSegment = 0; 5902 size_t cbWriteLeft = cbWrite; 5903 uint64_t uOffCurr = uOffset; 5886 5904 5887 5905 AssertPtr(pImage); … … 5896 5914 } 5897 5915 5898 while (cbWrite && cSeg)5916 while (cbWriteLeft && cSeg) 5899 5917 { 5900 5918 size_t cbToWrite; 5901 5919 uint64_t uSectorExtentRel; 5902 5920 5903 rc = vmdkFindExtent(pImage, VMDK_BYTE2SECTOR(uOff set),5921 rc = vmdkFindExtent(pImage, VMDK_BYTE2SECTOR(uOffCurr), 5904 5922 &pExtent, &uSectorExtentRel); 5905 5923 if (RT_FAILURE(rc)) … … 5964 5982 } 5965 5983 5966 cbWrite -= cbToWrite;5967 uOff set+= cbToWrite;5984 cbWriteLeft -= cbToWrite; 5985 uOffCurr += cbToWrite; 5968 5986 cbLeftInCurrentSegment -= cbToWrite; 5969 5987 uOffsetInCurrentSegment += cbToWrite; … … 5978 5996 } 5979 5997 5980 AssertMsg(cbWrite == 0, ("No segment left but there is still data to write\n"));5998 AssertMsg(cbWriteLeft == 0, ("No segment left but there is still data to write\n")); 5981 5999 5982 6000 if (cSegments == 0)
Note:
See TracChangeset
for help on using the changeset viewer.