Commit Graph

195 Commits

Author SHA1 Message Date
Alexander Motin
4ab4d6879c Fix tpc_create_token() introduced in r269497 to encode CREATOR LOGICAL UNIT
DESCRIPTOR field as Identification Descriptor CSCD descriptor, not just as
Identification Descriptor.

MFC after:	3 days
2014-09-17 07:08:59 +00:00
Alexander Motin
29611ce906 Always report that we support REPORT TARGET PORT GROUPS command.
Without clustering support we any way have only one group of permanently
active ports, but that gives us one more supported VMWare feature. ;)

Solaris' Comstar also reports it even when only one port is present.
2014-09-14 23:39:13 +00:00
Alexander Motin
ab55ae255a Implement control over command reordering via options and control mode page.
It allows to bypass range checks between UNMAP and READ/WRITE commands,
which may introduce additional delays while waiting for UNMAP parameters.
READ and WRITE commands are always processed in safe order since their
range checks are almost free.
2014-09-13 10:34:23 +00:00
Alexander Motin
8e6441d87d Add "readcache" and "writecache" LUN options to control default behavior.
Default values are "on".  Disabling requires backend to support IO_DIRECT
and IO_SYNC flags respectively, or some alternatives.
2014-09-13 08:55:22 +00:00
Alexander Motin
abafbab15f Implement range checks between UNMAP and READ/WRITE commands.
Before this change UNMAP completely blocked other I/Os while running.
Now it blocks only colliding ones, slowing down others only due to ZFS
locks collisions.

Sponsored by:	iXsystems, Inc.
2014-09-13 07:45:03 +00:00
Alexander Motin
5e5ac52b42 Add support for Extended INQUIRY Data (0x86) VPD page. 2014-09-11 22:40:11 +00:00
Edward Tomasz Napierala
2c5b89e54b Make sure we handle less than zero timeouts in iSCSI initiator and target
in a reasonable way.

Sponsored by:	The FreeBSD Foundation
2014-09-10 14:04:10 +00:00
Edward Tomasz Napierala
42c12ebf91 Make it possible to disable NOP-In PDUs by the iSCSI initiator by setting
kern.cam.ctl.iscsi.ping_timeout to 0.  This fixes interoperability with
some initiators that don't properly support NOP-Ins, namely iPXE/gPXE.

Submitted by:	Chen Wen <pokkys@gmail.com>
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
2014-09-10 13:34:27 +00:00
Alexander Motin
bfa005503c Make ctl_port_mask an array to support more then 32 ports.
Overflow reported by Coverity.

CID:		1229894
MFC after:	3 days
2014-09-10 07:16:17 +00:00
Alexander Motin
f198b1719a Remove uninitialized and unused variable, reported by Coverity.
CID:		1230015
2014-09-10 07:00:36 +00:00
Alexander Motin
436b3d2f5a Fix array overrun, reported by Coverity.
CID:		1229970
2014-09-10 06:56:45 +00:00
Alexander Motin
0d5de8346a Fix couple off-by-one range check errors, reported by Coverity.
CID:		1007837
2014-09-10 06:35:00 +00:00
Alexander Motin
41ee818335 Fix memory leak on error, reported by Coverity.
CID:		1007773
2014-09-10 06:29:31 +00:00
Alexander Motin
888da1578a Fix minor buffer overflow reported by Coverity.
CID:		1006781
2014-09-10 06:25:18 +00:00
Alexander Motin
4f3fe448f5 Report that DPO and FUA bits are supported after r271311. 2014-09-09 15:19:38 +00:00
Alexander Motin
c97f969b95 Add support for Mode Page Policy (0x87) VPD page. 2014-09-09 14:09:51 +00:00
Alexander Motin
55551d0542 Improve cache control support, including DPO/FUA flags and the mode page.
At this moment it works only for files and ZVOLs in device mode since BIOs
have no respective respective cache control flags (DPO/FUA).

MFC after:	1 month
Sponsored by:	iXsystems, Inc.
2014-09-09 11:38:29 +00:00
Edward Tomasz Napierala
ddc5fd903d Use proper include paths in kernel iSCSI code.
MFC after:	2 weeks
Sponsored by:	The FreeBSD Foundation
2014-08-21 16:08:17 +00:00
Alexander Motin
2ac1d5afc8 Fix lock recursion on LUN shutdown, introduced on r269497.
MFC after:	3 days
2014-08-19 17:04:18 +00:00
Alexander Motin
b0529e0a2d Reduce reported additional INQUIRY data length.
sizeof(struct scsi_inquiry_data) of 256 bytes combined with off-by-one
error in the changed code gave total INQUIRY data length above 255 bytes,
that was maximal INQUIRY length in SPC-2.  While SPC-3 increased the
maximal length to 64K, at least sg3_utils are still confused by that.

MFC after:	1 week
2014-08-06 17:02:19 +00:00
Alexander Motin
3406a2a083 Fix several issues and inconsistencies in UNMAP capabilities reporting.
This makes Windows 2012 to start using UNMAP on our disks.

MFC after:	2 weeks
Sponsored by:	iXsystems, Inc.
2014-08-06 08:54:31 +00:00
Alexander Motin
e3e592bb7d Reimplement WRITE USING TOKEN with Block Zero token using WRITE SAME.
On my ZVOL of SSDs that increases speed of zero writing in that way from
1 to 2.5GB/s by reducing CPU overhead.
MFC after:	2 weeks
2014-08-05 15:01:30 +00:00
Alexander Motin
25eee848cd Add support for Windows dialect of EXTENDED COPY command, aka Microsoft ODX.
This allows to avoid extra network traffic when copying files on NTFS iSCSI
disks within one storage host by drag'n'dropping them in Windows Explorer
of Windows 8/2012.  It should also accelerate Hyper-V VM operations, etc.

MFC after:	2 weeks
Sponsored by:	iXsystems, Inc.
2014-08-04 01:16:20 +00:00
Alexander Motin
c5c6059574 Rework r269444 to work also for lists without IDs.
MFC after:	3 days
2014-08-02 23:20:43 +00:00
Alexander Motin
475267eff1 Plug EXTENDED COPY request data memory leak.
MFC after:	3 days
2014-08-02 20:15:00 +00:00
Alexander Motin
a7c09f5c12 Fix some bugs in RECEIVE COPY STATUS data.
MFC after:	3 days
2014-08-02 19:59:19 +00:00
Alexander Motin
43d2d71953 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.

MFC after:	3 days
2014-08-02 19:51:10 +00:00
Alexander Motin
1b5307b2b0 Fix several cases of NULL dereference when INQUIRY sent to absent LUN.
MFC after:	3 days
2014-07-27 06:49:55 +00:00
Alexander Motin
67f586a8c1 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.

MFC after:	1 week
2014-07-26 13:56:50 +00:00
Alexander Motin
696297ad2f Fix infinite loop, when doing WRITE SAME on file-backed LUN.
MFC after:	3 days
2014-07-26 13:43:25 +00:00
Edward Tomasz Napierala
cb6cc00d74 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)
MFC after:	3 days
Sponsored by:	FreeBSD Foundation
2014-07-25 11:29:45 +00:00
Alexander Motin
e2507751a6 Fix build with QUEUE_MACRO_DEBUG.
Submitted by:	benno@
MFC after:	3 days
2014-07-24 14:10:58 +00:00
Alexander Motin
8cbf9eae6f 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.

MFC after:	2 weeks
2014-07-17 21:16:52 +00:00
Alexander Motin
38afa8f733 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 even need it.

MFC after:	2 weeks
2014-07-17 20:28:51 +00:00
Alexander Motin
984a2ea91f 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!

MFC after:	2 weeks
Sponsored by:	iXsystems, Inc.
2014-07-16 15:57:17 +00:00
Alexander Motin
4d877c4148 Merge several equal serialization indexes. 2014-07-13 06:01:23 +00:00
Alexander Motin
409a3c1383 Add LUN options to specify 64-bit EUI and NAA identifiers. 2014-07-09 04:37:50 +00:00
Alexander Motin
3120a49e50 Remove status setting from datamove() path. Leave that to other places. 2014-07-08 18:51:03 +00:00
Alexander Motin
ad3cd840f2 Fix use-after-free on XPT_RESET_BUS.
That command is not queued, so does not use later status update.
2014-07-08 16:56:21 +00:00
Alexander Motin
b33b96e352 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-08 16:38:05 +00:00
Alexander Motin
d6205772da Fix typo in r267873. 2014-07-08 13:28:37 +00:00
Alexander Motin
6c7a99be9f Do not return statuses for aborted iSCSI commands. 2014-07-08 12:16:28 +00:00
Alexander Motin
f5ffef352f Return task management requests to queued execution, but differently.
Testing shown that both original queued design with separate task queue,
and recent direct execution design had significant flaw: If abort request
arrives just after the victim, the last one may not be in the ooa_queue
yet, and so invisible for the task management function.

Unlike original queued implementation, use same queue for all SCSI and
TASK requests from the same initiator. That avoids races between them:
task functions are always executed in proper time, relatively to other
requests.
2014-07-08 12:15:15 +00:00
Alexander Motin
fdfc6c8ebd Fix task management functions status: task not found is not an error,
while not implemented function is.
2014-07-08 08:34:34 +00:00
Alexander Motin
dbd849d868 Fix "use after free" on port creation error in r268291. 2014-07-07 11:52:22 +00:00
Alexander Motin
1e5a8b8f4b Add support for READ FULL STATUS action of PERSISTENT RESERVE IN command. 2014-07-07 11:05:04 +00:00
Alexander Motin
604e257984 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-07 09:37:22 +00:00
Alexander Motin
0f8de8afaa Fix bugs for PERSISTENT RESERVE OUT bits in r268096. 2014-07-07 08:58:36 +00:00
Alexander Motin
99f8c067e6 Correction to r268356: collide only sessions to the same target. 2014-07-07 06:17:07 +00:00
Alexander Motin
2c6c9e47b2 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-07 05:48:11 +00:00