diff options
| author | 泽淼 周 <zhouzemiao@ihuman.com> | 2025-09-26 19:54:44 +0800 |
|---|---|---|
| committer | Chris Lu <chrislusf@users.noreply.github.com> | 2025-12-06 18:53:22 -0800 |
| commit | 2828d5a05c36aa8719778142eb4472007906f14c (patch) | |
| tree | 7a60daa0bc9cf86204ddeddc94bc7dc748483cb5 /pkg/mountmanager/keymutex.go | |
| parent | fd2b35494095ccf7b06fb210305406f83ed17998 (diff) | |
| download | seaweedfs-csi-driver-2828d5a05c36aa8719778142eb4472007906f14c.tar.xz seaweedfs-csi-driver-2828d5a05c36aa8719778142eb4472007906f14c.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.go | 21 |
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) +} |
