mirror of
https://github.com/libvirt/libvirt.git
synced 2025-02-25 18:55:26 -06:00
storage: Don't try sparse detection if writing to block device.
We don't gain any space savings, so skip the detection to speed up the cloning operation.
This commit is contained in:
parent
7471357081
commit
f23814e0cd
@ -108,7 +108,8 @@ virStorageBackendCopyToFD(virConnectPtr conn,
|
|||||||
virStorageVolDefPtr vol,
|
virStorageVolDefPtr vol,
|
||||||
virStorageVolDefPtr inputvol,
|
virStorageVolDefPtr inputvol,
|
||||||
int fd,
|
int fd,
|
||||||
unsigned long long *total)
|
unsigned long long *total,
|
||||||
|
int is_dest_file)
|
||||||
{
|
{
|
||||||
int inputfd = -1;
|
int inputfd = -1;
|
||||||
int amtread = -1;
|
int amtread = -1;
|
||||||
@ -157,7 +158,7 @@ virStorageBackendCopyToFD(virConnectPtr conn,
|
|||||||
int interval = ((512 > amtleft) ? amtleft : 512);
|
int interval = ((512 > amtleft) ? amtleft : 512);
|
||||||
int offset = amtread - amtleft;
|
int offset = amtread - amtleft;
|
||||||
|
|
||||||
if (memcmp(buf+offset, zerobuf, interval) == 0) {
|
if (is_dest_file && memcmp(buf+offset, zerobuf, interval) == 0) {
|
||||||
if (lseek(fd, interval, SEEK_CUR) < 0) {
|
if (lseek(fd, interval, SEEK_CUR) < 0) {
|
||||||
virReportSystemError(conn, errno,
|
virReportSystemError(conn, errno,
|
||||||
_("cannot extend file '%s'"),
|
_("cannot extend file '%s'"),
|
||||||
@ -212,7 +213,8 @@ virStorageBackendCreateBlockFrom(virConnectPtr conn,
|
|||||||
remain = vol->allocation;
|
remain = vol->allocation;
|
||||||
|
|
||||||
if (inputvol) {
|
if (inputvol) {
|
||||||
int res = virStorageBackendCopyToFD(conn, vol, inputvol, fd, &remain);
|
int res = virStorageBackendCopyToFD(conn, vol, inputvol,
|
||||||
|
fd, &remain, 0);
|
||||||
if (res < 0)
|
if (res < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
@ -264,7 +266,8 @@ virStorageBackendCreateRaw(virConnectPtr conn,
|
|||||||
remain = vol->allocation;
|
remain = vol->allocation;
|
||||||
|
|
||||||
if (inputvol) {
|
if (inputvol) {
|
||||||
int res = virStorageBackendCopyToFD(conn, vol, inputvol, fd, &remain);
|
int res = virStorageBackendCopyToFD(conn, vol, inputvol,
|
||||||
|
fd, &remain, 1);
|
||||||
if (res < 0)
|
if (res < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user