Commit Graph

335 Commits

Author SHA1 Message Date
Alexander Motin
a3977bea20 Allow LUN options modification via CTL_LUNREQ_MODIFY.
Not all changes take effect, but that is a different question.
2015-09-06 11:23:01 +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
bd236ba5c0 Remove some dead code. 2015-09-04 09:19:01 +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
7278725be5 Remove 600 bytes of port_priv from struct ctl_io_hdr.
This field used only for camtgt frontend, and once it any way preallocates
all requests, let it preallocate this memory too, not bothering core code.
2015-08-29 15:33:31 +00:00
Alexander Motin
f6295033c1 Fix type bug introduced at r286811. 2015-08-27 21:16:24 +00:00
Alexander Motin
a15bbf1508 Polish sizes processing. 2015-08-15 18:22:16 +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
f2a20b166a Relax serialization of SYNCHRONIZE CACHE commands.
Before this change SYNCHRONIZE CACHE commands were executed exclusively,
as if they had ORDERED tag.  But looking through SCSI specs I've found
no any reason to be so strict.  For reads this ordering seems pointless.
For writes it looks less obvious, so I left ordering against preceeding
write commands, while following ones are no longer required to wait.

MFC after:	2 weeks
Sponsored by:	iXsystems, Inc.
2015-08-05 21:58:32 +00:00
Alexander Motin
73942c5ce0 Issue all reads of single XCOPY segment simultaneously.
During vMotion and Clone VMware by default runs multiple sequential 4MB
XCOPY requests same time.  If CTL issues reads sequentially in 1MB chunks
for each XCOPY command, reads from different commands are not detected
as sequential by serseq option code and allowed to execute simultaneously.
Such read pattern confused ZFS prefetcher, causing suboptimal disk access.
Issuing all reads same time make serseq code work properly, serializing
reads both within each XCOPY command and between them.

My tests with ZFS pool of 14 disks in RAID10 shows prefetcher efficiency
improved from 37% to 99.7%, copying speed improved by 10-60%, average
read latency reduced twice on HDD layer and by five times on zvol layer.

MFC after:	2 weeks
Sponsored by:	iXsystems, Inc.
2015-08-05 13:46:15 +00:00
Mateusz Guzik
8a08cec166 Create a dedicated function for ensuring that cdir and rdir are populated.
Previously several places were doing it on its own, partially
incorrectly (e.g. without the filedesc locked) or even actively harmful
by populating jdir or assigning rootvnode without vrefing it.

Reviewed by:	kib
2015-07-11 16:22:48 +00:00
Alexander Motin
d1f4058735 Make first step toward supporting target and initiator roles same time.
To avoid conflicts between target and initiator devices in CAM, make
CTL use target ID reported by HBA as its initiator_id in XPT_PATH_INQ.
That target ID is known to never be used for initiator role, so it won't
conflict.  For Fibre Channel and FireWire HBAs this specific ID choice
is irrelevant since all target IDs there are virtual. Same time for SPI
HBAs it seems could be even requirement to use same target ID for both
initiator and target roles.

While there are some more things to polish in isp(4) driver, first tests
of using both roles same time on the same port appeared successfull:

# camcontrol devlist -v
scbus0 on isp0 bus 0:
<FREEBSD CTLDISK 0001>             at scbus0 target 1 lun 0 (da20,pass21)
<>                                 at scbus0 target 256 lun 0 (ctl0)
<>                                 at scbus0 target -1 lun ffffffff (ctl1)
2015-07-05 03:38:58 +00:00
Alexander Motin
b9b4269c1d Fix couple panics on forced unmount of backing file.
MFC after:	1 week
Sponsored by:	iXsystems, Inc.
2015-07-02 12:53:22 +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
2d8b28765c Introduce separate lock for tokens to reduce ctl_lock scope. 2015-06-20 11:20:25 +00:00
Alexander Motin
754e493530 Remove some dead and duplicate LUN enabling code. 2015-06-20 07:33:06 +00:00
Alexander Motin
b9807a43b0 Remove device queue freeze handling and replace it with dummy.
At this point CTL has no known use case for device queue freezes.
Same time existing (considered to be broken) code was found to cause
modify-after-free issues.

Discussed with:	ken
MFC after:	1 week
2015-06-20 03:40:19 +00:00
Alexander Motin
521db0ac8d Change ATIO/INOT counting to prevent periph destruction while requests
are still running inside CTL.

MFC after:	1 week
2015-06-18 09:39:51 +00:00
Alexander Motin
6fbc43fdfb Fix wrong function name in error message.
MFC after:	3 days
2015-06-05 20:30:36 +00:00
Alexander Motin
7607afb12f Allow setting only WWNN or only WWPN.
MFC after:	2 weeks
2015-06-05 06:46:11 +00:00
Alexander Motin
0631de4a79 Handle EDQUOT backend storage errors same as ENOSPC.
MFC after:	1 week
2015-05-06 19:47:31 +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
fbc8d4ff38 Teach CTL to ask GEOM devices about BIO_DELETE support.
MFC after:	1 week
2015-02-13 13:26:23 +00:00
Alexander Motin
fee04ef7a9 Make XCOPY and WUT commands respect physical block size/offset.
This change by 2-3 times improves performance of misaligned XCOPY and WUT
commands by avoiding unneeded read-modify-write cycles inside ZFS.

MFC after:	1 week
2015-02-12 15:46:44 +00:00
Alexander Motin
93b8c96cfd Make WRITE SAME commands respect physical block size.
This change by 2-3 times improves performance of misaligned WRITE SAME
commands by avoiding unneeded read-modify-write cycles inside ZFS.

MFC after:	1 week
2015-02-12 10:28:45 +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
Edward Tomasz Napierala
d5153415b8 Fix ordering of "*logout" and "*terminate"; no functional changes.
MFC after:	1 month
Sponsored by:	The FreeBSD Foundation
2015-02-08 19:18:23 +00:00
Edward Tomasz Napierala
7a03d007cf Extend ICL to add receive offload methods. For software ICL backend
they are no-ops.

MFC after:	1 month
Sponsored by:	The FreeBSD Foundation
2015-02-08 19:15:14 +00:00
Edward Tomasz Napierala
07b49a3eed Make it possible to set (via ctl.conf(5)) and query (via ctladm islist -v)
target iSCSI offload.  Add mechanism to query maximum receive data segment
size supported by chosen hardware offload module, and use it in ctld(8)
to determine the value to advertise to the other side.

MFC after:	1 month
Sponsored by:	The FreeBSD Foundation
2015-02-06 21:03:25 +00:00
Alexander Motin
6b31e1302f Bring some more order into iSCSI portal group tags support.
While ctld(8) still does not allow multiple portal groups per target
to be configured, kernel should now be able to handle it.

MFC after:	2 weeks
Sponsored by:	iXsystems, Inc.
2015-02-03 16:17:54 +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
Edward Tomasz Napierala
321b17ec15 Add kobj interface between ICL and the rest of the iSCSI stack.
Review note - icl.c was moved to icl_soft.c.

MFC after:	1 month
Sponsored by:	The FreeBSD Foundation
2015-01-31 07:49:50 +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
Alexander Motin
117f1bc17f Fix wrong LUN reference in XCOPY block-to-block operation.
This could cause data corruption due to accessing wrong LUN in case of
retries on write errors.  Failed writes were retried to read LUN.

MFC after:	3 days
2015-01-24 15:40:52 +00:00
Alexander Motin
379694e3d3 Don't count requests with status sent as overlapping.
While those requests are still in target OOA queue, for initiator they are
already completed, so tags can be reused.

MFC after:	1 week
2015-01-22 14:49:36 +00:00
Alexander Motin
1b922b707e Don't count status as sent until CTIO completes successfully.
If we aggregated status sending with data move and got error, allow status
to be updated and resent again separately.  Without this command may stuck
without status sent at all.

MFC after:	2 weeks
2015-01-16 12:35:55 +00:00
Alexander Motin
7a19455d22 Hide block device VPD pages for non-block devices.
MFC after:	2 weeks
2014-12-23 15:18:28 +00:00
Alexander Motin
1f69310e70 Fix potential division by zero after r275920.
Reported by:	Coverity Scan
CID:		1260387
MFC after:	3 days
2014-12-23 10:18:42 +00:00
Alexander Motin
83c25ce791 Report initiator id in portlist XML in more formalized way.
MFC after:	3 days
2014-12-20 16:39:56 +00:00
Alexander Motin
e7038eb747 Replace ctl_min() macro with MIN().
MFC after:	1 week
2014-12-20 13:33:31 +00:00