1
0
mirror of https://gitlab.com/libvirt/libvirt.git synced 2025-02-04 21:47:16 +03:00

Shrink volume even with ALLOCATE flag

Calling fallocate on the new (smaller) capacity ensures
that the whole file is allocated, but it does not reduce
the file size.

Also call ftruncate after fallocate.

https://bugzilla.redhat.com/show_bug.cgi?id=1366446
This commit is contained in:
Ján Tomko 2016-08-16 12:29:05 +02:00
parent 3f702f5ab1
commit 959fe7de1f

View File

@ -1338,12 +1338,12 @@ virStorageFileResize(const char *path,
}
goto cleanup;
}
} else {
if (ftruncate(fd, capacity) < 0) {
virReportSystemError(errno,
_("Failed to truncate file '%s'"), path);
goto cleanup;
}
}
if (ftruncate(fd, capacity) < 0) {
virReportSystemError(errno,
_("Failed to truncate file '%s'"), path);
goto cleanup;
}
if (VIR_CLOSE(fd) < 0) {