util: do not use mount-utils.IsLikelyNotMountPoint anymore

`IsLikelyNotMountPoint()` is an optimized version for `IsMountPoint()`
which can not detect all type of mounts (anymore). The slower
`IsMountPoint()` is more safe to use. This can cause a slight
performance regression in the case there are many mountpoints on the
system, but correctness is more important than speed while mounting.

Fixes: #4633
Signed-off-by: Niels de Vos <ndevos@ibm.com>
This commit is contained in:
Niels de Vos
2025-03-07 17:09:40 +01:00
committed by mergify[bot]
parent 76b4f53897
commit 79cf0321dd
23 changed files with 599 additions and 112 deletions

View File

@ -880,9 +880,9 @@ func (ns *NodeServer) mountVolume(ctx context.Context, stagingPath string, req *
func (ns *NodeServer) createTargetMountPath(ctx context.Context, mountPath string, isBlock bool) (bool, error) {
// Check if that mount path exists properly
notMnt, err := ns.Mounter.IsLikelyNotMountPoint(mountPath)
isMnt, err := ns.Mounter.IsMountPoint(mountPath)
if err == nil {
return notMnt, nil
return !isMnt, nil
}
if !os.IsNotExist(err) {
return false, status.Error(codes.Internal, err.Error())
@ -893,22 +893,22 @@ func (ns *NodeServer) createTargetMountPath(ctx context.Context, mountPath strin
if e != nil {
log.DebugLog(ctx, "Failed to create mountPath:%s with error: %v", mountPath, err)
return notMnt, status.Error(codes.Internal, e.Error())
return !isMnt, status.Error(codes.Internal, e.Error())
}
if err = pathFile.Close(); err != nil {
log.DebugLog(ctx, "Failed to close mountPath:%s with error: %v", mountPath, err)
return notMnt, status.Error(codes.Internal, err.Error())
return !isMnt, status.Error(codes.Internal, err.Error())
}
} else {
// Create a mountpath directory
if err = util.CreateMountPoint(mountPath); err != nil {
return notMnt, status.Error(codes.Internal, err.Error())
return !isMnt, status.Error(codes.Internal, err.Error())
}
}
notMnt = true
isMnt = false
return notMnt, err
return !isMnt, err
}
// NodeUnpublishVolume unmounts the volume from the target path.