Skip to content

Commit 77cc47c

Browse files
committed
lio_ha: add TrueNAS LIO HA forwarding module
Introduces lio_ha.ko, a kernel module that implements active/standby high-availability for the LIO SCSI target subsystem on TrueNAS. On the STANDBY node, the module intercepts every SCSI command, TMR, and PR OUT before it reaches the local backend and forwards it to the ACTIVE node over a private TCP channel (port 999). On failover a single write to a configfs attribute clears the forwarding flag; lio_ha restores replicated Persistent Reservation state directly into LIO core, opens the local iblock/fileio backends, and resumes local execution -- without removing or reinserting any LUN. On the ACTIVE node, a private fabric driver (ha_recv) accepts the TCP connection from STANDBY, creates a synthetic se_session for each initiator with the correct node_acl, and submits forwarded commands to LIO core for local execution under the right I_T nexus context so that PR per-I_T nexus checking remains correct across the HA pair. The module is loaded on both nodes. A single persistent TCP connection carries session lifecycle, I/O, TMR, PR replication (PERS_ACTION), and bulk PR sync (LUN_SYNC) traffic. Enabled by CONFIG_LIO_HA (tristate, depends on CONFIG_TRUENAS).
1 parent ba4e7fa commit 77cc47c

15 files changed

Lines changed: 4524 additions & 0 deletions

File tree

drivers/target/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,5 +48,6 @@ source "drivers/target/tcm_fc/Kconfig"
4848
source "drivers/target/iscsi/Kconfig"
4949
source "drivers/target/sbp/Kconfig"
5050
source "drivers/target/tcm_remote/Kconfig"
51+
source "drivers/target/lio_ha/Kconfig"
5152

5253
endif

drivers/target/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,4 @@ obj-$(CONFIG_TCM_FC) += tcm_fc/
3131
obj-$(CONFIG_ISCSI_TARGET) += iscsi/
3232
obj-$(CONFIG_SBP_TARGET) += sbp/
3333
obj-$(CONFIG_REMOTE_TARGET) += tcm_remote/
34+
obj-$(CONFIG_LIO_HA) += lio_ha/

drivers/target/lio_ha/Kconfig

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# SPDX-License-Identifier: GPL-2.0-only
2+
3+
config LIO_HA
4+
tristate "TrueNAS LIO HA forwarding module"
5+
depends on TARGET_CORE && TRUENAS
6+
help
7+
Enables the lio_ha.ko kernel module for TrueNAS High Availability
8+
with the Linux LIO iSCSI/FC target stack.
9+
10+
On a STANDBY node, lio_ha intercepts all I/O and Task Management
11+
Requests before they reach the local backend and forwards them to
12+
the ACTIVE node over a private TCP channel. On failover, a single
13+
write clears the forwarding flag; lio_ha restores replicated
14+
Persistent Reservation state, opens the local iblock/fileio backends,
15+
and stops forwarding -- without any LUN removal or reinsertion.
16+
17+
The module is loaded on both ACTIVE and STANDBY nodes. On ACTIVE
18+
it registers the ha_recv fabric driver that accepts forwarded commands
19+
and submits them to the local LIO stack on behalf of STANDBY's
20+
initiators, preserving correct per-I_T nexus PR checking.
21+
22+
If unsure, say N.

drivers/target/lio_ha/Makefile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# SPDX-License-Identifier: GPL-2.0-only
2+
3+
lio_ha-y := lio_ha_main.o lio_ha_recv.o lio_ha_tcp.o lio_ha_fwd.o
4+
5+
obj-$(CONFIG_LIO_HA) += lio_ha.o

0 commit comments

Comments
 (0)