mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2025-08-24 06:31:59 +08:00
ensure only compatible volume versions are writable
This commit is contained in:
parent
8af7906b3d
commit
6c8810e4d2
@ -6,6 +6,7 @@ type VolumeInfo struct {
|
|||||||
Id VolumeId
|
Id VolumeId
|
||||||
Size uint64
|
Size uint64
|
||||||
RepType ReplicationType
|
RepType ReplicationType
|
||||||
|
Version Version
|
||||||
FileCount int
|
FileCount int
|
||||||
DeleteCount int
|
DeleteCount int
|
||||||
DeletedByteCount uint64
|
DeletedByteCount uint64
|
||||||
|
@ -59,8 +59,8 @@ func (t *Topology) UnRegisterDataNode(dn *DataNode) {
|
|||||||
}
|
}
|
||||||
func (t *Topology) RegisterRecoveredDataNode(dn *DataNode) {
|
func (t *Topology) RegisterRecoveredDataNode(dn *DataNode) {
|
||||||
for _, v := range dn.volumes {
|
for _, v := range dn.volumes {
|
||||||
if uint64(v.Size) < t.volumeSizeLimit {
|
vl := t.GetVolumeLayout(v.RepType)
|
||||||
vl := t.GetVolumeLayout(v.RepType)
|
if vl.isWritable(&v) {
|
||||||
vl.SetVolumeAvailable(dn, v.Id)
|
vl.SetVolumeAvailable(dn, v.Id)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -31,13 +31,17 @@ func (vl *VolumeLayout) RegisterVolume(v *storage.VolumeInfo, dn *DataNode) {
|
|||||||
}
|
}
|
||||||
if vl.vid2location[v.Id].Add(dn) {
|
if vl.vid2location[v.Id].Add(dn) {
|
||||||
if len(vl.vid2location[v.Id].list) == v.RepType.GetCopyCount() {
|
if len(vl.vid2location[v.Id].list) == v.RepType.GetCopyCount() {
|
||||||
if uint64(v.Size) < vl.volumeSizeLimit {
|
if vl.isWritable(v) {
|
||||||
vl.writables = append(vl.writables, v.Id)
|
vl.writables = append(vl.writables, v.Id)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (vl *VolumeLayout) isWritable(v *storage.VolumeInfo) bool{
|
||||||
|
return uint64(v.Size) < vl.volumeSizeLimit && v.Version == storage.CurrentVersion
|
||||||
|
}
|
||||||
|
|
||||||
func (vl *VolumeLayout) Lookup(vid storage.VolumeId) *[]*DataNode {
|
func (vl *VolumeLayout) Lookup(vid storage.VolumeId) *[]*DataNode {
|
||||||
return &vl.vid2location[vid].list
|
return &vl.vid2location[vid].list
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user