Commit Graph

6 Commits

Author SHA1 Message Date
Kovid Goyal
90223b5d14 Fix compilation against musl
As usual in C stdlib world. Ill thought out break the world changes.
Sigh. musl no longer defines off64_t.

Fixes #6441
2023-07-11 09:22:40 +05:30
Luflosi
4c78a50dcf 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.
2022-01-27 00:45:30 +01:00
Luflosi
9d87b08c52 Fix logic error in file copy helper functions
If `errno` is `EAGAIN`, the second if statement is never true and if `errno` is not `EAGAIN`, the function returns immediately, not checking the second if statement.
This commit fixes this.
A logically equivalent change would have been to simply swap the two if statements but I find this version to be more readable.
2022-01-26 23:35:54 +01:00
Kovid Goyal
617316e8d9 Linux: Use copy_file_range for defrag of the disk cache which should give even better performance on filesystems that support it 2021-11-24 19:42:00 +05:30
Kovid Goyal
bd21b79959 Only malloc the buffer for fast file copy when needed 2021-11-24 18:20:37 +05:30
Kovid Goyal
732ff7ee58 Move copy between files into its own module 2021-11-24 16:42:52 +05:30