Adding fallback when O_DIRECT is not supported
This commit is contained in:
parent
ceccfb9ee6
commit
d2acc3a8a8
|
|
@ -165,6 +165,10 @@ struct llama_file::impl {
|
||||||
impl(const char * fname, const char * mode, bool uncached_read) {
|
impl(const char * fname, const char * mode, bool uncached_read) {
|
||||||
if (uncached_read) {
|
if (uncached_read) {
|
||||||
fd = open(fname, O_RDONLY | O_DIRECT);
|
fd = open(fname, O_RDONLY | O_DIRECT);
|
||||||
|
if (fd == -1 && (errno == EINVAL || errno == EOPNOTSUPP)) {
|
||||||
|
fd = open(fname, O_RDONLY); // retry without O_DIRECT
|
||||||
|
}
|
||||||
|
|
||||||
if (fd == -1) {
|
if (fd == -1) {
|
||||||
throw std::runtime_error(format("failed to open %s: %s", fname, strerror(errno)));
|
throw std::runtime_error(format("failed to open %s: %s", fname, strerror(errno)));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue