From 2828d5a05c36aa8719778142eb4472007906f14c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B3=BD=E6=B7=BC=20=E5=91=A8?= Date: Fri, 26 Sep 2025 19:54:44 +0800 Subject: feat: Separated weed mount lifecycle into a dedicated service and rewired the CSI components to call it. --- pkg/mountmanager/keymutex.go | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 pkg/mountmanager/keymutex.go (limited to 'pkg/mountmanager/keymutex.go') 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) +} -- cgit v1.2.3