mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-12-01 14:47:38 +00:00
8b7917cd81
See https://tip.golang.org/doc/go1.17#gofmt for more details
23 lines
425 B
Go
23 lines
425 B
Go
//go:build linux || freebsd
|
|
// +build linux freebsd
|
|
|
|
package fs
|
|
|
|
import (
|
|
"fmt"
|
|
"os"
|
|
|
|
"golang.org/x/sys/unix"
|
|
)
|
|
|
|
func fadviseSequentialRead(f *os.File, prefetch bool) error {
|
|
fd := int(f.Fd())
|
|
mode := unix.FADV_SEQUENTIAL
|
|
if prefetch {
|
|
mode |= unix.FADV_WILLNEED
|
|
}
|
|
if err := unix.Fadvise(int(fd), 0, 0, mode); err != nil {
|
|
return fmt.Errorf("error returned from unix.Fadvise(%d): %w", mode, err)
|
|
}
|
|
return nil
|
|
}
|