When a new login arrives while the previous connection's async cleanup
is still running, LookupISCSISession finds the stale session but
LookupConnection returns nil (old connection already closed). This
caused a nil pointer dereference when accessing existConn.session
during session reinstatement.
Fix by checking existConn != nil before reinstatement. If the old
connection is already gone, unbind the stale session and create
a fresh one instead.
Also add sync.Once to removeConnectionFromSession to prevent
concurrent goroutine and main-path cleanup from racing.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Read path: eliminate redundant allocation in bsPerformCommand - remove
the pre-allocation before bs.Read() and the append loop for zero-fill,
use direct copy and in-place zero-fill instead
- parseHeader: use command pool (getCommand) instead of direct allocation,
reducing GC pressure on the hot path
- Unmap: use a shared 1MB zero buffer instead of allocating per-descriptor,
dramatically reducing allocations for large unmap operations
- Network I/O: add 256KB bufio.Writer to iSCSI connections, batching
small PDU writes into fewer syscalls. Flush after txHandler completes
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Convert constant to var so that it can be configured from backend
- Add options to disable persistent reservation and ORWrite16 commands
Signed-off-by: Utkarsh Mani Tripathi <utkarsh.tripathi@mayadata.io>