VirtualBox

Changeset 43861 in vbox


Ignore:
Timestamp:
Nov 13, 2012 10:35:55 AM (12 years ago)
Author:
vboxsync
Message:

Storage: Introduce new flag to skip unnecessary consistency checks in the VMDK backend while opening an image in readonly mode to speed up opening snapshots

Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/VBox/vd.h

    r42859 r43861  
    152152
    153153/**
    154  * Auxiliary data structure for difference between GPT and MBR 
    155  * disks. 
    156  */
    157 enum PARTITIONING_TYPE 
     154 * Auxiliary data structure for difference between GPT and MBR
     155 * disks.
     156 */
     157enum PARTITIONING_TYPE
    158158{
    159159    MBR,
     
    179179    /** Pointer to the partition descriptor array. */
    180180    PVBOXHDDRAWPARTDESC pPartDescs;
    181     /**partitioning type of the disk */ 
     181    /**partitioning type of the disk */
    182182    PARTITIONING_TYPE uPartitioningType;
    183183
     
    231231 */
    232232#define VD_OPEN_FLAGS_INFORM_ABOUT_ZERO_BLOCKS RT_BIT(9)
     233/**
     234 * Don't do unnecessary consistency checks when opening the image.
     235 * Only valid when the image is opened in readonly because inconsistencies
     236 * can lead to corrupted images in read-write mode.
     237 */
     238#define VD_OPEN_FLAGS_SKIP_CONSISTENCY_CHECKS  RT_BIT(10)
    233239/** Mask of valid flags. */
    234 #define VD_OPEN_FLAGS_MASK          (VD_OPEN_FLAGS_NORMAL | VD_OPEN_FLAGS_READONLY | VD_OPEN_FLAGS_HONOR_ZEROES | VD_OPEN_FLAGS_HONOR_SAME | VD_OPEN_FLAGS_INFO | VD_OPEN_FLAGS_ASYNC_IO | VD_OPEN_FLAGS_SHAREABLE | VD_OPEN_FLAGS_SEQUENTIAL | VD_OPEN_FLAGS_DISCARD | VD_OPEN_FLAGS_IGNORE_FLUSH | VD_OPEN_FLAGS_INFORM_ABOUT_ZERO_BLOCKS)
     240#define VD_OPEN_FLAGS_MASK          (VD_OPEN_FLAGS_NORMAL | VD_OPEN_FLAGS_READONLY | VD_OPEN_FLAGS_HONOR_ZEROES | VD_OPEN_FLAGS_HONOR_SAME | VD_OPEN_FLAGS_INFO | VD_OPEN_FLAGS_ASYNC_IO | VD_OPEN_FLAGS_SHAREABLE | VD_OPEN_FLAGS_SEQUENTIAL | VD_OPEN_FLAGS_DISCARD | VD_OPEN_FLAGS_IGNORE_FLUSH | VD_OPEN_FLAGS_INFORM_ABOUT_ZERO_BLOCKS | VD_OPEN_FLAGS_SKIP_CONSISTENCY_CHECKS)
    235241/** @}*/
    236242
  • trunk/src/VBox/Devices/Storage/DrvVD.cpp

    r42073 r43861  
    21422142    bool        fDiscard = false;
    21432143    bool        fInformAboutZeroBlocks = false;
     2144    bool        fSkipConsistencyChecks = false;
    21442145    unsigned    iLevel = 0;
    21452146    PCFGMNODE   pCurNode = pCfg;
     
    21592160                                          "HostIPStack\0UseNewIo\0BootAcceleration\0BootAccelerationBuffer\0"
    21602161                                          "SetupMerge\0MergeSource\0MergeTarget\0BwGroup\0Type\0BlockCache\0"
    2161                                           "CachePath\0CacheFormat\0Discard\0InformAboutZeroBlocks\0");
     2162                                          "CachePath\0CacheFormat\0Discard\0InformAboutZeroBlocks\0"
     2163                                          "SkipConsistencyChecks\0");
    21622164        }
    21632165        else
     
    22992301                rc = PDMDRV_SET_ERROR(pDrvIns, rc,
    23002302                                      N_("DrvVD: Configuration error: Querying \"InformAboutZeroBlocks\" as boolean failed"));
     2303                break;
     2304            }
     2305            rc = CFGMR3QueryBoolDef(pCurNode, "SkipConsistencyChecks", &fSkipConsistencyChecks, true);
     2306            if (RT_FAILURE(rc))
     2307            {
     2308                rc = PDMDRV_SET_ERROR(pDrvIns, rc,
     2309                                      N_("DrvVD: Configuration error: Querying \"SKipConsistencyChecks\" as boolean failed"));
    23012310                break;
    23022311            }
     
    24052414    if (pThis->pDrvMediaAsyncPort && fUseNewIo)
    24062415        pThis->fAsyncIOSupported = true;
     2416
     2417    uint64_t tsStart = RTTimeNanoTS();
    24072418
    24082419    unsigned iImageIdx = 0;
     
    26032614        if (fInformAboutZeroBlocks)
    26042615            uOpenFlags |= VD_OPEN_FLAGS_INFORM_ABOUT_ZERO_BLOCKS;
     2616        if (   (uOpenFlags & VD_OPEN_FLAGS_READONLY)
     2617            && fSkipConsistencyChecks)
     2618            uOpenFlags |= VD_OPEN_FLAGS_SKIP_CONSISTENCY_CHECKS;
    26052619
    26062620        /* Try to open backend in async I/O mode first. */
     
    26622676        pCurNode = CFGMR3GetParent(pCurNode);
    26632677    }
     2678
     2679    LogRel(("VD: Opening the disk took %lld ns\n", RTTimeNanoTS() - tsStart));
    26642680
    26652681    /* Open the cache image if set. */
  • trunk/src/VBox/Storage/VD.cpp

    r43787 r43861  
    53575357                           rc = VERR_INVALID_PARAMETER);
    53585358        AssertMsgBreakStmt((uOpenFlags & ~VD_OPEN_FLAGS_MASK) == 0,
     5359                           ("uOpenFlags=%#x\n", uOpenFlags),
     5360                           rc = VERR_INVALID_PARAMETER);
     5361        AssertMsgBreakStmt(   !(uOpenFlags & VD_OPEN_FLAGS_SKIP_CONSISTENCY_CHECKS)
     5362                           ||  (uOpenFlags & VD_OPEN_FLAGS_READONLY),
    53595363                           ("uOpenFlags=%#x\n", uOpenFlags),
    53605364                           rc = VERR_INVALID_PARAMETER);
  • trunk/src/VBox/Storage/VMDK.cpp

    r43818 r43861  
    10861086        *pGDTmp = RT_LE2H_U32(*pGDTmp);
    10871087
    1088     if (pExtent->uSectorRGD)
     1088    if (   pExtent->uSectorRGD
     1089        && !(pImage->uOpenFlags & VD_OPEN_FLAGS_SKIP_CONSISTENCY_CHECKS))
    10891090    {
    10901091        /* The VMDK 1.1 spec seems to talk about compressed grain directories,
     
    65486549        else
    65496550            rc = VERR_INVALID_PARAMETER;
    6550         goto out;
    6551     }
    6552 
    6553     /* Implement this operation via reopening the image. */
    6554     vmdkFreeImage(pImage, false);
    6555     rc = vmdkOpenImage(pImage, uOpenFlags);
     6551    }
     6552    else
     6553    {
     6554        /* Implement this operation via reopening the image. */
     6555        vmdkFreeImage(pImage, false);
     6556        rc = vmdkOpenImage(pImage, uOpenFlags);
     6557    }
    65566558
    65576559out:
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