mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2025-08-24 10:33:06 +08:00
ensure unwritable volumes are not in writables list
This commit is contained in:
parent
82f6a6838f
commit
a74978baeb
@ -1,9 +1,9 @@
|
|||||||
package topology
|
package topology
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"code.google.com/p/weed-fs/go/glog"
|
||||||
"code.google.com/p/weed-fs/go/storage"
|
"code.google.com/p/weed-fs/go/storage"
|
||||||
"errors"
|
"errors"
|
||||||
"code.google.com/p/weed-fs/go/glog"
|
|
||||||
"math/rand"
|
"math/rand"
|
||||||
"sync"
|
"sync"
|
||||||
)
|
)
|
||||||
@ -38,6 +38,8 @@ func (vl *VolumeLayout) RegisterVolume(v *storage.VolumeInfo, dn *DataNode) {
|
|||||||
if len(vl.vid2location[v.Id].list) == v.RepType.GetCopyCount() {
|
if len(vl.vid2location[v.Id].list) == v.RepType.GetCopyCount() {
|
||||||
if vl.isWritable(v) {
|
if vl.isWritable(v) {
|
||||||
vl.writables = append(vl.writables, v.Id)
|
vl.writables = append(vl.writables, v.Id)
|
||||||
|
} else {
|
||||||
|
vl.removeFromWritable(v.Id)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -105,13 +107,18 @@ func (vl *VolumeLayout) GetActiveVolumeCount(dataCenter string) int {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (vl *VolumeLayout) removeFromWritable(vid storage.VolumeId) bool {
|
func (vl *VolumeLayout) removeFromWritable(vid storage.VolumeId) bool {
|
||||||
for i, v := range vl.writables {
|
toDeleteIndex := -1
|
||||||
if v == vid {
|
for k, id := range vl.writables {
|
||||||
glog.V(0).Infoln("Volume", vid, "becomes unwritable")
|
if id == vid {
|
||||||
vl.writables = append(vl.writables[:i], vl.writables[i+1:]...)
|
toDeleteIndex = k
|
||||||
return true
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if toDeleteIndex >= 0 {
|
||||||
|
glog.V(0).Infoln("Volume", vid, "becomes unwritable")
|
||||||
|
vl.writables = append(vl.writables[0:toDeleteIndex], vl.writables[toDeleteIndex+1:]...)
|
||||||
|
return true
|
||||||
|
}
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
func (vl *VolumeLayout) setVolumeWritable(vid storage.VolumeId) bool {
|
func (vl *VolumeLayout) setVolumeWritable(vid storage.VolumeId) bool {
|
||||||
|
Loading…
Reference in New Issue
Block a user