aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--weed/topology/topology.go2
-rw-r--r--weed/topology/volume_layout.go7
-rw-r--r--weed/topology/volume_location_list.go3
3 files changed, 11 insertions, 1 deletions
diff --git a/weed/topology/topology.go b/weed/topology/topology.go
index a11a1bac6..e217617e9 100644
--- a/weed/topology/topology.go
+++ b/weed/topology/topology.go
@@ -221,7 +221,7 @@ func (t *Topology) SyncDataNodeRegistration(volumes []*master_pb.VolumeInformati
}
for _, v := range changedVolumes {
vl := t.GetVolumeLayout(v.Collection, v.ReplicaPlacement, v.Ttl)
- vl.ensureCorrectWritables(&v)
+ vl.EnsureCorrectWritables(&v)
}
return
}
diff --git a/weed/topology/volume_layout.go b/weed/topology/volume_layout.go
index e7659e0eb..dddcfc9c9 100644
--- a/weed/topology/volume_layout.go
+++ b/weed/topology/volume_layout.go
@@ -198,6 +198,13 @@ func (vl *VolumeLayout) UnRegisterVolume(v *storage.VolumeInfo, dn *DataNode) {
}
}
+func (vl *VolumeLayout) EnsureCorrectWritables(v *storage.VolumeInfo) {
+ vl.accessLock.Lock()
+ defer vl.accessLock.Unlock()
+
+ vl.ensureCorrectWritables(v)
+}
+
func (vl *VolumeLayout) ensureCorrectWritables(v *storage.VolumeInfo) {
if vl.enoughCopies(v.Id) && vl.isWritable(v) {
if !vl.oversizedVolumes.IsTrue(v.Id) {
diff --git a/weed/topology/volume_location_list.go b/weed/topology/volume_location_list.go
index 6acd70f2f..64c13ca52 100644
--- a/weed/topology/volume_location_list.go
+++ b/weed/topology/volume_location_list.go
@@ -32,6 +32,9 @@ func (dnll *VolumeLocationList) Head() *DataNode {
}
func (dnll *VolumeLocationList) Length() int {
+ if dnll == nil {
+ return 0
+ }
return len(dnll.list)
}