Add more copy_file_range() and sendfile() errno exceptions
On ZFS `copy_file_range()` and `sendfile()` fail for some reason, so add `EINVAL` to the list of error codes for which the code will fall back to a slower implementation. While we are at it, add all the error codes from https://go.dev/src/internal/poll/copy_file_range_linux.go for different filesystems and older kernel versions to the list of error codes from `copy_file_range()`. Without this, the cache defragmentation and the test testing it (`test_disk_cache`) fail with the error message "Failed to copy data to new disk cache file during defrag: Invalid argument" when the cache directory is stored on ZFS. Perhaps this is caused by me running ZFS 2.1.2 on Linux 5.16.0, which is not a supported combination. This ZFS version is only "compatible with 3.10 - 5.15 kernels" according to the release notes. Or maybe it's just not implemented. To reproduce the problem, execute `KITTY_CACHE_DIRECTORY=/path/to/zfs python3 test.py` with `KITTY_CACHE_DIRECTORY` pointing to a directory on ZFS.
This commit is contained in:
parent
9d87b08c52
commit
4c78a50dcf
@ -61,7 +61,10 @@ copy_with_sendfile(int infd, int outfd, off_t in_pos, size_t len, FastFileCopyBu
|
|||||||
ssize_t n = sendfile(outfd, infd, &r, len);
|
ssize_t n = sendfile(outfd, infd, &r, len);
|
||||||
if (n < 0) {
|
if (n < 0) {
|
||||||
if (errno == EAGAIN) continue;
|
if (errno == EAGAIN) continue;
|
||||||
if (errno == ENOSYS || errno == EPERM) return copy_with_buffer(infd, outfd, in_pos, len, fcb);
|
if (errno == ENOSYS || // No kernel support
|
||||||
|
errno == EPERM ||
|
||||||
|
errno == EINVAL) // ZFS for some reason
|
||||||
|
return copy_with_buffer(infd, outfd, in_pos, len, fcb);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (n == 0) {
|
if (n == 0) {
|
||||||
@ -84,7 +87,13 @@ copy_with_file_range(int infd, int outfd, off_t in_pos, size_t len, FastFileCopy
|
|||||||
ssize_t n = copy_file_range(infd, &r, outfd, NULL, len, 0);
|
ssize_t n = copy_file_range(infd, &r, outfd, NULL, len, 0);
|
||||||
if (n < 0) {
|
if (n < 0) {
|
||||||
if (errno == EAGAIN) continue;
|
if (errno == EAGAIN) continue;
|
||||||
if (errno == ENOSYS || errno == EPERM) return copy_with_sendfile(infd, outfd, in_pos, len, fcb);
|
if (errno == ENOSYS || // Linux < 4.5
|
||||||
|
errno == EPERM || // Possibly Docker
|
||||||
|
errno == EINVAL || // ZFS for some reason
|
||||||
|
errno == EIO || // CIFS
|
||||||
|
errno == EOPNOTSUPP || // NFS
|
||||||
|
errno == EXDEV) // Prior to Linux 5.3, it was not possible to copy_file_range across file systems
|
||||||
|
return copy_with_sendfile(infd, outfd, in_pos, len, fcb);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (n == 0) {
|
if (n == 0) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user