Files
VictoriaMetrics/lib/fs/mincore_linux.go
Nikolay 1fc548b63a lib/fs: add fs.disableMincore flag
This flag allows disabling the mincore() syscall introduced in
50fc48ac47. On older ZFS filesystems,
mincore() may trigger a bug related to ZFSÕs own in-memory cache. Mixing
reads from mmap()ed files and direct disk reads can corrupt the ZFS ARC
cache and lead to data read corruption.

Fixes https://github.com/VictoriaMetrics/VictoriaMetrics/issues/10327
2026-01-27 20:29:01 +01:00

25 lines
477 B
Go

//go:build linux
package fs
import (
"unsafe"
"golang.org/x/sys/unix"
"github.com/VictoriaMetrics/VictoriaMetrics/lib/logger"
)
func supportsMincore() bool {
return true
}
func mincore(ptr *byte) bool {
var result [1]byte
_, _, err := unix.Syscall(unix.SYS_MINCORE, uintptr(unsafe.Pointer(ptr)), 1, uintptr(unsafe.Pointer(&result[0])))
if err != 0 {
logger.Panicf("FATAL: cannot call mincore(ptr=%p, 1): %s", ptr, err)
}
ok := (result[0] & 1) == 1
return ok
}