FreeNAS-11.3-U5
I ran into the issue where all the extends on the FreeNAS server were being exported on FC. The issue for me is that I have an iSCSI volume (RHEV) that gets corrupted by the Linux FC initiator host when it tries to access it. Turns out the oVirt iSCSI back-store is just an LVM group.
The behavior of ctladm when you define a target that doesn't match a physical port is to give that target access to everything. So in my /etc/ctl.conf:
target "iqn.2005-10.org.freenas.ctl:qbufc0" {
alias "qbufc0"
portal-group "pg4" "no-authentication"
lun "0" "belkira_qsdp_0"
lun "1" "belkira_qsdp_1"
}
I really want it to look like:
target "naa.21000024ff33f1b2" {
alias "qbufc0"
portal-group "pg4" "no-authentication"
port isp0
lun "0" "belkira_qsdp_0"
lun "1" "belkira_qsdp_1"
}
The naa is the target name assigned by ctld based on the WWN of the port.
root@maragor[~]# ctladm portlist
Port Online Frontend Name pp vp
0 YES ioctl ioctl 0 0
1 YES tpc tpc 0 0
2 NO camsim camsim 0 0 naa.5000000364345303
3 YES camtgt isp0 0 0 naa.21000024ff33f1b2
4 YES camtgt isp1 0 0 naa.21000024ff33f1b3
5 YES iscsi iscsi 2 1 iqn.2005-10.org.freenas.ctl:kvm0,t,0x0002
6 YES iscsi iscsi 4 2 naa.21000024ff33f1b2,t,0x0004
7 YES iscsi iscsi 1 3 iqn.2005-10.org.freenas.ctl:vmware0,t,0x0001
root@maragor[~]#
I tried this manually, and sure enough when it looks like this, only the two LUNs I have defined are exported through port 0 o FC. So the question then was how to make it always look like this. The answer is in /usr/local/lib/python3.7/site-packages/middlewared/etc_files/ctld.py. I opted to change the logic so when the target name starts with naa and there is an : in the name, to use the part to the left of the colon as the target field, and the part to the right of the colon as the port field. A quick delete of the pycache, and I validated. I now get this entry when I create or modify from the GUI:
target "naa.21000024ff33f1b2" {
port "isp0"
alias "qbufc0"
portal-group "pg4" "no-authentication"
lun "0" "belkira_qsdp_0"
lun "1" "belkira_qsdp_1"
}
which behaves as I need it to. From the FC initiator:
--------------------------------------------------------------------------------
HBA Instance 0: QLE2562 Port 1 WWPN 21-00-00-24-FF-33-F5-DA PortID 00-00-E8
Link: Online
--------------------------------------------------------------------------------
Path : 0
Target : 0
Device ID : 0xffff
Product Vendor : FreeNAS
Product ID : iSCSI Disk
Product Revision : 0123
Serial Number : ac1f6bb058a3002
Node Name : 21-00-00-24-FF-33-F1-B2
Port Name : 21-00-00-24-FF-33-F1-B2
Port ID : 00-00-EF
Product Type : FCP Disk
LUN Count(s) : 2
Remote Type : Unknown
Session State : N/A
Secure Mode : Disabled
Rekey Count : 0x0
Congestion Current State : Unknown
Status : Online
------------------------------------------------------------
i am doing a x-connect between the two, so I don't need full blown lun masking based on initiator. Port based zoning like this is quite sufficient for me.