Discovery sessions have nil Target and nil ITNexus. The cleanup
path crashed with nil pointer dereference when trying to remove
ITNexus or access Target.Sessions for discovery sessions.
Guard against nil Target (just release TSIH) and nil ITNexus.
Also add nil safety to clearHostIP helper.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Restore CurrentHostIP cleanup on connection close (needed for
blockMultipleHostLogin feature). Extract to clearHostIP helper
to reduce duplication.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Move session cleanup out of iscsiExecLogout() and keep it only in
the CONN_STATE_CLOSE handler. The logout response must be fully sent
before the session is removed; cleaning up during logout causes the
daemon to hang because subsequent operations reference a nil session.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
When an iSCSI connection closes or a logout occurs, the associated
session was never removed from the target's Sessions map, and the
TSIH was never released back to the bitmap allocator. This caused
session and TSIH leaks over repeated connect/disconnect cycles.
Changes:
- Add removeConnectionFromSession() to properly clean up session
when its last connection is closed
- Call session cleanup from handler() on CONN_STATE_CLOSE
- Convert iscsiExecLogout to a method and add session cleanup on logout
- Release TSIH in UnBindISCSISession to prevent TSIH bitmap exhaustion
Fixes#42
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>
- Fix nil pointer dereference in BindISCSISession when existSess is nil
- Fix reversed logic in SPCLuOffline/SPCLuOnline (Online flag was swapped)
- Use negotiated MaxXmitDataSegmentLength for response PDU segmentation (issue #41)
- Fix debug log incorrectly using Warn level in SBCGetLbaStatus
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>
- Respond with failure for unsupported task management commands
- Increase MaxRecvDataSegmentLength to 65536, to match FirstBurstLength
Signed-off-by: Utkarsh Mani Tripathi <utkarsh.tripathi@mayadata.io>