mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2024-01-19 02:48:24 +00:00
mount: adjust df stats reporting when close to the limit
fix https://github.com/seaweedfs/seaweedfs/issues/3407
This commit is contained in:
parent
4d08393b7c
commit
b278bb24d3
|
@ -10,7 +10,7 @@ import (
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
const blockSize = 512
|
const blockSize = 4096 * 4
|
||||||
|
|
||||||
type statsCache struct {
|
type statsCache struct {
|
||||||
filer_pb.StatisticsResponse
|
filer_pb.StatisticsResponse
|
||||||
|
@ -64,15 +64,43 @@ func (wfs *WFS) StatFs(cancel <-chan struct{}, in *fuse.InHeader, out *fuse.Stat
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// http://man.he.net/man2/statfs
|
||||||
|
/*
|
||||||
|
struct statfs {
|
||||||
|
__fsword_t f_type; // Type of filesystem (see below)
|
||||||
|
__fsword_t f_bsize; // Optimal transfer block size
|
||||||
|
fsblkcnt_t f_blocks; // Total data blocks in filesystem
|
||||||
|
fsblkcnt_t f_bfree; // Free blocks in filesystem
|
||||||
|
fsblkcnt_t f_bavail; // Free blocks available to
|
||||||
|
unprivileged user
|
||||||
|
fsfilcnt_t f_files; // Total file nodes in filesystem
|
||||||
|
fsfilcnt_t f_ffree; // Free file nodes in filesystem
|
||||||
|
fsid_t f_fsid; // Filesystem ID
|
||||||
|
__fsword_t f_namelen; // Maximum length of filenames
|
||||||
|
__fsword_t f_frsize; // Fragment size (since Linux 2.6)
|
||||||
|
__fsword_t f_flags; // Mount flags of filesystem
|
||||||
|
(since Linux 2.6.36)
|
||||||
|
__fsword_t f_spare[xxx];
|
||||||
|
// Padding bytes reserved for future use
|
||||||
|
};
|
||||||
|
*/
|
||||||
|
|
||||||
// Compute the total number of available blocks
|
// Compute the total number of available blocks
|
||||||
out.Blocks = totalDiskSize / blockSize
|
out.Blocks = totalDiskSize / blockSize
|
||||||
|
if out.Blocks <= 0 {
|
||||||
|
out.Blocks = 1
|
||||||
|
}
|
||||||
// Compute the number of used blocks
|
// Compute the number of used blocks
|
||||||
numBlocks := uint64(usedDiskSize / blockSize)
|
numBlocks := usedDiskSize / blockSize
|
||||||
|
|
||||||
|
remainingBlocks := int64(out.Blocks) - int64(numBlocks)
|
||||||
|
if remainingBlocks < 0 {
|
||||||
|
remainingBlocks = 0
|
||||||
|
}
|
||||||
|
|
||||||
// Report the number of free and available blocks for the block size
|
// Report the number of free and available blocks for the block size
|
||||||
out.Bfree = out.Blocks - numBlocks
|
out.Bfree = uint64(remainingBlocks)
|
||||||
out.Bavail = out.Blocks - numBlocks
|
out.Bavail = uint64(remainingBlocks)
|
||||||
out.Bsize = uint32(blockSize)
|
out.Bsize = uint32(blockSize)
|
||||||
|
|
||||||
// Report the total number of possible files in the file system (and those free)
|
// Report the total number of possible files in the file system (and those free)
|
||||||
|
|
Loading…
Reference in a new issue