The Storage Performance Development Kit iSCSI target application is named
iscsi_tgt. This following section describes how to run iscsi from your cloned package.
This guide starts by assuming that you can already build the standard SPDK distribution on your platform.
Once built, the binary will be in
If you want to kill the application by using signal, make sure use the SIGTERM, then the application will release all the shared memory resource before exit, the SIGKILL will make the shared memory resource have no chance to be released by applications, you may need to release the resource manually.
The following diagram shows relations between different parts of iSCSI structure described in this document.
SPDK uses the DPDK Environment Abstraction Layer to gain access to hardware resources such as huge memory pages and CPU core(s). DPDK EAL provides functions to assign threads to specific cores. To ensure the SPDK iSCSI target has the best performance, place the NICs and the NVMe devices on the same NUMA node and configure the target to run on CPU cores associated with that node. The following command line option is used to configure the SPDK iSCSI target:
This is a hexadecimal bit mask of the CPU cores where the iSCSI target will start polling threads. In this example, CPU cores 24, 25, 26 and 27 would be used.
The iSCSI target is configured via JSON-RPC calls. See JSON-RPC for details.
The Linux initiator is open-iscsi.
Installing open-iscsi package Fedora:
iscsid must be restarted or receive SIGHUP for changes to take effect. To send SIGHUP, run:
Recommended changes to /etc/sysctl.conf
Assume target is at 10.0.0.1
At this point the iSCSI target should show up as SCSI disks. Check dmesg to see what they came up as.
This will cause the initiator to forget all previously discovered iSCSI target nodes.
This will show the /dev node name for each SCSI LUN in all logged in iSCSI sessions.
After the targets are connected, they can be tuned. For example if /dev/sdc is an iSCSI disk then the following can be done: Set noop to scheduler
Disable merging/coalescing (can be useful for precise workload measurements)
Increase requests for block queue
Assuming we have one iSCSI Target server with portal at 10.0.0.1:3200, two LUNs (Malloc0 and Malloc1), and accepting initiators on 10.0.0.2/32, like on diagram below:
Start iscsi_tgt application:
Construct two 64MB Malloc block devices with 512B sector size "Malloc0" and "Malloc1":
Create new portal group with id 1, and address 10.0.0.1:3260:
Create one initiator group with id 2 to accept any connection from 10.0.0.2/32:
Finally construct one target using previously created bdevs as LUN0 (Malloc0) and LUN1 (Malloc1) with a name "disk1" and alias "Data Disk1" using portal group 1 and initiator group 2.
Connect to the target
At this point the iSCSI target should show up as SCSI disks.
Check dmesg to see what they came up as. In this example it can look like below:
You may also use simple bash command to find /dev/sdX nodes for each iSCSI LUN in all logged iSCSI sessions:
At the iSCSI level, we provide the following support for Hotplug:
At the bdev/nvme level, we start one hotplug monitor which will call spdk_nvme_probe() periodically to get the hotplug events. We provide the private attach_cb and remove_cb for spdk_nvme_probe(). For the attach_cb, we will create the block device base on the NVMe device attached, and for the remove_cb, we will unregister the block device, which will also notify the upper level stack (for iSCSI target, the upper level stack is scsi/lun) to handle the hot-remove event.
When the LUN receive the hot-remove notification from block device layer, the LUN will be marked as removed, and all the IOs after this point will return with check condition status. Then the LUN starts one poller which will wait for all the commands which have already been submitted to block device to return back; after all the commands return back, the LUN will be deleted.
The SPDK iSCSI target application supports iSCSI login redirection feature.
A portal refers to an IP address and TCP port number pair, and a portal group contains a set of portals. Users for the SPDK iSCSI target application configure portals through portal groups.
To support login redirection feature, we utilize two types of portal groups, public portal group and private portal group.
The SPDK iSCSI target application usually has a discovery portal. The discovery portal is connected by an initiator to get a list of targets, as well as the list of portals on which these target may be accessed, by a discovery session.
Public portal groups have their portals returned by a discovery session. Private portal groups do not have their portals returned by a discovery session. A public portal group may optionally have a redirect portal for non-discovery logins for each associated target. This redirect portal must be from a private portal group.
Initiators configure portals in public portal groups as target portals. When an initiator logs in to a target through a portal in an associated public portal group, the target sends a temporary redirection response with a redirect portal. Then the initiator logs in to the target again through the redirect portal.
Users set a portal group to public or private at creation using the
iscsi_create_portal_group RPC, associate portal groups with a target using the
iscsi_create_target_node RPC or the
iscsi_target_node_add_pg_ig_maps RPC, specify a up-to-date redirect portal in a public portal group for a target using the
iscsi_target_node_set_redirect RPC, and terminate the corresponding connections by asynchronous logout request using the
Typically users will use the login redirection feature in scale out iSCSI target system, which runs multiple SPDK iSCSI target applications.