mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-11-21 14:44:00 +00:00
added openbsd implementations (#790)
https://github.com/VictoriaMetrics/VictoriaMetrics/issues/785 removed fadvise for openbsd, added freespace implemenation for openbsd
This commit is contained in:
parent
bc37f1cbec
commit
658a05ef0f
4 changed files with 50 additions and 2 deletions
30
lib/filestream/filestream_openbsd.go
Normal file
30
lib/filestream/filestream_openbsd.go
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
package filestream
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
|
||||||
|
"golang.org/x/sys/unix"
|
||||||
|
)
|
||||||
|
|
||||||
|
func (st *streamTracker) adviseDontNeed(n int, fdatasync bool) error {
|
||||||
|
st.length += uint64(n)
|
||||||
|
if st.fd == 0 {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
if st.length < dontNeedBlockSize {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
blockSize := st.length - (st.length % dontNeedBlockSize)
|
||||||
|
if fdatasync {
|
||||||
|
if err := unix.Fsync(int(st.fd)); err != nil {
|
||||||
|
return fmt.Errorf("unix.Fsync error: %w", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
st.length -= blockSize
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (st *streamTracker) close() error {
|
||||||
|
return nil
|
||||||
|
}
|
|
@ -338,6 +338,6 @@ func mustGetFreeSpace(path string) uint64 {
|
||||||
if err := unix.Fstatfs(int(fd), &stat); err != nil {
|
if err := unix.Fstatfs(int(fd), &stat); err != nil {
|
||||||
logger.Panicf("FATAL: cannot determine free disk space on %q: %s", path, err)
|
logger.Panicf("FATAL: cannot determine free disk space on %q: %s", path, err)
|
||||||
}
|
}
|
||||||
freeSpace := uint64(stat.Bavail) * uint64(stat.Bsize)
|
|
||||||
return freeSpace
|
return freeSpace(stat)
|
||||||
}
|
}
|
||||||
|
|
9
lib/fs/fs_nix.go
Normal file
9
lib/fs/fs_nix.go
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
// +build linux darwin freebsd
|
||||||
|
|
||||||
|
package fs
|
||||||
|
|
||||||
|
import "golang.org/x/sys/unix"
|
||||||
|
|
||||||
|
func freeSpace(stat unix.Statfs_t) uint64 {
|
||||||
|
return uint64(stat.Bavail) * uint64(stat.Bsize)
|
||||||
|
}
|
9
lib/fs/fs_openbsd.go
Normal file
9
lib/fs/fs_openbsd.go
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
package fs
|
||||||
|
|
||||||
|
import (
|
||||||
|
"golang.org/x/sys/unix"
|
||||||
|
)
|
||||||
|
|
||||||
|
func freeSpace(stat unix.Statfs_t) uint64 {
|
||||||
|
return uint64(stat.F_bavail) * uint64(stat.F_bsize)
|
||||||
|
}
|
Loading…
Reference in a new issue