mirror of
https://github.com/ceph/ceph-csi.git
synced 2024-12-18 02:50:30 +00:00
rbd: take lock on parent image during snapshotcreate
we need to take lock on parent rbd image when we are creating a snapshot from it, if the user tries to delete/resize the rbd image when we are taking snapshots,we may face issues. if the volume lock is present on the rbd image, the user cannot resize the rbd image nor delete the rbd image. Signed-off-by: Madhu Rajanna <madhupr007@gmail.com>
This commit is contained in:
parent
f946efb7b7
commit
032fb228dd
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user