mirror of
https://github.com/ceph/ceph-csi.git
synced 2025-06-14 18:53:35 +00:00
rbd: take lock on targetpath during node operation
We should not be dependent on the CO to ensure
that it will serialize the request instead of
that we need to have own internal locks to ensure
that we dont do concurrent operations for same
request.
Signed-off-by: Madhu Rajanna <madhupr007@gmail.com>
(cherry picked from commit 38c0e64307
)
This commit is contained in:
@ -709,8 +709,12 @@ func (ns *NodeServer) NodePublishVolume(
|
||||
volID := req.GetVolumeId()
|
||||
stagingPath += "/" + volID
|
||||
|
||||
// Considering kubelet make sure the stage and publish operations
|
||||
// are serialized, we dont need any extra locking in nodePublish
|
||||
if acquired := ns.VolumeLocks.TryAcquire(targetPath); !acquired {
|
||||
log.ErrorLog(ctx, util.TargetPathOperationAlreadyExistsFmt, targetPath)
|
||||
|
||||
return nil, status.Errorf(codes.Aborted, util.TargetPathOperationAlreadyExistsFmt, targetPath)
|
||||
}
|
||||
defer ns.VolumeLocks.Release(targetPath)
|
||||
|
||||
// Check if that target path exists properly
|
||||
notMnt, err := ns.createTargetMountPath(ctx, targetPath, isBlock)
|
||||
@ -913,8 +917,14 @@ func (ns *NodeServer) NodeUnpublishVolume(
|
||||
}
|
||||
|
||||
targetPath := req.GetTargetPath()
|
||||
// considering kubelet make sure node operations like unpublish/unstage...etc can not be called
|
||||
// at same time, an explicit locking at time of nodeunpublish is not required.
|
||||
|
||||
if acquired := ns.VolumeLocks.TryAcquire(targetPath); !acquired {
|
||||
log.ErrorLog(ctx, util.TargetPathOperationAlreadyExistsFmt, targetPath)
|
||||
|
||||
return nil, status.Errorf(codes.Aborted, util.TargetPathOperationAlreadyExistsFmt, targetPath)
|
||||
}
|
||||
defer ns.VolumeLocks.Release(targetPath)
|
||||
|
||||
isMnt, err := ns.Mounter.IsMountPoint(targetPath)
|
||||
if err != nil {
|
||||
if os.IsNotExist(err) {
|
||||
|
Reference in New Issue
Block a user