Changeset 44412 in vbox
- Timestamp:
- Jan 28, 2013 10:39:34 AM (12 years ago)
- svn:sync-xref-src-repo-rev:
- 83386
- Location:
- trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/VBox/vd-cache-plugin.h
r38469 r44412 132 132 133 133 /** 134 * Read data from a cache image. The area read never crosses a block 135 * boundary. 136 * 137 * @returns VBox status code. 138 * @returns VERR_VD_BLOCK_FREE if this image contains no data for this block. 139 * @param pBackendData Opaque state data for this image. 140 * @param uOffset Offset to start reading from. 141 * @param pvBuf Where to store the read bits. 142 * @param cbRead Number of bytes to read. 143 * @param pcbActuallyRead Pointer to returned number of bytes read. 144 */ 145 DECLR3CALLBACKMEMBER(int, pfnRead, (void *pBackendData, uint64_t uOffset, void *pvBuf, 146 size_t cbRead, size_t *pcbActuallyRead)); 147 148 /** 149 * Write data to a cache image. The area written never crosses a block 150 * boundary. 151 * 152 * @returns VBox status code. 153 * @param pBackendData Opaque state data for this image. 154 * @param uOffset Offset to start writing to. 155 * @param pvBuf Where to retrieve the written bits. 156 * @param cbWrite Number of bytes to write. 157 * @param pcbWriteProcess Pointer to returned number of bytes that could 158 * be processed. 159 */ 160 DECLR3CALLBACKMEMBER(int, pfnWrite, (void *pBackendData, uint64_t uOffset, 161 const void *pvBuf, size_t cbWrite, 162 size_t *pcbWriteProcess)); 163 164 /** 165 * Flush data to disk. 166 * 167 * @returns VBox status code. 168 * @param pBackendData Opaque state data for this image. 169 */ 170 DECLR3CALLBACKMEMBER(int, pfnFlush, (void *pBackendData)); 171 172 /** 173 * Get the version of a cache image. 174 * 175 * @returns version of cache image. 176 * @param pBackendData Opaque state data for this image. 177 */ 178 DECLR3CALLBACKMEMBER(unsigned, pfnGetVersion, (void *pBackendData)); 179 180 /** 181 * Get the capacity of a cache image. 182 * 183 * @returns size of cache image in bytes. 184 * @param pBackendData Opaque state data for this image. 185 */ 186 DECLR3CALLBACKMEMBER(uint64_t, pfnGetSize, (void *pBackendData)); 187 188 /** 189 * Get the file size of a cache image. 190 * 191 * @returns size of cache image in bytes. 192 * @param pBackendData Opaque state data for this image. 193 */ 194 DECLR3CALLBACKMEMBER(uint64_t, pfnGetFileSize, (void *pBackendData)); 195 196 /** 197 * Get the image flags of a cache image. 198 * 199 * @returns image flags of cache image. 200 * @param pBackendData Opaque state data for this image. 201 */ 202 DECLR3CALLBACKMEMBER(unsigned, pfnGetImageFlags, (void *pBackendData)); 203 204 /** 205 * Get the open flags of a cache image. 206 * 207 * @returns open flags of cache image. 208 * @param pBackendData Opaque state data for this image. 209 */ 210 DECLR3CALLBACKMEMBER(unsigned, pfnGetOpenFlags, (void *pBackendData)); 211 212 /** 213 * Set the open flags of a cache image. May cause the image to be locked 214 * in a different mode or be reopened (which can fail). 215 * 216 * @returns VBox status code. 217 * @param pBackendData Opaque state data for this image. 218 * @param uOpenFlags New open flags for this image. 219 */ 220 DECLR3CALLBACKMEMBER(int, pfnSetOpenFlags, (void *pBackendData, unsigned uOpenFlags)); 221 222 /** 223 * Get comment of a cache image. 224 * 225 * @returns VBox status code. 226 * @param pBackendData Opaque state data for this image. 227 * @param pszComment Where to store the comment. 228 * @param cbComment Size of the comment buffer. 229 */ 230 DECLR3CALLBACKMEMBER(int, pfnGetComment, (void *pBackendData, char *pszComment, size_t cbComment)); 231 232 /** 233 * Set comment of a cache image. 234 * 235 * @returns VBox status code. 236 * @param pBackendData Opaque state data for this image. 237 * @param pszComment Where to get the comment from. NULL resets comment. 238 * The comment is silently truncated if the image format 239 * limit is exceeded. 240 */ 241 DECLR3CALLBACKMEMBER(int, pfnSetComment, (void *pBackendData, const char *pszComment)); 242 243 /** 244 * Get UUID of a cache image. 245 * 246 * @returns VBox status code. 247 * @param pBackendData Opaque state data for this image. 248 * @param pUuid Where to store the image UUID. 249 */ 250 DECLR3CALLBACKMEMBER(int, pfnGetUuid, (void *pBackendData, PRTUUID pUuid)); 251 252 /** 253 * Set UUID of a cache image. 254 * 255 * @returns VBox status code. 256 * @param pBackendData Opaque state data for this image. 257 * @param pUuid Where to get the image UUID from. 258 */ 259 DECLR3CALLBACKMEMBER(int, pfnSetUuid, (void *pBackendData, PCRTUUID pUuid)); 260 261 /** 262 * Get last modification UUID of a cache image. 263 * 264 * @returns VBox status code. 265 * @param pBackendData Opaque state data for this image. 266 * @param pUuid Where to store the image modification UUID. 267 */ 268 DECLR3CALLBACKMEMBER(int, pfnGetModificationUuid, (void *pBackendData, PRTUUID pUuid)); 269 270 /** 271 * Set last modification UUID of a cache image. 272 * 273 * @returns VBox status code. 274 * @param pBackendData Opaque state data for this image. 275 * @param pUuid Where to get the image modification UUID from. 276 */ 277 DECLR3CALLBACKMEMBER(int, pfnSetModificationUuid, (void *pBackendData, PCRTUUID pUuid)); 278 279 /** 280 * Dump information about a cache image. 281 * 282 * @param pBackendData Opaque state data for this image. 283 */ 284 DECLR3CALLBACKMEMBER(void, pfnDump, (void *pBackendData)); 285 286 /** 287 * Start an asynchronous read request. 134 * Start a read request. 288 135 * 289 136 * @returns VBox status code. … … 294 141 * @param pcbActuallyRead Pointer to returned number of bytes read. 295 142 */ 296 DECLR3CALLBACKMEMBER(int, pfn AsyncRead, (void *pBackendData, uint64_t uOffset, size_t cbRead,297 298 299 /** 300 * Start a n asynchronouswrite request.143 DECLR3CALLBACKMEMBER(int, pfnRead, (void *pBackendData, uint64_t uOffset, size_t cbRead, 144 PVDIOCTX pIoCtx, size_t *pcbActuallyRead)); 145 146 /** 147 * Start a write request. 301 148 * 302 149 * @returns VBox status code. … … 312 159 * amount of (previously read) padding data. 313 160 */ 314 DECLR3CALLBACKMEMBER(int, pfn AsyncWrite, (void *pBackendData, uint64_t uOffset, size_t cbWrite,315 161 DECLR3CALLBACKMEMBER(int, pfnWrite, (void *pBackendData, uint64_t uOffset, size_t cbWrite, 162 PVDIOCTX pIoCtx, size_t *pcbWriteProcess)); 316 163 317 164 /** … … 322 169 * @param pIoCtx I/O context associated with this request. 323 170 */ 324 DECLR3CALLBACKMEMBER(int, pfnAsyncFlush, (void *pBackendData, PVDIOCTX pIoCtx)); 171 DECLR3CALLBACKMEMBER(int, pfnFlush, (void *pBackendData, PVDIOCTX pIoCtx)); 172 173 /** 174 * Discards the given amount of bytes from the cache. 175 * 176 * @returns VBox status code. 177 * @retval VERR_VD_DISCARD_ALIGNMENT_NOT_MET if the range doesn't meet the required alignment 178 * for the discard. 179 * @param pBackendData Opaque state data for this image. 180 * @param pIoCtx I/O context associated with this request. 181 * @param uOffset The offset of the first byte to discard. 182 * @param cbDiscard How many bytes to discard. 183 */ 184 DECLR3CALLBACKMEMBER(int, pfnDiscard, (void *pBackendData, PVDIOCTX pIoCtx, 185 uint64_t uOffset, size_t cbDiscard, 186 size_t *pcbPreAllocated, 187 size_t *pcbPostAllocated, 188 size_t *pcbActuallyDiscarded, 189 void **ppbmAllocationBitmap, 190 unsigned fDiscard)); 191 192 /** 193 * Get the version of a cache image. 194 * 195 * @returns version of cache image. 196 * @param pBackendData Opaque state data for this image. 197 */ 198 DECLR3CALLBACKMEMBER(unsigned, pfnGetVersion, (void *pBackendData)); 199 200 /** 201 * Get the capacity of a cache image. 202 * 203 * @returns size of cache image in bytes. 204 * @param pBackendData Opaque state data for this image. 205 */ 206 DECLR3CALLBACKMEMBER(uint64_t, pfnGetSize, (void *pBackendData)); 207 208 /** 209 * Get the file size of a cache image. 210 * 211 * @returns size of cache image in bytes. 212 * @param pBackendData Opaque state data for this image. 213 */ 214 DECLR3CALLBACKMEMBER(uint64_t, pfnGetFileSize, (void *pBackendData)); 215 216 /** 217 * Get the image flags of a cache image. 218 * 219 * @returns image flags of cache image. 220 * @param pBackendData Opaque state data for this image. 221 */ 222 DECLR3CALLBACKMEMBER(unsigned, pfnGetImageFlags, (void *pBackendData)); 223 224 /** 225 * Get the open flags of a cache image. 226 * 227 * @returns open flags of cache image. 228 * @param pBackendData Opaque state data for this image. 229 */ 230 DECLR3CALLBACKMEMBER(unsigned, pfnGetOpenFlags, (void *pBackendData)); 231 232 /** 233 * Set the open flags of a cache image. May cause the image to be locked 234 * in a different mode or be reopened (which can fail). 235 * 236 * @returns VBox status code. 237 * @param pBackendData Opaque state data for this image. 238 * @param uOpenFlags New open flags for this image. 239 */ 240 DECLR3CALLBACKMEMBER(int, pfnSetOpenFlags, (void *pBackendData, unsigned uOpenFlags)); 241 242 /** 243 * Get comment of a cache image. 244 * 245 * @returns VBox status code. 246 * @param pBackendData Opaque state data for this image. 247 * @param pszComment Where to store the comment. 248 * @param cbComment Size of the comment buffer. 249 */ 250 DECLR3CALLBACKMEMBER(int, pfnGetComment, (void *pBackendData, char *pszComment, size_t cbComment)); 251 252 /** 253 * Set comment of a cache image. 254 * 255 * @returns VBox status code. 256 * @param pBackendData Opaque state data for this image. 257 * @param pszComment Where to get the comment from. NULL resets comment. 258 * The comment is silently truncated if the image format 259 * limit is exceeded. 260 */ 261 DECLR3CALLBACKMEMBER(int, pfnSetComment, (void *pBackendData, const char *pszComment)); 262 263 /** 264 * Get UUID of a cache image. 265 * 266 * @returns VBox status code. 267 * @param pBackendData Opaque state data for this image. 268 * @param pUuid Where to store the image UUID. 269 */ 270 DECLR3CALLBACKMEMBER(int, pfnGetUuid, (void *pBackendData, PRTUUID pUuid)); 271 272 /** 273 * Set UUID of a cache image. 274 * 275 * @returns VBox status code. 276 * @param pBackendData Opaque state data for this image. 277 * @param pUuid Where to get the image UUID from. 278 */ 279 DECLR3CALLBACKMEMBER(int, pfnSetUuid, (void *pBackendData, PCRTUUID pUuid)); 280 281 /** 282 * Get last modification UUID of a cache image. 283 * 284 * @returns VBox status code. 285 * @param pBackendData Opaque state data for this image. 286 * @param pUuid Where to store the image modification UUID. 287 */ 288 DECLR3CALLBACKMEMBER(int, pfnGetModificationUuid, (void *pBackendData, PRTUUID pUuid)); 289 290 /** 291 * Set last modification UUID of a cache image. 292 * 293 * @returns VBox status code. 294 * @param pBackendData Opaque state data for this image. 295 * @param pUuid Where to get the image modification UUID from. 296 */ 297 DECLR3CALLBACKMEMBER(int, pfnSetModificationUuid, (void *pBackendData, PCRTUUID pUuid)); 298 299 /** 300 * Dump information about a cache image. 301 * 302 * @param pBackendData Opaque state data for this image. 303 */ 304 DECLR3CALLBACKMEMBER(void, pfnDump, (void *pBackendData)); 325 305 326 306 /** Returns a human readable hard disk location string given a -
trunk/src/VBox/Storage/VCICache.cpp
r44233 r44412 1183 1183 while (pInt) 1184 1184 { 1185 1185 1186 1186 } 1187 1187 } … … 1632 1632 1633 1633 /** @copydoc VDCACHEBACKEND::pfnRead */ 1634 static int vciRead(void *pBackendData, uint64_t uOffset, void *pvBuf, 1635 size_t cbToRead, size_t *pcbActuallyRead) 1636 { 1637 LogFlowFunc(("pBackendData=%#p uOffset=%llu pvBuf=%#p cbToRead=%zu pcbActuallyRead=%#p\n", pBackendData, uOffset, pvBuf, cbToRead, pcbActuallyRead)); 1634 static int vciRead(void *pBackendData, uint64_t uOffset, size_t cbToRead, 1635 PVDIOCTX pIoCtx, size_t *pcbActuallyRead) 1636 { 1637 LogFlowFunc(("pBackendData=%#p uOffset=%llu cbToRead=%zu pIoCtx=%#p pcbActuallyRead=%#p\n", 1638 pBackendData, uOffset, cbToRead, pIoCtx, pcbActuallyRead)); 1638 1639 PVCICACHE pCache = (PVCICACHE)pBackendData; 1639 1640 int rc = VINF_SUCCESS; … … 1652 1653 cBlocksToRead = RT_MIN(cBlocksToRead, pExtent->u32Blocks - offRead); 1653 1654 1654 rc = vdIfIoIntFileRead Sync(pCache->pIfIo, pCache->pStorage,1655 rc = vdIfIoIntFileReadUser(pCache->pIfIo, pCache->pStorage, 1655 1656 pExtent->u64BlockAddr + offRead, 1656 p vBuf, cBlocksToRead);1657 pIoCtx, cBlocksToRead); 1657 1658 } 1658 1659 else … … 1672 1673 1673 1674 /** @copydoc VDCACHEBACKEND::pfnWrite */ 1674 static int vciWrite(void *pBackendData, uint64_t uOffset, const void *pvBuf,1675 size_t cbToWrite, size_t *pcbWriteProcess)1676 { 1677 LogFlowFunc(("pBackendData=%#p uOffset=%llu pvBuf=%#p cbToWrite=%zupcbWriteProcess=%#p\n",1678 pBackendData, uOffset, pvBuf, cbToWrite, pcbWriteProcess));1675 static int vciWrite(void *pBackendData, uint64_t uOffset, size_t cbToWrite, 1676 PVDIOCTX pIoCtx, size_t *pcbWriteProcess) 1677 { 1678 LogFlowFunc(("pBackendData=%#p uOffset=%llu cbToWrite=%zu pIoCtx=%#p pcbWriteProcess=%#p\n", 1679 pBackendData, uOffset, cbToWrite, pIoCtx, pcbWriteProcess)); 1679 1680 PVCICACHE pCache = (PVCICACHE)pBackendData; 1680 1681 int rc = VINF_SUCCESS; … … 1689 1690 while (cBlocksToWrite) 1690 1691 { 1691 1692 1692 1693 } 1693 1694 … … 1699 1700 1700 1701 /** @copydoc VDCACHEBACKEND::pfnFlush */ 1701 static int vciFlush(void *pBackendData )1702 static int vciFlush(void *pBackendData, PVDIOCTX pIoCtx) 1702 1703 { 1703 1704 LogFlowFunc(("pBackendData=%#p\n", pBackendData)); … … 1956 1957 { 1957 1958 NOREF(pBackendData); 1958 }1959 1960 /** @copydoc VDCACHEBACKEND::pfnAsyncRead */1961 static int vciAsyncRead(void *pBackendData, uint64_t uOffset, size_t cbRead,1962 PVDIOCTX pIoCtx, size_t *pcbActuallyRead)1963 {1964 int rc = VERR_NOT_SUPPORTED;1965 PVCICACHE pCache = (PVCICACHE)pBackendData;1966 1967 return rc;1968 }1969 1970 /** @copydoc VDCACHEBACKEND::pfnAsyncWrite */1971 static int vciAsyncWrite(void *pBackendData, uint64_t uOffset, size_t cbWrite,1972 PVDIOCTX pIoCtx, size_t *pcbWriteProcess)1973 {1974 int rc = VERR_NOT_SUPPORTED;1975 PVCICACHE pCache = (PVCICACHE)pBackendData;1976 1977 return rc;1978 }1979 1980 /** @copydoc VDCACHEBACKEND::pfnAsyncFlush */1981 static int vciAsyncFlush(void *pBackendData, PVDIOCTX pIoCtx)1982 {1983 int rc = VERR_NOT_SUPPORTED;1984 PVCICACHE pCache = (PVCICACHE)pBackendData;1985 1986 return rc;1987 1959 } 1988 1960 … … 2016 1988 /* pfnFlush */ 2017 1989 vciFlush, 1990 /* pfnDiscard */ 1991 NULL, 2018 1992 /* pfnGetVersion */ 2019 1993 vciGetVersion, … … 2042 2016 /* pfnDump */ 2043 2017 vciDump, 2044 /* pfnAsyncRead */2045 vciAsyncRead,2046 /* pfnAsyncWrite */2047 vciAsyncWrite,2048 /* pfnAsyncFlush */2049 vciAsyncFlush,2050 2018 /* pfnComposeLocation */ 2051 2019 NULL, -
trunk/src/VBox/Storage/VD.cpp
r44408 r44412 833 833 * @param pCache The cache to read from. 834 834 * @param uOffset Offset of the virtual disk to read. 835 * @param pvBuf Where to store the read data.836 835 * @param cbRead How much to read. 836 * @param pIoCtx The I/O context to read into. 837 837 * @param pcbRead Where to store the number of bytes actually read. 838 838 * On success this indicates the number of bytes read from the cache. … … 843 843 */ 844 844 static int vdCacheReadHelper(PVDCACHE pCache, uint64_t uOffset, 845 void *pvBuf, size_t cbRead, size_t *pcbRead)845 PVDIOCTX pIoCtx, size_t cbRead, size_t *pcbRead) 846 846 { 847 847 int rc = VINF_SUCCESS; 848 848 849 LogFlowFunc(("pCache=%#p uOffset=%llu p vBuf=%#p cbRead=%zu pcbRead=%#p\n",850 pCache, uOffset, p vBuf, cbRead, pcbRead));849 LogFlowFunc(("pCache=%#p uOffset=%llu pIoCtx=%p cbRead=%zu pcbRead=%#p\n", 850 pCache, uOffset, pIoCtx, cbRead, pcbRead)); 851 851 852 852 AssertPtr(pCache); 853 853 AssertPtr(pcbRead); 854 854 855 #if 0 /** @todo: Cache implementation update */ 856 rc = pCache->Backend->pfnRead(pCache->pBackendData, uOffset, pvBuf, 857 cbRead, pcbRead); 858 #endif 855 rc = pCache->Backend->pfnRead(pCache->pBackendData, uOffset, cbRead, 856 pIoCtx, pcbRead); 859 857 860 858 LogFlowFunc(("returns rc=%Rrc pcbRead=%zu\n", rc, *pcbRead)); … … 868 866 * @param pCache The cache to write to. 869 867 * @param uOffset Offset of the virtual disk to write to the cache. 870 * @param pcvBuf The data to write.871 868 * @param cbWrite How much to write. 869 * @param pIoCtx The I/O context to ẃrite from. 872 870 * @param pcbWritten How much data could be written, optional. 873 871 */ 874 static int vdCacheWriteHelper(PVDCACHE pCache, uint64_t uOffset, const void *pcvBuf,875 size_t cbWrite, size_t *pcbWritten)872 static int vdCacheWriteHelper(PVDCACHE pCache, uint64_t uOffset, size_t cbWrite, 873 PVDIOCTX pIoCtx, size_t *pcbWritten) 876 874 { 877 875 int rc = VINF_SUCCESS; 878 876 879 LogFlowFunc(("pCache=%#p uOffset=%llu p vBuf=%#p cbWrite=%zu pcbWritten=%#p\n",880 pCache, uOffset, p cvBuf, cbWrite, pcbWritten));877 LogFlowFunc(("pCache=%#p uOffset=%llu pIoCtx=%p cbWrite=%zu pcbWritten=%#p\n", 878 pCache, uOffset, pIoCtx, cbWrite, pcbWritten)); 881 879 882 880 AssertPtr(pCache); 883 AssertPtr(p cvBuf);881 AssertPtr(pIoCtx); 884 882 Assert(cbWrite > 0); 885 883 886 #if 0 /** @todo: Change cache implementation */887 884 if (pcbWritten) 888 rc = pCache->Backend->pfnWrite(pCache->pBackendData, uOffset, pcvBuf,889 cbWrite, pcbWritten);885 rc = pCache->Backend->pfnWrite(pCache->pBackendData, uOffset, cbWrite, 886 pIoCtx, pcbWritten); 890 887 else 891 888 { … … 894 891 do 895 892 { 896 rc = pCache->Backend->pfnWrite(pCache->pBackendData, uOffset, pcvBuf,897 cbWrite, &cbWritten);893 rc = pCache->Backend->pfnWrite(pCache->pBackendData, uOffset, cbWrite, 894 pIoCtx, &cbWritten); 898 895 uOffset += cbWritten; 899 pcvBuf = (char *)pcvBuf + cbWritten;900 896 cbWrite -= cbWritten; 901 897 } while ( cbWrite 902 && RT_SUCCESS(rc));903 }904 #endif 898 && ( RT_SUCCESS(rc) 899 || rc == VERR_VD_ASYNC_IO_IN_PROGRESS)); 900 } 905 901 906 902 LogFlowFunc(("returns rc=%Rrc pcbWritten=%zu\n", … … 1002 998 && !pImageParentOverride) 1003 999 { 1000 #if 0 /** @todo: Will go soon when the sync and async read helper versions are merged. */ 1004 1001 rc = vdCacheReadHelper(pDisk->pCache, uOffset, pvBuf, 1005 1002 cbThisRead, &cbThisRead); 1006 1003 #endif 1007 1004 if (rc == VERR_VD_BLOCK_FREE) 1008 1005 { … … 1014 1011 && fUpdateCache) 1015 1012 { 1013 #if 0 /** @todo: Will go soon when the sync and async read helper versions are merged. */ 1016 1014 rc = vdCacheWriteHelper(pDisk->pCache, uOffset, pvBuf, 1017 1015 cbThisRead, NULL); 1016 #endif 1018 1017 } 1019 1018 } … … 2212 2211 } while (cbWriteCur != 0 && RT_SUCCESS(rc)); 2213 2212 2213 #if 0 /** @todo: Soon removed when sync and async version of the write helper are merged. */ 2214 2214 /* Update the cache on success */ 2215 2215 if ( RT_SUCCESS(rc) … … 2220 2220 if (RT_SUCCESS(rc)) 2221 2221 rc = vdDiscardSetRangeAllocated(pDisk, uOffset, cbWrite); 2222 #endif 2222 2223 2223 2224 return rc; … … 8205 8206 rc = pImage->Backend->pfnFlush(pImage->pBackendData, &IoCtx); 8206 8207 8207 #if 0 /** @todo: Change cache implementation. */8208 8208 if ( RT_SUCCESS(rc) 8209 8209 && pDisk->pCache) 8210 rc = pDisk->pCache->Backend->pfnFlush(pDisk->pCache->pBackendData); 8211 #endif 8210 rc = pDisk->pCache->Backend->pfnFlush(pDisk->pCache->pBackendData, &IoCtx); 8212 8211 } while (0); 8213 8212
Note:
See TracChangeset
for help on using the changeset viewer.