VirtualBox

Changeset 46712 in vbox


Ignore:
Timestamp:
Jun 20, 2013 3:40:24 PM (11 years ago)
Author:
vboxsync
Message:

Storage: Don't set the modified flag when copying images with VDCopy, fixes non sequential access assertions when exporting to OVA

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Storage/VD.cpp

    r46679 r46712  
    430430
    431431/** Default flags for an I/O context, i.e. unblocked and async. */
    432 #define VDIOCTX_FLAGS_DEFAULT                   (0)
     432#define VDIOCTX_FLAGS_DEFAULT                         (0)
    433433/** Flag whether the context is blocked. */
    434 #define VDIOCTX_FLAGS_BLOCKED          RT_BIT_32(0)
     434#define VDIOCTX_FLAGS_BLOCKED                RT_BIT_32(0)
    435435/** 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)
    437437/** Flag whether the read should update the cache. */
    438 #define VDIOCTX_FLAGS_READ_UDATE_CACHE RT_BIT_32(2)
     438#define VDIOCTX_FLAGS_READ_UPDATE_CACHE      RT_BIT_32(2)
    439439/** Flag whether free blocks should be zeroed.
    440440 * If false and no image has data for sepcified
     
    444444 * of the range.
    445445 */
    446 #define VDIOCTX_FLAGS_ZERO_FREE_BLOCKS RT_BIT_32(3)
     446#define VDIOCTX_FLAGS_ZERO_FREE_BLOCKS       RT_BIT_32(3)
    447447/** Don't free the I/O context when complete because
    448448 * 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)
    450452
    451453/** NIL I/O context pointer value. */
     
    17761778                /* If the read was successful, write the data back into the cache. */
    17771779                if (   RT_SUCCESS(rc)
    1778                     && pIoCtx->fFlags & VDIOCTX_FLAGS_READ_UDATE_CACHE)
     1780                    && pIoCtx->fFlags & VDIOCTX_FLAGS_READ_UPDATE_CACHE)
    17791781                {
    17801782                    rc = vdCacheWriteHelper(pDisk->pCache, uOffset, cbThisRead,
     
    19501952        fFlags |= VDIOCTX_FLAGS_ZERO_FREE_BLOCKS;
    19511953    if (fUpdateCache)
    1952         fFlags |= VDIOCTX_FLAGS_READ_UDATE_CACHE;
     1954        fFlags |= VDIOCTX_FLAGS_READ_UPDATE_CACHE;
    19531955
    19541956    Segment.pvSeg = pvBuf;
     
    20322034                           PVDIMAGE pImageParentOverride, uint64_t uOffset,
    20332035                           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{
    20372038    RTSGSEG Segment;
    20382039    RTSGBUF SgBuf;
    20392040    VDIOCTX IoCtx;
    20402041
    2041     if (fUpdateCache)
    2042         fFlags |= VDIOCTX_FLAGS_READ_UDATE_CACHE;
     2042    fFlags |= VDIOCTX_FLAGS_SYNC | VDIOCTX_FLAGS_DONT_FREE;
    20432043
    20442044    Segment.pvSeg = (void *)pvBuf;
     
    20622062 */
    20632063static 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)
    20652065{
    20662066    return vdWriteHelperEx(pDisk, pImage, NULL, uOffset, pvBuf, cbWrite,
    2067                            fUpdateCache, 0);
     2067                           fFlags, 0);
    20682068}
    20692069
     
    21632163            /* Only do collapsed I/O if we are copying the data blockwise. */
    21642164            rc = vdWriteHelperEx(pDiskTo, pDiskTo->pLast, NULL, uOffset, pvBuf,
    2165                                  cbThisRead, false /* fUpdateCache */,
     2165                                 cbThisRead, VDIOCTX_FLAGS_DONT_SET_MODIFIED_FLAG /* fFlags */,
    21662166                                 fBlockwiseCopy ? cImagesToRead : 0);
    21672167            if (RT_FAILURE(rc))
     
    26182618    size_t cbPreRead, cbPostRead;
    26192619
    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    }
    26232626
    26242627    rc = vdDiscardSetRangeAllocated(pDisk, uOffset, cbWrite);
     
    67866789                        rc = vdWriteHelperEx(pDisk, pImageTo, pImageFrom->pPrev,
    67876790                                             uOffset, pvBuf, cbThisRead,
    6788                                              true /* fUpdateCache */, 0);
     6791                                             VDIOCTX_FLAGS_READ_UPDATE_CACHE, 0);
    67896792                        if (RT_FAILURE(rc))
    67906793                            break;
     
    69106913                        break;
    69116914                    rc = vdWriteHelper(pDisk, pImageTo, uOffset, pvBuf,
    6912                                        cbThisRead, true /* fUpdateCache */);
     6915                                       cbThisRead, VDIOCTX_FLAGS_READ_UPDATE_CACHE);
    69136916                    if (RT_FAILURE(rc))
    69146917                        break;
     
    80428045        vdSetModifiedFlag(pDisk);
    80438046        rc = vdWriteHelper(pDisk, pImage, uOffset, pvBuf, cbWrite,
    8044                            true /* fUpdateCache */);
     8047                           VDIOCTX_FLAGS_READ_UPDATE_CACHE);
    80458048        if (RT_FAILURE(rc))
    80468049            break;
     
    80568059        if (RT_UNLIKELY(pDisk->pImageRelay))
    80578060            rc = vdWriteHelper(pDisk, pDisk->pImageRelay, uOffset,
    8058                                pvBuf, cbWrite, false /* fUpdateCache */);
     8061                               pvBuf, cbWrite, VDIOCTX_FLAGS_DEFAULT);
    80598062    } while (0);
    80608063
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette