VirtualBox

Changeset 6472 in vbox


Ignore:
Timestamp:
Jan 24, 2008 8:47:39 AM (17 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
27468
Message:

vdi: fill fixed-size images with zeros during creation

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/Storage/VDICore.cpp

    r6363 r6472  
    473473            goto l_create_failed;
    474474
    475         if (    (enmType == VDI_IMAGE_TYPE_FIXED)
    476             &&  (fFlags & VDI_IMAGE_FLAGS_ZERO_EXPAND))
    477         {
    478             /* Fill image with zeroes. */
     475        if (enmType == VDI_IMAGE_TYPE_FIXED)
     476        {
     477            /* Fill image with zeroes. We do this for every fixed-size image since on some systems
     478             * (for example Windows Vista), it takes ages to write a block near the end of a sparse
     479             * file and the guest could complain about an ATA timeout. */
    479480
    480481            /** @todo Starting with Linux 2.6.23, there is an fallocate() system call.
     
    485486                goto l_create_failed;
    486487
    487             /* alloc tmp zero-filled buffer */
    488             void *pvBuf = RTMemTmpAllocZ(VDIDISK_DEFAULT_BUFFER_SIZE);
     488            /* Allocate a temporary zero-filled buffer. Use a bigger block size to optimize writing */
     489            const size_t cbBuf = 128 * _1K;
     490            void *pvBuf = RTMemTmpAllocZ(cbBuf);
    489491            if (pvBuf)
    490492            {
     
    495497                while (cbFill > 0)
    496498                {
    497                     unsigned to_fill = (unsigned)RT_MIN(cbFill, VDIDISK_DEFAULT_BUFFER_SIZE);
     499                    unsigned to_fill = (unsigned)RT_MIN(cbFill, cbBuf);
    498500
    499501                    rc = RTFileWrite(pImage->File, pvBuf, to_fill, NULL);
Note: See TracChangeset for help on using the changeset viewer.

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