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:
Chris Lu authored and GitHub committed 2026-07-27 14:28:29 -07:00
1 parent 152f1a2096
commit fee3fcb55a
21 files changed
+429 -43

No files matched your search

+17 -4
View File
@@ -23,7 +23,7 @@ func (fs *FilerServer) Statistics(ctx context.Context, req *filer_pb.StatisticsR
err = fs.filer.MasterClient.WithClient(false, func(masterClient master_pb.SeaweedClient) error {
grpcResponse, grpcErr := masterClient.Statistics(context.Background(), &master_pb.StatisticsRequest{
Replication: req.Replication,
Replication: fs.statisticsReplication(req.Replication),
Collection: req.Collection,
Ttl: req.Ttl,
DiskType: req.DiskType,
@@ -41,12 +41,25 @@ func (fs *FilerServer) Statistics(ctx context.Context, req *filer_pb.StatisticsR
}
return &filer_pb.StatisticsResponse{
TotalSize: output.TotalSize,
UsedSize: output.UsedSize,
FileCount: output.FileCount,
TotalSize: output.TotalSize,
UsedSize: output.UsedSize,
FileCount: output.FileCount,
LogicalTotalSize: output.LogicalTotalSize,
LogicalUsedSize: output.LogicalUsedSize,
}, nil
}
// statisticsReplication names the replication the caller's writes will use, so
// the master sizes free space by the right number of copies. Writes through
// this filer follow its default, not the master's, so fill that in when the
// request leaves the choice open.
func (fs *FilerServer) statisticsReplication(requested string) string {
if requested != "" {
return requested
}
return fs.option.DefaultReplication
}
// isKnownPingTarget reports whether target is a peer the filer has learned
// about from its master subscription (other filers, volume servers) or from
// its own master list. Restricting Ping prevents the RPC from being used as