diff --git a/internal/rbd/controllerserver.go b/internal/rbd/controllerserver.go index dd3a442d3..7e41e23ac 100644 --- a/internal/rbd/controllerserver.go +++ b/internal/rbd/controllerserver.go @@ -671,6 +671,13 @@ func (cs *ControllerServer) CreateSnapshot(ctx context.Context, req *csi.CreateS } defer cs.SnapshotLocks.Release(req.GetName()) + // Take lock on parent rbd image + if acquired := cs.VolumeLocks.TryAcquire(rbdSnap.SourceVolumeID); !acquired { + klog.Errorf(util.Log(ctx, util.VolumeOperationAlreadyExistsFmt), rbdSnap.SourceVolumeID) + return nil, status.Errorf(codes.Aborted, util.VolumeOperationAlreadyExistsFmt, rbdSnap.SourceVolumeID) + } + defer cs.VolumeLocks.Release(rbdSnap.SourceVolumeID) + // Need to check for already existing snapshot name, and if found // check for the requested source volume id and already allocated source volume id found, err := checkSnapCloneExists(ctx, rbdVol, rbdSnap, cr)