Changeset 39054 in vbox for trunk/src/VBox/VMM
- Timestamp:
- Oct 20, 2011 1:47:45 PM (13 years ago)
- svn:sync-xref-src-repo-rev:
- 74476
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/VMM/VMMR3/PDMBlkCache.cpp
r39042 r39054 1745 1745 * 1746 1746 * @returns The number of bytes the entry can hold of the requested amount 1747 * of byte .1747 * of bytes. 1748 1748 * @param pEndpoint The endpoint. 1749 1749 * @param pBlkCache The endpoint cache. … … 1751 1751 * @param cb The number of bytes the entry needs to hold at 1752 1752 * least. 1753 * @param uAlignment Alignment of the boundary sizes. 1754 * @param poffAligned Where to store the aligned offset. 1755 * @param pcbAligned Where to store the aligned size of the entry. 1753 * @param pcbEntry Where to store the number of bytes the entry can hold. 1754 * Can be less than given because of other entries. 1756 1755 */ 1757 1756 static uint32_t pdmBlkCacheEntryBoundariesCalc(PPDMBLKCACHE pBlkCache, 1758 1757 uint64_t off, uint32_t cb, 1759 unsigned uAlignment, 1760 uint64_t *poffAligned, uint32_t *pcbAligned) 1758 uint32_t *pcbEntry) 1761 1759 { 1762 1760 /* Get the best fit entries around the offset */ … … 1772 1770 pEntryAbove ? pEntryAbove->cbData : 0)); 1773 1771 1774 /** @todo r=bird: Why is uAlignment disregarded here? */ 1775 uint64_t offAligned = off; 1776 1777 uint32_t cbAligned; 1772 uint32_t cbNext; 1778 1773 uint32_t cbInEntry; 1779 1774 if ( pEntryAbove … … 1781 1776 { 1782 1777 cbInEntry = (uint32_t)(pEntryAbove->Core.Key - off); 1783 cb Aligned = (uint32_t)(pEntryAbove->Core.Key - offAligned);1778 cbNext = (uint32_t)(pEntryAbove->Core.Key - off); 1784 1779 } 1785 1780 else 1786 1781 { 1787 1782 cbInEntry = cb; 1788 cb Aligned= cb;1783 cbNext = cb; 1789 1784 } 1790 1785 1791 1786 /* A few sanity checks */ 1792 AssertMsg(!pEntryAbove || off Aligned + cbAligned<= pEntryAbove->Core.Key,1787 AssertMsg(!pEntryAbove || off + cbNext <= pEntryAbove->Core.Key, 1793 1788 ("Aligned size intersects with another cache entry\n")); 1794 Assert(cbInEntry <= cb Aligned);1789 Assert(cbInEntry <= cbNext); 1795 1790 1796 1791 if (pEntryAbove) 1797 1792 pdmBlkCacheEntryRelease(pEntryAbove); 1798 1793 1799 LogFlow(("offAligned=%llu cbAligned=%u\n", offAligned, cbAligned)); 1800 1801 *poffAligned = offAligned; 1802 *pcbAligned = cbAligned; 1794 LogFlow(("off=%llu cbNext=%u\n", off, cbNext)); 1795 1796 *pcbEntry = cbNext; 1803 1797 1804 1798 return cbInEntry; … … 1814 1808 * @param off The offset. 1815 1809 * @param cb Number of bytes the cache entry should have. 1816 * @param uAlignment Alignment the size of the entry should have.1817 1810 * @param pcbData Where to store the number of bytes the new 1818 1811 * entry can hold. May be lower than actually requested … … 1821 1814 static PPDMBLKCACHEENTRY pdmBlkCacheEntryCreate(PPDMBLKCACHE pBlkCache, 1822 1815 uint64_t off, size_t cb, 1823 unsigned uAlignment,1824 1816 size_t *pcbData) 1825 1817 { 1826 uint64_t offStart = 0;1827 1818 uint32_t cbEntry = 0; 1828 *pcbData = pdmBlkCacheEntryBoundariesCalc(pBlkCache, off, (uint32_t)cb, uAlignment, 1829 &offStart, &cbEntry);1819 1820 *pcbData = pdmBlkCacheEntryBoundariesCalc(pBlkCache, off, (uint32_t)cb, &cbEntry); 1830 1821 AssertReturn(cb <= UINT32_MAX, NULL); 1831 1822 … … 1840 1831 LogFlow(("Evicted enough bytes (%u requested). Creating new cache entry\n", cbEntry)); 1841 1832 1842 pEntryNew = pdmBlkCacheEntryAlloc(pBlkCache, off Start, cbEntry, pbBuffer);1833 pEntryNew = pdmBlkCacheEntryAlloc(pBlkCache, off, cbEntry, pbBuffer); 1843 1834 if (RT_LIKELY(pEntryNew)) 1844 1835 { … … 1851 1842 AssertMsg( (off >= pEntryNew->Core.Key) 1852 1843 && (off + *pcbData <= pEntryNew->Core.KeyLast + 1), 1853 ("Overflow in calculation off=%llu OffsetAligned=%llu\n", 1854 off, pEntryNew->Core.Key)); 1844 ("Overflow in calculation off=%llu\n", off)); 1855 1845 } 1856 1846 else … … 2085 2075 PPDMBLKCACHEENTRY pEntryNew = pdmBlkCacheEntryCreate(pBlkCache, 2086 2076 off, cbRead, 2087 PAGE_SIZE,2088 2077 &cbToRead); 2089 2078 … … 2317 2306 PPDMBLKCACHEENTRY pEntryNew = pdmBlkCacheEntryCreate(pBlkCache, 2318 2307 off, cbWrite, 2319 512,&cbToWrite);2308 &cbToWrite); 2320 2309 2321 2310 cbWrite -= cbToWrite;
Note:
See TracChangeset
for help on using the changeset viewer.