Although we are flushing cache after some critical writes (e.g.
volume creation), after some others we do not (e.g. volume cloning).
This patch fix this issue. That is for volume cloning, writing
header of logical volume, and storage wipe.
} while ((amtleft -= interval) > 0);
}
+ if (fdatasync(fd) < 0) {
+ ret = -errno;
+ virReportSystemError(errno, _("cannot sync data to file '%s'"),
+ vol->target.path);
+ goto cleanup;
+ }
+
+
if (VIR_CLOSE(inputfd) < 0) {
ret = -errno;
virReportSystemError(errno,
VIR_FORCE_CLOSE(fd);
goto cleanup;
}
+ if (fsync(fd) < 0) {
+ virReportSystemError(errno,
+ _("cannot flush header of device'%s'"),
+ pool->def->source.devices[i].path);
+ VIR_FORCE_CLOSE(fd);
+ goto cleanup;
+ }
if (VIR_CLOSE(fd) < 0) {
virReportSystemError(errno,
_("cannot close device '%s'"),
remaining -= written;
}
+ if (fdatasync(fd) < 0) {
+ ret = -errno;
+ virReportSystemError(errno,
+ _("cannot sync data to volume with path '%s'"),
+ vol->target.path);
+ goto out;
+ }
+
VIR_DEBUG("Wrote %zu bytes to volume with path '%s'",
*bytes_wiped, vol->target.path);