mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-10-23 06:20:48 +02:00
The max volume count subtracted each volume's remaining room from the free disk space, except when the master had preallocation turned on, in which case it subtracted nothing. That is wrong for a disk that mixes preallocated and plain volumes, and on platforms where preallocation is not supported. Use the larger of the .dat file's size and its allocated blocks, in the Go and the Rust volume server, so a preallocated volume counts as full and a plain one keeps its remaining room reserved. Fixes #5778 Co-authored-by: Dan Foster <4570306+danfoster@users.noreply.github.com>
19 lines
358 B
Go
19 lines
358 B
Go
//go:build !windows
|
|
|
|
package storage
|
|
|
|
import (
|
|
"os"
|
|
"syscall"
|
|
)
|
|
|
|
// allocatedSize reports the bytes the filesystem holds for a file, which
|
|
// exceeds its size when the file was preallocated with FALLOC_FL_KEEP_SIZE.
|
|
func allocatedSize(fi os.FileInfo) uint64 {
|
|
st, ok := fi.Sys().(*syscall.Stat_t)
|
|
if !ok {
|
|
return 0
|
|
}
|
|
return uint64(st.Blocks) * 512
|
|
}
|