diff options
| author | Linus Torvalds <torvalds@linux-foundation.org> | 2014-10-21 16:06:38 -0400 |
|---|---|---|
| committer | Linus Torvalds <torvalds@linux-foundation.org> | 2014-10-21 16:06:38 -0400 |
| commit | c3351dfabf5c78fb5ddc79d0f7b65ebd9e441337 (patch) | |
| tree | 032d5b9c844577c7ca2d4937d6a33e189c64c9f9 | |
| parent | 848a552893ff1fe071c57231edcd179cf84ec4f8 (diff) | |
| parent | 62d3ab49b8a5438d11a11605ea1a6d2fe0118f32 (diff) | |
Merge branch 'for-next' of git://git.kernel.org/pub/scm/linux/kernel/git/nab/target-pending
Pull SCSI target updates from Nicholas Bellinger:
"Here are the target updates for v3.18-rc2 code. These where
originally destined for -rc1, but due to the combination of travel
last week for KVM Forum and my mistake of taking the three week merge
window literally, the pull request slipped.. Apologies for that.
Things where reasonably quiet this round. The highlights include:
- New userspace backend driver (target_core_user.ko) by Shaohua Li
and Andy Grover
- A number of cleanups in target, iscsi-taret and qla_target code
from Joern Engel
- Fix an OOPs related to queue full handling with CHECK_CONDITION
status from Quinn Tran
- Fix to disable TX completion interrupt coalescing in iser-target,
that was causing problems on some hardware
- Fix for PR APTPL metadata handling with demo-mode ACLs
I'm most excited about the new backend driver that uses UIO + shared
memory ring to dispatch I/O and control commands into user-space.
This was probably the most requested feature by users over the last
couple of years, and opens up a new area of development + porting of
existing user-space storage applications to LIO. Thanks to Shaohua +
Andy for making this happen.
Also another honorable mention, a new Xen PV SCSI driver was merged
via the xen/tip.git tree recently, which puts us now at 10 target
drivers in upstream! Thanks to David Vrabel + Juergen Gross for their
work to get this code merged"
* 'for-next' of git://git.kernel.org/pub/scm/linux/kernel/git/nab/target-pending: (40 commits)
target/file: fix inclusive vfs_fsync_range() end
iser-target: Disable TX completion interrupt coalescing
target: Add force_pr_aptpl device attribute
target: Fix APTPL metadata handling for dynamic MappedLUNs
qla_target: don't delete changed nacls
target/user: Recalculate pad size inside is_ring_space_avail()
tcm_loop: Fixup tag handling
iser-target: Fix smatch warning
target/user: Fix up smatch warnings in tcmu_netlink_event
target: Add a user-passthrough backstore
target: Add documentation on the target userspace pass-through driver
uio: Export definition of struct uio_device
target: Remove unneeded check in sbc_parse_cdb
target: Fix queue full status NULL pointer for SCF_TRANSPORT_TASK_SENSE
qla_target: rearrange struct qla_tgt_prm
qla_target: improve qlt_unmap_sg()
qla_target: make some global functions static
qla_target: remove unused parameter
target: simplify core_tmr_abort_task
target: encapsulate smp_mb__after_atomic()
...
36 files changed, 1941 insertions, 318 deletions
diff --git a/Documentation/target/tcmu-design.txt b/Documentation/target/tcmu-design.txt new file mode 100644 index 000000000000..5518465290bf --- /dev/null +++ b/Documentation/target/tcmu-design.txt | |||
| @@ -0,0 +1,378 @@ | |||
| 1 | Contents: | ||
| 2 | |||
| 3 | 1) TCM Userspace Design | ||
| 4 | a) Background | ||
| 5 | b) Benefits | ||
| 6 | c) Design constraints | ||
| 7 | d) Implementation overview | ||
| 8 | i. Mailbox | ||
| 9 | ii. Command ring | ||
| 10 | iii. Data Area | ||
| 11 | e) Device discovery | ||
| 12 | f) Device events | ||
| 13 | g) Other contingencies | ||
| 14 | 2) Writing a user pass-through handler | ||
| 15 | a) Discovering and configuring TCMU uio devices | ||
| 16 | b) Waiting for events on the device(s) | ||
| 17 | c) Managing the command ring | ||
| 18 | 3) Command filtering and pass_level | ||
| 19 | 4) A final note | ||
| 20 | |||
| 21 | |||
| 22 | TCM Userspace Design | ||
| 23 | -------------------- | ||
| 24 | |||
| 25 | TCM is another name for LIO, an in-kernel iSCSI target (server). | ||
| 26 | Existing TCM targets run in the kernel. TCMU (TCM in Userspace) | ||
| 27 | allows userspace programs to be written which act as iSCSI targets. | ||
| 28 | This document describes the design. | ||
| 29 | |||
| 30 | The existing kernel provides modules for different SCSI transport | ||
| 31 | protocols. TCM also modularizes the data storage. There are existing | ||
| 32 | modules for file, block device, RAM or using another SCSI device as | ||
| 33 | storage. These are called "backstores" or "storage engines". These | ||
| 34 | built-in modules are implemented entirely as kernel code. | ||
| 35 | |||
| 36 | Background: | ||
| 37 | |||
| 38 | In addition to modularizing the transport protocol used for carrying | ||
| 39 | SCSI commands ("fabrics"), the Linux kernel target, LIO, also modularizes | ||
| 40 | the actual data storage as well. These are referred to as "backstores" | ||
| 41 | or "storage engines". The target comes with backstores that allow a | ||
| 42 | file, a block device, RAM, or another SCSI device to be used for the | ||
| 43 | local storage needed for the exported SCSI LUN. Like the rest of LIO, | ||
| 44 | these are implemented entirely as kernel code. | ||
| 45 | |||
| 46 | These backstores cover the most common use cases, but not all. One new | ||
| 47 | use case that other non-kernel target solutions, such as tgt, are able | ||
| 48 | to support is using Gluster's GLFS or Ceph's RBD as a backstore. The | ||
| 49 | target then serves as a translator, allowing initiators to store data | ||
| 50 | in these non-traditional networked storage systems, while still only | ||
| 51 | using standard protocols themselves. | ||
| 52 | |||
| 53 | If the target is a userspace process, supporting these is easy. tgt, | ||
| 54 | for example, needs only a small adapter module for each, because the | ||
| 55 | modules just use the available userspace libraries for RBD and GLFS. | ||
| 56 | |||
| 57 | Adding support for these backstores in LIO is considerably more | ||
| 58 | difficult, because LIO is entirely kernel code. Instead of undertaking | ||
| 59 | the significant work to port the GLFS or RBD APIs and protocols to the | ||
| 60 | kernel, another approach is to create a userspace pass-through | ||
| 61 | backstore for LIO, "TCMU". | ||
| 62 | |||
| 63 | |||
| 64 | Benefits: | ||
| 65 | |||
| 66 | In addition to allowing relatively easy support for RBD and GLFS, TCMU | ||
| 67 | will also allow easier development of new backstores. TCMU combines | ||
| 68 | with the LIO loopback fabric to become something similar to FUSE | ||
| 69 | (Filesystem in Userspace), but at the SCSI layer instead of the | ||
| 70 | filesystem layer. A SUSE, if you will. | ||
| 71 | |||
| 72 | The disadvantage is there are more distinct components to configure, and | ||
| 73 | potentially to malfunction. This is unavoidable, but hopefully not | ||
| 74 | fatal if we're careful to keep things as simple as possible. | ||
| 75 | |||
| 76 | Design constraints: | ||
| 77 | |||
| 78 | - Good performance: high throughput, low latency | ||
| 79 | - Cleanly handle if userspace: | ||
| 80 | 1) never attaches | ||
| 81 | 2) hangs | ||
| 82 | 3) dies | ||
| 83 | 4) misbehaves | ||
| 84 | - Allow future flexibility in user & kernel implementations | ||
| 85 | - Be reasonably memory-efficient | ||
| 86 | - Simple to configure & run | ||
| 87 | - Simple to write a userspace backend | ||
| 88 | |||
| 89 | |||
| 90 | Implementation overview: | ||
| 91 | |||
| 92 | The core of the TCMU interface is a memory region that is shared | ||
| 93 | between kernel and userspace. Within this region is: a control area | ||
| 94 | (mailbox); a lockless producer/consumer circular buffer for commands | ||
| 95 | to be passed up, and status returned; and an in/out data buffer area. | ||
| 96 | |||
| 97 | TCMU uses the pre-existing UIO subsystem. UIO allows device driver | ||
| 98 | development in userspace, and this is conceptually very close to the | ||
| 99 | TCMU use case, except instead of a physical device, TCMU implements a | ||
| 100 | memory-mapped layout designed for SCSI commands. Using UIO also | ||
| 101 | benefits TCMU by handling device introspection (e.g. a way for | ||
| 102 | userspace to determine how large the shared region is) and signaling | ||
| 103 | mechanisms in both directions. | ||
| 104 | |||
| 105 | There are no embedded pointers in the memory region. Everything is | ||
| 106 | expressed as an offset from the region's starting address. This allows | ||
| 107 | the ring to still work if the user process dies and is restarted with | ||
| 108 | the region mapped at a different virtual address. | ||
| 109 | |||
| 110 | See target_core_user.h for the struct definitions. | ||
| 111 | |||
| 112 | The Mailbox: | ||
| 113 | |||
| 114 | The mailbox is always at the start of the shared memory region, and | ||
| 115 | contains a version, details about the starting offset and size of the | ||
| 116 | command ring, and head and tail pointers to be used by the kernel and | ||
| 117 | userspace (respectively) to put commands on the ring, and indicate | ||
| 118 | when the commands are completed. | ||
| 119 | |||
| 120 | version - 1 (userspace should abort if otherwise) | ||
| 121 | flags - none yet defined. | ||
| 122 | cmdr_off - The offset of the start of the command ring from the start | ||
