Commit Graph

2032 Commits

Author SHA1 Message Date
Alexander Motin
b1303ffeb2 Increase device openings to tagged maximum.
Some SIMs report much less untagged device openings then tagged ones.
Target mode devices are not handled by regular probing routines, and so
there is nothing to increase queue size for them to the SIM's maximum.
To fix that resize the queue explicitly on ctl periph registration.
This radically improves performance of mpt(4) in target mode.

Also fetch and report device queue statistics in `ctladm dumpstructs`,
since regular way of `camcontrol tags` is not usable in target mode.

MFC after:	2 weeks
2017-03-11 18:46:46 +00:00
Alexander Motin
2ef6e7aea8 Allow XPT_GDEV_STATS for UNCONFIGURED devices.
Queue statistics has nothing to do with presence or absence of INQUIRY
data, etc.  Target mode devices are never configured, but have queues.

MFC after:	2 weeks
2017-03-11 18:23:05 +00:00
Alexander Motin
ad0f05e629 Abort all ATIOs and INOTs queued to SIM on LUN disable.
Some SIMs may not abort them implicitly, that either fail the LUN disable
request or just make us wait for those CCBs forever.  With this change
I can successfully disable LUNs on mpt(4).  For isp(4), which aborts them
implicitly, this change should be irrelevant.

MFC after:	2 weeks
2017-03-10 21:09:33 +00:00
Alexander Motin
832529c5bd Switch work_queue from TAILQ to STAILQ.
It is mostly FIFO and we don't need random removal there.

MFC after:	2 weeks
2017-03-10 20:20:00 +00:00
Alexander Motin
45400376e0 Request change of SIM target role only when it is different.
Separate WWNs change into separate request to know what actually failed.

MFC after:	2 weeks
2017-03-10 19:43:45 +00:00
Alexander Motin
6fffdbbd67 Add initial support for UNMAP granularity.
Report UNMAP granularity as stripesize/-offset if we have no other values
to report there.

Add new quirk DA_Q_STRICT_UNMAP for cases when target is too critical to
misaligned UNMAP request, reporting errors instead of being suboptimal.
Setting this quirk makes da periph to forcefully align all UNMAP requests
to avoid those errors by the cost of some odd ranges not being UNMAP'ed.
This makes UNMAP usable within VMware 6.x VMs, just now 100% efficient.

MFC after:	2 weeks
2017-03-08 11:24:33 +00:00
Alexander Motin
94173c3c9b Add mechanism to unload CAM periph drivers.
For now it allows to unload CTL kernel module if there are no target-capable
SIMs in CAM.  As next step full teardown of CAM targets can be implemented.
2017-03-07 17:41:08 +00:00
Mark Johnston
a0bbf9e0e3 Reject userland CCBs that have CAM_UNLOCKED set.
CAM_UNLOCKED is internal flag and cannot correctly be set by userland.
Return EINVAL from CAMIOCOMMAND and CAMIOQUEUE if it is set.

Also fix leaks in some of the error paths for CAMIOQUEUE.

PR:		215356
Reviewed by:	ken, mav
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D9869
2017-03-03 20:51:57 +00:00
Alexander Motin
9d42b1fc43 Add check missed in r314257.
MFC after:	11 days
2017-03-01 17:35:56 +00:00
Alexander Motin
3a13860a1b Make ctl_queue_sense() not sleep.
It may be called in non-sleepable frontend context.

MFC after:	2 weeks
2017-02-28 11:56:17 +00:00
Alexander Motin
9ff948d05f Polish handling of different reset flavours.
The biggest change is that ctl_remove_initiator() now generates I_T NEXUS
LOSS event, cleaning part of LUs state related to the initiator.

MFC after:	2 weeks
2017-02-27 14:59:00 +00:00
Alexander Motin
b371466e29 Add support for SIMs without autosense.
If we asked to send sense data by setting CAM_SEND_SENSE, but SIM didn't
confirm transmission by setting CAM_SENT_SENSE, assume it was not sent.
Queue the I/O back to CTL for later REQUEST SENSE with ctl_queue_sense().
This is needed for error reporting on SPI HBAs like ahc(4)/ahd(4).

MFC after:	2 weeks
2017-02-26 19:23:03 +00:00
Alexander Motin
15b2cdedca Use resid field of CTIO to detect under/overruns.
MFC after:	2 weeks
2017-02-26 12:54:27 +00:00
Warner Losh
2379d1d6ed Move inclusion of opt_printf.h around so that we can compile all the
SCSI modules outside of a sub-build from the kernel.

Differential Revision: https://reviews.freebsd.org/D9653
Sponsored by: Netflix
2017-02-25 22:11:10 +00:00
Alexander Motin
a9d2a1930b Add reporting SAS protocol, in case we ever have one.
MFC after:	2 weeks
2017-02-25 14:36:24 +00:00
Alexander Motin
6563855634 Reenable CTL_WITH_CA, optimizing it for lower memory usage.
This code was disabled due to its high memory usage.  But now we need this
functionality for cfumass(4) frontend, since USB MS BBB transport does not
support autosense.

MFC after:	2 weeks
2017-02-25 14:20:30 +00:00
Alexander Motin
03ea6ef2db Axe out some forever disabled questionable functionality.
This code is complicated enough even in its base shape.

MFC after:	2 weeks
2017-02-25 04:24:51 +00:00
Alexander Motin
3afd480696 Improve CAM target frontend reference counting.
Before this change it was possible to trigger some use-after-free panics
by disabling LUNs/ports under heavy load.

MFC after:	2 weeks
2017-02-25 04:04:11 +00:00
Alexander Motin
d7c2cc352e Explicitly abort ATIO if CTIO sending status has failed.
This helps SIM to free related resources in questionable cases.

MFC after:	2 weeks
2017-02-24 12:12:30 +00:00
Alexander Motin
8d1316f914 We can't access periph after ctlfe_free_ccb().
MFC after:	2 weeks
2017-02-24 11:25:32 +00:00
Alexander Motin
a504738fac Unify ATIO/INOT CCBs requeuing.
MFC after:	2 weeks
2017-02-24 09:16:21 +00:00
Alexander Motin
6b0878502e Some code cleanup.
MFC after:	2 weeks
2017-02-24 07:47:50 +00:00
Alexander Motin
3b63a91d6d Do not blindly free completed ATIOs/INOTs on invalidation.
When LUN is disabled, SIM starts returning queued ATIOs/INOTs.  But at the
same time there can be some ATIOs/INOTs still carrying real new requests.
If we free those, SIM may leak some resources, forever expecting for any
response from us.  So try to be careful, separating ATIOs/INOTs carrying
requests which still must be processed, from ATIOs/INOTs completed with
errors which can be freed.

MFC after:	2 weeks
2017-02-21 06:10:11 +00:00
Alexander Motin
950c5aca4a Remove dead mentions of CAM target mode APIs from drivers.
This makes grepping kernel for target mode implementation much easier.
2017-02-19 17:27:58 +00:00
Alexander Motin
46511441fb Change XCOPY memory allocations.
Before this change XCOPY code could allocate memory in chunks up to 16-32MB
(VMware does XCOPY in 4MB chunks by default), that could be difficult for
VM subsystem to do due to KVA fragmentation, that sometimes created huge
allocation delays, blocking any I/O for respective LU for that time.

This change limits allocations down to TPC_MAX_IO_SIZE, which is 1MB now.
1MB is also not a cookie, but ZFS also can do that for large blocks, so
it should be less dramatic.  As drawback this increases CPU overhead, but
it still look acceptable comparing to time consumed by ZFS read/write.

MFC after:	1 week
2017-02-18 06:03:16 +00:00
Kenneth D. Merry
e9200a6cc2 Make ctl(4) build with CTL_IO_DELAY defined.
sys/cam/ctl/ctl.c:
	In ctl_datamove(), inside CTL_IO_DELAY, add a lun variable and fill
	it in before trying to dereference it.

MFC after:	3 days
Sponsored by:	Spectra Logic
2017-02-17 20:15:27 +00:00
Alexander Motin
7a465c285f Change the way MaxCmdSN is used.
Before this change MaxCmdSN was reported as CmdSN + delta, that made it
limit number of requests in transmission from the initiator to target,
that was pretty useless.  After this change MaxCmdSN limits number of
requests queued to CTL, i.e. maximal queue depth for the initiator.
The default limit is 256 outstanding requests per initiator at a time.

This code uses existing cs_outstanding_ctl_pdus counter to track queue
depth.  It's semantics doen't perfectly match, but close enough to not
add another counter.  Just don't set the maxtags below 2.

MFC after:	2 weeks
2017-02-17 05:22:58 +00:00
Alexander Motin
b6eed5e4e0 No need to erase sense_data when sense_len is set to zero.
MFC after:	2 weeks
2017-02-14 21:05:36 +00:00
Alexander Motin
2fb3637007 Fix panic on shutdown of ramdisk LU with zero capacity.
MFC after:	1 week
2017-02-14 18:03:17 +00:00
Baptiste Daroussin
b4b4b5304b Revert crap accidentally committed 2017-01-28 16:31:23 +00:00
Baptiste Daroussin
814aaaa7da Revert r312923 a better approach will be taken later 2017-01-28 16:30:14 +00:00
Yoshihiro Takahashi
2b375b4edd Remove pc98 support completely.
I thank all developers and contributors for pc98.

Relnotes:	yes
2017-01-28 02:22:15 +00:00
Scott Long
bf1a889535 Squash a couple of uses of xpt_print_path()
Sponsored by:	Netflix
2017-01-27 21:55:47 +00:00
Warner Losh
e831795b8a Remove nested #ifdef that can't possibly be false. 2017-01-27 08:30:43 +00:00
Jung-uk Kim
a196ef645a Fix libcam build. It was broken with r312827. 2017-01-27 00:17:07 +00:00
Scott Long
a136ca542c Fix a development mis-merge from r312827
Sponsored by:	Netflix
2017-01-26 20:18:03 +00:00
Scott Long
ab3e89f1ab Refactor xpt_print_path, xpt_print, and xpt_path_string. Implement
all of them in terms of an sbuf-based back-end, xpt_path_sbuf.  This
unifies the implementation, but more importantly it stops the output
fropm being split between 4 or more invocations of printf.  The
multiple invocations cause interleaving of the messages on the
console during boot, making the output of disk discovery often
unintelligible.  This change helps a lot, but more work is needed.

Reviewed by:	ken, mav
Sponsored by:	Netflix
2017-01-26 20:08:58 +00:00
Edward Tomasz Napierala
5ab1cf33f7 Bring the ctl headers a bit closer to style(9). No functional changes. 2017-01-25 22:52:57 +00:00
Warner Losh
b20c0a07fb Preening pass to fix up trailing white space and other minor style(9)
nits (though I'm sure others remain).

MFC After: 3 days
2017-01-25 02:05:08 +00:00
Alexander Motin
e7037673ca Make CTL ramdisk backend a real RAM disk.
If "capacity" LU option is set, ramdisk backend now implements featured
thin provisioned disk, storing data in malloc(9) allocated memory blocks
of pblocksize bytes (default PAGE_SIZE or 4KB).  Additionally ~0.2% of LU
size is used for indirection tree (bigger pblocksize reduce the overhead).
Backend supports all unmap and anchor operations.  If configured capacity
is overflowed, proper error conditions are reported.

If "capacity" LU option is not set, the backend operates mostly the same
as before without allocating real storage: writes go to nowhere, reads
return zeroes, reporting that all LBAs are unmapped.

This backend is still mostly oriented on testing and benchmarking (it is
still a volatile RAM disk), but now it should allow to run real FS tests,
not only simple dumb dd.

MFC after:	2 weeks
2017-01-24 12:13:41 +00:00
Alexander Motin
b96d9778eb Fix overrun handling issue in r312291.
MFC after:	1 week
2017-01-23 17:44:33 +00:00
Edward Tomasz Napierala
f308ab7043 Remove max_targets and max_target_id CTL port variables; they were unused.
This changes the CTL frontend ABI and thus shouldn't be MFC-ed.

Reviewed by:	mav@
2017-01-22 20:06:15 +00:00
Edward Tomasz Napierala
c6646787ab Add SCSI descriptors for USB Mass Storage.
MFC after:	2 weeks
Sponsored by:	The FreeBSD Foundation
2017-01-22 15:32:17 +00:00
Alexander Motin
0c629e2884 Add initial support for CTL module unloading.
It is only a first step and not perfect, but better then nothing.
The main blocker is CAM target frontend, that can not be unloaded,
since CAM does not have mechanism to unregister periph driver now.

MFC after:	2 weeks
2017-01-21 19:38:26 +00:00
Alan Somers
c9bd03d87f Fix "camcontrol timestamp -s" with LTO-7 drives
The length of the scsi_set_timestamp_parameters struct was incorrect.  LTO-5
drives don't care, but LTO-7 drives do.

Reviewed by:	Sam Klopsch
MFC after:	2 weeks
Sponsored by:	Spectra Logic Corp
2017-01-20 17:54:24 +00:00
Alexander Motin
640603fbf6 Remove writing 'residual' field of struct ctl_scsiio.
This field has no practical use and never readed.  Initiators already
receive respective residual size from frontends.  Removed field had
different semantics, which looks useless, and was never passed through
by any frontend.

While there, fix kern_data_resid field support in case of HA, missed in
r312291.

MFC after:	13 days
2017-01-17 18:32:47 +00:00
Sean Bruno
23030355c6 Add 4k quirk for Micron 5100 and Intel S3610 SSDs
Submitted by:	Jason Wolfe <j@nitrology.com>
MFH:		1 week
Sponsored by:	Limelight Networks
Differential Revision:	https://reviews.freebsd.org/D9209
2017-01-17 14:52:48 +00:00
Alexander Motin
a8d32bff70 Improve error message on duplicate iSCSI port.
MFC after:	2 weeks
2017-01-17 14:13:14 +00:00
Alexander Motin
eb6ac6f9db Make CTL frontends report kern_data_resid for under-/overruns.
It seems like kern_data_resid was never really implemented.  This change
finally does it.  Now frontends update this field while transferring data,
while CTL/backends getting it can more flexibly handle the result.
At this point behavior should not change significantly, still reporting
errors on write overrun, but that may be changed later, if we decide so.

CAM target frontend still does not properly handle overruns due to CAM API
limitations.  We may need to add some fields to struct ccb_accept_tio to
pass information about initiator requested transfer size(s).

MFC after:	2 weeks
2017-01-16 16:19:55 +00:00
Conrad Meyer
1d64db52f3 Fix a variety of cosmetic typos and misspellings
No functional change.

PR:		216096, 216097, 216098, 216101, 216102, 216106, 216109, 216110
Reported by:	Bulat <bltsrc at mail.ru>
Sponsored by:	Dell EMC Isilon
2017-01-15 18:00:45 +00:00
Conrad Meyer
db4fcadf52 "Buses" is the preferred plural of "bus"
Replace archaic "busses" with modern form "buses."

Intentionally excluded:
* Old/random drivers I didn't recognize
  * Old hardware in general
* Use of "busses" in code as identifiers

No functional change.

http://grammarist.com/spelling/buses-busses/

PR:		216099
Reported by:	bltsrc at mail.ru
Sponsored by:	Dell EMC Isilon
2017-01-15 17:54:01 +00:00
Alexander Motin
953f538e0e Add under-/overrun support to IOCTL and CAM SIM frontends.
MFC after:	1 week
2017-01-15 13:57:42 +00:00
Alexander Motin
f319059631 When in kernel, map ctl_scsi_zero_io() to ctl_zero_io().
MFC after:	1 week
2017-01-15 13:51:44 +00:00
Alexander Motin
4902e14dc8 Improve CAM_CDB_POINTER support.
MFC after:	2 weeks
2017-01-13 08:31:55 +00:00
Alexander Motin
17160457b4 Report random flash storage as non-rotating to GEOM_DISK.
While doing it, introduce respective constants in geom_disk.h.

MFC after:	1 week
2017-01-12 08:53:10 +00:00
Alexander Motin
4982dca18d Do not wait for HA thread shutdown if scheduler is stopped.
This wait loop made system hang on panic instead of reboot.

MFC after:	1 week
2017-01-10 20:16:16 +00:00
Alexander Motin
7c07ea9aa2 Fix malloc(M_WAITOK) under mutex, introduced at r311787.
MFC after:	13 days
2017-01-10 10:33:36 +00:00
Alexander Motin
bb8f9017b3 Rewrite CTL statistics in more simple and scalable way.
Instead of collecting statistics for each combination of ports and logical
units, that consumed ~45KB per LU with present number of ports, collect
separate statistics for every port and every logical unit separately, that
consume only 176 bytes per each single LU/port.  This reduces struct
ctl_lun size down to just 6KB.

Also new IOCTL API/ABI does not hardcode number of LUs/ports, and should
allow handling of very large quantities.

MFC after:	2 weeks (probably keeping old API enabled for some time)
2017-01-09 18:18:15 +00:00
Alexander Motin
0e2d6474ca Allocate memory for prevent flags only for removable LUs.
This array takes 64KB of RAM now, that was more then half of struct ctl_lun
size.  If at some point we support more ports, this may need another tune.

MFC after:	2 weeks
2017-01-09 16:21:06 +00:00
Alexander Motin
81241f2828 Make CTL_GETSTATS ioctl return partial data if buffer is small.
MFC after:	2 weeks
2017-01-08 13:26:34 +00:00
Alexander Motin
54644e21e8 Make 'camcontrol modepage' support subpages.
MFC after:	2 weeks
2017-01-07 09:56:12 +00:00
Alexander Motin
f9b66e4c7d Fix bootverbose affecting code logic in r294558.
Reported by:	Jilles Tjoelker <jilles@stack.nl>
2017-01-05 16:30:13 +00:00
Alan Somers
4195c7de24 Always null-terminate ccb_pathinq.(sim_vid|hba_vid|dev_name)
The sim_vid, hba_vid, and dev_name fields of struct ccb_pathinq are
fixed-length strings. AFAICT the only place they're read is in
sbin/camcontrol/camcontrol.c, which assumes they'll be null-terminated.
However, the kernel doesn't null-terminate them. A bunch of copy-pasted code
uses strncpy to write them, and doesn't guarantee null-termination. For at
least 4 drivers (mpr, mps, ciss, and hyperv), the hba_vid field actually
overflows. You can see the result by doing "camcontrol negotiate da0 -v".

This change null-terminates those fields everywhere they're set in the
kernel. It also shortens a few strings to ensure they'll fit within the
16-character field.

PR:		215474
Reported by:	Coverity
CID:		1009997 1010000 1010001 1010002 1010003 1010004 1010005
CID:		1331519 1010006 1215097 1010007 1288967 1010008 1306000
CID:		1211924 1010009 1010010 1010011 1010012 1010013 1010014
CID:		1147190 1010017 1010016 1010018 1216435 1010020 1010021
CID:		1010022 1009666 1018185 1010023 1010025 1010026 1010027
CID:		1010028 1010029 1010030 1010031 1010033 1018186 1018187
CID:		1010035 1010036 1010042 1010041 1010040 1010039
Reviewed by:	imp, sephe, slm
MFC after:	4 weeks
Sponsored by:	Spectra Logic Corp
Differential Revision:	https://reviews.freebsd.org/D9037
Differential Revision:	https://reviews.freebsd.org/D9038
2017-01-04 20:26:42 +00:00
Edward Tomasz Napierala
3a408ce90d Don't release the cfiscsi session refcount too early. It wasn't
observed to fix any actual error, but it's the right thing to do
from the correctness point of view.

Tested by:	Eugene M. Zheganin <emz at norma.perm.ru>
MFC after:	1 month
2017-01-04 12:50:44 +00:00
Alexander Motin
49fe3b378b Fix build with enabled debug after r310778.
MFC after:	2 weeks
2016-12-29 18:08:04 +00:00
Alexander Motin
9cbbfd2f5c Improve use of I/O's private area.
- Since I/Os are allocates from per-port pools, make allocations store
pointer to CTL softc there, and use it where needed instead of global.
 - Created bunch of helper macros to access LUN, port and CTL softc.

MFC after:	 2 weeks
2016-12-29 15:09:34 +00:00
Alexander Motin
e67ac203a6 Allow more efficient use of private area.
There are 16 bytes of space, so we may store two pointers in one.

MFC after:	2 weeks
2016-12-27 23:56:46 +00:00
Alexander Motin
ca734d8a13 Do not update "saved" mode page on every MODE SELECT.
We do not have non-volatile memory to really save those values, so we
neither report nor support this capability.  Also saved mode pages are
not replicated between HA peers now.

MFC after:	2 weeks
2016-12-27 22:38:44 +00:00
Alexander Motin
2e0a1f828e Fix/synchronize field types in struct ctl_modepage_header.
MFC after:	2 weeks
2016-12-27 22:31:06 +00:00
Alexander Motin
2c966e8500 Missed piece of r310640.
MFC after:	2 weeks
2016-12-27 22:28:14 +00:00
Alexander Motin
3722787c8a Add support for revert to defaults (RTD) bit in MODE SELECT.
MFC after:	2 weeks
2016-12-27 21:11:54 +00:00
Alexander Motin
ee5e44e076 Decouple limits on number of LUNs per port and LUs per CTL.
Those two values are not directly related, so make them independent.
This does not change any limits immediately, but makes number of LUNs
per port controllable via tunable/sysctl kern.cam.ctl.lun_map_size.
After this change increasing CTL_MAX_LUNS should be pretty cheap,
and even making it tunable should be easy.

MFC after:	2 weeks
2016-12-27 18:23:16 +00:00
Alexander Motin
92efdd4305 Fix improperly used nexus.targ_lun.
MFC after:	2 weeks
2016-12-26 08:47:35 +00:00
Alexander Motin
a16253002c Some random code cleaning.
- Reduce indentation.
 - Remove extra braces.
 - Add few missing savety checks.

MFC after:	2 weeks
2016-12-25 20:17:15 +00:00
Alexander Motin
4124315924 Remove CTL_MAX_LUNS from places where it is not required.
MFC after:	2 weeks
2016-12-25 13:34:02 +00:00
Alexander Motin
a3dd837892 Improve third-party copy error reporting.
For EXTENDED COPY:
 - improve parameters checking to report some errors before copy start;
 - forward sense data from copy target as descriptor in case of error;
 - report which CSCD reported error in sense key specific information.
For WRITE USING TOKEN:
 - pass through real sense data from copy target instead of reporting
our copy error, since for initiator its a "simple" write, not a copy.

MFC after:	2 weeks
2016-12-25 09:40:44 +00:00
Alexander Motin
4fc0d1d757 Improve length handling when writing sense data.
- Allow maximal sense size limitation via Control Extension mode page.
 - When sense size limited, include descriptors atomically: whole or none.
 - Set new SDAT_OVFL bit if some descriptors don't fit the limit.
 - Report real written sense length instead of static maximal 252 bytes.

MFC after:	2 weeks
2016-12-24 17:42:34 +00:00
Alexander Motin
5bb5027e27 Implement printing forwarded sense data.
MFC after:	2 weeks
2016-12-23 21:56:08 +00:00
Alexander Motin
368cbc2c67 Add place-holders for TAPE STREAM MIRRORING subcommands of XCOPY.
We do not support tapes, so this is only a comments.

MFC after:	2 weeks
2016-12-23 14:54:40 +00:00
Alexander Motin
2be7cd9bdb Add support for REPD bit in RSTMF command.
We have no real timeout values to report there, but its better then error.

MFC after:	2 weeks
2016-12-22 12:18:40 +00:00
Alexander Motin
8202971892 Fix REPORT SUPPORTED OPERATION CODES for READ/WRITE BUFFER commands.
Specifications require MODE parameter of those commands to be treated
the same as SERVICE ACTION parameter of other commands.

MFC after:	2 weeks
2016-12-22 11:10:11 +00:00
Alexander Motin
20549bf66f Add support for REPORTING OPTIONS == 3 in REPORT SUPPORTED OPERATION CODES.
MFC after:	2 weeks
2016-12-21 20:19:12 +00:00
Alexander Motin
33e7ba9cf9 Add support for SITUA bit in Logical Block Provisioning mode page.
VMware tries to enable this bit to avoid multiple threshold notifications
in case of multiple initiators connected to the same LUN.  Unfortunately
their code sends MODE SELECT(6) request with parameter length hardcoded
for the page without any thresholds.  Since we have four threshold and our
page is bigger, this attempt fails, that is correct in my understanding.
So all we can do about this now is to report proper error code and hope
VMware fix their code one day.

MFC after:	2 weeks
2016-12-21 15:17:47 +00:00
Alexander Motin
3157c36886 Fix UUID formatting added in r310360. Oops!
MFC after:	2 weeks
2016-12-21 09:49:16 +00:00
Alexander Motin
00d72d5714 Report UUID and MD5 LUN IDs.
MFC after:	2 weeks
2016-12-21 09:36:23 +00:00
Alexander Motin
f383d6efd5 Add support for locally assigned RFC 4122 UUID LUN identifiers.
MFC after:	2 weeks
2016-12-21 09:05:30 +00:00
Alexander Motin
171e4b68b3 Bump specifications support to SAM-6/SPC-5. 2016-12-20 21:58:43 +00:00
Alexander Motin
1f0694a680 Improve error handling when I/O split between several BIOs.
If we get several error codes, handle one with lowest offset.

MFC after:	2 weeks
2016-12-19 21:27:18 +00:00
Alexander Motin
32920cbfa3 When reporting "Logical block address out of range" error, report the LBA
in sense data INFORMATION field.

MFC after:	2 weeks
2016-12-19 19:00:03 +00:00
Alexander Motin
b9985489dd When writing fixed format sense data, set VALID bit only if provided value
for INFORMATION field fit into available 4 bytes (has no non-zero bytes
except last 4), as explicitly required by SPC-5 specification.

MFC after:	2 weeks
2016-12-19 18:55:10 +00:00
Alexander Motin
c329b295dc Fix typo in function name. 2016-12-19 15:49:59 +00:00
Alexander Motin
f60639b79e Add new bits into Extended Inquiry VPD page.
MFC after:	2 weeks
2016-12-19 15:18:31 +00:00
Alexander Motin
7f900be181 Add support for NUAR bit in Control mode page.
MFC after:	2 weeks
2016-12-19 14:19:52 +00:00
Alexander Motin
1188787581 Add set of macros to simplify code access to mode pages fields.
MFC after:	2 weeks
2016-12-19 13:25:53 +00:00
Alexander Motin
f3ee47571e Following SPC-5, make REQUEST SENSE report "Logical unit not supported"
in returned parameter data for not accessible LUNs.

MFC after:	2 weeks
2016-12-19 11:44:41 +00:00
Alexander Motin
d9ba4eefdc Improve support for informational exceptions.
While CTL still has no real events to report in this way (like SMART),
it is possible to trigger false event by manually setting TEST bit in
Informational Exceptions Control mode page, that can be useful for
initiator testing.  This code supports all flavours of IE reporting:
UNIT ATTENTION, RECOVERED ERROR and NO SENSE sense keys, REQUEST SENSE
command and Informational Exceptions log page.

MFC after:	2 weeks
Sponsored by:	iXsystems, Inc.
2016-12-19 10:25:47 +00:00
Alexander Motin
b7599b7205 Don't treat informational exceptions (warnings and impending failures)
a.k.a. SCSI SMART events as errors.  Log them to console and continue.

MFC after:	2 weeks
2016-12-18 15:02:50 +00:00
Ed Schouten
4c484fd216 Add label annotations to CAM sysctls.
Under kern.cam we have certain sysctls that are per-device, such as the
ones under kern.cam.ada.[0-9]+.*. Add a "device_index" label annotation
to such sysctls, so that the Prometheus metrics exporter will give all
of those metrics the same name. The device number will be added to the
metric name as the "device_index" label.

Reviewed by:	cem
Differential Revision:	https://reviews.freebsd.org/D8775
2016-12-14 12:53:33 +00:00
Kenneth D. Merry
28db0a5e74 Add SCSI REPORT TIMESTAMP and SET TIMESTAMP support.
This adds support to camcontrol(8) and libcam(3) for getting and setting
the time on SCSI protocol drives.  This is more commonly found on tape
drives, but is a SPC (SCSI Primary Commands) command, and may be found
on any device that speaks SCSI.

The new camcontrol timestamp subcommand allows getting the current device
time or setting the time to the current system time or any arbitrary time.

sbin/camcontrol/Makefile:
	Add timestamp.c.

sbin/camcontrol/camcontrol.8:
	Document the new timestamp subcommand.

sbin/camcontrol/camcontrol.c:
	Add the timestamp subcommand to camcontrol.

sbin/camcontrol/camcontrol.h:
	Add the timestamp() function prototype.

sbin/camcontrol/timestamp.c:
	Timestamp setting and reporting functionality.

sys/cam/scsi/scsi_all.c:
	Add two new CCB building functions, scsi_set_timestamp() and
	scsi_report_timestamp().  Also, add a new helper function,
	scsi_create_timestamp().

sys/cam/scsi/scsi_all.h:
	Add CDB and parameter data for the the set and report timestamp
	commands.

	Add function declarations for the new CCB building and helper
	functions.

Submitted by:	Sam Klopsch
Sponsored by:	Spectra Logic
MFC After:	2 weeks
2016-12-01 22:20:27 +00:00
Alexander Motin
7027c01c56 Make SES status updates more aggressive.
- On control request update all status pages, since they may also be
affected if user enables/disables enclosure slots.
 - Periodically update element descriptors too, since there is some
hardware where they are changed dynamically.

MFC after:	2 weeks
Sponsored by:	iXsystems, Inc.
2016-11-29 13:48:36 +00:00