aboutsummaryrefslogtreecommitdiff
path: root/sys/cam/ctl/ctl_frontend_ioctl.c
Commit message (Collapse)AuthorAgeFilesLines
* cam: Remove left-over sys/cdefs.h in sys/camWarner Losh2023-11-061-1/+0
| | | | | | | These weren't removed when $FreeBSD$ was removed. They aren't needed and now are a style(9) nonconformity. Sponsored by: Netflix
* sys: Remove $FreeBSD$: one-line .c patternWarner Losh2023-08-161-2/+0
| | | | Remove /^[\s*]*__FBSDID\("\$FreeBSD\$"\);?\s*\n/
* spdx: The BSD-2-Clause-FreeBSD identifier is obsolete, drop -FreeBSDWarner Losh2023-05-121-1/+1
| | | | | | | | | The SPDX folks have obsoleted the BSD-2-Clause-FreeBSD identifier. Catch up to that fact and revert to their recommended match of BSD-2-Clause. Discussed with: pfg MFC After: 3 days Sponsored by: Netflix
* CTL: Allow userland supply tags via ioctl frontend.Alexander Motin2022-12-031-2/+3
| | | | | | | | | | | | Before this ioctl frontend always replaced tags with sequential ones. It was done for ctladm, that can not keep track of global tag list. But in case of virtio-scsi in bhyve we can pass provided tags as-is. It should be on virtio-scsi initiator to provide us valid tags. It should allow proper task management, error reporting, etc. In case of several virtio-scsi devices, they should use different CTL ports or initiator IDs to avoid conflicts, but this is expected by design. PR: 267539
* CTL: Increase maximum SCSI tag size from 32 to 64 bits.Alexander Motin2022-12-031-2/+2
| | | | | | | | | | | | | | | | | | | SAM-5 specification states maximum size of command identifier (tag), defined by specific transports, should not be larger than 64 bits. While most of supported transports use 32 bits or less, it was reported that virtio-scsi uses 64 bits. Truncation to 32 bits in bhyve code caused false tag conflict errors reported and possibly other issues. This changes CTL ABI and HA protocol, so CTL_HA_VERSION is bumped. While we make HA protocol incompatible, increase default maximum number of ports in CTL from 256 to 1024, matching number of LUNs. There are many reports from people who need many iSCSI targets with only one LUN each. Increased memory consumption should be less of a problem these days. PR: 267539
* Refactor CTL datamove KPI.Alexander Motin2021-02-211-1/+1
| | | | | | | | | | | | | | | - Make frontends call unified CTL core method ctl_datamove_done() to report move completion. It allows to reduce code duplication in differerent backends by accounting DMA time in common code. - Add to ctl_datamove_done() and be_move_done() callback samethr argument, reporting whether the callback is called in the same context as ctl_datamove(). It allows for some cases like iSCSI write with immediate data or camsim frontend write save one context switch, since we know that the context is sleepable. - Remove data_move_done() methods from struct ctl_backend_driver, unused since forever. MFC after: 1 month
* Save context switch per I/O for iSCSI and IOCTL frontends.Alexander Motin2021-02-191-1/+1
| | | | | | | | | | | | | | | Introduce new CTL core KPI ctl_run(), preprocessing I/Os in the caller context instead of scheduling another thread just for that. This call may sleep, that is not acceptable for some frontends like the original CAM/FC one, but iSCSI already has separate sleepable per-connection RX threads, and another thread scheduling is mostly just a waste of time. IOCTL frontend actually waits for the I/O completion in the caller thread, so the use of another thread for this has even less sense. With this change I can measure ~5% IOPS improvement on 4KB iSCSI I/Os to ZFS. MFC after: 1 month
* cam: clean up empty lines in .c and .h filesMateusz Guzik2020-09-011-3/+1
| | | | Notes: svn path=/head/; revision=365225
* Fix CTL ioctl port creation error handling.Alexander Motin2020-08-211-2/+4
| | | | | | | | | Submitted by: Bret Ketchum MFC after: 3 days Differential Revision: https://reviews.freebsd.org/D26143 Notes: svn path=/head/; revision=364463
* Refactor command ordering/blocking mechanism in CTL.Alexander Motin2019-02-271-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | 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
* Rework CTL frontend & backend options to use nv(3), allow creating multipleMarcelo Araujo2018-05-101-13/+223
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ioctl frontend ports. This revision introduces two changes to CTL: - Changes the way options are passed to CTL_LUN_REQ and CTL_PORT_REQ ioctls. Removes ctl_be_arg structure and associated logic and replaces it with nv(3)-based logic for passing in and out arguments. - Allows creating multiple ioctl frontend ports using either ctladm(8) or ctld(8). New frontend ports are represented by /dev/cam/ctl<pp>.<vp> nodes, eg /dev/cam/ctl5.3. Those device nodes respond only to CTL_IO ioctl. New command-line options for ctladm: # creates new ioctl frontend port with using free pp and vp=0 ctladm port -c # creates new ioctl frontend port with pp=10 and vp=0 ctladm port -c -O pp=10 # creates new ioctl frontend port with pp=11 and vp=12 ctladm port -c -O pp=11 -O vp=12 # removes port with number 4 (it's a "targ_port" number, not pp number) ctladm port -r -p 4 New syntax for ctl.conf: target ... { port ioctl/<pp> ... } target ... { port ioctl/<pp>/<vp> ... Note: Most of this work was made by jceel@, thank you. Submitted by: jceel Reworked by: myself Reviewed by: mav (earlier versions and recently during the rework) Obtained from: FreeNAS and TrueOS Relnotes: Yes Sponsored by: iXsystems Inc. Differential Revision: https://reviews.freebsd.org/D9299 Notes: svn path=/head/; revision=333446
* Remove max_targets and max_target_id CTL port variables; they were unused.Edward Tomasz Napierala2017-01-221-2/+0
| | | | | | | | | This changes the CTL frontend ABI and thus shouldn't be MFC-ed. Reviewed by: mav@ Notes: svn path=/head/; revision=312651
* Add initial support for CTL module unloading.Alexander Motin2017-01-211-8/+10
| | | | | | | | | | | 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
* Make CTL frontends report kern_data_resid for under-/overruns.Alexander Motin2017-01-161-18/+7
| | | | | | | | | | | | | | | | | 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 Notes: svn path=/head/; revision=312291
* Add under-/overrun support to IOCTL and CAM SIM frontends.Alexander Motin2017-01-151-9/+15
| | | | | | | MFC after: 1 week Notes: svn path=/head/; revision=312232
* sys/cam: spelling fixes in comments.Pedro F. Giffuni2016-04-291-1/+1
| | | | | | | No functional change. Notes: svn path=/head/; revision=298810
* Move ioctl frontend defines where they belong.Alexander Motin2015-09-261-0/+12
| | | | Notes: svn path=/head/; revision=288261
* Remove some dead code found by Clang analyzer.Alexander Motin2015-09-251-3/+0
| | | | Notes: svn path=/head/; revision=288221
* Remove couple excess SGLIST I/O flags.Alexander Motin2015-09-201-1/+1
| | | | | | | Those flags duplicated respective (sg_entries > 0) values. Notes: svn path=/head/; revision=288020
* Frontends don't need to set errors themselves.Alexander Motin2015-09-161-11/+4
| | | | Notes: svn path=/head/; revision=287860
* Reimplement CTL High Availability.Alexander Motin2015-09-101-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Make most of port methods optional and remove bunch of dummies.Alexander Motin2015-09-011-34/+0
| | | | Notes: svn path=/head/; revision=287372
* Move "ioctl" CAM frontend into separate file.Alexander Motin2015-08-151-0/+470
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