Skip to content

Commit

Permalink
fix(CSI-241): fix unmountWithOptions to use map key rather than optio…
Browse files Browse the repository at this point in the history
…ns.String()
  • Loading branch information
sergeyberezansky committed Sep 11, 2024
1 parent 1ee9988 commit 1269d0d
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions pkg/wekafs/nfsmounter.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func (m *nfsMounter) NewMount(fsName string, options MountOptions) AnyMount {
if _, ok := m.mountMap[fsName]; !ok {
m.mountMap[fsName] = mountsMapPerFs{}
}
if _, ok := m.mountMap[fsName][options.String()]; !ok {
if _, ok := m.mountMap[fsName][options.AsMapKey()]; !ok {
uniqueId := getStringSha1AsB32(fsName + ":" + options.String())
wMount := &nfsMount{
kMounter: m.kMounter,
Expand All @@ -58,10 +58,10 @@ func (m *nfsMounter) NewMount(fsName string, options MountOptions) AnyMount {
interfaceGroupName: m.interfaceGroupName,
clientGroupName: m.clientGroupName,
}
m.mountMap[fsName][options.String()] = wMount
m.mountMap[fsName][options.AsMapKey()] = wMount
}
m.lock.Unlock()
return m.mountMap[fsName][options.String()]
return m.mountMap[fsName][options.AsMapKey()]
}

func (m *nfsMounter) getSelinuxStatus(ctx context.Context) bool {
Expand Down Expand Up @@ -99,10 +99,10 @@ func (m *nfsMounter) unmountWithOptions(ctx context.Context, fsName string, opti
options.setSelinux(m.getSelinuxStatus(ctx), MountProtocolNfs)

log.Ctx(ctx).Trace().Strs("mount_options", opts.Strings()).Str("filesystem", fsName).Msg("Received an unmount request")
if mnt, ok := m.mountMap[fsName][options.String()]; ok {
if mnt, ok := m.mountMap[fsName][options.AsMapKey()]; ok {
err := mnt.decRef(ctx)
if err == nil {
if m.mountMap[fsName][options.String()].getRefCount() <= 0 {
if m.mountMap[fsName][options.AsMapKey()].getRefCount() <= 0 {
log.Ctx(ctx).Trace().Str("filesystem", fsName).Strs("mount_options", options.Strings()).Msg("This is a last use of this mount, removing from map")
delete(m.mountMap[fsName], options.String())
}
Expand Down

0 comments on commit 1269d0d

Please sign in to comment.