diff --git a/pkg/spdk/replica.go b/pkg/spdk/replica.go index 22bd2ee3..d257c00b 100644 --- a/pkg/spdk/replica.go +++ b/pkg/spdk/replica.go @@ -182,6 +182,12 @@ func NewReplica(ctx context.Context, replicaName, lvsName, lvsUUID string, specS } } +func (r *Replica) IsRebuilding() bool { + r.RLock() + defer r.RUnlock() + return r.State == types.InstanceStateRunning && r.isRebuilding +} + func (r *Replica) replicaLvolFilter(bdev *spdktypes.BdevInfo) bool { if bdev == nil || len(bdev.Aliases) < 1 || bdev.DriverSpecific.Lvol == nil { return false diff --git a/pkg/spdk/server.go b/pkg/spdk/server.go index a8e598df..24222192 100644 --- a/pkg/spdk/server.go +++ b/pkg/spdk/server.go @@ -255,8 +255,11 @@ func (s *Server) verify() (err error) { replicaMapForSync[lvolName] = replicaMap[lvolName] } for replicaName, r := range replicaMap { - // Try the best to avoid eliminating broken replicas without a head lvol + // Try the best to avoid eliminating broken replicas or rebuilding replicas without head lvols if bdevLvolMap[r.Name] == nil { + if r.IsRebuilding() { + continue + } noReplicaLvol := true for lvolName := range bdevLvolMap { if IsReplicaLvol(r.Name, lvolName) {