From: Roman Bogorodskiy Date: Mon, 20 Apr 2026 18:06:58 +0000 (+0200) Subject: virfile: safezero: handle posix_fallocate()'s EOPNOTSUPP X-Git-Url: http://git.ipfire.org/index.cgi?a=commitdiff_plain;ds=inline;p=thirdparty%2Flibvirt.git virfile: safezero: handle posix_fallocate()'s EOPNOTSUPP FreeBSD 15.x updated posix_fallocate() to return EOPNOTSUPP instead of EINVAL when the operation is not supported. Quoting posix_fallocate(2): Previous versions of posix_fallocate used EINVAL to indicate that the operation is not supported by the file system, as specified in IEEE Std 1003.1 (“POSIX.1”) Base Specifications, Issue 7. IEEE Std 1003.1 (“POSIX.1”) Base Specifications, Issue 8 switched to requiring EOPNOTSUPP for this error case. ZFS adopted the latter convention in FreeBSD 15.0, and the remaining filesystems in base adopted it in FreeBSD 15.1. Update safezero_posix_fallocate() to handle this return value along with EINVAL to fix the waterfall down to safezero_slow() for filesystems that do not support that. Signed-off-by: Roman Bogorodskiy Reviewed-by: Daniel P. Berrangé --- diff --git a/src/util/virfile.c b/src/util/virfile.c index e3c0026841..a0c6cb8048 100644 --- a/src/util/virfile.c +++ b/src/util/virfile.c @@ -1301,13 +1301,16 @@ safezero_posix_fallocate(int fd, off_t offset, off_t len) int ret = posix_fallocate(fd, offset, len); if (ret == 0) { return 0; - } else if (ret == EINVAL) { + } else if (ret == EINVAL || ret == EOPNOTSUPP) { /* EINVAL is returned when either: - Operation is not supported by the underlying filesystem, - offset or len argument values are invalid. Assuming that offset and len are valid, this error means the operation is not supported, and we need to fall back to other methods. + + Newer versions of FreeBSD return EOPNOTSUPP when the + operation is not supported. */ return -2; }