mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-11-10 13:58:24 +01:00
mount: report data sizes to df with -df.logical (#10459)
df on a mount shows the space the cluster gives up to the data: every replica of a regular volume, every shard of an ec one. That is the honest answer for capacity planning, but it is not the question a user asks when they want to know how much of their data is stored. Add -df.logical. The master reports the logical sizes alongside the raw ones: one replica per regular volume, the data shards of each ec volume counted once. Free space is divided by the copies the requested replication makes, so used plus available stays the amount of data the mount can still write, and it comes off the cluster-wide usage rather than one collection's, since capacity is cluster-wide too. Statistics through a filer resolves an unset replication to the filer's default rather than the master's, matching where the writes it is sizing for actually land. The flag governs the quota check too, so a mount has one notion of how much it is using. A filer that predates the new fields sends zeros, and the mount keeps reporting the raw sizes.
This commit is contained in:
1 parent
152f1a2096
commit
fee3fcb55a
21 files changed
+429
-43
No files matched your search
@@ -205,19 +205,49 @@ func (ms *MasterServer) Statistics(ctx context.Context, req *master_pb.Statistic
|
||||
}
|
||||
|
||||
// an empty collection means all collections, and a named collection covers
|
||||
// all its layouts and EC volumes, so used size matches the topology-wide
|
||||
// total size below
|
||||
// all its layouts and EC volumes
|
||||
stats := ms.Topo.CollectionVolumeStats(req.Collection)
|
||||
totalSize := ms.Topo.GetDiskUsages().GetMaxVolumeCount() * int64(ms.option.VolumeSizeLimitMB) * 1024 * 1024
|
||||
totalSize := uint64(ms.Topo.GetDiskUsages().GetMaxVolumeCount() * int64(ms.option.VolumeSizeLimitMB) * 1024 * 1024)
|
||||
// capacity is cluster-wide, so what is left over is what every collection
|
||||
// has not taken, not just the one asked about
|
||||
clusterUsedSize := stats.UsedSize
|
||||
if req.Collection != "" {
|
||||
clusterUsedSize = ms.Topo.CollectionVolumeStats("").UsedSize
|
||||
}
|
||||
// and the free space holds that many copies fewer of whatever the caller writes
|
||||
var freeSize uint64
|
||||
if totalSize > clusterUsedSize {
|
||||
freeSize = (totalSize - clusterUsedSize) / uint64(ms.replicaCopyCount(req.Replication))
|
||||
}
|
||||
resp := &master_pb.StatisticsResponse{
|
||||
TotalSize: uint64(totalSize),
|
||||
UsedSize: stats.UsedSize,
|
||||
FileCount: stats.FileCount,
|
||||
TotalSize: totalSize,
|
||||
UsedSize: stats.UsedSize,
|
||||
FileCount: stats.FileCount,
|
||||
LogicalTotalSize: stats.LogicalUsedSize + freeSize,
|
||||
LogicalUsedSize: stats.LogicalUsedSize,
|
||||
}
|
||||
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
// replicaCopyCount returns how many copies the given replication makes, falling
|
||||
// back to the master default and then to a single copy. Unparsable input is
|
||||
// reported rather than failing the call: statistics are informational.
|
||||
func (ms *MasterServer) replicaCopyCount(replication string) int {
|
||||
for _, s := range []string{replication, ms.option.DefaultReplicaPlacement} {
|
||||
if s == "" {
|
||||
continue
|
||||
}
|
||||
rp, err := super_block.NewReplicaPlacementFromString(s)
|
||||
if err != nil {
|
||||
glog.V(1).Infof("statistics replication %q: %v", s, err)
|
||||
continue
|
||||
}
|
||||
return rp.GetCopyCount()
|
||||
}
|
||||
return 1
|
||||
}
|
||||
|
||||
func (ms *MasterServer) VolumeList(ctx context.Context, req *master_pb.VolumeListRequest) (*master_pb.VolumeListResponse, error) {
|
||||
|
||||
if !ms.Topo.IsLeader() {
|
||||
|
||||
Reference in new issue
Block a user