Files
scst/srpt
Yan Burman 799ddae085 Merged revisions 5322-5326,5329-5340,5344-5371,5382-5407 via svnmerge from
svn+ssh://yanb123@svn.code.sf.net/p/scst/svn/trunk

........
  r5322 | vlnb | 2014-03-05 05:27:21 +0200 (Wed, 05 Mar 2014) | 13 lines
  
  scst_vdisk: Make vdisk_nullio size configurable
  
  Keep the default size of vdisk_nullio devices at VDISK_NULLIO_SIZE. Add
  a sysfs attribute 'size' which is the size of a vdisk device in
  bytes. Make the size of vdisk_nullio devices configurable. Accept
  "size" and "size_mb" as creation parameters for vdisk_nullio
  devices. Generate a CAPACITY DATA HAS CHANGED unit attention after size
  changes. Refuse any attempt to change the size into a number that is
  not a multiple of the block size.
  
  Signed-off-by: Bart Van Assche <bvanassche@acm.org>
........
  r5323 | bvassche | 2014-03-06 09:29:00 +0200 (Thu, 06 Mar 2014) | 1 line
  
  scst_vdisk: Avoid that smatch complains about unreachable code
........
  r5324 | vlnb | 2014-03-07 06:02:39 +0200 (Fri, 07 Mar 2014) | 27 lines
  
  PERSISTENT RESERVE IN: Suppress a kernel warning for small output buffer sizes
  
  This patch suppresses the following error message and kernel warning:
  
  scst: ***ERROR***: Too big response data len 24 (max 8), limiting it to the max (dev iis)
  Call Trace:
   [<ffffffff818b1193>] ? dump_stack+0x41/0x56
   [<ffffffffa01c1a8f>] ? scst_set_resp_data_len+0x82/0xb1 [scst]
   [<ffffffffa01ca80f>] ? scst_pr_read_reservation+0xbf/0xc4 [scst]
   [<ffffffffa01b707b>] ? scst_persistent_reserve_in_local+0x140/0x1ce [scst]
   [<ffffffffa01b7cee>] ? scst_exec_check_blocking+0x57/0xf1 [scst]
   [<ffffffffa01b85f4>] ? scst_process_active_cmd+0x86c/0x136f [scst]
   [<ffffffffa01b913c>] ? scst_do_job_active+0x45/0x5b [scst]
   [<ffffffffa01b939c>] ? scst_cmd_thread+0x218/0x2b7 [scst]
   [<ffffffff8105292a>] ? wake_up_bit+0x23/0x23
   [<ffffffffa01b9184>] ? scst_cmd_tasklet+0x32/0x32 [scst]
   [<ffffffff81052355>] ? kthread_freezable_should_stop+0x51/0x51
   [<ffffffffa01b9184>] ? scst_cmd_tasklet+0x32/0x32 [scst]
   [<ffffffff81052400>] ? kthread+0xab/0xb3
   [<ffffffff81052355>] ? kthread_freezable_should_stop+0x51/0x51
   [<ffffffff818b4e3c>] ? ret_from_fork+0x7c/0xb0
   [<ffffffff81052355>] ? kthread_freezable_should_stop+0x51/0x51
  
  Reported-by: Roman Bogdanov <bogdanovr@gmail.com>
  Signed-off-by: Bart Van Assche <bvanassche@acm.org>
........
  r5325 | bvassche | 2014-03-08 15:30:29 +0200 (Sat, 08 Mar 2014) | 1 line
  
  nightly build: Update kernel versions
........
  r5326 | vlnb | 2014-03-13 05:50:37 +0200 (Thu, 13 Mar 2014) | 3 lines
  
  Update link to Gentoo HOWTO from Jurie Botha
........
  r5329 | vlnb | 2014-03-15 03:38:06 +0200 (Sat, 15 Mar 2014) | 3 lines
  
  Cleanup
........
  r5330 | vlnb | 2014-03-15 03:38:37 +0200 (Sat, 15 Mar 2014) | 3 lines
  
  Implement REPORT SUPPORTED TASK MANAGEMENT FUNCTIONS command
........
  r5331 | vlnb | 2014-03-15 03:40:57 +0200 (Sat, 15 Mar 2014) | 8 lines
  
  scst_vdisk: Remove an unused parameter from vdisk_fsync*()
  
  The "struct vdisk_cmd_params *p" parameter is neither used by vdisk_fsync(),
  vdisk_fsync_blockio() nor by vdisk_fsync_fileio() so remove it.
  
  Signed-off-by: Bart Van Assche <bvanassche@acm.org>
........
  r5332 | vlnb | 2014-03-15 03:42:06 +0200 (Sat, 15 Mar 2014) | 8 lines
  
  vdisk_blockio: Change default vendor name back to "SCST_BIO"
  
  In r5316 the default vendor name for vdisk_blockio devices was changed
  into "SCST_FIO". Change this back into "SCST_BIO".
  
  Signed-off-by: Bart Van Assche <bvanassche@acm.org>
........
  r5333 | vlnb | 2014-03-15 03:44:35 +0200 (Sat, 15 Mar 2014) | 8 lines
  
  vdisk_blockio: Add VERIFY implementation
  
  There is already an implementation of the VERIFY command for vdisk_fileio
  devices. Add an implementation for vdisk_blockio devices.
  
  Signed-off-by: Bart Van Assche <bvanassche@acm.org>
........
  r5334 | vlnb | 2014-03-15 04:01:17 +0200 (Sat, 15 Mar 2014) | 8 lines
  
  scst_vdisk: Implement COMPARE AND WRITE
  
  Ensure that COMPARE AND WRITE is executed atomically by serializing
  all COMPARE AND WRITE commands per device (SCST_SERIALIZED).
  
  Signed-off-by: Bart Van Assche <bvanassche@acm.org>
........
  r5335 | vlnb | 2014-03-15 04:09:17 +0200 (Sat, 15 Mar 2014) | 5 lines
  
  Fix URL to SCST website
  
  Signed-off-by: Steven J. Magnani <steve@digidescorp.com>
........
  r5336 | vlnb | 2014-03-15 04:13:58 +0200 (Sat, 15 Mar 2014) | 3 lines
  
  Cleanup
........
  r5337 | bvassche | 2014-03-15 08:47:26 +0200 (Sat, 15 Mar 2014) | 1 line
  
  scripts/kernel-functions: Kernel 3.13.6 build fix
........
  r5338 | bvassche | 2014-03-16 15:38:50 +0200 (Sun, 16 Mar 2014) | 1 line
  
  srpt: Minor buid process terminology change
........
  r5339 | bvassche | 2014-03-18 17:35:13 +0200 (Tue, 18 Mar 2014) | 1 line
  
  ib_srpt: Avoid that session logout hangs sporadically
........
  r5340 | vlnb | 2014-03-19 06:28:46 +0200 (Wed, 19 Mar 2014) | 8 lines
  
  scst/README: Show how to read SCST sysfs attributes
  
  Make the behavior of SCST sysfs attributes more clear by adding
  examples in scst/README of code for reading and writing these attributes.
  
  Signed-off-by: Bart Van Assche <bvanassche@acm.org>
........
  r5344 | bvassche | 2014-03-20 17:13:50 +0200 (Thu, 20 Mar 2014) | 1 line
  
  ib_srpt: Simplify srpt_handle_cmd()
........
  r5345 | bvassche | 2014-03-20 17:14:45 +0200 (Thu, 20 Mar 2014) | 5 lines
  
  ib_srpt: Micro-optimize I/O context state manipulation
      
  All ioctx->state manipulations are serialized per command so it is
  not necessary to use locking to protect these manipulations.
........
  r5346 | bvassche | 2014-03-20 17:15:54 +0200 (Thu, 20 Mar 2014) | 8 lines
  
  ib_srpt: Handle GID change events properly
      
  The mlx4_core driver generates a GID change event after a port has been
  changed from IB into Ethernet mode. Avoid that this causes the following
  error message to appear in the system log:
      
  ib_srpt: ***ERROR***: received unrecognized IB event 18
........
  r5347 | bvassche | 2014-03-20 17:16:27 +0200 (Thu, 20 Mar 2014) | 1 line
  
  ib_srpt/Makefile: Add kerneldoc target
........
  r5348 | bvassche | 2014-03-20 17:17:04 +0200 (Thu, 20 Mar 2014) | 1 line
  
  ib_srpt: Fix an error reported by the kerneldoc tool
........
  r5349 | bvassche | 2014-03-20 17:18:06 +0200 (Thu, 20 Mar 2014) | 5 lines
  
  ib_srpt: Avoid that cmd_wait_list processing triggers command reordering
  
  Although harmless for SCSI commands with SIMPLE ordering, avoid that commands
  received before RTU can get reordered.
........
  r5350 | bvassche | 2014-03-20 17:18:38 +0200 (Thu, 20 Mar 2014) | 2 lines
  
  ib_srpt: Micro-optimize SRP_CMD parsing
........
  r5351 | bvassche | 2014-03-20 17:19:05 +0200 (Thu, 20 Mar 2014) | 1 line
  
  ib_srpt: Sync information unit memory only once
........
  r5352 | bvassche | 2014-03-20 17:19:34 +0200 (Thu, 20 Mar 2014) | 2 lines
  
  ib_srpt: Introduce a temporary variable in srpt_handle_new_iu()
........
  r5353 | bvassche | 2014-03-20 17:20:55 +0200 (Thu, 20 Mar 2014) | 2 lines
  
  ib_srpt: Micro-optimize polling
........
  r5354 | bvassche | 2014-03-20 17:22:19 +0200 (Thu, 20 Mar 2014) | 5 lines
  
  ib_srpt: Rework multi-channel support
  
  Store initiator and target port ID's once per nexus instead of in each
  channel data structure.
........
  r5355 | bvassche | 2014-03-20 17:23:16 +0200 (Thu, 20 Mar 2014) | 2 lines
  
  ib_srpt: Simplify channel state management code
........
  r5356 | bvassche | 2014-03-20 17:24:18 +0200 (Thu, 20 Mar 2014) | 5 lines
  
  ib_srpt: Defer destroying the QP until the TimeWait state has been left
  
  This is necessary to avoid that a login gets rejected due to reusing a
  queue pair number that has not yet been freed by the target side.
........
  r5357 | bvassche | 2014-03-20 17:25:34 +0200 (Thu, 20 Mar 2014) | 5 lines
  
  ib_srpt: Rework waiting for last WQE
  
  After having changed the queue pair state into "error", queue an additional
  work request instead of waiting for the last WQE event.
........
  r5358 | bvassche | 2014-03-20 17:26:48 +0200 (Thu, 20 Mar 2014) | 1 line
  
  srpt/session-management.txt: Document how sessions are managed by the ib_srpt driver
........
  r5359 | bvassche | 2014-03-20 18:10:19 +0200 (Thu, 20 Mar 2014) | 1 line
  
  scst_const.h: Make COMPARE_AND_WRITE definition available for kernel versions 3.6..3.11
........
  r5360 | vlnb | 2014-03-21 03:58:13 +0200 (Fri, 21 Mar 2014) | 3 lines
  
  In VERIFY commands BYTCHK 1x is not supported (yet)
........
  r5361 | bvassche | 2014-03-21 18:29:26 +0200 (Fri, 21 Mar 2014) | 1 line
  
  srpt/Makefile: Avoid that the build process depends on source control tools
........
  r5362 | vlnb | 2014-03-22 01:12:42 +0200 (Sat, 22 Mar 2014) | 3 lines
  
  Fix error recovery of internal commands
........
  r5363 | bvassche | 2014-03-24 13:53:00 +0200 (Mon, 24 Mar 2014) | 1 line
  
  ib_srpt: Clarify a kernel-doc comment
........
  r5364 | bvassche | 2014-03-24 13:55:56 +0200 (Mon, 24 Mar 2014) | 1 line
  
  ib_srpt: Add newline at the end of kernel warning statements
........
  r5365 | bvassche | 2014-03-24 13:57:39 +0200 (Mon, 24 Mar 2014) | 5 lines
  
  ib_srpt: Change the severity level of a log message
  
  Make sure that target port state changes get logged even with
  debugging disabled.
........
  r5366 | bvassche | 2014-03-24 13:59:27 +0200 (Mon, 24 Mar 2014) | 5 lines
  
  ib_srpt: Clean up srpt_destroy_ch_ib()
  
  All callers guarantee that the completion queue is empty so it is
  not necessary to invoke ib_poll_cq() from inside this function.
........
  r5367 | bvassche | 2014-03-24 14:01:07 +0200 (Mon, 24 Mar 2014) | 5 lines
  
  ib_srpt: Micro-optimize srpt_adjust_srq_wr_avail()
  
  The overhead of atomic_add_return() is lower than that of a
  spin_lock() / spin_unlock() pair, hence switch to the former.
........
  r5368 | bvassche | 2014-03-24 14:03:09 +0200 (Mon, 24 Mar 2014) | 20 lines
  
  ib_srpt: Fix a kernel warning
  
  Avoid that the following (very rare) kernel warning is reported
  when an ib_srpt target port is disabled while I/O is ongoing:
  
  WARNING: CPU: 3 PID: 12259 at srpt/src/ib_srpt.c:3334 srpt_xmit_response+0x165/0x300 [ib_srpt]()
  Unexpected command state 6
  Call Trace:
   [<ffffffff814a15dc>] dump_stack+0x4e/0x7a
   [<ffffffff8104bc5d>] warn_slowpath_common+0x7d/0xa0
   [<ffffffff8104bccc>] warn_slowpath_fmt+0x4c/0x50
   [<ffffffffa0771525>] srpt_xmit_response+0x165/0x300 [ib_srpt]
   [<ffffffffa082aacc>] scst_xmit_response+0xbc/0x560 [scst]
   [<ffffffffa083123d>] scst_process_active_cmd+0x29d/0x7b0 [scst]
   [<ffffffffa0832bd9>] scst_do_job_active+0x89/0x1a0 [scst]
   [<ffffffffa0832e4f>] scst_cmd_thread+0x15f/0x350 [scst]
   [<ffffffff810766cd>] kthread+0xed/0x110
   [<ffffffff814b312c>] ret_from_fork+0x7c/0xb0
  ---[ end trace 591f7af7d006fc0e ]---
........
  r5369 | bvassche | 2014-03-24 14:04:44 +0200 (Mon, 24 Mar 2014) | 5 lines
  
  ib_srpt: Add a kernel warning
  
  Invoking srpt_zerolength_write() before the queue pair has reached
  the error state is a bug, so complain loudly if that happens.
........
  r5370 | bvassche | 2014-03-24 14:07:43 +0200 (Mon, 24 Mar 2014) | 7 lines
  
  ib_srpt: Avoid waiting for missing error completions
  
  Apparently with mlx4 firmware up to and including 2.30.8000 it is not
  guaranteed that for a QP associated with an SRQ error completions are
  generated for all pending work requests. Avoid triggering
  srpt_pending_cmd_timeout() for missing error completions.
........
  r5371 | bvassche | 2014-03-25 18:19:00 +0200 (Tue, 25 Mar 2014) | 1 line
  
  nightly build: Update kernel versions
........
  r5382 | vlnb | 2014-03-26 04:31:52 +0200 (Wed, 26 Mar 2014) | 6 lines
  
  Black hole functionality added
  
  Scst_mutex intentially used directly in the sysfs handler, because
  comming sysfs improvements will allow that.
........
  r5383 | vlnb | 2014-03-26 05:18:03 +0200 (Wed, 26 Mar 2014) | 5 lines
  
  documentation: Document SCST_SERIALIZED and SCST_STRICTLY_SERIALIZED
  
  Signed-off-by: Bart Van Assche <bvanassche@acm.org>
........
  r5384 | vlnb | 2014-03-26 05:18:36 +0200 (Wed, 26 Mar 2014) | 3 lines
  
  Cleanup
........
  r5385 | vlnb | 2014-03-26 05:20:04 +0200 (Wed, 26 Mar 2014) | 9 lines
  
  scst_local: Remove two superfluous tests
  
  The to_scst_lcl_sess() macro is based on container_of() and hence never
  returns NULL. Hence remove the two tests that compare the result of that
  macro against NULL.
  
  Signed-off-by: Bart Van Assche <bvanassche@acm.org>
........
  r5386 | vlnb | 2014-03-26 05:21:25 +0200 (Wed, 26 Mar 2014) | 7 lines
  
  iscsi-scst: Introduce ARRAY_SIZE()
  
  This patch does not change any functionality.
  
  Signed-off-by: Bart Van Assche <bvanassche@acm.org>
........
  r5387 | vlnb | 2014-03-26 05:22:16 +0200 (Wed, 26 Mar 2014) | 8 lines
  
  scst: Clarify a comment
  
  The comment above scst_nexus_loss() is somewhat confusing so change
  it into something that is more clear.
  
  Signed-off-by: Bart Van Assche <bvanassche@acm.org>
........
  r5388 | vlnb | 2014-03-26 05:23:57 +0200 (Wed, 26 Mar 2014) | 9 lines
  
  scst_vdisk: Fix READ CAPACITY(10)
  
  SBC-2 defines the LBA as a 32-bit field that starts at offset 2 and
  not as a 64-bit field.
  
  Reported-by: Mike Christie <michaelc@cs.wisc.edu>
  Signed-off-by: Bart Van Assche <bvanassche@acm.org>
........
  r5389 | bvassche | 2014-03-26 13:56:13 +0200 (Wed, 26 Mar 2014) | 4 lines
  
  ib_srpt: Clean up srpt_handle_rdma_comp()
  
  This patch does not change any functionality.
........
  r5390 | bvassche | 2014-03-26 13:56:59 +0200 (Wed, 26 Mar 2014) | 4 lines
  
  ib_srpt: Clean up srpt_handle_send_err_comp()
  
  This patch does not change any functionality.
........
  r5391 | bvassche | 2014-03-26 13:58:25 +0200 (Wed, 26 Mar 2014) | 4 lines
  
  ib_srpt: Clean up srpt_handle_rdma_err_comp()
  
  This patch does not change any functionality.
........
  r5392 | bvassche | 2014-03-26 13:59:37 +0200 (Wed, 26 Mar 2014) | 5 lines
  
  ib_srpt: Suppress superfluous error messages
  
  Only complain about a missing completion for I/O contexts that are
  in a state where the ib_srpt driver is waiting for the HCA.
........
  r5393 | bvassche | 2014-03-26 14:00:43 +0200 (Wed, 26 Mar 2014) | 5 lines
  
  ib_srpt: Make srpt_abort_cmd() state checks more strict
  
  Complain if srpt_abort_cmd() is called for an I/O context that is
  being processed by SCST and not by the HCA.
........
  r5394 | vlnb | 2014-03-27 00:16:16 +0200 (Thu, 27 Mar 2014) | 3 lines
  
  Cosmetics
........
  r5395 | vlnb | 2014-03-27 01:51:36 +0200 (Thu, 27 Mar 2014) | 3 lines
  
  Reimplement dropping of TM requests in a more reliable manner
........
  r5396 | vlnb | 2014-03-27 03:57:08 +0200 (Thu, 27 Mar 2014) | 3 lines
  
  Possibility to specify SCSI target device name added
........
  r5397 | bvassche | 2014-03-27 10:27:45 +0200 (Thu, 27 Mar 2014) | 6 lines
  
  Fix two checkpatch complaints about whitespace
  
  Avoid that checkpatch reports the following error message:
  
  ERROR: "(foo*)" should be "(foo *)"
........
  r5398 | bvassche | 2014-03-27 10:34:27 +0200 (Thu, 27 Mar 2014) | 6 lines
  
  Avoid that checkpatch complains that return is not a function
  
  Avoid that checkpatch reports the following error message:
  
  ERROR: return is not a function, parentheses are not required
........
  r5399 | bvassche | 2014-03-27 10:39:53 +0200 (Thu, 27 Mar 2014) | 1 line
  
  scripts/generate-kernel-patch: Fix for kernel versions 3.7, 3.10, 3.12 and 3.13
........
  r5400 | vlnb | 2014-03-29 04:07:22 +0300 (Sat, 29 Mar 2014) | 3 lines
  
  Cleanup
........
  r5401 | bvassche | 2014-04-01 20:46:36 +0300 (Tue, 01 Apr 2014) | 1 line
  
  vdisk_blockio: Temporarily disable COMPARE AND WRITE support
........
  r5402 | bvassche | 2014-04-02 00:05:31 +0300 (Wed, 02 Apr 2014) | 1 line
  
  vdisk_blockio: Fix the (recently enabled) VERIFY command
........
  r5403 | bvassche | 2014-04-03 18:58:16 +0300 (Thu, 03 Apr 2014) | 1 line
  
  ib_srpt: RHEL 6.5 build fix
........
  r5404 | vlnb | 2014-04-04 03:57:30 +0300 (Fri, 04 Apr 2014) | 3 lines
  
  Fix typo in scst_report_supported_tm_fns() reported by Steve Magnani <steve.magnani@digidescorp.com>
........
  r5405 | bvassche | 2014-04-04 07:38:33 +0300 (Fri, 04 Apr 2014) | 1 line
  
  scripts/specialize-patch: Handle numbers surrounded by parentheses properly
........
  r5406 | bvassche | 2014-04-04 08:50:52 +0300 (Fri, 04 Apr 2014) | 1 line
  
  scripts/specialize-patch: Rework r5405
........
  r5407 | bvassche | 2014-04-04 08:56:25 +0300 (Fri, 04 Apr 2014) | 1 line
  
  nightly build: Update kernel versions
........


git-svn-id: http://svn.code.sf.net/p/scst/svn/branches/iser@5408 d57e44dd-8a1f-0410-8b47-8ef2f437770f
2014-04-06 08:13:25 +00:00
..
2012-04-07 09:13:50 +00:00
2010-04-29 06:35:35 +00:00
2012-12-21 12:02:53 +00:00

SCSI RDMA Protocol (SRP) Target driver for Linux
=================================================

The SRP target driver has been designed to work on top of the Linux
InfiniBand kernel drivers -- either the InfiniBand drivers included
with a Linux distribution or the OFED InfiniBand drivers. For more
information about using the SRP target driver in combination with
OFED, see also README.ofed.

The SRP target driver has been implemented as an SCST driver. This
makes it possible to support a lot of I/O modes on real and virtual
devices. A few examples of supported device handlers are:

1. scst_disk. This device handler implements transparent pass-through
   of SCSI commands and allows SRP to access and to export real
   SCSI devices, i.e. disks, hardware RAID volumes, tape libraries
   as SRP LUNs.

2. scst_vdisk, either in fileio or in blockio mode. This device handler
   allows to export software RAID volumes, LVM volumes, IDE disks, and
   normal files as SRP LUNs.

3. nullio. The nullio device handler allows to measure the performance
   of the SRP target implementation without performing any actual I/O.


Installation
------------

Building and installing the SRP target driver is possible as follows:

   cd ${SCST_DIR}
   make -s scst_clean scst scst_install
   make -s srpt_clean srpt srpt_install
   make -s scstadm scstadm_install

The ib_srpt kernel module supports the following parameters:
* one_target_per_port (boolean) and
* use_node_guid_in_target_name (boolean)
  ib_srpt can operate in one of the following three modes:
  1. Access control configuration per HCA and assigning a "ib_srpt_target_<n>"
     style name to each HCA.
  2. Access control configuration per HCA and referring to a HCA via its node
     GUID (e.g. 0002:c903:0005:f34a).
  3. Access control configuration per HCA port and referring to a HCA via its
     port GID (e.g. fe80:0000:0000:0000:0002:c903:0005:f34b).
  Mode (1) is choosen if both one_target_per_port and
  use_node_guid_in_target_name are false. Mode (2) is choosen if
  one_target_per_port is false and use_node_guid_in_target_name is true. Mode
  (3) is choosen if one_target_per_port is true.
* srp_max_req_size (number)
  Maximum size of an SRP control message in bytes. Examples of SRP control
  messages are: login request, logout request, data transfer request, ...
  The larger this parameter, the more scatter/gather list elements can be
  sent at once. Use the following formula to compute an appropriate value
  for this parameter: 68 + 16 * (sg_tablesize). The default value of
  this parameter is 4148, which corresponds to an sg table size of 255.
* srp_max_rsp_size (number)
  Maximum size of an SRP response message in bytes. Sense data is sent back
  via these messages towards the initiator. The default size is 256 bytes.
  With this value there remains (256-36) = 220 bytes for sense data.
* srp_max_rdma_size (number)
  Maximum number of bytes that may be transferred at once via RDMA. Defaults
  to 65536 bytes, which is sufficient to use the full bandwidth of low-latency
  HCAs. Increasing this value may decrease latency for applications
  transferring large amounts of data at once.
* srpt_srq_size (number, default 4095)
  ib_srpt uses a shared receive queue (SRQ) for processing incoming SRP
  requests. This number may have to be increased when a large number of
  initiator systems is accessing a single SRP target system.
* srpt_sq_size (number, default 4096)
  Per-channel InfiniBand send queue size. The default setting is sufficient
  for a credit limit of 128. Changing this parameter to a smaller value may
  cause RDMA requests to be retried and hence may slow down data transfer
  severely.
* trace_flag (unsigned integer, only available in debug builds)
  The individual bits of the trace_flag parameter define which categories of
  trace messages should be sent to the kernel log and which ones not.


Configuring the SRP Target System
---------------------------------

The first step is to choose whether access control will be controlled per
HCA or per HCA port and to create a modprobe configuration file that reflects
this choice. An example:

  # cat /etc/modprobe.d/ib_srpt.conf
  options ib_srpt one_target_per_port=1

Next, create the file /etc/scst.conf. You can create this file with
the scstadmin tool as follows:

  /etc/init.d/scst stop
  /etc/init.d/scst start

Now configure SCST using scstadmin - see also the scstadmin documentation for
further information. Once finished, save the configuration to /etc/scst.conf:

  scstadmin -write_config /etc/scst.conf  (sysfs version)
or
  scstadmin -WriteConfig /etc/scst.conf   (procfs version)

One can verify the contents of scst.conf e.g. as follows:

  cat /etc/scst.conf

Now verify that loading the configuration from file works correctly:

  /etc/init.d/scst reload


Configuring the SRP Initiator System
------------------------------------

First of all, load the SRP kernel module as follows:

   modprobe ib_srp

Next, discover the new SRP target by running the srp_daemon command:

   for d in /dev/infiniband/umad*; do srp_daemon -oacd$d; done

If you want to let the initiator system log in to all SRP targets available
in the same InfiniBand subnet that is possible as follows (-e = execute):

   for d in /dev/infiniband/umad*; do srp_daemon -oecd$d; done

If you want to let the initiator log in to a specific target you can do that
e.g. as follows:

   echo "id_ext=0002c903000f1366,ioc_guid=0002c903000f1366,dgid=fe800000000000000002c903000f1367,pkey=ffff,service_id=0002c903000f1366" > /sys/class/infiniband_srp/${SRP_HCA_NAME}/add_target; done

The meaning of the parameters in the above command is as follows:
   * id_ext: must match ioc_guid.
   * ioc_guid: see also the documentation of the ib_srpt ioc_guid parameter.
   * dgid: target HCA port GID to connect to.
   * pkey: IB partition key (P_Key) of the target to connect to.
   * service_id: must match ioc_guid.

Target GIDs can be queried e.g. via sysfs:

$ for f in /sys/devices/*/*/*/infiniband/*/ports/*/gids/0; do echo $f; \
cat $f | sed 's/://g'; done
/sys/devices/pci0000:00/0000:00:01.0/0000:01:00.0/infiniband/mlx4_0/ports/1/gids/0
fe800000000000000002c9030005f34b
/sys/devices/pci0000:00/0000:00:01.0/0000:01:00.0/infiniband/mlx4_0/ports/2/gids/0
fe800000000000000002c9030005f34c
/sys/devices/pci0000:00/0000:00:1c.0/0000:05:00.0/infiniband/mlx4_1/ports/1/gids/0
fe800000000000000002c9030003cca7
/sys/devices/pci0000:00/0000:00:1c.0/0000:05:00.0/infiniband/mlx4_1/ports/2/gids/0
fe800000000000000002c9030003cca8

Finally run lsscsi to display the details of the newly discovered SCSI disks:

   lsscsi

SRP targets can be recognized in the output of lsscsi by looking for
the disk names assigned on the SCST target ("disk01" in the example below):

   [8:0:0:0]    disk    SCST_FIO disk01            102  /dev/sdb


Target names
------------

The name assigned by the ib_srpt target driver to an SCST target is either
ib_srpt_target_<n>, the node GUID of a HCA in hexadecimal form with a colon
after every fourth digit or the port GUID with a colon afer every fourth
digit. The HCA node and port GUIDs can be obtained via the ibv_devinfo
command. An example:

# ibv_devinfo -v | grep -E '[^a-z]port:|guid|GID'
node_guid:      0002:c903:0005:f34e
sys_image_guid: 0002:c903:0005:f351
  port: 1
    GID[0]:     fe80:0000:0000:0000:0002:c903:0005:f34f
  port: 2
    GID[0]:     fe80:0000:0000:0000:0002:c903:0005:f350

Once the ib_srpt driver has been loaded the available SCST targets can be
queried as follows:

# (cd /sys/kernel/scst_tgt/targets/ib_srpt && ls -d [0-9a-f]*)
fe80:0000:0000:0000:0002:c903:0005:f34f
fe80:0000:0000:0000:0002:c903:0005:f350


Session names
-------------

The name assigned by the ib_srpt target driver to a session depends on the
mode in which it is operating. If one_target_per_port=y then the source port
GID is used as the session name. If one_target_per_port=n then the 128-bit SRP
initiator port identifier is used as the session name. This identifier is sent
by the SRP initiator to the SRP target via the SRP_LOGIN_REQ information unit.
The Linux SRP initiator (ib_srp) generates the initiator port identifier as
follows:
- The first eight bytes are the identifier extension ('initiator_ext' parameter
  specified in the login string echoed into the sysfs file 'add_target').
- The last eight bytes are the GUID of the initiator HCA port used to
  communicate with the target.

An example:

[ INITIATOR ]

$ for f in /sys/devices/*/*/*/infiniband/*/ports/*/gids/0; do echo
f; cat $f; done
/sys/devices/pci0000:00/0000:00:01.0/0000:01:00.0/infiniband/mlx4_0/ports/1/gids/0
fe80:0000:0000:0000:0002:c903:0005:f34b
/sys/devices/pci0000:00/0000:00:01.0/0000:01:00.0/infiniband/mlx4_0/ports/2/gids/0
fe80:0000:0000:0000:0002:c903:0005:f34c
/sys/devices/pci0000:00/0000:00:1c.0/0000:05:00.0/infiniband/mlx4_1/ports/1/gids/0
fe80:0000:0000:0000:0002:c903:0003:cca7
/sys/devices/pci0000:00/0000:00:1c.0/0000:05:00.0/infiniband/mlx4_1/ports/2/gids/0
fe80:0000:0000:0000:0002:c903:0003:cca8

[ TARGET, after login ]

$ (cd /sys/kernel/scst_tgt/targets/ib_srpt/[0-9a-f]* && ls -d sessions/*)
sessions/fe80:0000:0000:0000:0002:c903:0003:cca7
sessions/fe80:0000:0000:0000:0002:c903:0005:f34b


LUN masking
-----------

In a straightforward configuration every LUN is visible to every initiator.
It is possible however to make a different set of LUNs visible to each
initiator by using the LUN masking feature of SCST. SRP initiators are
identified by their session name (see above). An example of an scst.conf
file using LUN masking for ib_srpt:

TARGET_DRIVER ib_srpt {
        TARGET fe80:0000:0000:0000:0002:c903:0005:f34b {
                enabled 1
                rel_tgt_id 1

                # LUNs visible by all initiators not listed below
                LUN 0 disk01

                GROUP grp1 {
                        # LUNs visible by initiator system 1
                        LUN 0 disk02

                        INITIATOR fe80:0000:0000:0000:0002:c903:0005:f34b
                }

                GROUP grp2 {
                        # LUNs visible by initiator system 2
                        LUN 0 disk03

                        INITIATOR fe80:0000:0000:0000:0002:c903:0005:f34c
                }
        }
}


Adding and Removing LUNs Dynamically
------------------------------------

It is possible to add and/or remove LUNs on the target without restarting
target or initiator. This can be done either via scstadmin or directly via the
sysfs interface. Although the SCST core will notify the initiator about LUN
changes, Linux initiators will ignore these notifications. In order to bring a
Linux initiator again in sync after a LUN change, the initiator has to be told
to rescan SCSI devices. Rescanning SCSI devices is e.g. possible via the
rescsan-scsi-bus.sh script that can be found here:
http://www.garloff.de/kurt/linux/#rescan-scsi. An example:
$ rescan-scsi-bus --hosts=${srp_host_id} --channels=0 --ids=0 --luns=0-31


InfiniBand Partitions
---------------------

Just like a VLAN allows to segment traffic on an Ethernet network partitions
allow to segment traffic on an InfiniBand network. Each InfiniBand partition
is identified by a partition key which is a 16-bit number. During fabric
initialization the subnet manager assigns one or more partition keys to
each InfiniBand port. For opensm partitions are defined in
/etc/opensm/partitions.conf. ib_srpt uses the partition with index 0. Which
partition key corresponds to index 0 can be found out by querying sysfs:

$ head /sys/class/infiniband/*/ports/*/pkeys/0
==> /sys/class/infiniband/mlx4_0/ports/1/pkeys/0 <==
0xffff

==> /sys/class/infiniband/mlx4_0/ports/2/pkeys/0 <==
0xffff


High availability
-----------------

If there are redundant paths in the IB network between initiator and target,
automatic path failover can be set up on the initiator as follows:
* Edit /etc/infiniband/openib.conf to load the SRP driver and SRP HA daemon
  automatically: set SRP_LOAD=yes and SRPHA_ENABLE=yes.
* To set up and use the high availability feature you need the dm-multipath
  driver and multipath tool.
* Please refer to the OFED-1.x user manual for more detailed instructions
  on how to enable and how to use the HA feature. See e.g.
  http://www.mellanox.com/related-docs/prod_software/Mellanox_OFED%20_Linux_user_manual_1_5_1_2.pdf.

A setup with automatic failover between redundant targets is possible by
installing and configuring DRBD on both targets. If the initiator system
supports mirroring (e.g. Linux), you can use the following approach:
* Configure DRBD in Active/Active mode.
* Configure the initiator(s) for mirroring between the redundant targets.
If the initiator system does not support mirroring (e.g. VMware ESX), you
can use the following approach:
* Configure DRBD in Active/Passive mode and enable STONITH mode in the
  Heartbeat software.

For more information, see also:
* http://www.drbd.org/
* http://www.linux-ha.org/wiki/Main_Page


Performance Notes - Target Side
-------------------------------

* Building the SCST core and the ib_srpt target driver in release mode
  improves performance compared to debug mode.

* When using high-latency storage devices (hard disks), the default value
  choosen by SCST for DEVICE.threads_num should be fine. When using
  low-latency storage devices though (SSDs), DEVICE.threads_num should be set
  to 1 or 2 in /etc/scst.conf in order to reach optimal performance for small
  block sizes (e.g. 4 KB).

* When multiple InfiniBand HCA's are present in a target system the Linux
  kernel by default will assign the associated interrupt handlers to CPU 0.
  Even irqbalance will often assign the interrupt handlers of multiple HCA's
  to the same CPU. That is unfortunate because it leads to unfair handling of
  SRP sessions. The solution is to assign InfiniBand HCA interrupts manually
  to different CPU's. That's possible by writing looking up the InfiniBand
  interrupt numbers in /proc/interrupts and by writing proper bitmasks into
  /proc/irq/<n>/smp_affinity.


Performance Notes - Initiator Side
----------------------------------

* Choose a proper value for the ib_srp kernel module parameter
  cmd_sg_entries. The default value 12 works well for buffered reads while
  the throughput for write-dominated workloads improves by changing this value
  into 255. One way to set this kernel module parameter is as follows:

  echo options ib_srp cmd_sg_entries=255 >>/etc/modprobe.d/ib_srp.conf

* For multithreaded workloads using small block sizes changing rq_affinity
  into 2 improves IOPS significantly (Linux kernel 3.1 and later; see also
  commit 5757a6d76cdf6dda2a492c09b985c015e86779b1).

* For latency sensitive applications, using the noop scheduler at the initiator
  side can give significantly better results than with other schedulers.

* The SRP initiator limits by default the queue depth to 64 commands. If your
  workload benefits from a larger queue depth, enlarge the queue depth by
  setting the max_cmd_per_lun parameter in the SRP login string.

* The following parameters have a small but measurable impact on SRP
  performance:
  * /sys/class/block/${dev}/queue/rotational
  * /sys/class/block/${dev}/queue/rq_affinity
  * /proc/irq/${ib_int_no}/smp_affinity


Performance Notes - Both Sides
------------------------------

* Disabling CONFIG_SCHED_DEBUG and CONFIG_SCHEDSTATS in the kernel config
  helps.

* Disable CONFIG_IRQSOFF_TRACER such that CONFIG_TRACE_IRQFLAGS is disabled.

* Consider which memory allocator to use. With recent kernels using the SLUB
  memory allocator instead of SLAB may help. On multi-socket systems the SLAB
  memory allocator may result in better performance. Please note that SLAB is
  tunable while SLUB is not. See also http://lkml.org/lkml/2010/7/9/264 and
  http://www.ibm.com/developerworks/linux/library/l-linux-slab-allocator/.


Frequently Asked Questions
--------------------------

Q: Every now and then "SRP abort called" and "SRP reset_device called"
   messages are logged at the initiator side. Around the same time I see the
   following message in the target log: "ib_srpt: ***ERROR***: Command ...: IB
   completion for idx ... has not been received in time (SRPT command state
   ...)". What is the meaning of these messages mean and how can I fix this ?

A: This means that a timeout occurred while a HCA was waiting for an
   acknowledge message. Check the IB network for bad IB cables, bad HCA's
   and/or bad switch ports. Also make sure that the HCA firmware is up to
   date.

Q: Loading the kernel module ib_srpt triggers a kernel panic with a call trace
   like the one below. What is the cause of this and how can this be solved ?

   Call Trace:
    [<ffffffffa02f2a50>] srpt_alloc_ioctx+0x60/0xb0 [ib_srpt]
    [<ffffffffa02f2f0a>] srpt_alloc_ioctx_ring+0xea/0x1e0 [ib_srpt]
    [<ffffffffa02f32e9>] srpt_add_one+0x2e9/0x670 [ib_srpt]
    [<ffffffffa015a480>] ib_register_client+0x80/0xa0 [ib_core]
    [<ffffffffa02421eb>] srpt_init_module+0x1eb/0x235 [ib_srpt]
    [<ffffffff81000344>] do_one_initcall+0x34/0x1a0
    [<ffffffff8107a63c>] sys_init_module+0xdc/0x260
    [<ffffffff81002e3b>] system_call_fastpath+0x16/0x1b

A: This means that you are using a system on which OFED has been installed but
   that ib_srpt has been compiled against the in-tree kernel headers instead
   of the OFED kernel headers. You can fix this by rebuilding ib_srpt against
   the OFED kernel headers. The ib_srpt makefile should detect the OFED kernel
   headers automatically - at least if ib_srpt is built after OFED has been
   installed.


Feedback
--------

Send questions about this driver to scst-devel@lists.sourceforge.net, CC:
Vu Pham <vuhuong@mellanox.com> and Bart Van Assche <bvanassche@acm.org>.