Skip to contentSkip to conversation

ib_srpt: Initial SRP Target merge for v3.2-rc1

PATCH In review Nicholas A. Bellinger 5 participants 8 messages Oct 24, 2011 – Oct 26, 2011 3 messages not in the archive

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 ib_srpt: Initial SRP Target merge for v3.2-rc1

From: Bart Van Assche <[email protected]>

This v2 patch adds the kernel module ib_srpt SCSI RDMA Protocol (SRP) target implementation conforming to the SRP r16a specification for the mainline drivers/target infrastructure.

This driver was originally developed by Vu Pham and has been optimized by Bart Van Assche and merged into upstream LIO based on his srpt-lio-4.1 branch. This patch is made against the current pending target-core changes for v3.2-rc1, the full tree is available here:

git://git.kernel.org/pub/scm/linux/kernel/git/nab/target-pending.git for-next-merge

This updated patch also contains the following two changes from lio-core-2.6.git/master. One is to fix a bug with 1 >= task->task_sg[] chained mappings in ib_srpt, and the other to convert the configfs control plane to reference IB Port GUID and struct srpt_port directly following mainline v4.x target_core_fabric_configfs.c convertion for ib_srpt to work with rtslib/rtsadmin v2 code.

These seperate patches can be found here:

ib_srpt: Fix bug with chainged SGLs in srpt_map_sg_to_ib_sge
http://www.risingtidesystems.com/git/?p=lio-core-2.6.git;a=commitdiff;h=ea485147563b6555a97dbf811825fbb586519252

ib_srpt: Convert se_wwn endpoint reference to struct srpt_port->port_wwn
http://www.risingtidesystems.com/git/?p=lio-core-2.6.git;a=commitdiff;h=4e544a210acb227df1bb4ca5086e65bdf4e648ea

This also includes the following recent v1 -> v2 review changes:

ib_srpt: Fix potential out-of-bounds array access
ib_srpt: Avoid failed multipart RDMA transfers
ib_srpt: Fix srpt_alloc_fabric_acl failure case return value
ib_srpt: Update comments to reference $driver/$port layout
ib_srpt: Fix sport->port_guid formatting code
ib_srpt: Remove legacy use_port_guid_in_session_name module parameter
ib_srpt: Convert srp_max_rdma_size into per port configfs attribute
ib_srpt: Convert srp_max_rsp_size into per port configfs attribute
ib_srpt: Convert srpt_sq_size into per port configfs attribute

Cc Bart Van Assche <[email protected]>
Cc Roland Dreier <[email protected]>
Cc Christoph Hellwig <[email protected]>
Cc Vu Pham <[email protected]>
Cc David Dillow <[email protected]>
---
 drivers/infiniband/Kconfig              |    1 +
 drivers/infiniband/Makefile             |    1 +
 drivers/infiniband/ulp/srpt/Kconfig     |   12 +
 drivers/infiniband/ulp/srpt/Makefile    |    2 +
 drivers/infiniband/ulp/srpt/ib_dm_mad.h |  139 ++
 drivers/infiniband/ulp/srpt/ib_srpt.c   | 4081 +++++++++++++++++++++++++++++++
 drivers/infiniband/ulp/srpt/ib_srpt.h   |  442 ++++
 7 files changed, 4678 insertions(+), 0 deletions(-)
 create mode 100644 drivers/infiniband/ulp/srpt/Kconfig
 create mode 100644 drivers/infiniband/ulp/srpt/Makefile
 create mode 100644 drivers/infiniband/ulp/srpt/ib_dm_mad.h
 create mode 100644 drivers/infiniband/ulp/srpt/ib_srpt.c
 create mode 100644 drivers/infiniband/ulp/srpt/ib_srpt.h
drivers/infiniband/Kconfig +1 -0
index 0f9a84c..eb0add3 100644
@@ -55,6 +55,7 @@ source "drivers/infiniband/hw/nes/Kconfig"
 source "drivers/infiniband/ulp/ipoib/Kconfig"
 
 source "drivers/infiniband/ulp/srp/Kconfig"
+source "drivers/infiniband/ulp/srpt/Kconfig"
 
 source "drivers/infiniband/ulp/iser/Kconfig"
 
drivers/infiniband/Makefile +1 -0
index 9cc7a47..a3b2d8e 100644
@@ -10,4 +10,5 @@ obj-$(CONFIG_MLX4_INFINIBAND)		+= hw/mlx4/
 obj-$(CONFIG_INFINIBAND_NES)		+= hw/nes/
 obj-$(CONFIG_INFINIBAND_IPOIB)		+= ulp/ipoib/
 obj-$(CONFIG_INFINIBAND_SRP)		+= ulp/srp/
+obj-$(CONFIG_INFINIBAND_SRPT)		+= ulp/srpt/
 obj-$(CONFIG_INFINIBAND_ISER)		+= ulp/iser/
drivers/infiniband/ulp/srpt/Kconfig new file +12 -0
new file mode 100644
index 0000000..31ee83d
@@ -0,0 +1,12 @@
+config INFINIBAND_SRPT
+	tristate "InfiniBand SCSI RDMA Protocol target support"
+	depends on INFINIBAND && TARGET_CORE
+	---help---
+
+	  Support for the SCSI RDMA Protocol (SRP) Target driver. The
+	  SRP protocol is a protocol that allows an initiator to access
+	  a block storage device on another host (target) over a network
+	  that supports the RDMA protocol. Currently the RDMA protocol is
+	  supported by InfiniBand and by iWarp network hardware. More
+	  information about the SRP protocol can be found on the website
+	  of the INCITS T10 technical committee (http://www.t10.org/).
drivers/infiniband/ulp/srpt/Makefile new file +2 -0
new file mode 100644
index 0000000..e3ee4bd
@@ -0,0 +1,2 @@
+ccflags-y			:= -Idrivers/target
+obj-$(CONFIG_INFINIBAND_SRPT)	+= ib_srpt.o
drivers/infiniband/ulp/srpt/ib_dm_mad.h new file +139 -0

139 lines not on this page · raw message

drivers/infiniband/ulp/srpt/ib_srpt.c new file +4081 -0

2,835 lines not on this page · raw message

drivers/infiniband/ulp/srpt/ib_srpt.h new file +442 -0

442 lines not on this page · raw message

The rest of this diff is not shown. View the raw message.

Signature · 1 line
1.5.6.5

Part of the diff is not shown here. View the raw message.

A message that is not in the archive (sent off-list or not yet received): 1319435841-19046-1-git-send-email-nab-IzHhD5pYlfBP7FQvKIMDCQ@public.gmane.org

#2 lore raw
Quoted 8 lines · Nicholas A. Bellinger

This v2 patch adds the kernel module ib_srpt SCSI RDMA Protocol (SRP) target implementation conforming to the SRP r16a specification for the mainline drivers/target infrastructure.

This driver was originally developed by Vu Pham and has been optimized by Bart Van Assche and merged into upstream LIO based on his srpt-lio-4.1 branch. This patch is made against the current pending target-core changes for v3.2-rc1, the full tree is available here:

Maybe you remember that the reason why I developed this patch was to be able to run performance measurements ? The following changes are necessary to convert this patch into a robust kernel driver:
- Handle the case where the last WQE event arrives before the corresponding queue pair is reset (r3870 in the SCST SVN repo).
- Handle IB completion timeouts. Although the InfiniBand Architecture Manual specifies that a HCA must generate an error completion for each pending work item when a queue pair reset is issued, an important class of HCAs doesn't do this (that includes the HCA in your test setup). In the SCST version of this driver such timeouts are handled by the function srpt_pending_cmd_timeout().

Both issues mentioned above can lead to sessions not being cleaned up properly and hence all future logins from the initiator associated with that session to be blocked.

Bart.
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#3 lore raw
Quoted 23 lines · Bart Van Assche
Quoted 8 lines · Nicholas A. Bellinger

This v2 patch adds the kernel module ib_srpt SCSI RDMA Protocol (SRP) target implementation conforming to the SRP r16a specification for the mainline drivers/target infrastructure.

This driver was originally developed by Vu Pham and has been optimized by Bart Van Assche and merged into upstream LIO based on his srpt-lio-4.1 branch. This patch is made against the current pending target-core changes for v3.2-rc1, the full tree is available here:

Maybe you remember that the reason why I developed this patch was to be able to run performance measurements ? The following changes are necessary to convert this patch into a robust kernel driver:
- Handle the case where the last WQE event arrives before the corresponding queue pair is reset (r3870 in the SCST SVN repo).
- Handle IB completion timeouts. Although the InfiniBand Architecture Manual specifies that a HCA must generate an error completion for each pending work item when a queue pair reset is issued, an important class of HCAs doesn't do this (that includes the HCA in your test setup). In the SCST version of this driver such timeouts are handled by the function srpt_pending_cmd_timeout().

Quoted 4 lines

Both issues mentioned above can lead to sessions not being cleaned up properly and hence all future logins from the initiator associated with that session to be blocked.

It would have been nice if you bothered to mention these in any of the pre merge window reviews, but given your delay responsed on these items they will have to be something we'll fix post merge.

Thanks,

--nab

#4 lore raw
Quoted 6 lines · Nicholas A. Bellinger
Quoted 6 lines

- Handle IB completion timeouts. Although the InfiniBand Architecture Manual specifies that a HCA must generate an error completion for each pending work item when a queue pair reset is issued, an important class of HCAs doesn't do this (that includes the HCA in your test setup). In the SCST version of this driver such timeouts are handled by the function srpt_pending_cmd_timeout().

Hold on... not sure what you mean by a "queue pair reset" but the IB spec does not say that a flush error should be generated when a QP is transitioned to the "reset" state. The flush error completions are required when a QP is transitioned to the "error" state, and in fact completion entries may be lost when a QP transitions to "reset".

As far as I know every HCA supported by Linux does implement this correctly. Which class did you have in mind as not doing that?

- R.

A message that is not in the archive (sent off-list or not yet received): CAG4TOxMmB13exCOx_QC6+302sS4GjhggNrTwdLi4n14=as2PWQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org

#6 lore raw
Quoted 9 lines · Roland Dreier
Quoted 6 lines · Nicholas A. Bellinger
Quoted 6 lines

- Handle IB completion timeouts. Although the InfiniBand Architecture Manual specifies that a HCA must generate an error completion for each pending work item when a queue pair reset is issued, an important class of HCAs doesn't do this (that includes the HCA in your test setup). In the SCST version of this driver such timeouts are handled by the function srpt_pending_cmd_timeout().

Quoted 5 lines

Hold on... not sure what you mean by a "queue pair reset" but the IB spec does not say that a flush error should be generated when a QP is transitioned to the "reset" state.  The flush error completions are required when a QP is transitioned to the "error" state, and in fact completion entries may be lost when a QP transitions to "reset".

I was referring to transitioning a QP to the error state -- see also srpt_ch_qp_err().

Quoted 2 lines

As far as I know every HCA supported by Linux does implement this correctly.  Which class did you have in mind as not doing that?

At least QDR ConnectX 2 HCAs with fairly recent firmware. This behavior can be reproduced easily with the SCST version of ib_srpt as follows:
- Log in from an SRP initiator to ib_srpt.
- Start a direct I/O read test, e.g. with fio.
- Issue the command "rmmod ib_srpt" on the target during I/O.

Bart.
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

maintainer
#7 lore raw
In reply to Nicholas A. Bellinger
Quoted 3 lines · Nicholas A. Bellinger

It would have been nice if you bothered to mention these in any of the pre merge window reviews, but given your delay responsed on these items they will have to be something we'll fix post merge.

Sorry for that - it took some time though before I remembered myself about all this.

If you are looking for a test case: pulling an IB cable during I/O a few times should allow to trigger this.

Bart.

#8 lore raw
In reply to a message not in the archive
Quoted 29 lines · Nicholas A. Bellinger
drivers/infiniband/ulp/srpt/ib_srpt.c new file +29 -0
+static int srpt_write_pending(struct se_cmd *se_cmd)
+{
+       struct srpt_rdma_ch *ch;
+       struct srpt_send_ioctx *ioctx;
+       enum srpt_command_state new_state;
+       enum rdma_ch_state ch_state;
+       int ret;
+
+       ioctx = container_of(se_cmd, struct srpt_send_ioctx, cmd);
+
+       new_state = srpt_set_cmd_state(ioctx, SRPT_STATE_NEED_DATA);
+       WARN_ON(new_state == SRPT_STATE_DONE);
+
+       ch = ioctx->ch;
+       BUG_ON(!ch);
+
+       ch_state = srpt_get_ch_state(ch);
+       switch (ch_state) {
+       case CH_CONNECTING:
+               /* This code should never be reached. */
+               __WARN();
+               ret = -EINVAL;
+               goto out;
+       case CH_LIVE:
+               break;
+       case CH_DISCONNECTING:
+       case CH_DRAINING:
+       case CH_RELEASING:
+               pr_debug("cmd with tag %lld: channel disconnecting\n",

drivers/infiniband/ulp/srpt/ib_srpt.c line 3007

Quoted 10 lines
drivers/infiniband/ulp/srpt/ib_srpt.c new file +10 -0
+                        ioctx->tag);
+               srpt_set_cmd_state(ioctx, SRPT_STATE_DATA_IN);
+               ret = -EINVAL;
+               goto out;
+       }
+       ret = srpt_xfer_data(ch, ioctx);
+
+out:
+       return ret;
+}

If not enough memory is available to perform a SCSI write, this function returns -ENOMEM and the LIO core will report that error to the initiator. At least when mounting a filesystem on top of ib_srp and when performing asynchronous I/O that will result in data loss. Shouldn't the LIO core retry writes as long as not enough memory is available ?

A similar argument holds for reads.

Bart.
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): CAO+b5-p-qRe_GvuB3+WWqk9d_P_1rkqB0OFvQ0Y0jTHK+oc=Zg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org

#10 lore raw
Quoted 49 lines · Bart Van Assche
Quoted 29 lines · Nicholas A. Bellinger
drivers/infiniband/ulp/srpt/ib_srpt.c new file +29 -0
+static int srpt_write_pending(struct se_cmd *se_cmd)
+{
+       struct srpt_rdma_ch *ch;
+       struct srpt_send_ioctx *ioctx;
+       enum srpt_command_state new_state;
+       enum rdma_ch_state ch_state;
+       int ret;
+
+       ioctx = container_of(se_cmd, struct srpt_send_ioctx, cmd);
+
+       new_state = srpt_set_cmd_state(ioctx, SRPT_STATE_NEED_DATA);
+       WARN_ON(new_state == SRPT_STATE_DONE);
+
+       ch = ioctx->ch;
+       BUG_ON(!ch);
+
+       ch_state = srpt_get_ch_state(ch);
+       switch (ch_state) {
+       case CH_CONNECTING:
+               /* This code should never be reached. */
+               __WARN();
+               ret = -EINVAL;
+               goto out;
+       case CH_LIVE:
+               break;
+       case CH_DISCONNECTING:
+       case CH_DRAINING:
+       case CH_RELEASING:
+               pr_debug("cmd with tag %lld: channel disconnecting\n",

drivers/infiniband/ulp/srpt/ib_srpt.c line 3007

Quoted 10 lines
drivers/infiniband/ulp/srpt/ib_srpt.c new file +10 -0
+                        ioctx->tag);
+               srpt_set_cmd_state(ioctx, SRPT_STATE_DATA_IN);
+               ret = -EINVAL;
+               goto out;
+       }
+       ret = srpt_xfer_data(ch, ioctx);
+
+out:
+       return ret;
+}

If not enough memory is available to perform a SCSI write, this function returns -ENOMEM and the LIO core will report that error to the initiator. At least when mounting a filesystem on top of ib_srp and when performing asynchronous I/O that will result in data loss. Shouldn't the LIO core retry writes as long as not enough memory is available ?

Quoted 1 line

A similar argument holds for reads.

So target_core_fabric_ops->write_pending(), ->queue_data_in() and ->queue_status() currently check for a -EAGAIN return in order to signal that QUEUE_FULL logic should kick in for the associated se_cmd descriptor.

I think it's reasonable to also allow fabric modules to signal QUEUE_FULL using -ENOMEM as well, so I'll go ahead and change this for v3.2 w/ ib_srpt and will send out a patch shortly.

Also, I did notice one extra case in srpt_map_sg_to_ib_sge() -> srpt_xfer_data() that returns -EBUSY, so i'll change this to -EAGAIN to signal QUEUE_FULL as well.

Thanks for the feedback Bart!

--nab

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html