Changeset 46712 in vbox
- Timestamp:
- Jun 20, 2013 3:40:24 PM (11 years ago)
- File:
-
- 1 edited
-
trunk/src/VBox/Storage/VD.cpp (modified) (12 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Storage/VD.cpp
r46679 r46712 430 430 431 431 /** Default flags for an I/O context, i.e. unblocked and async. */ 432 #define VDIOCTX_FLAGS_DEFAULT (0)432 #define VDIOCTX_FLAGS_DEFAULT (0) 433 433 /** Flag whether the context is blocked. */ 434 #define VDIOCTX_FLAGS_BLOCKED RT_BIT_32(0)434 #define VDIOCTX_FLAGS_BLOCKED RT_BIT_32(0) 435 435 /** Flag whether the I/O context is using synchronous I/O. */ 436 #define VDIOCTX_FLAGS_SYNC RT_BIT_32(1)436 #define VDIOCTX_FLAGS_SYNC RT_BIT_32(1) 437 437 /** Flag whether the read should update the cache. */ 438 #define VDIOCTX_FLAGS_READ_U DATE_CACHERT_BIT_32(2)438 #define VDIOCTX_FLAGS_READ_UPDATE_CACHE RT_BIT_32(2) 439 439 /** Flag whether free blocks should be zeroed. 440 440 * If false and no image has data for sepcified … … 444 444 * of the range. 445 445 */ 446 #define VDIOCTX_FLAGS_ZERO_FREE_BLOCKS RT_BIT_32(3)446 #define VDIOCTX_FLAGS_ZERO_FREE_BLOCKS RT_BIT_32(3) 447 447 /** Don't free the I/O context when complete because 448 448 * it was alloacted elsewhere (stack, ...). */ 449 #define VDIOCTX_FLAGS_DONT_FREE RT_BIT_32(4) 449 #define VDIOCTX_FLAGS_DONT_FREE RT_BIT_32(4) 450 /* Don't set the modified flag for this I/O context when writing. */ 451 #define VDIOCTX_FLAGS_DONT_SET_MODIFIED_FLAG RT_BIT_32(5) 450 452 451 453 /** NIL I/O context pointer value. */ … … 1776 1778 /* If the read was successful, write the data back into the cache. */ 1777 1779 if ( RT_SUCCESS(rc) 1778 && pIoCtx->fFlags & VDIOCTX_FLAGS_READ_U DATE_CACHE)1780 && pIoCtx->fFlags & VDIOCTX_FLAGS_READ_UPDATE_CACHE) 1779 1781 { 1780 1782 rc = vdCacheWriteHelper(pDisk->pCache, uOffset, cbThisRead, … … 1950 1952 fFlags |= VDIOCTX_FLAGS_ZERO_FREE_BLOCKS; 1951 1953 if (fUpdateCache) 1952 fFlags |= VDIOCTX_FLAGS_READ_U DATE_CACHE;1954 fFlags |= VDIOCTX_FLAGS_READ_UPDATE_CACHE; 1953 1955 1954 1956 Segment.pvSeg = pvBuf; … … 2032 2034 PVDIMAGE pImageParentOverride, uint64_t uOffset, 2033 2035 const void *pvBuf, size_t cbWrite, 2034 bool fUpdateCache, unsigned cImagesRead) 2035 { 2036 uint32_t fFlags = VDIOCTX_FLAGS_SYNC | VDIOCTX_FLAGS_DONT_FREE; 2036 uint32_t fFlags, unsigned cImagesRead) 2037 { 2037 2038 RTSGSEG Segment; 2038 2039 RTSGBUF SgBuf; 2039 2040 VDIOCTX IoCtx; 2040 2041 2041 if (fUpdateCache) 2042 fFlags |= VDIOCTX_FLAGS_READ_UDATE_CACHE; 2042 fFlags |= VDIOCTX_FLAGS_SYNC | VDIOCTX_FLAGS_DONT_FREE; 2043 2043 2044 2044 Segment.pvSeg = (void *)pvBuf; … … 2062 2062 */ 2063 2063 static int vdWriteHelper(PVBOXHDD pDisk, PVDIMAGE pImage, uint64_t uOffset, 2064 const void *pvBuf, size_t cbWrite, bool fUpdateCache)2064 const void *pvBuf, size_t cbWrite, uint32_t fFlags) 2065 2065 { 2066 2066 return vdWriteHelperEx(pDisk, pImage, NULL, uOffset, pvBuf, cbWrite, 2067 f UpdateCache, 0);2067 fFlags, 0); 2068 2068 } 2069 2069 … … 2163 2163 /* Only do collapsed I/O if we are copying the data blockwise. */ 2164 2164 rc = vdWriteHelperEx(pDiskTo, pDiskTo->pLast, NULL, uOffset, pvBuf, 2165 cbThisRead, false /* fUpdateCache*/,2165 cbThisRead, VDIOCTX_FLAGS_DONT_SET_MODIFIED_FLAG /* fFlags */, 2166 2166 fBlockwiseCopy ? cImagesToRead : 0); 2167 2167 if (RT_FAILURE(rc)) … … 2618 2618 size_t cbPreRead, cbPostRead; 2619 2619 2620 rc = vdSetModifiedFlagAsync(pDisk, pIoCtx); 2621 if (RT_FAILURE(rc)) /* Includes I/O in progress. */ 2622 return rc; 2620 if (!(pIoCtx->fFlags & VDIOCTX_FLAGS_DONT_SET_MODIFIED_FLAG)) 2621 { 2622 rc = vdSetModifiedFlagAsync(pDisk, pIoCtx); 2623 if (RT_FAILURE(rc)) /* Includes I/O in progress. */ 2624 return rc; 2625 } 2623 2626 2624 2627 rc = vdDiscardSetRangeAllocated(pDisk, uOffset, cbWrite); … … 6786 6789 rc = vdWriteHelperEx(pDisk, pImageTo, pImageFrom->pPrev, 6787 6790 uOffset, pvBuf, cbThisRead, 6788 true /* fUpdateCache */, 0);6791 VDIOCTX_FLAGS_READ_UPDATE_CACHE, 0); 6789 6792 if (RT_FAILURE(rc)) 6790 6793 break; … … 6910 6913 break; 6911 6914 rc = vdWriteHelper(pDisk, pImageTo, uOffset, pvBuf, 6912 cbThisRead, true /* fUpdateCache */);6915 cbThisRead, VDIOCTX_FLAGS_READ_UPDATE_CACHE); 6913 6916 if (RT_FAILURE(rc)) 6914 6917 break; … … 8042 8045 vdSetModifiedFlag(pDisk); 8043 8046 rc = vdWriteHelper(pDisk, pImage, uOffset, pvBuf, cbWrite, 8044 true /* fUpdateCache */);8047 VDIOCTX_FLAGS_READ_UPDATE_CACHE); 8045 8048 if (RT_FAILURE(rc)) 8046 8049 break; … … 8056 8059 if (RT_UNLIKELY(pDisk->pImageRelay)) 8057 8060 rc = vdWriteHelper(pDisk, pDisk->pImageRelay, uOffset, 8058 pvBuf, cbWrite, false /* fUpdateCache */);8061 pvBuf, cbWrite, VDIOCTX_FLAGS_DEFAULT); 8059 8062 } while (0); 8060 8063
Note:
See TracChangeset
for help on using the changeset viewer.

