Skip to content

SeaweedFS is a distributed storage system for object storage (S3), file systems, Iceberg table buckets, and Lance vector buckets, designed to handle billions of files with O(1) disk access and effortless horizontal scaling.

if replicated volume has one copy in readonly mode at one node,it should be removed from writable list

霍晓栋f04d8fcbcc7b
diff --git a/weed/topology/data_node.go b/weed/topology/data_node.go
index 1404d4aa89..da6ed2895e 100644
--- a/weed/topology/data_node.go
+++ b/weed/topology/data_node.go
@@ -79,6 +79,17 @@ func (dn *DataNode) GetVolumes() (ret []storage.VolumeInfo) {
return ret
}
+func (dn *DataNode) GetVolumesById(id storage.VolumeId) (storage.VolumeInfo, error) {
+ dn.RLock()
+ defer dn.RUnlock()
+ v_info, ok := dn.volumes[id]
+ if ok {
+ return v_info, nil
+ } else {
+ return storage.VolumeInfo{}, fmt.Errorf("volumeInfo not found")
+ }
+}
+
func (dn *DataNode) GetDataCenter() *DataCenter {
return dn.Parent().Parent().(*NodeImpl).value.(*DataCenter)
}
diff --git a/weed/topology/volume_layout.go b/weed/topology/volume_layout.go
index 066f5f69ac..af8503b294 100644
--- a/weed/topology/volume_layout.go
+++ b/weed/topology/volume_layout.go
@@ -45,6 +45,19 @@ func (vl *VolumeLayout) RegisterVolume(v *storage.VolumeInfo, dn *DataNode) {
}
vl.vid2location[v.Id].Set(dn)
glog.V(4).Infoln("volume", v.Id, "added to dn", dn.Id(), "len", vl.vid2location[v.Id].Length(), "copy", v.ReplicaPlacement.GetCopyCount())
+ for _, dn := range vl.vid2location[v.Id].list {
+ if v_info, err := dn.GetVolumesById(v.Id); err == nil {
+ if v_info.ReadOnly {
+ glog.V(3).Infof("vid %d removed from writable", v.Id)
+ vl.removeFromWritable(v.Id)
+ return
+ }
+ } else {
+ glog.V(3).Infof("vid %d removed from writable", v.Id)
+ vl.removeFromWritable(v.Id)
+ return
+ }
+ }
if vl.vid2location[v.Id].Length() == vl.rp.GetCopyCount() && vl.isWritable(v) {
if _, ok := vl.oversizedVolumes[v.Id]; !ok {
vl.addToWritable(v.Id)