skip only readonly volumes

fix https://github.com/chrislusf/seaweedfs/issues/405
This commit is contained in:
Chris Lu
2017-05-22 17:05:27 -07:00
parent 4ce6586710
commit b3513d3167
2 changed files with 13 additions and 5 deletions

View File

@@ -86,14 +86,16 @@ func (t *Topology) Vacuum(garbageThreshold string) int {
for _, vl := range c.storageType2VolumeLayout.Items() {
if vl != nil {
volumeLayout := vl.(*VolumeLayout)
writableSet := make(map[storage.VolumeId]bool)
for _, id := range volumeLayout.writables {
writableSet[id] = true
}
for vid, locationlist := range volumeLayout.vid2location {
if _, isWritable := writableSet[vid]; !isWritable {
vl.accessLock.RLock()
isReadOnly, hasValue := volumeLayout.readonlyVolumes[vid]
vl.accessLock.RUnlock()
if hasValue && isReadOnly {
continue
}
glog.V(0).Infof("check vacuum on collection:%s volume:%d", c.Name, vid)
if batchVacuumVolumeCheck(volumeLayout, vid, locationlist, garbageThreshold) {
if batchVacuumVolumeCompact(volumeLayout, vid, locationlist) {