1408 Commits

Author SHA1 Message Date
mav
c09a8b3510 MFC r268287:
Implement and use ctl_frontend_find().
2014-07-15 17:00:41 +00:00
mav
7da5c8a0d6 MFC r268284:
Introduce new IOCTL CTL_PORT_LIST reporting in more flexible XML format.

Leave old CTL_GET_PORT_LIST in place so far.  Garbage-collect it later.
2014-07-15 16:59:46 +00:00
mav
639ef1613c MFC r268280:
Make options KPI more generic to allow it to be used for ports too,
not only for LUNs.
2014-07-15 16:58:38 +00:00
mav
8bfe00fd8a MFC r268266, r268275:
Separate concepts of frontend and port.

Before iSCSI implementation CTL had no knowledge about frontend drivers,
it had only frontends, which really were ports (alike to LUNs, if comparing
to backends).  But iSCSI added there ioctl() method, which does not belong
to frontend as a port, but belongs to a frontend driver.
2014-07-15 16:57:30 +00:00
mav
e396aeead5 MFC r268265:
Remove targ_enable()/targ_disable() frontend methods.

Those methods were never implemented, and I believe that their concept is
wrong, since single frontend (SCSI port) can not handle several targets.
2014-07-15 16:55:13 +00:00
mav
75f2a98771 MFC r268103:
Add support for REPORT TIMESTAMP command.
2014-07-15 16:54:04 +00:00
mav
da977d4032 MFC r268096, r268306, r268361:
Add more formal and strict command parsing and validation.

For every supported command define CDB length and mask of bits that are
allowed to be set.  This allows to remove bunch of checks through the code
and still make the validation more strict.  To properly do it for commands
supporting multiple service actions, formalize their parsing by adding
subtables for each of such commands.

As visible effect, this change allows to add support for REPORT SUPPORTED
OPERATION CODES command, reporting to client all the data about supported
SCSI commands, except timeouts.
2014-07-15 16:53:04 +00:00
mav
a64cd56a0c MFC r267639:
Increase CTL_DEVID_LEN from 16 to 64 bytes.

SPC-4 recommends T10 vendor ID based LUN ID was created by concatenating
product name and serial number (and istgt follows that).  But product name
is 16 bytes long by itself, so 16 bytes total length is clearly not enough
to fit both.

To keep compatibility with existing configurations, pad short device IDs
to old length of 16, same as before.

This change probably breaks CTL user-level ABI, so control tools should
be rebuilt after this change.
2014-07-15 16:49:35 +00:00
mav
fe5b2cf89f MFC r267643, r267873, r268391, r268398:
Introduce fine-grained CTL locking to improve SMP scalability.

Split global ctl_lock, historically protecting most of CTL context:
 - remaining ctl_lock now protects lists of fronends and backends;
 - per-LUN lun_lock(s) protect LUN-specific information;
 - per-thread queue_lock(s) protect request queues.
This allows to radically reduce congestion on ctl_lock.

Create multiple worker threads, depending on number of CPUs, and assign
each LUN to one of them.  This allows to spread load between multiple CPUs,
still avoiging congestion on queues and LUNs locks.

On 40-core server, exporting 5 LUNs, each backed by gstripe of SATA SSDs,
accessed via 6 iSCSI connections, this change improves peak request rate
from 250K to 680K IOPS.

Sponsored by:	iXsystems, Inc.
2014-07-12 04:34:39 +00:00
mav
48e8be2fd2 MFC r268283:
Improve readability of XML generated by CTL_LUN_LIST.
2014-07-12 02:40:25 +00:00
mav
59eea8bc78 MFC r268392:
Do not return statuses for aborted iSCSI commands.
2014-07-12 02:33:03 +00:00
mav
593a15490b MFC r268204:
Use separate memory type M_CTLIO for I/Os.

CTL allocate large amount of RAM.  This change give some more stats.
2014-07-12 02:29:33 +00:00
mav
e1151dc51c MFC r267933:
Simplify statistics calculation.

Instead of trying to guess size of disk I/O operations (it just won't work
that way for newly added commands, and is equal to data move size for old
ones), account data move traffic.  If disk I/Os are that interesting, then
backends have to account and provide that information.

Block backend already exports the information about disk I/Os via devstat,
so having it here too is excessive.
2014-07-12 02:28:11 +00:00
mav
dcab9610fe MFC r267906:
Allow MODE SENSE commands through Write Exclusive persistent reservation,
as required by SPC-4.

Report that fact in persistent reservation capabilities.
2014-07-12 02:26:11 +00:00
mav
38fbbeedce MFC r267905:
Add READ BUFFER and improve WRITE BUFFER SCSI commands support.

This gives some use to 512KB per-LUN buffers, allocated for Copan-specific
processor code and not used.  It allows, for example, to test transport
performance and/or correctness without accessing the media, as supported
by Linux version of sg3_utils.
2014-07-12 02:24:52 +00:00
mav
a52f21b413 MFC r267877:
Lock devstat updates in block backend to make it usable.  Polish lock names.
2014-07-12 02:17:10 +00:00
mav
51dd83f4d5 MFC r268419:
Fix use-after-free on XPT_RESET_BUS.

That command is not queued, so does not use later status update.
2014-07-12 02:03:29 +00:00
mav
95c9d23391 MFC r267986:
Remove odd practice of inverting error codes.

-EPERM is equal to ERESTART, returning which from ioctl() handler causes
infinite syscall restart.
2014-07-12 01:59:07 +00:00
mav
dc2d478426 MFC r267641:
Add some more CTL_FLAG_ABORT check points.

This should allow to abort commands doing mostly disk I/O, such as VERIFY
or WRITE SAME.  Before this change CTL_FLAG_ABORT was only checked around
data moves, which for these commands may not happen for a very long time.
2014-07-04 16:11:30 +00:00
mav
37a9790756 MFC r267637:
Add iSCSI Target Name ID descriptor to VPD 83h.

It shall/should be there according to SPC-4, and istgt also provides it.
2014-07-04 16:10:14 +00:00
mav
8eb696c14e MFC r267610 (by trasz):
Rework session termination in iSCSI target to actually wait
for any outstanding commands to be properly aborted by CTL.
Without it, in some cases (such as files backing the LUNs
stored on failing disk drives), terminating a busy session
would result in panic.
2014-07-04 16:09:09 +00:00
mav
f736ccce13 MFC r267574 (by trasz):
Make cs_terminating a bool; no functional changes.
2014-07-04 16:07:57 +00:00
mav
cfae63c84f MFC r267547, r267551 (by trasz):
Add LUN-associated name to VPD, to make Hyper-V Failover Cluster happy.
2014-07-04 16:06:56 +00:00
mav
526d9691dc MFC r267051:
- Add support for SG_GET_SG_TABLESIZE IOCTL to report that we don't support
scatter/gather lists.
- Return error for still unsupported SG 3.x API read/write calls.
2014-07-04 15:09:56 +00:00
mav
2019810069 MFC r267537:
Add support for VERIFY(10/12/16) and COMPARE AND WRITE SCSI commands.

Make data_submit backends method support not only read and write requests,
but also two new ones: verify and compare.  Verify just checks readability
of the data in specified location without transferring them outside.
Compare reads the specified data and compares them to received data,
returning error if they are different.

VERIFY(10/12/16) commands request either verify or compare from backend,
depending on BYTCHK CDB field.  COMPARE AND WRITE command executed in two
stages: first it requests compare, and then, if succeesed, requests write.
Atomicity of operation is guarantied by CTL request ordering code.

Sponsored by:	iXsystems, Inc.
2014-07-02 10:45:31 +00:00
mav
ada40bacc7 MFC r267519:
Make backends track completion by processed number of sectors instead of
total transfer size.

Commands such as VERIFY or COMPARE AND WRITE may have transfer size not
matching directly to number of sectors.
2014-07-02 10:43:53 +00:00
mav
15c36a3817 MFC r267515:
Remove memcpy() from ctl_private[] accesses.

That union is aligned enough to access data directly.
2014-07-02 10:42:43 +00:00
mav
27197291fa MFC r267514:
Move kern_total_len setting from backend to core code.
2014-07-02 10:41:11 +00:00
mav
cf9ef68328 MFC r267500:
Format Portal Group Tag same as istgt does -- %4.4x instead of %x.

SPC-4 spec tells it should be "two or more hexadecimal digits".
RFC3720 tells it is 16-bit value.
2014-07-02 10:39:45 +00:00
mav
9389599de5 MFC r267499:
Remove custom processing for "file" option.
2014-07-02 10:38:22 +00:00
mav
eeaafb7fba MFC r267496, r267498:
Add "vendor", "product" and "revision" options to control inquiry data.
2014-07-02 10:37:22 +00:00
mav
a615b5284a MFC r267485:
Remove non-functional remnants of control LUN -- 18MB of RAM for nothing.
2014-07-02 10:36:04 +00:00
mav
a7e3ab1dac MFC r267481, r267952:
Implement small KPI to access LUN options instead doing it by hands.
2014-07-02 10:35:06 +00:00
mav
f77bfe41e2 MFC r265323 (by trasz):
Provide better descriptions for 'struct ctl_scsiio' fields; based mostly
on emails from ken@.
2014-07-02 10:32:44 +00:00
mav
9922777340 MFC r267872:
Allow to use iSCSI immediate data by several ctl_datamove() calls.

While for FreeBSD client that is only a minor optimization, VMWare client
doesn't support additional data requests after all data being sent once as
immediate.
2014-07-02 10:20:08 +00:00
mav
927a52fbbf MFC r266981:
Overhaul CAM SG driver IOCTL interfaces.

Make it really work for native FreeBSD programs.  Before this it was broken
for years due to different number of pointer dereferences in Linux and
FreeBSD IOCTL paths, permanently returning errors to FreeBSD programs.
This change breaks the driver FreeBSD IOCTL ABI, making it more strict,
but since it was not working any way -- who bother.

Add shims for 32-bit programs on 64-bit host, translating the argument
of the SG_IO IOCTL for both FreeBSD and Linux ABIs.

With this change I was able to run 32-bit Linux sg3_utils tools and simple
32 and 64-bit FreeBSD test tools on both 32 and 64-bit FreeBSD systems.
2014-07-02 10:16:12 +00:00
marius
27080bb5dd MFC: r267638
Don't denounce peripherals on system shutdown. Together with r267321
(MFCed to stable/10 in r267775), we're now back to the pre-r228483
level of default verbosity. This in turn again typically allows for
reading information that userland might have printed on the screen
before initiating a halt, but still permits to debug potential device
shutdown problems on system shutdown via CAM_DEBUG etc.

Reviewed by:	mav
Sponsored by:	Bally Wulff Games & Entertainment GmbH
2014-06-23 08:32:36 +00:00
mav
afa2d243ef MFC r267429:
Fix some leaks on LUN creation error.
2014-06-22 21:28:05 +00:00
mav
8c42300872 MFC r265159:
Respect MAXIMUM TRANSFER LENGTH field of Block Limits VPD page.

Nobody yet reported disk supporting I/Os less then our MAXPHYS value, but
since we any way have code to read Block Limits VPD page, that is easy.
2014-05-08 07:13:22 +00:00
mav
878513ca7d MFC r265150:
Do not reread SCSI disk VPD pages on every device open.

Instead of rereading VPD pages on every device open, do it only on initial
device probe, and in cases when device reported via UNIT ATTENTIONs that
something has changed.  Capacity is still rereaded on every open because
it is more critical for operation and more probable to change in run time.

On my tests with Intel 530 SSDs on mps(4) HBA this change reduces time
GEOM needs to retaste the device (that includes few open/close cycles)
from ~150ms to ~30ms.
2014-05-08 07:12:06 +00:00
mav
c2e87a8026 MFC r264886:
Remove limits on size of READ/WRITE operations.

Instead of allocating up to 16MB or RAM at once to handle whole I/O,
allocate up to 1MB at a time, but do multiple ctl_datamove() and storage
I/Os if needed.
2014-05-08 07:10:38 +00:00
mav
e2d7108ca8 MFC r264884:
Make CAM target CTL frontend respect SIM I/O size limitations.

If datamove size is bigger then SIM can handle, or it has more segments
then this code can handle -- split it into several CTIO requests.
2014-05-08 07:08:47 +00:00
mav
84e0de396e MFC r264880 (by trasz):
Modify CTL iSCSI frontend to properly handle situations where datamove
routine is called multiple times per SCSI task.
2014-05-08 07:07:51 +00:00
mav
df5d1f3a9b MFC r264834:
Disable UNMAP support for STEC 842 SSDs.

In some unknown cases UNMAP commands make device firmware stuck.
2014-05-08 07:05:19 +00:00
mav
1252c77788 MFC r264407:
Join CTL worker threads into one process for convenience.
Report their idle state as "-".
2014-05-08 07:04:13 +00:00
mav
9f15393e22 MFC r264406:
Report more readable state "-" for idle CAM scan thread.
2014-05-08 07:01:54 +00:00
mav
2d5dc4736b MFC r264274, r264279, r264283, r264296, r264297:
Add support for SCSI UNMAP commands to CTL.

This patch adds support for three new SCSI commands: UNMAP, WRITE SAME(10)
and WRITE SAME(16).  WRITE SAME commands support both normal write mode
and UNMAP flag.  To properly report UNMAP capabilities this patch also adds
support for reporting two new VPD pages: Block limits and Logical Block
Provisioning.

UNMAP support can be enabled per-LUN by adding "-o unmap=on" to `ctladm
create` command line or "option unmap on" to lun sections of /etc/ctl.conf.

At this moment UNMAP supported for ramdisks and device-backed block LUNs.
It was tested to work great with ZFS ZVOLs.  For file-backed LUNs UNMAP
support is unfortunately missing due to absence of respective VFS KPI.

Sponsored by:   iXsystems, Inc
2014-05-08 07:00:45 +00:00
mav
246a5ae3a0 MFC r260509:
Replace several instances of -1 with appropriate CAM_*_WILDCARD and types.

It was equal before r259397, but for good or bad, not any more for LUNs.

This change fixes at least CAM debugging.
2014-05-08 06:55:48 +00:00
trasz
21ec0cf2d0 MFC r264530:
Properly pass the initiator address when running in proxy mode.

Sponsored by:	The FreeBSD Foundation
2014-05-07 07:37:55 +00:00
trasz
1abd1411d7 MFC r264527:
Make it possible to interrupt login when running in proxy mode.

Sponsored by:	The FreeBSD Foundation
2014-05-07 07:33:56 +00:00