1389 Commits

Author SHA1 Message Date
mav
0c8d93565f MFC r269441:
Add missing comparisons to make list IDs in EXTENDED COPY per-initiator,
as they should be.  Wrap it into a function to not duplicate the code.
2014-08-05 08:28:29 +00:00
mav
c1cec10724 MFC r269123:
Implement separate I/O dispatch method for ZVOLs in "dev" mode.

Unlike disk devices ZVOLs process all requests synchronously.  That makes
impossible sending multiple requests to them from single thread.  From the
other side ZVOLs have real d_read/d_write methods, which unlike d_strategy
can handle uio scatter/gather and have no strict I/O size limitations.

So, if ZVOL in "dev" mode is detected, use of d_read/d_write methods instead
of d_strategy allows to avoid pointless splitting of large requests into
MAXPHYS (128K) sized chunks.
2014-08-02 06:56:00 +00:00
mav
375621a9a5 MFC r268808:
Increase maximal number of SCSI ports in CTL from 32 to 128.

After I gave each iSCSI target its own port, the old limit appeared to be
not so big.  This change almost proportionally increases per-LUN memory
use, but it is still three times better then it was before r268807.
2014-07-30 07:21:30 +00:00
mav
16407addf1 MFC r268807:
Reduce per-LUN memory usage from 18MB to 1.8MB.

CTL never had use for CA support code since SPI has gone, and there is no
even frontends supporting that.  But it still was reserving 256 bytes of
memory per LUN per every possible initiator on every possible port.

Wrap unused code with ifdef's in case somebody ever need it.
2014-07-30 07:20:36 +00:00
mav
dd34ac0859 MFC r268767:
Add support for VMWare dialect of EXTENDED COPY command, aka VAAI Clone.

This allows to clone VMs and move them between LUNs inside one storage
host without generating extra network traffic to the initiator and back,
and without being limited by network bandwidth.

LUNs participating in copy operation should have UNIQUE NAA or EUI IDs set.
For LUNs without these IDs VMWare will use traditional copy operations.

Beware: the above LUN IDs explicitly set to values non-unique from the VM
cluster point of view may cause data corruption if wrong LUN is addressed!

Sponsored by:	iXsystems, Inc.
2014-07-30 07:18:32 +00:00
mav
1c2891173e MFC r268581:
Merge several equal serialization indexes.
2014-07-30 07:16:08 +00:00
mav
9418843a93 MFC r269149:
Fix several cases of NULL dereference when INQUIRY sent to absent LUN.
2014-07-30 07:08:59 +00:00
mav
e6ff5c766b MFC r269122:
Fix infinite loop, when doing WRITE SAME on file-backed LUN.
2014-07-29 07:40:14 +00:00
trasz
24c4578f54 MFC r269088:
Fix ctl(4) kldload failure that manifested like this:

link_elf_obj: symbol icl_pdu_new_bhs undefined

PR:		192031
Submitted by:	Nils Beyer (earlier version)
Sponsored by:	FreeBSD Foundation
2014-07-28 22:25:27 +00:00
mav
7219c9daf2 MFC r269058:
Fix build with QUEUE_MACRO_DEBUG.
2014-07-27 08:02:24 +00:00
imp
0dacc9824c MFC:
>r267118 | imp | 2014-06-05 11:13:42 -0600 (Thu, 05 Jun 2014) | 9 lines
>The code that combines adjacent ranges for BIO_DELETEs to optimize
>trims to the device assumes the list is sorted. Don't apply the
>optimization of not sorting the queue when we have SSDs to the
>delete_queue, since it causes more discard traffic to the drive. While
>one could argue that the higher levels should coalesce the trims,
>that's not done today, so some optimization at this level is needed.
>CR: https://phabric.freebsd.org/D142
2014-07-17 23:05:20 +00:00
imp
ae99afdd7d MFC:
>r268205 | imp | 2014-07-02 23:22:13 -0600 (Wed, 02 Jul 2014) | 9 lines
>Rework the BIO_DELETE code slightly. Always queue the BIO_DELETE
>requests on the trim_queue, even for the CFA ERASE. This allows us, in
>the future, to collapse adjacent requests. Since CFA ERASE is only for
>CF cards, and it is so restrictive in what it can do, the collapse
>code is not presently here. This also brings the ada driver more in
>line with the da driver's treatment of BIO_DELETEs.
2014-07-17 22:58:05 +00:00
mav
2c6230a1ad MFC r268240 (by ken):
Add persistent reservation support to camcontrol(8).

camcontrol(8) now supports a new 'persist' subcommand that allows users to
issue SCSI PERSISTENT RESERVE IN / OUT commands.
2014-07-15 17:26:43 +00:00
mav
c0be426ce6 MFC r268447:
Add LUN options to specify 64-bit EUI and NAA identifiers.
2014-07-15 17:20:40 +00:00
mav
68cf85bc2c MFC r268421:
Remove status setting from datamove() path.  Leave that to other places.
2014-07-15 17:19:43 +00:00
mav
1e9a14c2c4 MFC r268418:
Enable TAS feature: notify initiator if its command was aborted by other.

That should make operation more kind to multi-initiator environment.
Without this, other initiators may find out that something bad happened
to their commands only via command timeout.
2014-07-15 17:18:50 +00:00
mav
05919e7e4c MFC r268387:
Fix task management functions status: task not found is not an error,
while not implemented function is.
2014-07-15 17:17:52 +00:00
mav
870d4a24fe MFC r268364:
Fix "use after free" on port creation error in r268291.
2014-07-15 17:16:58 +00:00
mav
7bd4e3c249 MFC r268363:
Add support for READ FULL STATUS action of PERSISTENT RESERVE IN command.
2014-07-15 17:16:06 +00:00
mav
342f128143 MFC r268362:
Teach ctl_add_initiator() to dynamically allocate IIDs from pool.

If port passed negative IID value, the function will try to allocate IID
from the pool of unused, based on passed wwpn or name arguments.  It does
all its best to make IID unique and persistent across reconnects.

This makes persistent reservation properly work for iSCSI.  Previously,
in case of reconnects, reservation could be unexpectedly lost, or even
migrate between intiators.
2014-07-15 17:14:53 +00:00
mav
14a59860bb MFC r268356, r268357:
When new connection comes in, check whether we already have session from
the same intiator (Name+ISID).  If so -- terminate the old session and let
the new one take its place, as required by iSCSI RFC.
2014-07-15 17:13:49 +00:00
mav
a0bee6cdf5 MFC r268353:
Implement ABORT TASK SET and I_T NEXUS RESET task management functions.

Use the last one to terminate active commands on iSCSI session termination.
Previous code was aborting only commands doing some data moves.
2014-07-15 17:12:37 +00:00
mav
ebf361d529 MFC r268330:
Make gcc happy, init idlen2.
2014-07-15 17:11:42 +00:00
mav
100d0f0aa6 MFC r268328:
Close race in r268291 between port destruction, delayed by sessions
teardown, and new port creation during `service ctld restart`.

Close it by returning iSCSI port internal state, that allows to identify
dying ports, which should not be counted as existing, from really alive.
2014-07-15 17:10:48 +00:00
mav
247c4d2053 MFC r268309:
Add support for SCSI Ports (88h) VPD page.
2014-07-15 17:09:52 +00:00
mav
938fb0a5f5 MFC r268308:
Make REPORT TARGET PORT GROUPS command report realistic data instead of
hardcoded garbage.
2014-07-15 17:09:02 +00:00
mav
6cb3a6ad50 MFC r268307:
Move lun_map() method from command nexus to port.

Previous implementation made impossible to do some things, such as calling
it for ports other then one through which command arrived.
2014-07-15 17:08:04 +00:00
mav
0468376762 MFC r268302:
Pass through iSCSI session ISID from LOGIN request to the CTL frontend.

ISID is an important part of initiator transport ID for iSCSI.  It is not
used now, but should be to properly implement persistent reservation.
2014-07-15 17:07:07 +00:00
mav
f1200cac15 MFC r268293:
Burry devid port method, which was a gross hack.

Instead make ports provide wanted port and target IDs, and LUNs provide
wanted LUN IDs.  After that core Device ID VPD code only had to link all
of them together and add relative port and port group numbers.

LUN ID for iSCSI LUNs no longer created by CTL, but by ctld, and passed
to CTL as "scsiname" LUN option.  This makes LUNs to report the same set
of IDs, independently from the port through which it is accessed, as
required by SCSI specifications.
2014-07-15 17:06:10 +00:00
mav
b40b547aa1 MFC r268291:
Create separate CTL port for every iSCSI target (and maybe portal group).

Having single port for all iSCSI connections makes problematic implementing
some more advanced SCSI functionality in CTL, that require proper ports
enumeration and identification.

This change extends CTL iSCSI API, making ctld daemon to control list of
iSCSI ports in CTL.  When new target is defined in config fine, ctld will
create respective port in CTL.  When target is removed -- port will be
also removed after all active commands through that port properly aborted.
This change require ctld to be rebuilt to match the kernel.

As a minor side effect, this allows to have iSCSI targets without LUNs.
While that may look odd and not very useful, that is not incorrect.
2014-07-15 17:05:11 +00:00
mav
5df1093df8 MFC r268288:
Improve CTL_BEARG_* flags support, including optional values copyout.
2014-07-15 17:01:39 +00:00
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