Commit Graph

205 Commits

Author SHA1 Message Date
Alexander Motin
de988746be Add support for READ BUFFER(16) command. 2015-09-24 07:16:34 +00:00
Alexander Motin
ca85b7c4e9 Synchronize mode pages between HA peers.
We allow to modify only few fields in mode pages now, but still it is
not good if they unexpectedly change during failover.  Also this fixes
reporting of "Mode parameters changed" UAs on secondary node.
2015-09-23 18:33:00 +00:00
Alexander Motin
a85700a912 Make HA peers announce their parameters on connect.
HA protocol requires strict version, parameters and configuration match.
Differences there may cause full set of problems up to kernel panic.
To avoid that, validate peer parameters on connect, and abort connection
immediately if some mismatch detected.
2015-09-23 15:49:27 +00:00
Alexander Motin
c53993057b Add support for Control extension mode page. 2015-09-22 14:55:46 +00:00
Alexander Motin
921af50782 Always execute REPORT LUNS and REQUEST SENSE commands locally.
REPORT LUNS command is more related to target rather then specific LUN.
This node may be primary for LUNs for some reason unknown to another,
and command forwarded to another node won't be able to report them.

REQUEST SENSE is related to LUN, but in our implementation it reports
only UAs and CAs, that are stored locally rather then on primary node.
2015-09-19 19:30:55 +00:00
Alexander Motin
efbf6139a4 Split two command flags with different meaning.
This is only a cosmetical change.
2015-09-19 19:11:59 +00:00
Alexander Motin
6861045bda Fix memory corruption when >128K transferred through HA link.
While there, do some cleaning.
2015-09-19 13:12:09 +00:00
Alexander Motin
bc8749e2ff Mark I/Os with DMA flag while moving data through the HA link. 2015-09-18 20:11:10 +00:00
Alexander Motin
75a3108e13 Relax serseq option operation for reads.
Previously, with serseq enabled, next command was unblocked only after
previous completed.  With this change, for read operations, next command
is unblocked as soon as last media read completed.  This is important
for frontends that actually wait for data move completion (like camtgt),
or when data are moved through the HA link, or especially when both.
2015-09-18 19:43:14 +00:00
Alexander Motin
59bb97a934 Kill HA link and shutdown the threads on shutdown. 2015-09-18 12:08:00 +00:00
Alexander Motin
0c05f0dc16 Replicate initiators WWPNs and names between HA peers. 2015-09-17 21:51:11 +00:00
Alexander Motin
54713bce25 Replicate port->init_devid to HA peer. 2015-09-17 20:36:34 +00:00
Alexander Motin
6213882769 When reporting TPT UA, report which of thresholds was reached. 2015-09-17 17:00:36 +00:00
Alexander Motin
7f7bb97a0f Report proper medium error code for VERIFY commands. 2015-09-17 12:52:18 +00:00
Alexander Motin
923863546a Close potential race between datamove and HA failover. 2015-09-15 09:36:46 +00:00
Alexander Motin
d0f25804a7 Implement data/status aggregation for secondary HA node.
For short read requests this reduces latency by 30%, reporting command
completion after two interlink roundtrips instead of full three.
2015-09-14 15:21:23 +00:00
Alexander Motin
7b6660c9aa Remove CTL_PRIV_LBA_LEN from HA messages.
Previously it was used for statistics, but now just a 16 extra bytes.
2015-09-14 09:56:01 +00:00
Alexander Motin
ceff31dc0c Implement QUERY TASK, QUERY TASK SET and QUERY ASYNC EVENT.
Now we support most of SAM-5 task management.
2015-09-14 08:01:05 +00:00
Alexander Motin
6187d4722a Improve read-only support. 2015-09-13 16:49:41 +00:00
Alexander Motin
6b56dd0cfa Reannounce port to HA peer if LUN map changed after online. 2015-09-13 15:31:55 +00:00
Alexander Motin
cfa0987386 Report INQUIRY DATA HAS CHANGED for related LUNs on port on-/offline. 2015-09-13 14:52:31 +00:00
Alexander Motin
eebde34629 Report CTL_UA_LUN_CHANGE on LUN map change. 2015-09-13 14:04:42 +00:00
Alexander Motin
844c2a3a94 Make TARGET RESET respect LUN mapping. 2015-09-13 13:00:20 +00:00
Alexander Motin
051481a24e Add HA support for CTL_TASK_I_T_NEXUS_RESET. 2015-09-12 20:06:22 +00:00
Alexander Motin
0a4c638188 Fix false CTL_UA_RES_RELEASE on secondary HA node. 2015-09-12 18:29:05 +00:00
Alexander Motin
e184d2576a Some HA polishing. 2015-09-12 12:46:04 +00:00
Alexander Motin
572846e089 Make ctld restart on primary HA node less invasive for secondary. 2015-09-11 14:47:35 +00:00
Alexander Motin
7ac58230ea Reimplement CTL High Availability.
CTL HA functionality was originally implemented by Copan many years ago,
but large part of the sources was never published.  This change includes
clean room implementation of the missing code and fixes for many bugs.

This code supports dual-node HA with ALUA in four modes:
 - Active/Unavailable without interlink between nodes;
 - Active/Standby with second node handling only basic LUN discovery and
reservation, synchronizing with the first node through the interlink;
 - Active/Active with both nodes processing commands and accessing the
backing storage, synchronizing with the first node through the interlink;
 - Active/Active with second node working as proxy, transfering all
commands to the first node for execution through the interlink.

Unlike original Copan's implementation, depending on specific hardware,
this code uses simple custom TCP-based protocol for interlink.  It has
no authentication, so it should never be enabled on public interfaces.

The code may still need some polishing, but generally it is functional.

Relnotes:	yes
Sponsored by:	iXsystems, Inc.
2015-09-10 12:40:31 +00:00
Alexander Motin
fb606ebabc Remove unused target and initiator IDs. 2015-09-10 10:46:21 +00:00
Alexander Motin
3f326305fc Disable CTL_IO_DELAY feature.
It is too developer-oriented to be enabled by default.
2015-09-10 09:27:22 +00:00
Alexander Motin
0bcd4ab6ba Move setting of media parameters inside open routines.
This is preparation for possibility to open/close media several times
per LUN life cycle.  While there, rename variables to reduce confusion.
As additional bonus this allows to open read-only media, such as ZFS
snapshots.
2015-09-06 09:54:56 +00:00
Alexander Motin
420abfcecd Small UA cleanup. 2015-09-03 12:56:57 +00:00
Alexander Motin
8be6a2df51 Fix copy-paste bug introduced in r275458.
MFC after:	3 days
2015-09-03 12:15:14 +00:00
Alexander Motin
1b7849d0f2 Make most of port methods optional and remove bunch of dummies. 2015-09-01 16:28:06 +00:00
Alexander Motin
67ceb24bca Move "ioctl" CAM frontend into separate file.
It has nothing to share with too huge ctl.c other then device descriptor,
but even that may be counted as design error that may be fixed later.
At some point we may even want to have several ioctl ports.
2015-08-15 15:42:21 +00:00
Alexander Motin
2f444d157b Drop "internal" CTL frontend.
Its idea was to be a simple initiator and execute several commands from
kernel level, but FreeBSD never had consumer for that functionality,
while its implementation polluted many unrelated places..
2015-08-15 13:34:38 +00:00
Alexander Motin
4ddb055594 Remove verbose CTL messages.
Reporting SCSI errors to console is often useless, pollutes logs and may
affect performance.  For debugging there is kern.cam.ctl.debug sysctl

MFC after:	1 week
2015-08-09 09:54:29 +00:00
Alexander Motin
3301406331 Add more ifdefs to fix build with GCC after r286406. 2015-08-07 14:12:51 +00:00
Marcelo Araujo
8b3ae99560 Wrap some unused functions with notyet, it is necessary to be able to
build the modules/ctl directly.
Remove a dead MALLOC_DEFINE.

Differential Revision:	D3329
Reviewed by:		mav
Sponsored by:		gandi.net
2015-08-07 08:30:43 +00:00
Alexander Motin
7d0d4342e3 Pass SYNCHRONIZE CACHE command parameters to backends.
At this point IMMED flag is translated to MNT_NOWAIT flag of VOP_FSYNC(),
hoping that file system implements that (ZFS seems doesn't).

MFC after:	2 weeks
Sponsored by:	iXsystems, Inc.
2015-08-05 22:24:49 +00:00
Alexander Motin
1ec1012dd2 Fix REPORT LUNS command output for the case when same LUN mapped to same
port several times.  While it is unusual configuration, it is not illegal.

MFC after:	1 week
2015-06-20 13:02:57 +00:00
Alexander Motin
7834ea8891 Bring per-port LUN enable/disable code up to date:
- remove last remnants of never implemented multiple targets support;
 - implement missing support for LUN mapping in this area.

Due to existing locking constraints LUN mapping code is practically
unlocked at this point.  Hopefully it is not racy enough to live until
somebody get idea how to call sleeping fronend methods under lock also
taken by the same frontend in non-sleepable context. :(
2015-06-20 12:43:54 +00:00
Alexander Motin
754e493530 Remove some dead and duplicate LUN enabling code. 2015-06-20 07:33:06 +00:00
Alexander Motin
6fbc43fdfb Fix wrong function name in error message.
MFC after:	3 days
2015-06-05 20:30:36 +00:00
Kenneth D. Merry
873da79689 Remove some #if 0'ed code that apparently confuses cscope.
Requested by:	Peter Xu <xzpeter@gmail.com>
MFC after:	3 days
2015-03-24 21:42:28 +00:00
Alexander Motin
b7fc0d6732 Do not dereference NULL clearing UA that was not set in r277917.
MFC after:	3 days
2015-02-11 22:03:23 +00:00
Alexander Motin
2c8cab2a4e Add support for General Statistics and Performance log page.
CTL already collects most of statistics reported there, so why not.

MFC after:	2 weeks
2015-02-11 16:10:31 +00:00
Alexander Motin
aecb7ac16f Do not abort already aborted tasks.
This fixes abort of new tasks with the same tags as previously aborted,
but still remaining on the queue.

MFC after:	1 week
2015-02-10 11:37:32 +00:00
Alexander Motin
920c6cbadc CTL LUN mapping rewrite.
Replace iSCSI-specific LUN mapping mechanism with new one, working for any
ports.  By default all ports are created without LUN mapping, exposing all
CTL LUNs as before.  But, if needed, LUN mapping can be manually set on
per-port basis via ctladm.  For its iSCSI ports ctld does it via ioctl(2).
The next step will be to teach ctld to work with FibreChannel ports also.

Respecting additional flexibility of the new mechanism, ctl.conf now allows
alternative syntax for LUN definition.  LUNs can now be defined in global
context, and then referenced from targets by unique name, as needed.  It
allows same LUN to be exposed several times via multiple targets.

While there, increase limit for LUNs per target in ctld from 256 to 1024.
Some initiators do not support LUNs above 255, but that is not our problem.

Discussed with:	trasz
MFC after:	2 weeks
Relnotes:	yes
Sponsored by:	iXsystems, Inc.
2015-02-01 21:50:28 +00:00
Kenneth D. Merry
e761f855a0 Improve SCSI Extended Inquiry VPD page (0x86) support.
sys/cam/scsi/scsi_all.h:
	In struct scsi_extended_inquiry_data:
	- Increase the length field to 2 bytes, as it is 2 bytes in SPC-4.
	- Add bit definitions for the various Activiate Microcode actions.
	- Add the Sequential Access Logical Block Protection support bit,
	  since we need that in the sa(4) driver.  (For modifications
	  that will come later.)
	- Add definitions for the various Multi I_T Nexus Microcode
	  Download modes.

sys/cam/ctl/ctl.c:
	As of SPC-4, a single report of "REPORTED LUNS DATA HAS CHANGED"
	is to be given per I_T nexus.  Once it is reported, the unit
	attention condition should be cleared for all LUNS attached to
	an I_T nexus.

	Previously that only happened when a REPORT LUNS command was
	processed.

	This behavior may be different (according to SAM-5) when the
	UA_INTLCK_CTRL bits are non-zero in the control mode page but
	CTL does not currently support that.

	So, in view of the spec, whenever we report a LUN inventory
	change unit attention, clear it on all LUNs for that
	particular I_T nexus.

	Add a new function, ctl_clear_ua() that will clear a unit
	attention on all LUNs for the given I_T nexus.

	One field in the extended inquiry data that we could potentially
	report at some point is the maximum supported sense data length.
	To do that, we would the SIM to report (via path inquiry
	perhaps) how much sense data it is able to send.

	Add comments to explain some of the bits that are set in the
	Extended Inquiry VPD page.

	Add a few comments to make it more clear which functions handle
	various VPD pages.

Sponsored by:	Spectra Logic
MFC after:	1 week
2015-01-30 05:23:39 +00:00