Commit Graph

21 Commits

Author SHA1 Message Date
Lei Xue
a7b58b8eb3 fix: handle discovery sessions in UnBindISCSISession
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>
2026-03-17 15:01:22 +08:00
Lei Xue
8ffe5ec5ce fix: prevent nil deref on session reinstatement during cleanup race
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>
2026-03-17 14:37:16 +08:00
Lei Xue
70e1955487 fix: remove dead sessions from target session list
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>
2026-03-16 17:22:01 +08:00
Lei Xue
b2776dc5c2 fix critical bugs and improve iSCSI protocol compliance
- 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>
2026-03-14 12:11:23 +08:00
Lei Xue
00cfac3d24 optimize the perf and support more features 2026-03-14 11:45:35 +08:00
Utkarsh Mani Tripathi
d7891b1f68 Implement stats and resize and fix remote backing store apis
- 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>
2019-11-20 14:34:35 +05:30
Utkarsh Mani Tripathi
1b02c7897e fix error handling for unsupported commands
- 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>
2019-11-18 18:20:59 +05:30
Utkarsh Mani Tripathi
64deda8106 convert initialR2T to always true for datadigest
tttttt-off-by: Utkarsh Mani Tripathi <utkarsh.tripathi@mayadata.io>
2019-11-18 18:10:53 +05:30
Utkarsh Mani Tripathi
a8cc3e6db2 improve logs and add client (initiator) status
Signed-off-by: Utkarsh Mani Tripathi <utkarsh.tripathi@mayadata.io>
2019-11-18 16:25:55 +05:30
chessman
db2ed21438 remove task from PendingTasks queue 2019-06-28 19:56:14 +03:00
chessman
f339c5e70c downgrade ceph 2019-06-12 20:14:12 +03:00
chessman
8d17243b3a update dependencies 2019-06-12 19:10:59 +03:00
Lei Xue
7a2b08ff80 support iscsi task function 2017-06-12 21:06:57 +08:00
Le Zhang
bb67ec66c7 login negotiation and session/conn reinstatment 2016-12-03 04:23:08 +08:00
Lei Xue
82ae696822 remove unnecessary code and doc 2016-11-28 14:36:13 +08:00
Lei Xue
ed47ac5ea0 move port interface to scsi package 2016-11-27 17:02:17 +08:00
Le Zhang
82e6d230a2 PR implementation 2016-11-24 23:16:53 +08:00
Le Zhang
547faf684d iSCSI/SCSI multi port/ALUA support
fix ALUA flag issue
fix NNA flag issue
fix fixed format sense data builder issue
2016-10-18 16:59:25 +08:00
Lei Xue
aedc09021f fix bugs and make it run basically 2016-08-27 20:07:51 +08:00
Lei Xue
c5d68b38b2 run the basic process with iscsi driver 2016-05-02 22:11:33 +08:00
Lei Xue
a9a7d63c20 init commit 2015-12-14 10:23:35 +08:00