mirror of
https://github.com/ceph/ceph-csi.git
synced 2024-11-23 14:50:24 +00:00
cephfs: take lock on targetpath on 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 7cfeae579f
)
This commit is contained in:
parent
2a7f6bbcb9
commit
e6292d8f90
@ -494,6 +494,13 @@ func (ns *NodeServer) NodePublishVolume(
|
|||||||
targetPath := req.GetTargetPath()
|
targetPath := req.GetTargetPath()
|
||||||
volID := fsutil.VolumeID(req.GetVolumeId())
|
volID := fsutil.VolumeID(req.GetVolumeId())
|
||||||
|
|
||||||
|
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)
|
||||||
|
|
||||||
volOptions := &store.VolumeOptions{}
|
volOptions := &store.VolumeOptions{}
|
||||||
defer volOptions.Destroy()
|
defer volOptions.Destroy()
|
||||||
|
|
||||||
@ -506,9 +513,6 @@ func (ns *NodeServer) NodePublishVolume(
|
|||||||
return nil, status.Errorf(codes.Internal, "failed to create mounter for volume %s: %v", volID, err.Error())
|
return nil, status.Errorf(codes.Internal, "failed to create mounter for volume %s: %v", volID, err.Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
// Considering kubelet make sure the stage and publish operations
|
|
||||||
// are serialized, we dont need any extra locking in nodePublish
|
|
||||||
|
|
||||||
if err = util.CreateMountPoint(targetPath); err != nil {
|
if err = util.CreateMountPoint(targetPath); err != nil {
|
||||||
log.ErrorLog(ctx, "failed to create mount point at %s: %v", targetPath, err)
|
log.ErrorLog(ctx, "failed to create mount point at %s: %v", targetPath, err)
|
||||||
|
|
||||||
@ -599,12 +603,17 @@ func (ns *NodeServer) NodeUnpublishVolume(
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// 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.
|
|
||||||
targetPath := req.GetTargetPath()
|
targetPath := req.GetTargetPath()
|
||||||
|
volID := req.GetVolumeId()
|
||||||
|
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)
|
||||||
|
|
||||||
// stop the health-checker that may have been started in NodeGetVolumeStats()
|
// stop the health-checker that may have been started in NodeGetVolumeStats()
|
||||||
ns.healthChecker.StopChecker(req.GetVolumeId(), targetPath)
|
ns.healthChecker.StopChecker(volID, targetPath)
|
||||||
|
|
||||||
isMnt, err := util.IsMountPoint(ns.Mounter, targetPath)
|
isMnt, err := util.IsMountPoint(ns.Mounter, targetPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user