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 <bogorodskiy@gmail.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
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;
}