Changeset 100078 in vbox for trunk/src/VBox/Storage/VD.cpp
- Timestamp:
- Jun 6, 2023 5:15:22 AM (18 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Storage/VD.cpp
r99739 r100078 2053 2053 * to speed up the copy process if possible. 2054 2054 */ 2055 static int vdCopyHelper(PVDISK pDiskFrom, PVDIMAGE pImageFrom, PVDISK pDiskTo, 2055 static int vdCopyHelper(PVDISK pDiskFrom, PVDIMAGE pImageFrom, PVDISK pDiskTo, PVDIMAGE pImageTo, 2056 2056 uint64_t cbSize, unsigned cImagesFromRead, unsigned cImagesToRead, 2057 2057 bool fSuppressRedundantIo, PVDINTERFACEPROGRESS pIfProgress, … … 2068 2068 unsigned uProgressOld = 0; 2069 2069 2070 LogFlowFunc(("pDiskFrom=%#p pImageFrom=%#p pDiskTo=%#p cbSize=%llu cImagesFromRead=%u cImagesToRead=%u fSuppressRedundantIo=%RTbool pIfProgress=%#p pDstIfProgress=%#p\n",2071 pDiskFrom, pImageFrom, pDiskTo, cbSize, cImagesFromRead, cImagesToRead, fSuppressRedundantIo, pDstIfProgress, pDstIfProgress));2070 LogFlowFunc(("pDiskFrom=%#p pImageFrom=%#p pDiskTo=%#p pImageTo=%#p cbSize=%llu cImagesFromRead=%u cImagesToRead=%u fSuppressRedundantIo=%RTbool pIfProgress=%#p pDstIfProgress=%#p\n", 2071 pDiskFrom, pImageFrom, pDiskTo, pImageTo, cbSize, cImagesFromRead, cImagesToRead, fSuppressRedundantIo, pDstIfProgress, pDstIfProgress)); 2072 2072 2073 2073 if ( (fSuppressRedundantIo || (cImagesFromRead > 0)) … … 2147 2147 2148 2148 /* Only do collapsed I/O if we are copying the data blockwise. */ 2149 rc = vdWriteHelperEx(pDiskTo, p DiskTo->pLast, NULL, uOffset, pvBuf,2149 rc = vdWriteHelperEx(pDiskTo, pImageTo, NULL, uOffset, pvBuf, 2150 2150 cbThisRead, VDIOCTX_FLAGS_DONT_SET_MODIFIED_FLAG /* fFlags */, 2151 2151 fBlockwiseCopy ? cImagesToRead : 0); … … 7183 7183 7184 7184 7185 VBOXDDU_DECL(int) VDCopyEx(PVDISK pDiskFrom, unsigned nImage , PVDISK pDiskTo,7185 VBOXDDU_DECL(int) VDCopyEx(PVDISK pDiskFrom, unsigned nImageFrom, PVDISK pDiskTo, unsigned nImageTo, 7186 7186 const char *pszBackend, const char *pszFilename, 7187 7187 bool fMoveByRename, uint64_t cbSize, … … 7197 7197 PVDIMAGE pImageTo = NULL; 7198 7198 7199 LogFlowFunc(("pDiskFrom=%#p nImage =%u pDiskTo=%#ppszBackend=\"%s\" pszFilename=\"%s\" fMoveByRename=%d cbSize=%llu nImageFromSame=%u nImageToSame=%u uImageFlags=%#x pDstUuid=%#p uOpenFlags=%#x pVDIfsOperation=%#p pDstVDIfsImage=%#p pDstVDIfsOperation=%#p\n",7200 pDiskFrom, nImage , pDiskTo, pszBackend, pszFilename, fMoveByRename, cbSize, nImageFromSame, nImageToSame, uImageFlags, pDstUuid, uOpenFlags, pVDIfsOperation, pDstVDIfsImage, pDstVDIfsOperation));7199 LogFlowFunc(("pDiskFrom=%#p nImageFrom=%u pDiskTo=%#p nImageTo=%u pszBackend=\"%s\" pszFilename=\"%s\" fMoveByRename=%d cbSize=%llu nImageFromSame=%u nImageToSame=%u uImageFlags=%#x pDstUuid=%#p uOpenFlags=%#x pVDIfsOperation=%#p pDstVDIfsImage=%#p pDstVDIfsOperation=%#p\n", 7200 pDiskFrom, nImageFrom, nImageTo, pDiskTo, pszBackend, pszFilename, fMoveByRename, cbSize, nImageFromSame, nImageToSame, uImageFlags, pDstUuid, uOpenFlags, pVDIfsOperation, pDstVDIfsImage, pDstVDIfsOperation)); 7201 7201 7202 7202 /* Check arguments. */ … … 7212 7212 AssertRC(rc2); 7213 7213 fLockReadFrom = true; 7214 PVDIMAGE pImageFrom = vdGetImageByNumber(pDiskFrom, nImage );7214 PVDIMAGE pImageFrom = vdGetImageByNumber(pDiskFrom, nImageFrom); 7215 7215 AssertPtrBreakStmt(pImageFrom, rc = VERR_VD_IMAGE_NOT_FOUND); 7216 7216 AssertPtrBreakStmt(pDiskTo, rc = VERR_INVALID_POINTER); 7217 7217 AssertMsg(pDiskTo->u32Signature == VDISK_SIGNATURE, 7218 7218 ("u32Signature=%08x\n", pDiskTo->u32Signature)); 7219 AssertMsgBreakStmt( (nImageFromSame < nImage || nImageFromSame == VD_IMAGE_CONTENT_UNKNOWN)7219 AssertMsgBreakStmt( (nImageFromSame < nImageFrom || nImageFromSame == VD_IMAGE_CONTENT_UNKNOWN) 7220 7220 && (nImageToSame < pDiskTo->cImages || nImageToSame == VD_IMAGE_CONTENT_UNKNOWN) 7221 7221 && ( (nImageFromSame == VD_IMAGE_CONTENT_UNKNOWN && nImageToSame == VD_IMAGE_CONTENT_UNKNOWN) … … 7225 7225 7226 7226 /* Move the image. */ 7227 if ( pDiskFrom == pDiskTo)7227 if (fMoveByRename) 7228 7228 { 7229 7229 /* Rename only works when backends are the same, are file based … … 7345 7345 fLockWriteTo = true; 7346 7346 7347 pImageTo = vdGetImageByNumber(pDiskTo, nImageTo); 7348 AssertPtrBreakStmt(pImageTo, rc = VERR_VD_IMAGE_NOT_FOUND); 7347 7349 if (RT_SUCCESS(rc) && !RTUuidIsNull(&ImageUuid)) 7348 p DiskTo->pLast->Backend->pfnSetUuid(pDiskTo->pLast->pBackendData, &ImageUuid);7350 pImageTo->Backend->pfnSetUuid(pImageTo->pBackendData, &ImageUuid); 7349 7351 } 7350 7352 if (RT_FAILURE(rc)) 7351 7353 break; 7352 7354 7353 pImageTo = pDiskTo->pLast;7355 pImageTo = vdGetImageByNumber(pDiskTo, nImageTo); 7354 7356 AssertPtrBreakStmt(pImageTo, rc = VERR_VD_IMAGE_NOT_FOUND); 7355 7357 … … 7358 7360 else 7359 7361 { 7360 pImageTo = pDiskTo->pLast;7362 pImageTo = vdGetImageByNumber(pDiskTo, nImageTo); 7361 7363 AssertPtrBreakStmt(pImageTo, rc = VERR_VD_IMAGE_NOT_FOUND); 7362 7364 … … 7387 7389 * Don't optimize if the image existed or if it is a child image. */ 7388 7390 bool fSuppressRedundantIo = ( !(pszFilename == NULL || cImagesTo > 0) 7389 || (nImageToSame != VD_IMAGE_CONTENT_UNKNOWN)); 7391 || (nImageToSame != VD_IMAGE_CONTENT_UNKNOWN) 7392 || (pDiskTo == pDiskFrom)); 7390 7393 unsigned cImagesFromReadBack, cImagesToReadBack; 7391 7394 … … 7394 7397 else 7395 7398 { 7396 if (nImage == VD_LAST_IMAGE)7399 if (nImageFrom == VD_LAST_IMAGE) 7397 7400 cImagesFromReadBack = pDiskFrom->cImages - nImageFromSame - 1; 7398 7401 else 7399 cImagesFromReadBack = nImage - nImageFromSame;7402 cImagesFromReadBack = nImageFrom - nImageFromSame; 7400 7403 } 7401 7404 … … 7406 7409 7407 7410 /* Copy the data. */ 7408 rc = vdCopyHelper(pDiskFrom, pImageFrom, pDiskTo, cbSize,7411 rc = vdCopyHelper(pDiskFrom, pImageFrom, pDiskTo, pImageTo, cbSize, 7409 7412 cImagesFromReadBack, cImagesToReadBack, 7410 7413 fSuppressRedundantIo, pIfProgress, pDstIfProgress); … … 7492 7495 PVDINTERFACE pDstVDIfsOperation) 7493 7496 { 7494 return VDCopyEx(pDiskFrom, nImage, pDiskTo, pszBackend, pszFilename, fMoveByRename,7497 return VDCopyEx(pDiskFrom, nImage, pDiskTo, VD_IMAGE_CONTENT_UNKNOWN, pszBackend, pszFilename, fMoveByRename, 7495 7498 cbSize, VD_IMAGE_CONTENT_UNKNOWN, VD_IMAGE_CONTENT_UNKNOWN, 7496 7499 uImageFlags, pDstUuid, uOpenFlags, pVDIfsOperation, … … 9674 9677 return VINF_SUCCESS; 9675 9678 } 9676
Note:
See TracChangeset
for help on using the changeset viewer.