[et-mgmt-tools] [PATCH][virtinst] support for cloning a sparse file

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi, I made a patch that supported for copying a sparse file for reference in an opinion of Dan Berrange and investigating cp.c source in fileutils.
Now, I investigate sparse files copying.

There's no easy way to detect if a file is sparse - particularly in python.
I think the best option is to detect sequences of zeros. eg, if you are
reading the source file 4096  bytes at a time, check to see if that 4096
set of bytes are all zeros. If they are, then seek() forward 4096 bytes
instead of writing the set of zeros.

When copying a sparse file, I change read/write buffer to 4096 because it is 4096 in cp.c. And I add the "--nonsparse" option as virt-install. Default behavior is creating a sparse. Basically when destination file/disk doesn't
exist, create a sparse file and do sparselly copying (means lseek when detecting
4096 sequences of zeros) to that sparse file. When destination file exists, do non-sparselly copying(means no lseek when detecting 4096 sequences of zeros)
to the existing file.

In the above-mentioned, as a result of measuring the performance of copying a sparse, I get the performance equivalent to the command of 'cp --sparse=always'.

A)used source file
# ls -als sparse.img
2788280 -rwxr-xr-x 1 root root 5368709121 2007-05-18 12:48 sparse.img

B)cp
# time -p cp sparse.img sparse_copy.img --sparse=always --verbose
`sparse.img' -> `sparse_copy.img'
real 190.71
user 1.50
sys 10.70
# ls -als sparse*
2788280 -rwxr-xr-x 1 root root 5368709121 2007-05-18 12:48 sparse.img
2612528 -rwxr-xr-x 1 root root 5368709121 2007-05-18 16:25 sparse_copy.img

C)virt-clone (sparse to sparse)
# time -p ./virt-clone -o PV_RH5GA_SPA -n PV_RH5GA_SPA_CLONE
-f /var/tmp/img/sparse_copy.img
Cloning from /var/tmp/sparse.img to /var/tmp/img/sparse_copy.img
Cloning domain...         100% |=========================| 5.0 GB    03:15
real 196.49
user 16.87
sys 13.68
# ls -als sparse*
2788280 -rwxr-xr-x 1 root root 5368709121 2007-05-18 12:48 sparse.img
2612536 -rwxr-xr-x 1 root root 5368709122 2007-05-24 09:31 sparse_copy.img

Signed-off-by: Kazuki Mizushima <mizushima.kazuk@xxxxxxxxxxxxxx>

Thanks,
Kazuki Mizushima

Attachment: CloneManager.py.sparse.patch
Description: Binary data

Attachment: virt-clone.sparse.patch
Description: Binary data


[Index of Archives]     [Fedora Users]     [Fedora Legacy List]     [Fedora Maintainers]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux