aboutsummaryrefslogtreecommitdiff
path: root/pkg/driver/volume.go
diff options
context:
space:
mode:
authorViktor Kuzmin <kvaster@gmail.com>2023-08-06 20:55:56 +0300
committerViktor Kuzmin <kvaster@gmail.com>2023-08-06 20:55:56 +0300
commiteca9cde95a899ab5645b00d8c0d547abd4bc7e8e (patch)
treee3c646e031c35b0299d58407994b10b5ed38a89a /pkg/driver/volume.go
parentcb920765f5d0b3b7a6a54b9bacf5e9be28b46102 (diff)
downloadseaweedfs-csi-driver-eca9cde95a899ab5645b00d8c0d547abd4bc7e8e.tar.xz
seaweedfs-csi-driver-eca9cde95a899ab5645b00d8c0d547abd4bc7e8e.zip
Use single instance of mount utility - mount.New is expensive
Diffstat (limited to 'pkg/driver/volume.go')
-rw-r--r--pkg/driver/volume.go8
1 files changed, 3 insertions, 5 deletions
diff --git a/pkg/driver/volume.go b/pkg/driver/volume.go
index a6a8cfc..5358700 100644
--- a/pkg/driver/volume.go
+++ b/pkg/driver/volume.go
@@ -36,7 +36,7 @@ func (vol *Volume) Stage(stagingTargetPath string) error {
return err
} else if isMnt {
// try to unmount before mounting again
- _ = mount.New("").Unmount(stagingTargetPath)
+ _ = mountutil.Unmount(stagingTargetPath)
}
if u, err := vol.mounter.Mount(stagingTargetPath); err == nil {
@@ -62,8 +62,7 @@ func (vol *Volume) Publish(stagingTargetPath string, targetPath string, readOnly
mountOptions = append(mountOptions, "ro")
}
- mounter := mount.New("")
- if err := mounter.Mount(stagingTargetPath, targetPath, "", mountOptions); err != nil {
+ if err := mountutil.Mount(stagingTargetPath, targetPath, "", mountOptions); err != nil {
return err
}
@@ -89,8 +88,7 @@ func (vol *Volume) Expand(sizeByte int64) error {
func (vol *Volume) Unpublish(targetPath string) error {
// Try unmounting target path and deleting it.
- mounter := mount.New("")
- if err := mount.CleanupMountPoint(targetPath, mounter, true); err != nil {
+ if err := mount.CleanupMountPoint(targetPath, mountutil, true); err != nil {
return err
}