@@ -20,13 +20,8 @@ limitations under the License.
2020package smb
2121
2222import (
23- "fmt"
2423 "os"
25- "os/exec"
26- "strings"
27- "time"
2824
29- "k8s.io/klog/v2"
3025 mount "k8s.io/mount-utils"
3126)
3227
@@ -39,21 +34,7 @@ func CleanupSMBMountPoint(m *mount.SafeFormatAndMount, target string, extensiveM
3934}
4035
4136func CleanupMountPoint (m * mount.SafeFormatAndMount , target string , extensiveMountCheck bool ) error {
42- var err error
43- extensiveMountPointCheck := true
44- forceUnmounter , ok := m .Interface .(mount.MounterForceUnmounter )
45- if ok {
46- klog .V (2 ).Infof ("force unmount on %s" , target )
47- err = mount .CleanupMountWithForce (target , forceUnmounter , extensiveMountPointCheck , 30 * time .Second )
48- } else {
49- err = mount .CleanupMountPoint (target , m .Interface , extensiveMountPointCheck )
50- }
51-
52- if err != nil && strings .Contains (err .Error (), "target is busy" ) {
53- klog .Warningf ("unmount on %s failed with %v, try lazy unmount" , target , err )
54- err = forceUmount (target )
55- }
56- return err
37+ return mount .CleanupMountPoint (target , m , extensiveMountCheck )
5738}
5839
5940func preparePublishPath (path string , m * mount.SafeFormatAndMount ) error {
@@ -67,12 +48,3 @@ func prepareStagePath(path string, m *mount.SafeFormatAndMount) error {
6748func Mkdir (m * mount.SafeFormatAndMount , name string , perm os.FileMode ) error {
6849 return os .Mkdir (name , perm )
6950}
70-
71- func forceUmount (path string ) error {
72- cmd := exec .Command ("umount" , "-lf" , path )
73- out , cmderr := cmd .CombinedOutput ()
74- if cmderr != nil {
75- return fmt .Errorf ("lazy unmount on %s failed with %v, output: %s" , path , cmderr , string (out ))
76- }
77- return nil
78- }
0 commit comments