aboutsummaryrefslogtreecommitdiff
path: root/sys/cam/ctl/ctl_private.h
Commit message (Collapse)AuthorAgeFilesLines
* Add CTL support for REPORT IDENTIFYING INFORMATION command.Alexander Motin2020-08-061-0/+1
| | | | | | | | | | | | | | | It allows to report to initiator LU identifying information, preset via "ident_info" and "text_ident_info" options. Unfortunately it is impossible to implement SET IDENTIFYING INFORMATION, since we have no persistent storage it requires, so the information is read-only for initiator and has to be set out-of-band. MFC after: 1 week Sponsored by: iXsystems, Inc. Notes: svn path=/head/; revision=363979
* Cleanup LUN addition/removal.Alexander Motin2020-05-021-3/+0
| | | | | | | | | | | | | | - Make ctl_add_lun() synchronous. Asynchronous addition was used by Copan's proprietary code long ago and never for upstream FreeBSD. - Move LUN enable/disable calls from backends to CTL core. - Serialize LUN modification and partially removal to avoid double frees. - Slightly unify backends code. MFC after: 2 weeks Sponsored by: iXsystems, Inc. Notes: svn path=/head/; revision=360564
* Add device temperature reporting into CTL.Alexander Motin2019-07-261-0/+3
| | | | | | | | | | The values to report can be set via LUN options. It can be useful for testing, and also required for Drive Maintenance 2016 feature set. MFC after: 2 weeks Notes: svn path=/head/; revision=350346
* Refactor command ordering/blocking mechanism in CTL.Alexander Motin2019-02-271-1/+0
| | | | | | | | | | | | | | | | | | | | | | | | | Replace long per-LUN queue of blocked commands, scanned on each command completion and sometimes even twice, causing up to O(n^^2) processing cost, by much shorter per-command blocked queues, scanned only when respective command completes, and check only commands before the previous blocker, reducing cost to O(n). While there, unblock aborted commands to make them "complete" ASAP to be removed from the OOA queue and so not waste time ordering other commands against them. Aborted commands that were not sent to execution yet should have no visible side effects, so this is safe and easy optimization now, comparing to commands already in processing, which are a still pain. Together those two optimizations should fix quite pathological case, when due to backend slowness CTL accumulated many thousands of blocked requests, partially aborted by initiator and so supposedly not even existing, but still wasting CTL CPU time. MFC after: 2 weeks Sponsored by: iXsystems, Inc. Notes: svn path=/head/; revision=344636
* Remove disabled CTL_LEGACY_STATS support.Alexander Motin2019-02-231-3/+0
| | | | | | | | | | It was not only disabled for quite a while, but also appeared to be broken at r325517, when maximum number of ports was made configurable. MFC after: 1 week Notes: svn path=/head/; revision=344480
* sys/cam: further adoption of SPDX licensing ID tags.Pedro F. Giffuni2017-11-271-0/+2
| | | | | | | | | | | | | | | Mainly focus on files that use BSD 2-Clause license, however the tool I was using misidentified many licenses so this was mostly a manual - error prone - task. The Software Package Data Exchange (SPDX) group provides a specification to make it easier for automated tools to detect and summarize well known opensource licenses. We are gradually adopting the specification, noting that the tags are considered only advisory and do not, in any way, superceed or replace the license texts. Notes: svn path=/head/; revision=326265
* ctl: Make max_luns and max_ports tunable variables instead of hardcodedEmmanuel Vadot2017-11-071-7/+7
| | | | | | | | | | | | defines. Reviewed by: trasz (earlier version), bapt (earlier version), bcr (manpages) MFC after: 2 Weeks Sponsored by: Gandi.net Differential Revision: https://reviews.freebsd.org/D12836 Notes: svn path=/head/; revision=325517
* Polish handling of different reset flavours.Alexander Motin2017-02-271-0/+1
| | | | | | | | | | 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 Notes: svn path=/head/; revision=314338
* Reenable CTL_WITH_CA, optimizing it for lower memory usage.Alexander Motin2017-02-251-4/+1
| | | | | | | | | | | 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 Notes: svn path=/head/; revision=314255
* Bring the ctl headers a bit closer to style(9). No functional changes.Edward Tomasz Napierala2017-01-251-42/+42
| | | | Notes: svn path=/head/; revision=312785
* Add initial support for CTL module unloading.Alexander Motin2017-01-211-0/+3
| | | | | | | | | | | 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 Notes: svn path=/head/; revision=312603
* Rewrite CTL statistics in more simple and scalable way.Alexander Motin2017-01-091-2/+5
| | | | | | | | | | | | | | | | 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) Notes: svn path=/head/; revision=311804
* Allocate memory for prevent flags only for removable LUs.Alexander Motin2017-01-091-1/+1
| | | | | | | | | | 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 Notes: svn path=/head/; revision=311787
* Improve length handling when writing sense data.Alexander Motin2016-12-241-1/+1
| | | | | | | | | | | | - 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 Notes: svn path=/head/; revision=310524
* Add support for SITUA bit in Logical Block Provisioning mode page.Alexander Motin2016-12-211-1/+1
| | | | | | | | | | | | | | | 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 Notes: svn path=/head/; revision=310366
* Add set of macros to simplify code access to mode pages fields.Alexander Motin2016-12-191-0/+11
| | | | | | | MFC after: 2 weeks Notes: svn path=/head/; revision=310265
* Improve support for informational exceptions.Alexander Motin2016-12-191-9/+15
| | | | | | | | | | | | | | | 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. Notes: svn path=/head/; revision=310257
* Modify target port groups logic in CTL.Alexander Motin2015-11-111-4/+1
| | | | | | | | | | | | | | | | | | | | | | - Introduce "ha_shared" port option, which being set to "on" moves the port into separate port group, shared between HA nodes. This allows to better handle cases when iSCSI portals are bound to CARP address that can dynamically move between nodes. Some initiators (at least VMware) don't detect that after iSCSI reconnect they've attached to different SCSI port from different port group, that totally breakes ALUA status parsing. In theory, I believe, it should be enough to have different iSCSI portal group tags on different nodes to make initiators detect this condition, but it seems like VMware ignores those values, and even full LUN retaste forced by UA does not help. - Make CTL report up to three port groups: 1 -- non-HA mode or ports with "ha_shared" option set, 2 -- HA node 1, 3 -- HA node 2. - Report Transitioning state for all port groups when HA interlink is connected, but neither of nodes is primary for the LUN. MFC after: 2 weeks Notes: svn path=/head/; revision=290670
* Unify PR variable names to reduce confusion.Alexander Motin2015-10-011-2/+2
| | | | Notes: svn path=/head/; revision=288448
* Really implement PREVENT ALLOW MEDIUM REMOVAL command.Alexander Motin2015-09-291-0/+2
| | | | Notes: svn path=/head/; revision=288369
* Add CD/DVD Capabilities and Mechanical Status Page.Alexander Motin2015-09-291-0/+8
| | | | | | | This page is obsolete since MMC-4, but still used by some software. Notes: svn path=/head/; revision=288358
* Umplement media load/eject support for removable devices.Alexander Motin2015-09-281-10/+10
| | | | | | | | In case of block backend eject really closes the backing store, while load tries to open it back. Failed store open is reported as no media. Notes: svn path=/head/; revision=288348
* Add to CTL initial support for CDROMs and removable devices.Alexander Motin2015-09-271-19/+31
| | | | | | | Relnotes: yes Notes: svn path=/head/; revision=288310
* Allow LOG SENSE command on non-disk devices.Alexander Motin2015-09-261-1/+1
| | | | Notes: svn path=/head/; revision=288264
* Move ioctl frontend defines where they belong.Alexander Motin2015-09-261-12/+0
| | | | Notes: svn path=/head/; revision=288261
* Remove few more unused variables.Alexander Motin2015-09-261-3/+0
| | | | Notes: svn path=/head/; revision=288260
* Remove some duplicate, legacy, dead and questionable code.Alexander Motin2015-09-261-16/+0
| | | | Notes: svn path=/head/; revision=288259
* Add support for Control extension mode page.Alexander Motin2015-09-221-0/+4
| | | | Notes: svn path=/head/; revision=288110
* Split two command flags with different meaning.Alexander Motin2015-09-191-3/+4
| | | | | | | This is only a cosmetical change. Notes: svn path=/head/; revision=287993
* When reporting TPT UA, report which of thresholds was reached.Alexander Motin2015-09-171-0/+1
| | | | Notes: svn path=/head/; revision=287921
* Reimplement CTL High Availability.Alexander Motin2015-09-101-11/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | 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. Notes: svn path=/head/; revision=287621
* Move setting of media parameters inside open routines.Alexander Motin2015-09-061-7/+0
| | | | | | | | | | 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. Notes: svn path=/head/; revision=287499
* Move "ioctl" CAM frontend into separate file.Alexander Motin2015-08-151-13/+0
| | | | | | | | | 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. Notes: svn path=/head/; revision=286807
* Drop "internal" CTL frontend.Alexander Motin2015-08-151-12/+0
| | | | | | | | | 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.. Notes: svn path=/head/; revision=286806
* Relax serialization of SYNCHRONIZE CACHE commands.Alexander Motin2015-08-051-0/+1
| | | | | | | | | | | | | | 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. Notes: svn path=/head/; revision=286345
* Bring per-port LUN enable/disable code up to date:Alexander Motin2015-06-201-3/+0
| | | | | | | | | | | | | - 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. :( Notes: svn path=/head/; revision=284640
* Introduce separate lock for tokens to reduce ctl_lock scope.Alexander Motin2015-06-201-0/+1
| | | | Notes: svn path=/head/; revision=284639
* Add support for General Statistics and Performance log page.Alexander Motin2015-02-111-0/+11
| | | | | | | | | CTL already collects most of statistics reported there, so why not. MFC after: 2 weeks Notes: svn path=/head/; revision=278584
* CTL LUN mapping rewrite.Alexander Motin2015-02-011-0/+7
| | | | | | | | | | | | | | | | | | | | | | | | 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. Notes: svn path=/head/; revision=278037
* Count consecutive read requests as blocking in CTL for files and ZVOLs.Alexander Motin2014-12-061-0/+8
| | | | | | | | | | | | | | | | | | | Technically read requests can be executed in any order or simultaneously since they are not changing any data. But ZFS prefetcher goes crasy when it receives consecutive requests from different threads. Since prefetcher works on level of separate blocks, instead of two consecutive 128K requests it may receive 32 8K requests in mixed order. This patch is more workaround then a real fix, and it does not fix all of prefetcher problems, but it improves sequential read speed by 3-4x times in some configurations. On the other side it may hurt performance if some backing store has no prefetch, that is why it is disabled by default for raw devices. MFC after: 2 weeks Notes: svn path=/head/; revision=275568
* Add GET LBA STATUS command support to CTL.Alexander Motin2014-12-041-0/+1
| | | | | | | | | | | | It is implemented for LUNs backed by ZVOLs in "dev" mode and files. GEOM has no such API, so for LUNs backed by raw devices all LBAs will be reported as mapped/unknown. MFC after: 2 weeks Sponsored by: iXsystems, Inc. Notes: svn path=/head/; revision=275474
* Do not pre-allocate UNIT ATTENTIONs storage for every possible initiator.Alexander Motin2014-12-031-1/+1
| | | | | | | | | | | | | Abusing ability of major UAs cover minor ones we may not account UAs for inactive ports. Allocate UAs storage for port and start accounting only after some initiator from that port fetched its first POWER ON OCCURRED. This reduces per-LUN CTL memory usage from >1MB to less then 100K. MFC after: 1 month Notes: svn path=/head/; revision=275458
* Do not pre-allocate reservation keys memory for every possible initiator.Alexander Motin2014-12-031-1/+1
| | | | | | | | | | | In configurations with many ports, like iSCSI, each LUN is typically accessed only by limited subset of ports. Allocating that memory on demand allows to reduce CTL memory usage from 5.3MB/LUN to 1.3MB/LUN. MFC after: 1 month Notes: svn path=/head/; revision=275447
* Convert persis_offset from global variable to softc field.Alexander Motin2014-12-021-0/+1
| | | | Notes: svn path=/head/; revision=275405
* Replace home-grown CTL IO allocator with UMA.Alexander Motin2014-11-241-31/+6
| | | | | | | | | | | | | | | | | | | | | Old allocator created significant lock congestion protecting its lists of preallocated I/Os, while UMA provides much better SMP scalability. The downside of UMA is lack of reliable preallocation, that could guarantee successful allocation in non-sleepable environments. But careful code review shown, that only CAM target frontend really has that requirement. Fix that making that frontend preallocate and statically bind CTL I/O for every ATIO/INOT it preallocates any way. That allows to avoid allocations in hot I/O path. Other frontends either may sleep in allocation context or can properly handle allocation errors. On 40-core server with 6 ZVOL-backed LUNs and 7 iSCSI client connections this change increases peak performance from ~700K to >1M IOPS! Yay! :) MFC after: 1 month Sponsored by: iXsystems, Inc. Notes: svn path=/head/; revision=274962
* Partially reconstruct Active/Standby clusting.Alexander Motin2014-11-211-1/+5
| | | | | | | | | | | | In this mode one head is in Active state, supporting all commands, while another is in Standby state, supporting only minimal LUN discovery subset. It is still incomplete since Standby state requires reservation support, which is impossible to do right without having interlink between heads. But it allows to run some basic experiments. Notes: svn path=/head/; revision=274785
* Synchronize medium rotation rate in legacy Rigid Disk Drive Geometry modeAlexander Motin2014-11-071-1/+1
| | | | | | | | | page with modern Block Device Characteristics VPD page. MFC after: 1 week Notes: svn path=/head/; revision=274206
* Add to CTL support for logical block provisioning threshold notifications.Alexander Motin2014-11-061-2/+17
| | | | | | | | | | | For ZVOL-backed LUNs this allows to inform initiators if storage's used or available spaces get above/below the configured thresholds. MFC after: 2 weeks Sponsored by: iXsystems, Inc. Notes: svn path=/head/; revision=274154
* Reduce code duplication around Write Exclusive persistent reservation.Alexander Motin2014-10-271-0/+1
| | | | | | | | | While there, allow some more commands to pass persistent reservation. MFC after: 1 week Notes: svn path=/head/; revision=273730
* Allocate buffer for READ BUFFER/WRITE BUFFER commands on demand.Alexander Motin2014-10-261-1/+3
| | | | | | | | | These commands are rare, but consume additional 256KB RAM per LUN. MFC after: 1 week Notes: svn path=/head/; revision=273711