- Timestamp:
- Feb 5, 2007 4:57:01 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Storage/VBoxHDD.cpp
r294 r643 1719 1719 1720 1720 /* loop through blocks */ 1721 int rc ;1721 int rc = VINF_SUCCESS; 1722 1722 for (;;) 1723 1723 { … … 1727 1727 else 1728 1728 to_write = cbBlock - offWrite; 1729 1730 /* All callers write less than a VDI block right now (assuming 1731 * default VDI block size). So not worth optimizing for the case 1732 * where a full block is overwritten (no copying required). 1733 * Checking whether a block is all zeroes after the write is too 1734 * expensive (would require reading the rest of the block). */ 1729 1735 1730 1736 if (pDisk->cImages > 1) … … 1754 1760 } 1755 1761 1762 /* If the destination block is unallocated at this point, it's either 1763 * a zero block or a block which hasn't been used so far (which also 1764 * means that it's a zero block. Don't need to write anything to this 1765 * block if the data consists of just zeroes. */ 1766 bool fBlockZeroed = false; /* assume data, for blocks already with data */ 1767 if (!IS_VDI_IMAGE_BLOCK_ALLOCATED(pImage->paBlocks[uBlock])) 1768 { 1769 /* Check block for data. */ 1770 fBlockZeroed = true; /* Block is zeroed flag. */ 1771 for (unsigned i = 0; i < (to_write >> 2); i++) 1772 if (((uint32_t *)pvBuf)[i] != 0) 1773 { 1774 /* Block is not zeroed! */ 1775 fBlockZeroed = false; 1776 break; 1777 } 1778 } 1779 1756 1780 /* Actually write the data into block. */ 1757 rc = vdiWriteInBlock(pDisk, pImage, uBlock, offWrite, to_write, pvBuf); 1781 if (!fBlockZeroed) 1782 rc = vdiWriteInBlock(pDisk, pImage, uBlock, offWrite, to_write, pvBuf); 1758 1783 1759 1784 cbToWrite -= to_write; … … 2483 2508 * @param pfnProgress Progress callback. Optional. 2484 2509 * @param pvUser User argument for the progress callback. 2485 * @remark Only used by vditool2486 2510 */ 2487 2511 IDER3DECL(int) VDIShrinkImage(const char *pszFilename, PFNVMPROGRESS pfnProgress, void *pvUser) … … 2604 2628 2605 2629 /* Check block for data. */ 2606 bool f lBlockZeroed = true; /* Block is zeroed flag. */2630 bool fBlockZeroed = true; /* Block is zeroed flag. */ 2607 2631 for (unsigned i = 0; i < (cbBlock >> 2); i++) 2608 2632 if (((uint32_t *)pvBuf)[i] != 0) 2609 2633 { 2610 2634 /* Block is not zeroed! */ 2611 f lBlockZeroed = false;2635 fBlockZeroed = false; 2612 2636 break; 2613 2637 } 2614 2638 2615 if (!f lBlockZeroed)2639 if (!fBlockZeroed) 2616 2640 { 2617 2641 /* Block has a data, may be it must be moved. */ … … 4101 4125 /** 4102 4126 * internal: debug image dump. 4103 * 4127 * 4104 4128 * @remark Only used by tstVDI. 4105 4129 */
Note:
See TracChangeset
for help on using the changeset viewer.