Skip to content

Commit f8dbc31

Browse files
committed
pkg/system.EnsureRemoveAll: don't call Mounted
1. Call to mount.Mounted() is very expensive and it's redundant to call it before Unmount(). 2. Calling mount.Mounted() after an error from Unmount() is questionable -- if umount failed, the mount is probably still there anyway, it doesn't make sense to check it. This should result in faster code with no change in functionality. Signed-off-by: Kir Kolyshkin <[email protected]>
1 parent e67f42e commit f8dbc31

1 file changed

Lines changed: 2 additions & 6 deletions

File tree

pkg/system/rm.go

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -63,12 +63,8 @@ func EnsureRemoveAll(dir string) error {
6363
return err
6464
}
6565

66-
if mounted, _ := mount.Mounted(pe.Path); mounted {
67-
if e := mount.Unmount(pe.Path); e != nil {
68-
if mounted, _ := mount.Mounted(pe.Path); mounted {
69-
return errors.Wrapf(e, "error while removing %s", dir)
70-
}
71-
}
66+
if e := mount.Unmount(pe.Path); e != nil {
67+
return errors.Wrapf(e, "error while removing %s", dir)
7268
}
7369

7470
if exitOnErr[pe.Path] == maxRetry {

0 commit comments

Comments
 (0)