aboutsummaryrefslogtreecommitdiff
path: root/sys/cam
Commit message (Collapse)AuthorAgeFilesLines
* Update kernel inclusions of capability.h to use capsicum.h instead; someRobert Watson2014-03-161-1/+1
| | | | | | | | | | | further refinement is required as some device drivers intended to be portable over FreeBSD versions rely on __FreeBSD_version to decide whether to include capability.h. MFC after: 3 weeks Notes: svn path=/head/; revision=263233
* Fix support for increased logical sector size (4K-native drives).Alexander Motin2014-03-071-7/+10
| | | | | | | | | | | | | - Logical sector size is measured in words, not bytes. - If physical sector is not bigger then logical sector, it does not mean it should be set equal to 512 bytes, but set to logical sector. PR: misc/187269 Submitted by: Ravi Pokala <rpokala@panasas.com> MFC after: 1 week Notes: svn path=/head/; revision=262886
* Make reset handling in iSCSI target RFC-compliant. This fixes some rareEdward Tomasz Napierala2014-03-061-3/+3
| | | | | | | | | | hangs with Open-iSCSI (Linux). MFC after: 1 month Sponsored by: The FreeBSD Foundation Notes: svn path=/head/; revision=262837
* Fix missing unlock in persistent reservations code, which resulted in panicsEdward Tomasz Napierala2014-03-051-0/+1
| | | | | | | | | | | with Hyper-V Failover Cluster. Reviewed by: ken@ MFC after: 2 weeks Sponsored by: The FreeBSD Foundation Notes: svn path=/head/; revision=262782
* Do not retry on CAM_FUNC_NOTAVAIL error, but return immediately.Alexander Motin2014-03-041-0/+1
| | | | | | | MFC after: 2 weeks Notes: svn path=/head/; revision=262741
* Make CTL block backend return proper error code for operations unsupposedAlexander Motin2014-02-061-2/+6
| | | | | | | | | by the underlying device. MFC after: 2 weeks Notes: svn path=/head/; revision=261538
* Mostly revert r260267 and hopefully really fix the original problem.Alexander Motin2014-01-221-12/+14
| | | | | | | | | | | | | The latest draft of SBC-3 tells: "A MAXIMUM UNMAP LBA COUNT field set to a non-zero value indicates the maximum number of LBAs that may be unmapped by an UNMAP command." To me it does not sound like that limit is set per single descriptor, but rather per all command. And I have at least one device that behaves exactly that way. This patch fixes the problem there. MFC after: 1 week Notes: svn path=/head/; revision=261042
* Fix memory and references leak due to unfreed path in case we can'tAlexander Motin2014-01-211-1/+3
| | | | | | | | | allocate bus scan CCB. MFC after: 2 weeks Notes: svn path=/head/; revision=260996
* Move xpt_run_devq() call before request completion callback where it wasAlexander Motin2014-01-111-6/+2
| | | | | | | | | | | | | originally. I am not sure why exactly have I moved it during one of many refactorings during camlock project, but obviously it opens race window that may cause use after free panics during SIM (in reported cases umass(4)) detach. MFC after: 2 weeks Notes: svn path=/head/; revision=260549
* Fix for r260541: do not drop periph reference when request is restarted.Alexander Motin2014-01-111-9/+12
| | | | | | | CAM_DEV_QFREEZE flag is still there and it will freeze device again. Notes: svn path=/head/; revision=260547
* Take additional reference on SCSI probe periph to cover its freeze count.Alexander Motin2014-01-114-19/+20
| | | | | | | | Otherwise periph may be invalidated and freed before single-stepping freeze is dropped, causing use after free panic. Notes: svn path=/head/; revision=260541
* Replace several instances of -1 with appropriate CAM_*_WILDCARD and types.Alexander Motin2014-01-103-6/+8
| | | | | | | | | It was equal before r259397, but for good or bad, not any more for LUNs. This change fixes at least CAM debugging. Notes: svn path=/head/; revision=260509
* Allow delete_method sysctl to be set to "DISABLE".Alexander Motin2014-01-071-2/+3
| | | | Notes: svn path=/head/; revision=260407
* Correct short delete issue in SCSI UNMAP supportSteven Hartland2014-01-041-17/+15
| | | | | | | | | | Correct missing \n's in xpt_print's Correct incorrect count being passed to short delete xpt_print MFC after: 1 week Notes: svn path=/head/; revision=260267
* Widen lun_id_t to 64 bits. This is a follow-on to r257345 to let the kernelNathan Whitehorn2013-12-145-41/+234
| | | | | | | | | | | | support all valid SAM-5 LUN IDs. CAM_VERSION is bumped, as the CAM ABI (though not API) is changed. No behavior is changed relative to r257345 except that LUNs with non-zero high 32 bits will no longer be ignored during device enumeration for SIMs that have set PIM_EXTLUNS. Reviewed by: scottl Notes: svn path=/head/; revision=259397
* When comparing device IDs, make sure that they have the same typeAlexander Motin2013-12-081-1/+5
| | | | | | | | | | | (like NAA assigned) and identify the same entity (like device or port). Otherwise there can be false positives since at least some models of Seagate disks use same IDs for the whole device and one of its ports. MFC after: 2 weeks Notes: svn path=/head/; revision=259108
* Properly report an error instead of panicing when user tries to createEdward Tomasz Napierala2013-12-031-1/+3
| | | | | | | | | | | LUN backed by non-disk device, e.g. /dev/null. Reviewed by: ken (earlier version) MFC after: 3 days Sponsored by: The FreeBSD Foundation Notes: svn path=/head/; revision=258871
* dtrace sdt: remove the ugly sname parameter of SDT_PROBE_DEFINEAndriy Gapon2013-11-261-8/+8
| | | | | | | | | | | In its stead use the Solaris / illumos approach of emulating '-' (dash) in probe names with '__' (two consecutive underscores). Reviewed by: markj MFC after: 3 weeks Notes: svn path=/head/; revision=258622
* - For kernel compiled only with KDTRACE_HOOKS and not any lock debuggingAttilio Rao2013-11-251-2/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | option, unbreak the lock tracing release semantic by embedding calls to LOCKSTAT_PROFILE_RELEASE_LOCK() direclty in the inlined version of the releasing functions for mutex, rwlock and sxlock. Failing to do so skips the lockstat_probe_func invokation for unlocking. - As part of the LOCKSTAT support is inlined in mutex operation, for kernel compiled without lock debugging options, potentially every consumer must be compiled including opt_kdtrace.h. Fix this by moving KDTRACE_HOOKS into opt_global.h and remove the dependency by opt_kdtrace.h for all files, as now only KDTRACE_FRAMES is linked there and it is only used as a compile-time stub [0]. [0] immediately shows some new bug as DTRACE-derived support for debug in sfxge is broken and it was never really tested. As it was not including correctly opt_kdtrace.h before it was never enabled so it was kept broken for a while. Fix this by using a protection stub, leaving sfxge driver authors the responsibility for fixing it appropriately [1]. Sponsored by: EMC / Isilon storage division Discussed with: rstone [0] Reported by: rstone [1] Discussed with: philip Notes: svn path=/head/; revision=258541
* Introduce seperate mutex lock to protect protect CTL I/O pools, slightlyAlexander Motin2013-11-113-103/+66
| | | | | | | | | reducing global CTL lock scope and congestion. While there, simplify CTL I/O pools KPI, hiding implementation details. Notes: svn path=/head/; revision=257946
* Some CAM locks polishing:Alexander Motin2013-11-101-31/+34
| | | | | | | | | | - Fix LOR and possible lock recursion when handling high-power commands. Introduce new lock to protect left power quota and list of frozen devices. - Correct locking around xpt periph creation. - Remove seems never used XPT_FLAG_OPEN xpt periph flag. Notes: svn path=/head/; revision=257914
* Corrected definition for old_rate to match d_rotation_rateSteven Hartland2013-11-071-1/+1
| | | | | | | | MFC after: 2 Days X-MFC-With: r256956 Notes: svn path=/head/; revision=257831
* Fix lock recursion, triggered by `smartctl -a /dev/adaX`.Alexander Motin2013-11-011-1/+1
| | | | Notes: svn path=/head/; revision=257482
* printf() specifier updates to CAM to handle either 32-bit or 64-bit lun_id_t.Nathan Whitehorn2013-10-301-8/+9
| | | | | | | MFC after: 2 weeks Notes: svn path=/head/; revision=257382
* Implement extended LUN support. If PIM_EXTLUNS is set by a SIM, encodeNathan Whitehorn2013-10-292-43/+75
| | | | | | | | | | | | | | | | | | | | | | | | | | | | the upper 32-bits of the LUN, if possible, into the target_lun field as passed directly from the REPORT LUNs response. This allows extended LUN support to work for all LUNs with zeros in the lower 32-bits, which covers most addressing modes without breaking KBI. Behavior for drivers not setting PIM_EXTLUNS is unchanged. No user-facing interfaces are modified. Extended LUNs are stored with swizzled 16-bit word order so that, for devices implementing LUN addressing (like SCSI-2), the numerical representation of the LUN is identical with and without PIM_EXTLUNS. Thus setting PIM_EXTLUNS keeps most behavior, and user-facing LUN IDs, unchanged. This follows the strategy used in Solaris. A macro (CAM_EXTLUN_BYTE_SWIZZLE) is provided to transform a lun_id_t into a uint64_t ordered for the wire. This is the second part of work for full 64-bit extended LUN support and is designed to a bridge for stable/10 to the final 64-bit LUN code. The third and final part will involve widening lun_id_t to 64 bits and will not be MFCed. This third part will break the KBI but will keep the KPI unchanged so that all drivers that will care about this can be updated now and not require code changes between HEAD and stable/10. Reviewed by: scottl MFC after: 2 weeks Notes: svn path=/head/; revision=257345
* Some microoptimizations for da and ada drivers:Alexander Motin2013-10-242-41/+21
| | | | | | | | | - Replace ordered_tag_count counter with single flag; - From da remove outstanding_cmds counter, duplicating pending_ccbs list; - From da_softc remove unused links field. Notes: svn path=/head/; revision=257054
* Remove 128KB bzero() call done for every block I/O data buffer.Alexander Motin2013-10-231-14/+1
| | | | | | | | | | On my tests this improves performance of the new iSCSI target backed by GEOM STRIPE of SSDs from 75K to 110K IOPS. Reviewed by: ken Notes: svn path=/head/; revision=256995
* Minor (mostly cosmetical) addition to r256960.Alexander Motin2013-10-231-1/+0
| | | | Notes: svn path=/head/; revision=256975
* Move CAM_UNQUEUED_INDEX setting to the last moment and under the periph lock.Alexander Motin2013-10-231-1/+1
| | | | | | | This fixes race condition with cam_periph_ccbwait(), causing use-after-free. Notes: svn path=/head/; revision=256960
* Improve ZFS N-way mirror read performance by using load and localitySteven Hartland2013-10-233-5/+27
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | information. The existing algorithm selects a preferred leaf vdev based on offset of the zio request modulo the number of members in the mirror. It assumes the devices are of equal performance and that spreading the requests randomly over both drives will be sufficient to saturate them. In practice this results in the leaf vdevs being under utilized. The new algorithm takes into the following additional factors: * Load of the vdevs (number outstanding I/O requests) * The locality of last queued I/O vs the new I/O request. Within the locality calculation additional knowledge about the underlying vdev is considered such as; is the device backing the vdev a rotating media device. This results in performance increases across the board as well as significant increases for predominantly streaming loads and for configurations which don't have evenly performing devices. The following are results from a setup with 3 Way Mirror with 2 x HD's and 1 x SSD from a basic test running multiple parrallel dd's. With pre-fetch disabled (vfs.zfs.prefetch_disable=1): == Stripe Balanced (default) == Read 15360MB using bs: 1048576, readers: 3, took 161 seconds @ 95 MB/s == Load Balanced (zfslinux) == Read 15360MB using bs: 1048576, readers: 3, took 297 seconds @ 51 MB/s == Load Balanced (locality freebsd) == Read 15360MB using bs: 1048576, readers: 3, took 54 seconds @ 284 MB/s With pre-fetch enabled (vfs.zfs.prefetch_disable=0): == Stripe Balanced (default) == Read 15360MB using bs: 1048576, readers: 3, took 91 seconds @ 168 MB/s == Load Balanced (zfslinux) == Read 15360MB using bs: 1048576, readers: 3, took 108 seconds @ 142 MB/s == Load Balanced (locality freebsd) == Read 15360MB using bs: 1048576, readers: 3, took 48 seconds @ 320 MB/s In addition to the performance changes the code was also restructured, with the help of Justin Gibbs, to provide a more logical flow which also ensures vdevs loads are only calculated from the set of valid candidates. The following additional sysctls where added to allow the administrator to tune the behaviour of the load algorithm: * vfs.zfs.vdev.mirror.rotating_inc * vfs.zfs.vdev.mirror.rotating_seek_inc * vfs.zfs.vdev.mirror.rotating_seek_offset * vfs.zfs.vdev.mirror.non_rotating_inc * vfs.zfs.vdev.mirror.non_rotating_seek_inc These changes where based on work started by the zfsonlinux developers: https://github.com/zfsonlinux/zfs/pull/1487 Reviewed by: gibbs, mav, will MFC after: 2 weeks Sponsored by: Multiplay Notes: svn path=/head/; revision=256956
* Fix memory and references leak due to unfreed path.Alexander Motin2013-10-221-1/+3
| | | | | | | Coverity CID: 1054773 Notes: svn path=/head/; revision=256895
* Unconditionally acquire periph reference on CCB allocation failure.Alexander Motin2013-10-221-3/+4
| | | | | | | | | | | | cam_periph_acquire() can return error if periph already invalidated, but that may be unacceptable and cause deadlock if the invalidated periph can't be destroyed without "executing" the scheduled request. Coverity CID: 1109822 MFC after: 2 months Notes: svn path=/head/; revision=256888
* Merge GEOM direct dispatch changes from the projects/camlock branch.Alexander Motin2013-10-222-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When safety requirements are met, it allows to avoid passing I/O requests to GEOM g_up/g_down thread, executing them directly in the caller context. That allows to avoid CPU bottlenecks in g_up/g_down threads, plus avoid several context switches per I/O. The defined now safety requirements are: - caller should not hold any locks and should be reenterable; - callee should not depend on GEOM dual-threaded concurency semantics; - on the way down, if request is unmapped while callee doesn't support it, the context should be sleepable; - kernel thread stack usage should be below 50%. To keep compatibility with GEOM classes not meeting above requirements new provider and consumer flags added: - G_CF_DIRECT_SEND -- consumer code meets caller requirements (request); - G_CF_DIRECT_RECEIVE -- consumer code meets callee requirements (done); - G_PF_DIRECT_SEND -- provider code meets caller requirements (done); - G_PF_DIRECT_RECEIVE -- provider code meets callee requirements (request). Capable GEOM class can set them, allowing direct dispatch in cases where it is safe. If any of requirements are not met, request is queued to g_up or g_down thread same as before. Such GEOM classes were reviewed and updated to support direct dispatch: CONCAT, DEV, DISK, GATE, MD, MIRROR, MULTIPATH, NOP, PART, RAID, STRIPE, VFS, ZERO, ZFS::VDEV, ZFS::ZVOL, all classes based on g_slice KPI (LABEL, MAP, FLASHMAP, etc). To declare direct completion capability disk(9) KPI got new flag equivalent to G_PF_DIRECT_SEND -- DISKFLAG_DIRECT_COMPLETION. da(4) and ada(4) disk drivers got it set now thanks to earlier CAM locking work. This change more then twice increases peak block storage performance on systems with manu CPUs, together with earlier CAM locking changes reaching more then 1 million IOPS (512 byte raw reads from 16 SATA SSDs on 4 HBAs to 256 user-level threads). Sponsored by: iXsystems, Inc. MFC after: 2 months Notes: svn path=/head/; revision=256880
* Merge CAM locking changes from the projects/camlock branch to radicallyAlexander Motin2013-10-2130-1517/+1453
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | reduce lock congestion and improve SMP scalability of the SCSI/ATA stack, preparing the ground for the coming next GEOM direct dispatch support. Replace big per-SIM locks with bunch of smaller ones: - per-LUN locks to protect device and peripheral drivers state; - per-target locks to protect list of LUNs on target; - per-bus locks to protect reference counting; - per-send queue locks to protect queue of CCBs to be sent; - per-done queue locks to protect queue of completed CCBs; - remaining per-SIM locks now protect only HBA driver internals. While holding LUN lock it is allowed (while not recommended for performance reasons) to take SIM lock. The opposite acquisition order is forbidden. All the other locks are leaf locks, that can be taken anywhere, but should not be cascaded. Many functions, such as: xpt_action(), xpt_done(), xpt_async(), xpt_create_path(), etc. are no longer require (but allow) SIM lock to be held. To keep compatibility and solve cases where SIM lock can't be dropped, all xpt_async() calls in addition to xpt_done() calls are queued to completion threads for async processing in clean environment without SIM lock held. Instead of single CAM SWI thread, used for commands completion processing before, use multiple (depending on number of CPUs) threads. Load balanced between them using "hash" of the device B:T:L address. HBA drivers that can drop SIM lock during completion processing and have sufficient number of completion threads to efficiently scale to multiple CPUs can use new function xpt_done_direct() to avoid extra context switch. Make ahci(4) driver to use this mechanism depending on hardware setup. Sponsored by: iXsystems, Inc. MFC after: 2 months Notes: svn path=/head/; revision=256843
* MFprojects/camlock:Alexander Motin2013-10-211-16/+14
| | | | | | | Remove hard limit on number of BIOs handled with one ATA TRIM request. Notes: svn path=/head/; revision=256836
* Unify periph invalidation and destruction reporting.Alexander Motin2013-10-1518-41/+82
| | | | | | | | | | Print message containing device model and serial number on invalidation. Requested by: glebius MFC after: 1 week Notes: svn path=/head/; revision=256552
* Added 4K quirks for Corsair Neutron GTX SSD'sSteven Hartland2013-10-152-0/+16
| | | | Notes: svn path=/head/; revision=256547
* Unhide "Serial Number" lines from bootverbose. That information may beAlexander Motin2013-10-151-1/+1
| | | | | | | | | | | useful for system administration to have in hard copy (in logs) if one of several devices suddenly dies. Requested by: glebius MFC after: 1 week Notes: svn path=/head/; revision=256533
* Remove no longer useful debugging output and a stale comment.Edward Tomasz Napierala2013-10-091-13/+2
| | | | | | | | Approved by: re (gjb) Sponsored by: FreeBSD Foundation Notes: svn path=/head/; revision=256201
* Make the error handling more consistant. Shouldn't make any functionalEdward Tomasz Napierala2013-10-091-9/+23
| | | | | | | | | | difference. Approved by: re (gjb) Sponsored by: FreeBSD Foundation Notes: svn path=/head/; revision=256197
* Tidy up, cache return value of a function, and add an assertion;Edward Tomasz Napierala2013-10-091-6/+32
| | | | | | | | | | shouldn't make any functional difference. Approved by: re (gjb) Sponsored by: FreeBSD Foundation Notes: svn path=/head/; revision=256195
* Close the race on path ID allocation in xpt_bus_register() if two buses areAlexander Motin2013-10-091-9/+6
| | | | | | | | | | | | | | registered simultaneously. Due to topology unlock between the ID allocation and the bus registration there is a chance that two buses may get the same IDs. That is supposed reason of lock assertion panic in CAM during initial bus scanning after new iscsid initiates two sessions same time. Reported by: trasz Approved by: re (glebus, marius) MFC after: 2 weeks Notes: svn path=/head/; revision=256188
* Fix NOP-In/NOP-Out payload handling. Previous way didn't work at all; ↵Edward Tomasz Napierala2013-10-091-8/+33
| | | | | | | | | | | | fortunately nothing seems to actually use this feature, but it's required by standard. Approved by: re (glebius) Sponsored by: FreeBSD Foundation Notes: svn path=/head/; revision=256187
* Properly fix out of memory handling in the iSCSI target.Edward Tomasz Napierala2013-10-081-4/+11
| | | | | | | | Approved by: re (glebius) Sponsored by: FreeBSD Foundation Notes: svn path=/head/; revision=256163
* Split cfiscsi_datamove() in two; no functional changes.Edward Tomasz Napierala2013-10-051-182/+203
| | | | | | | | Approved by: re (glebius) Sponsored by: FreeBSD Foundation Notes: svn path=/head/; revision=256065
* Don't leak memory when removing an unconnected session, and remove uselessEdward Tomasz Napierala2013-10-041-1/+1
| | | | | | | | | | UMA_ZONE_NOFREE that caused another leak when unloading the module. Approved by: re (glebius) Sponsored by: FreeBSD Foundation Notes: svn path=/head/; revision=256058
* Make sure the CCB xflags field is initialized to zero so thatNathan Whitehorn2013-09-272-0/+5
| | | | | | | | | | | | CAM_EXTLUN_VALID is not erroneously set. Also add an XPORT_SRP identifier to the known SCSI transports for the SCSI RDMA protocol, as used, for example with Infiniband storage. Reviewed by: scottl Approved by: re (marius) Notes: svn path=/head/; revision=255915
* Re-do r255853. Along with adding back the API/ABI changes from theScott Long2013-09-256-90/+399
| | | | | | | | | | | original, this hides the contents of cam_compat.h from ktrace/kdump/truss, avoiding problems there. There are no user-servicable parts in there, so no need for those tools to be groping around in there. Approved by: re Notes: svn path=/head/; revision=255870
* Revert r255853 pending fixes to build errors in usr.bin/kdumpGlen Barber2013-09-256-392/+89
| | | | | | | Approved by: re (implicit) Notes: svn path=/head/; revision=255865
* Update the CAM API for FreeBSD 10:Scott Long2013-09-246-89/+392
| | | | | | | | | | | | | | | | | | | | | | | | | - Remove the timeout_ch field. It's been deprecated since FreeBSD 7.0; MPSAFE drivers should be managing their own timeout storage. The remaining non-MPSAFE drivers have been modified to also manage their own storage, and should be considered for updating to MPSAFE (or removal) during the FreeBSD 10.x lifecycle. - Add fields related to soft timeouts and quality of service, to be used in upcoming work. - Add room for more flags in the CCB header and path_inq structures. - Begin support for extended 64-bit LUNs. - Bump the CAM version number to 0x18, but add compat shims. Tested with camcontrol and smartctl. Reviewed by: nathanw, ken, kib Approved by: re Obtained from: Netflix Notes: svn path=/head/; revision=255853