Files
seaweedfs/weed/storage/erasure_coding/ec_volume_info.go
T
Chris LuandGitHub fee3fcb55a 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.
2026-07-27 14:28:29 -07:00

58 lines
2.0 KiB
Go

package erasure_coding
import (
"github.com/seaweedfs/seaweedfs/weed/pb/master_pb"
"github.com/seaweedfs/seaweedfs/weed/storage/needle"
)
// data structure used in master
type EcVolumeInfo struct {
VolumeId needle.VolumeId
Collection string
DiskType string
DiskId uint32 // ID of the disk this EC volume is on
ExpireAtSec uint64 // ec volume destroy time, calculated from the ec volume was created
ShardsInfo *ShardsInfo
FileCount uint64 // live needle count for this EC volume (same on every node holding shards)
DeleteCount uint64 // tombstoned needle count for this EC volume
EncodeTsNs int64 // encode-run identity (unix nanos); one value per (volume, disk)
}
// DataShardsOrDefault returns how many of this volume's shards hold data; shard
// ids below it are data, the rest are parity. Open-source SeaweedFS always uses
// the fixed 10+4 layout, so this returns DataShardsCount. It is a per-volume
// accessor, like EcShardsVolumeDataShards, so callers stay correct on builds
// that derive the ratio per volume.
func (ecInfo *EcVolumeInfo) DataShardsOrDefault() int {
return DataShardsCount
}
func (ecInfo *EcVolumeInfo) Minus(other *EcVolumeInfo) *EcVolumeInfo {
return &EcVolumeInfo{
VolumeId: ecInfo.VolumeId,
Collection: ecInfo.Collection,
ShardsInfo: ecInfo.ShardsInfo.Minus(other.ShardsInfo),
DiskType: ecInfo.DiskType,
DiskId: ecInfo.DiskId,
ExpireAtSec: ecInfo.ExpireAtSec,
FileCount: ecInfo.FileCount,
DeleteCount: ecInfo.DeleteCount,
EncodeTsNs: ecInfo.EncodeTsNs,
}
}
func (evi *EcVolumeInfo) ToVolumeEcShardInformationMessage() (ret *master_pb.VolumeEcShardInformationMessage) {
return &master_pb.VolumeEcShardInformationMessage{
Id: uint32(evi.VolumeId),
EcIndexBits: evi.ShardsInfo.Bitmap(),
ShardSizes: evi.ShardsInfo.SizesInt64(),
Collection: evi.Collection,
DiskType: evi.DiskType,
ExpireAtSec: evi.ExpireAtSec,
DiskId: evi.DiskId,
FileCount: evi.FileCount,
DeleteCount: evi.DeleteCount,
EncodeTsNs: evi.EncodeTsNs,
}
}