Set volumes ReadOnly if low free disk space

This commit is contained in:
Evgenii Kozlov
2020-06-05 18:18:15 +03:00
parent 393ab07c7c
commit 0e0db70f55
8 changed files with 73 additions and 21 deletions

View File

@@ -27,6 +27,7 @@ type Volume struct {
needleMapKind NeedleMapType
noWriteOrDelete bool // if readonly, either noWriteOrDelete or noWriteCanDelete
noWriteCanDelete bool // if readonly, either noWriteOrDelete or noWriteCanDelete
lowDiskSpace bool
hasRemoteFile bool // if the volume has a remote file
MemoryMapMaxSizeMb uint32
@@ -45,6 +46,11 @@ type Volume struct {
volumeInfo *volume_server_pb.VolumeInfo
}
func (v *Volume) SetLowDiskSpace(lowDiskSpace bool) {
glog.V(0).Infof("SetLowDiskSpace id %d value %t", v.Id, lowDiskSpace)
v.lowDiskSpace = lowDiskSpace
}
func NewVolume(dirname string, collection string, id needle.VolumeId, needleMapKind NeedleMapType, replicaPlacement *super_block.ReplicaPlacement, ttl *needle.TTL, preallocate int64, memoryMapMaxSizeMb uint32) (v *Volume, e error) {
// if replicaPlacement is nil, the superblock will be loaded from disk
v = &Volume{dir: dirname, Collection: collection, Id: id, MemoryMapMaxSizeMb: memoryMapMaxSizeMb,
@@ -244,5 +250,5 @@ func (v *Volume) RemoteStorageNameKey() (storageName, storageKey string) {
}
func (v *Volume) IsReadOnly() bool {
return v.noWriteOrDelete || v.noWriteCanDelete
return v.noWriteOrDelete || v.noWriteCanDelete || v.lowDiskSpace
}