diff --git a/pkg/wekafs/nfsmount.go b/pkg/wekafs/nfsmount.go index f14a35c6..25496263 100644 --- a/pkg/wekafs/nfsmount.go +++ b/pkg/wekafs/nfsmount.go @@ -10,15 +10,12 @@ import ( "os" "path/filepath" "strings" - "sync" "time" ) type nfsMount struct { fsName string mountPoint string - refCount int - lock sync.Mutex kMounter mount.Interface debugPath string mountOptions MountOptions @@ -33,7 +30,7 @@ func (m *nfsMount) getMountPoint() string { } func (m *nfsMount) getRefCount() int { - return m.refCount + return 0 } func (m *nfsMount) getMountOptions() MountOptions { @@ -53,44 +50,15 @@ func (m *nfsMount) isMounted() bool { } func (m *nfsMount) incRef(ctx context.Context, apiClient *apiclient.ApiClient) error { - logger := log.Ctx(ctx) - m.lock.Lock() - defer m.lock.Unlock() - if m.refCount < 0 { - logger.Error().Str("mount_point", m.mountPoint).Int("refcount", m.refCount).Msg("During incRef negative refcount encountered") - m.refCount = 0 // to make sure that we don't have negative refcount later - } - if m.refCount == 0 { - if err := m.doMount(ctx, apiClient, m.mountOptions); err != nil { - return err - } - } else if !m.isMounted() { - logger.Warn().Str("mount_point", m.mountPoint).Int("refcount", m.refCount).Msg("Mount not exists although should!") - if err := m.doMount(ctx, apiClient, m.mountOptions); err != nil { - return err - } - + if err := m.doMount(ctx, apiClient, m.mountOptions); err != nil { + return err } - m.refCount++ - logger.Trace().Int("refcount", m.refCount).Strs("mount_options", m.mountOptions.Strings()).Str("filesystem_name", m.fsName).Msg("RefCount increased") return nil } func (m *nfsMount) decRef(ctx context.Context) error { - logger := log.Ctx(ctx) - m.lock.Lock() - defer m.lock.Unlock() - m.refCount-- - m.lastUsed = time.Now() - logger.Trace().Int("refcount", m.refCount).Strs("mount_options", m.mountOptions.Strings()).Str("filesystem_name", m.fsName).Msg("RefCount decreased") - if m.refCount < 0 { - logger.Error().Int("refcount", m.refCount).Msg("During decRef negative refcount encountered") - m.refCount = 0 // to make sure that we don't have negative refcount later - } - if m.refCount == 0 { - if err := m.doUnmount(ctx); err != nil { - return err - } + if err := m.doUnmount(ctx); err != nil { + return err } return nil }