@@ -3480,17 +3480,16 @@ func (p *Plugin) disconnectNVMeSubsystemIfNeeded(
34803480 defer locks .Unlock (ctx , lockContext , nvmeSubsystemDisconnectLock )
34813481
34823482 // Get the number of namespaces associated with the subsystem (inside lock to avoid race conditions)
3483- numNs , err := nvmeSubsys . GetNamespaceCount ( ctx )
3484- if err != nil {
3485- Logc ( ctx ). WithField (
3486- "subsystem" , publishInfo . NVMeSubsystemNQN ,
3487- ). WithError ( err ). Debug ( "Error getting Namespace count." )
3488- }
3483+ numNs := publishedNVMeSessions . GetNamespaceCountForSession ( publishInfo . NVMeSubsystemNQN )
3484+ Logc ( ctx ). WithFields ( LogFields {
3485+ "subsystem" : publishInfo . NVMeSubsystemNQN ,
3486+ "namespaceCount" : numNs ,
3487+ "disconnectFlag" : disconnect ,
3488+ }). Info ( "Checking if subsystem should be disconnected." )
34893489
3490- // If number of namespaces is more than 1, don't disconnect the subsystem. If we get any issues while getting the
3491- // number of namespaces through the CLI, we can rely on the disconnect flag from NVMe self-healing sessions (if
3490+ // If number of namespaces is 0, disconnect the subsystem. we can rely on the disconnect flag from NVMe self-healing sessions (if
34923491 // NVMe self-healing is enabled), which keeps track of namespaces associated with the subsystem.
3493- if (err == nil && numNs <= 1 ) || (p .nvmeSelfHealingInterval > 0 && err != nil && disconnect ) {
3492+ if (numNs == 0 ) || (p .nvmeSelfHealingInterval > 0 && disconnect ) {
34943493 if err := nvmeSubsys .Disconnect (ctx ); err != nil {
34953494 Logc (ctx ).WithField (
34963495 "subsystem" , publishInfo .NVMeSubsystemNQN ,
0 commit comments