mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-09 06:25:19 +00:00
createRawFile: remove unused return variable
The caller doesn't care about errno really. The errno will be reported by virReportSystemError(). Signed-off-by: Yi Li <yili@winhong.com> Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
parent
24ddf9d0fb
commit
dbc643d598
@ -315,7 +315,6 @@ createRawFile(int fd, virStorageVolDefPtr vol,
|
|||||||
bool reflink_copy)
|
bool reflink_copy)
|
||||||
{
|
{
|
||||||
bool need_alloc = true;
|
bool need_alloc = true;
|
||||||
int ret = 0;
|
|
||||||
unsigned long long pos = 0;
|
unsigned long long pos = 0;
|
||||||
|
|
||||||
/* If the new allocation is lower than the capacity of the original file,
|
/* If the new allocation is lower than the capacity of the original file,
|
||||||
@ -327,11 +326,10 @@ createRawFile(int fd, virStorageVolDefPtr vol,
|
|||||||
/* Seek to the final size, so the capacity is available upfront
|
/* Seek to the final size, so the capacity is available upfront
|
||||||
* for progress reporting */
|
* for progress reporting */
|
||||||
if (ftruncate(fd, vol->target.capacity) < 0) {
|
if (ftruncate(fd, vol->target.capacity) < 0) {
|
||||||
ret = -errno;
|
|
||||||
virReportSystemError(errno,
|
virReportSystemError(errno,
|
||||||
_("cannot extend file '%s'"),
|
_("cannot extend file '%s'"),
|
||||||
vol->target.path);
|
vol->target.path);
|
||||||
return ret;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Avoid issues with older kernel's <linux/fs.h> namespace pollution. */
|
/* Avoid issues with older kernel's <linux/fs.h> namespace pollution. */
|
||||||
@ -347,11 +345,10 @@ createRawFile(int fd, virStorageVolDefPtr vol,
|
|||||||
if (fallocate(fd, 0, 0, vol->target.allocation) == 0) {
|
if (fallocate(fd, 0, 0, vol->target.allocation) == 0) {
|
||||||
need_alloc = false;
|
need_alloc = false;
|
||||||
} else if (errno != ENOSYS && errno != EOPNOTSUPP) {
|
} else if (errno != ENOSYS && errno != EOPNOTSUPP) {
|
||||||
ret = -errno;
|
|
||||||
virReportSystemError(errno,
|
virReportSystemError(errno,
|
||||||
_("cannot allocate %llu bytes in file '%s'"),
|
_("cannot allocate %llu bytes in file '%s'"),
|
||||||
vol->target.allocation, vol->target.path);
|
vol->target.allocation, vol->target.path);
|
||||||
return ret;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -361,9 +358,9 @@ createRawFile(int fd, virStorageVolDefPtr vol,
|
|||||||
/* allow zero blocks to be skipped if we've requested sparse
|
/* allow zero blocks to be skipped if we've requested sparse
|
||||||
* allocation (allocation < capacity) or we have already
|
* allocation (allocation < capacity) or we have already
|
||||||
* been able to allocate the required space. */
|
* been able to allocate the required space. */
|
||||||
if ((ret = virStorageBackendCopyToFD(vol, inputvol, fd, &remain,
|
if (virStorageBackendCopyToFD(vol, inputvol, fd, &remain,
|
||||||
!need_alloc, reflink_copy)) < 0)
|
!need_alloc, reflink_copy) < 0)
|
||||||
return ret;
|
return -1;
|
||||||
|
|
||||||
/* If the new allocation is greater than the original capacity,
|
/* If the new allocation is greater than the original capacity,
|
||||||
* but fallocate failed, fill the rest with zeroes.
|
* but fallocate failed, fill the rest with zeroes.
|
||||||
@ -373,21 +370,19 @@ createRawFile(int fd, virStorageVolDefPtr vol,
|
|||||||
|
|
||||||
if (need_alloc && (vol->target.allocation - pos > 0)) {
|
if (need_alloc && (vol->target.allocation - pos > 0)) {
|
||||||
if (safezero(fd, pos, vol->target.allocation - pos) < 0) {
|
if (safezero(fd, pos, vol->target.allocation - pos) < 0) {
|
||||||
ret = -errno;
|
|
||||||
virReportSystemError(errno, _("cannot fill file '%s'"),
|
virReportSystemError(errno, _("cannot fill file '%s'"),
|
||||||
vol->target.path);
|
vol->target.path);
|
||||||
return ret;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (g_fsync(fd) < 0) {
|
if (g_fsync(fd) < 0) {
|
||||||
ret = -errno;
|
|
||||||
virReportSystemError(errno, _("cannot sync data to file '%s'"),
|
virReportSystemError(errno, _("cannot sync data to file '%s'"),
|
||||||
vol->target.path);
|
vol->target.path);
|
||||||
return ret;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
|
Loading…
Reference in New Issue
Block a user