mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2025-09-23 05:45:34 +08:00
fix unclaimed spaces calculation when volumePreallocate is enabled (#6063)
Some checks failed
go: build dev binaries / cleanup (push) Has been cancelled
docker: build dev containers / build-dev-containers (push) Has been cancelled
End to End / FUSE Mount (push) Has been cancelled
go: build binary / Build (push) Has been cancelled
Ceph S3 tests / Ceph S3 tests (push) Has been cancelled
go: build dev binaries / build_dev_linux_windows (amd64, linux) (push) Has been cancelled
go: build dev binaries / build_dev_linux_windows (amd64, windows) (push) Has been cancelled
go: build dev binaries / build_dev_darwin (amd64, darwin) (push) Has been cancelled
go: build dev binaries / build_dev_darwin (arm64, darwin) (push) Has been cancelled
Some checks failed
go: build dev binaries / cleanup (push) Has been cancelled
docker: build dev containers / build-dev-containers (push) Has been cancelled
End to End / FUSE Mount (push) Has been cancelled
go: build binary / Build (push) Has been cancelled
Ceph S3 tests / Ceph S3 tests (push) Has been cancelled
go: build dev binaries / build_dev_linux_windows (amd64, linux) (push) Has been cancelled
go: build dev binaries / build_dev_linux_windows (amd64, windows) (push) Has been cancelled
go: build dev binaries / build_dev_darwin (amd64, darwin) (push) Has been cancelled
go: build dev binaries / build_dev_darwin (arm64, darwin) (push) Has been cancelled
the calculation of `unclaimedSpaces` only needs to subtract `unusedSpace` when `preallocate` is not enabled. Signed-off-by: LHHDZ <shichanglin5@qq.com>
This commit is contained in:
@@ -90,6 +90,7 @@ message HeartbeatResponse {
|
|||||||
uint32 metrics_interval_seconds = 4;
|
uint32 metrics_interval_seconds = 4;
|
||||||
repeated StorageBackend storage_backends = 5;
|
repeated StorageBackend storage_backends = 5;
|
||||||
repeated string duplicated_uuids = 6;
|
repeated string duplicated_uuids = 6;
|
||||||
|
bool preallocate = 7;
|
||||||
}
|
}
|
||||||
|
|
||||||
message VolumeInformationMessage {
|
message VolumeInformationMessage {
|
||||||
|
File diff suppressed because it is too large
Load Diff
@@ -151,6 +151,7 @@ func (ms *MasterServer) SendHeartbeat(stream master_pb.Seaweed_SendHeartbeatServ
|
|||||||
|
|
||||||
if err := stream.Send(&master_pb.HeartbeatResponse{
|
if err := stream.Send(&master_pb.HeartbeatResponse{
|
||||||
VolumeSizeLimit: uint64(ms.option.VolumeSizeLimitMB) * 1024 * 1024,
|
VolumeSizeLimit: uint64(ms.option.VolumeSizeLimitMB) * 1024 * 1024,
|
||||||
|
Preallocate: ms.preallocateSize > 0,
|
||||||
}); err != nil {
|
}); err != nil {
|
||||||
glog.Warningf("SendHeartbeat.Send volume size to %s:%d %v", dn.Ip, dn.Port, err)
|
glog.Warningf("SendHeartbeat.Send volume size to %s:%d %v", dn.Ip, dn.Port, err)
|
||||||
return err
|
return err
|
||||||
|
@@ -130,8 +130,16 @@ func (vs *VolumeServer) doHeartbeat(masterAddress pb.ServerAddress, grpcDialOpti
|
|||||||
glog.Errorf("Shut down Volume Server due to duplicate volume directories: %v", duplicateDir)
|
glog.Errorf("Shut down Volume Server due to duplicate volume directories: %v", duplicateDir)
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
|
volumeOptsChanged := false
|
||||||
|
if vs.store.GetPreallocate() != in.GetPreallocate() {
|
||||||
|
vs.store.SetPreallocate(in.GetPreallocate())
|
||||||
|
volumeOptsChanged = true
|
||||||
|
}
|
||||||
if in.GetVolumeSizeLimit() != 0 && vs.store.GetVolumeSizeLimit() != in.GetVolumeSizeLimit() {
|
if in.GetVolumeSizeLimit() != 0 && vs.store.GetVolumeSizeLimit() != in.GetVolumeSizeLimit() {
|
||||||
vs.store.SetVolumeSizeLimit(in.GetVolumeSizeLimit())
|
vs.store.SetVolumeSizeLimit(in.GetVolumeSizeLimit())
|
||||||
|
volumeOptsChanged = true
|
||||||
|
}
|
||||||
|
if volumeOptsChanged {
|
||||||
if vs.store.MaybeAdjustVolumeMax() {
|
if vs.store.MaybeAdjustVolumeMax() {
|
||||||
if err = stream.Send(vs.store.CollectHeartbeat()); err != nil {
|
if err = stream.Send(vs.store.CollectHeartbeat()); err != nil {
|
||||||
glog.V(0).Infof("Volume Server Failed to talk with master %s: %v", vs.currentMaster, err)
|
glog.V(0).Infof("Volume Server Failed to talk with master %s: %v", vs.currentMaster, err)
|
||||||
|
@@ -57,7 +57,8 @@ type ReadOption struct {
|
|||||||
type Store struct {
|
type Store struct {
|
||||||
MasterAddress pb.ServerAddress
|
MasterAddress pb.ServerAddress
|
||||||
grpcDialOption grpc.DialOption
|
grpcDialOption grpc.DialOption
|
||||||
volumeSizeLimit uint64 // read from the master
|
volumeSizeLimit uint64 // read from the master
|
||||||
|
preallocate atomic.Bool // read from the master
|
||||||
Ip string
|
Ip string
|
||||||
Port int
|
Port int
|
||||||
GrpcPort int
|
GrpcPort int
|
||||||
@@ -609,6 +610,14 @@ func (s *Store) GetVolumeSizeLimit() uint64 {
|
|||||||
return atomic.LoadUint64(&s.volumeSizeLimit)
|
return atomic.LoadUint64(&s.volumeSizeLimit)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s *Store) SetPreallocate(x bool) {
|
||||||
|
s.preallocate.Store(x)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *Store) GetPreallocate() bool {
|
||||||
|
return s.preallocate.Load()
|
||||||
|
}
|
||||||
|
|
||||||
func (s *Store) MaybeAdjustVolumeMax() (hasChanges bool) {
|
func (s *Store) MaybeAdjustVolumeMax() (hasChanges bool) {
|
||||||
volumeSizeLimit := s.GetVolumeSizeLimit()
|
volumeSizeLimit := s.GetVolumeSizeLimit()
|
||||||
if volumeSizeLimit == 0 {
|
if volumeSizeLimit == 0 {
|
||||||
@@ -619,8 +628,12 @@ func (s *Store) MaybeAdjustVolumeMax() (hasChanges bool) {
|
|||||||
if diskLocation.OriginalMaxVolumeCount == 0 {
|
if diskLocation.OriginalMaxVolumeCount == 0 {
|
||||||
currentMaxVolumeCount := atomic.LoadInt32(&diskLocation.MaxVolumeCount)
|
currentMaxVolumeCount := atomic.LoadInt32(&diskLocation.MaxVolumeCount)
|
||||||
diskStatus := stats.NewDiskStatus(diskLocation.Directory)
|
diskStatus := stats.NewDiskStatus(diskLocation.Directory)
|
||||||
unusedSpace := diskLocation.UnUsedSpace(volumeSizeLimit)
|
var unusedSpace uint64 = 0
|
||||||
unclaimedSpaces := int64(diskStatus.Free) - int64(unusedSpace)
|
unclaimedSpaces := int64(diskStatus.Free)
|
||||||
|
if !s.GetPreallocate() {
|
||||||
|
unusedSpace = diskLocation.UnUsedSpace(volumeSizeLimit)
|
||||||
|
unclaimedSpaces -= int64(unusedSpace)
|
||||||
|
}
|
||||||
volCount := diskLocation.VolumesLen()
|
volCount := diskLocation.VolumesLen()
|
||||||
ecShardCount := diskLocation.EcShardCount()
|
ecShardCount := diskLocation.EcShardCount()
|
||||||
maxVolumeCount := int32(volCount) + int32((ecShardCount+erasure_coding.DataShardsCount)/erasure_coding.DataShardsCount)
|
maxVolumeCount := int32(volCount) + int32((ecShardCount+erasure_coding.DataShardsCount)/erasure_coding.DataShardsCount)
|
||||||
|
Reference in New Issue
Block a user