VirtualBox

Changeset 49944 in vbox for trunk/src


Ignore:
Timestamp:
Dec 16, 2013 11:50:41 PM (11 years ago)
Author:
vboxsync
Message:

Storage,VHD: Fix I/O if VD_OPEN_FLAGS_HONOR_SAME is used

Location:
trunk/src/VBox/Storage
Files:
2 edited

Legend:

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

    r49880 r49944  
    24912491}
    24922492
     2493static int vdWriteHelperStandardReadImageAsync(PVDIOCTX pIoCtx)
     2494{
     2495    int rc = VINF_SUCCESS;
     2496
     2497    LogFlowFunc(("pIoCtx=%#p\n", pIoCtx));
     2498
     2499    pIoCtx->fFlags |= VDIOCTX_FLAGS_ZERO_FREE_BLOCKS;
     2500
     2501    if (   pIoCtx->Req.Io.cbTransferLeft
     2502        && !pIoCtx->cDataTransfersPending)
     2503        rc = vdReadHelperAsync(pIoCtx);
     2504
     2505    if (   RT_SUCCESS(rc)
     2506        && (   pIoCtx->Req.Io.cbTransferLeft
     2507            || pIoCtx->cMetaTransfersPending))
     2508        rc = VERR_VD_ASYNC_IO_IN_PROGRESS;
     2509    else
     2510    {
     2511        size_t cbFill = pIoCtx->Type.Child.Write.Optimized.cbFill;
     2512
     2513        /* Zero out the remainder of this block. Will never be visible, as this
     2514         * is beyond the limit of the image. */
     2515        if (cbFill)
     2516            vdIoCtxSet(pIoCtx, '\0', cbFill);
     2517
     2518        /* Write the full block to the virtual disk. */
     2519        RTSgBufReset(&pIoCtx->Req.Io.SgBuf);
     2520
     2521        vdIoCtxChildReset(pIoCtx);
     2522        pIoCtx->pfnIoCtxTransferNext = vdWriteHelperCommitAsync;
     2523    }
     2524
     2525    return rc;
     2526}
     2527
    24932528static int vdWriteHelperStandardAssemble(PVDIOCTX pIoCtx)
    24942529{
     
    25202555        }
    25212556
    2522         /* Zero out the remainder of this block. Will never be visible, as this
    2523          * is beyond the limit of the image. */
    2524         if (cbFill)
    2525         {
    2526             RTSgBufAdvance(&pIoCtx->Req.Io.SgBuf, cbReadImage);
    2527             vdIoCtxSet(pIoCtx, '\0', cbFill);
    2528         }
    2529 
    25302557        if (cbReadImage)
    25312558        {
    25322559            /* Read remaining data. */
     2560            pIoCtx->pfnIoCtxTransferNext = vdWriteHelperStandardReadImageAsync;
     2561
     2562            /* Read the data that goes before the write to fill the block. */
     2563            pIoCtx->Req.Io.cbTransferLeft = (uint32_t)cbReadImage; Assert(cbReadImage == (uint32_t)cbReadImage);
     2564            pIoCtx->Req.Io.cbTransfer     = pIoCtx->Req.Io.cbTransferLeft;
     2565            pIoCtx->Req.Io.uOffset       += cbWriteCopy;
    25332566        }
    25342567        else
    25352568        {
     2569            /* Zero out the remainder of this block. Will never be visible, as this
     2570             * is beyond the limit of the image. */
     2571            if (cbFill)
     2572                vdIoCtxSet(pIoCtx, '\0', cbFill);
     2573
    25362574            /* Write the full block to the virtual disk. */
    25372575            RTSgBufReset(&pIoCtx->Req.Io.SgBuf);
     2576            vdIoCtxChildReset(pIoCtx);
    25382577            pIoCtx->pfnIoCtxTransferNext = vdWriteHelperCommitAsync;
    25392578        }
     
    25432582        /* Write the full block to the virtual disk. */
    25442583        RTSgBufReset(&pIoCtx->Req.Io.SgBuf);
     2584        vdIoCtxChildReset(pIoCtx);
    25452585        pIoCtx->pfnIoCtxTransferNext = vdWriteHelperCommitAsync;
    25462586    }
     
    25572597    pIoCtx->fFlags |= VDIOCTX_FLAGS_ZERO_FREE_BLOCKS;
    25582598
    2559     if (pIoCtx->Req.Io.cbTransferLeft)
     2599    if (   pIoCtx->Req.Io.cbTransferLeft
     2600        && !pIoCtx->cDataTransfersPending)
    25602601        rc = vdReadHelperAsync(pIoCtx);
    25612602
     
    25922633        /* If we have data to be written, use that instead of reading
    25932634         * data from the image. */
    2594         cbWriteCopy;
    25952635        if (cbWrite > cbThisWrite)
    25962636            cbWriteCopy = RT_MIN(cbWrite - cbThisWrite, cbPostRead);
     2637        else
     2638            cbWriteCopy = 0;
    25972639
    25982640        /* Figure out how much we cannot read from the image, because
  • trunk/src/VBox/Storage/VHD.cpp

    r48851 r49944  
    16361636        {
    16371637            /* Check if the block allocation should be suppressed. */
    1638             if (fWrite & VD_WRITE_NO_ALLOC)
     1638            if (   (fWrite & VD_WRITE_NO_ALLOC)
     1639                || (cbWrite != pImage->cbDataBlock))
    16391640            {
    16401641                *pcbPreRead = cBATEntryIndex * VHD_SECTOR_SIZE;
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