aboutsummaryrefslogtreecommitdiff
path: root/pkg/mountmanager/keymutex.go
diff options
context:
space:
mode:
author泽淼 周 <zhouzemiao@ihuman.com>2025-09-26 19:54:44 +0800
committerchrislusf <chris.lu@gmail.com>2025-12-05 17:51:28 -0800
commitbedb15e3e3742a4bd4e26e71e6d9818e9e1474bd (patch)
tree7a60daa0bc9cf86204ddeddc94bc7dc748483cb5 /pkg/mountmanager/keymutex.go
parentfd2b35494095ccf7b06fb210305406f83ed17998 (diff)
downloadseaweedfs-csi-driver-bedb15e3e3742a4bd4e26e71e6d9818e9e1474bd.tar.xz
seaweedfs-csi-driver-bedb15e3e3742a4bd4e26e71e6d9818e9e1474bd.zip
feat: Separated weed mount lifecycle into a dedicated service and rewired the CSI components to call it.
Diffstat (limited to 'pkg/mountmanager/keymutex.go')
-rw-r--r--pkg/mountmanager/keymutex.go21
1 files changed, 21 insertions, 0 deletions
diff --git a/pkg/mountmanager/keymutex.go b/pkg/mountmanager/keymutex.go
new file mode 100644
index 0000000..0c64dcc
--- /dev/null
+++ b/pkg/mountmanager/keymutex.go
@@ -0,0 +1,21 @@
+package mountmanager
+
+import "sync"
+
+// keyMutex provides a lock per key to serialize operations per volume.
+type keyMutex struct {
+ mutexes sync.Map
+}
+
+func newKeyMutex() *keyMutex {
+ return &keyMutex{}
+}
+
+func (km *keyMutex) get(key string) *sync.Mutex {
+ m, _ := km.mutexes.LoadOrStore(key, &sync.Mutex{})
+ return m.(*sync.Mutex)
+}
+
+func (km *keyMutex) delete(key string) {
+ km.mutexes.Delete(key)
+}