os.Unmount: do not consult mountinfo, drop flags
1. Currently, Unmount() call takes a burden to parse the whole nine yards of /proc/self/mountinfo to figure out whether the given mount point is mounted or not (and returns an error in case parsing fails somehow). Instead, let's just call umount() and ignore EINVAL, which results in the same behavior, but much better performance. This also introduces a slight change: in case target does not exist, the appropriate error (ENOENT) is returned -- document that. 2. As Unmount() is always used with MNT_DETACH flag, let's drop the flags argument. This way, the only reason of EINVAL returned from umount(2) can only be "target is not mounted". 3. While at it, remove the 'containerdmount' alias from the package. Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
This commit is contained in:
@@ -494,16 +494,14 @@ func parseDNSOptions(servers, searches, options []string) (string, error) {
|
||||
}
|
||||
|
||||
// unmountSandboxFiles unmount some sandbox files, we rely on the removal of sandbox root directory to
|
||||
// remove these files. Unmount should *NOT* return error when:
|
||||
// 1) The mount point is already unmounted.
|
||||
// 2) The mount point doesn't exist.
|
||||
// remove these files. Unmount should *NOT* return error if the mount point is already unmounted.
|
||||
func (c *criService) unmountSandboxFiles(id string, config *runtime.PodSandboxConfig) error {
|
||||
if config.GetLinux().GetSecurityContext().GetNamespaceOptions().GetIpc() != runtime.NamespaceMode_NODE {
|
||||
path, err := c.os.FollowSymlinkInScope(c.getSandboxDevShm(id), "/")
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "failed to follow symlink")
|
||||
}
|
||||
if err := c.os.Unmount(path, unix.MNT_DETACH); err != nil && !os.IsNotExist(err) {
|
||||
if err := c.os.Unmount(path); err != nil && !os.IsNotExist(err) {
|
||||
return errors.Wrapf(err, "failed to unmount %q", path)
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user