aboutsummaryrefslogtreecommitdiff
path: root/sys/cam
Commit message (Collapse)AuthorAgeFilesLines
* cam_periph_acquire() now returns an errno.Kenneth D. Merry2018-03-191-2/+2
| | | | | | | | | | | | The ch(4) driver was missed in change 328918, which changed cam_periph_acquire() to return an errno instead of cam_status. As a result, ch(4) failed to attach. Sponsored by: Spectra Logic Notes: svn path=/head/; revision=331223
* Only take out the periph lock when we're modifying the flags of theWarner Losh2018-03-171-2/+6
| | | | | | | | | | | | | | | softc for an async unit attention. CAM locks, sometimes, the periph lock and other times does not. We were taking the lock always and running into lock recursion issues on a non-recursive lock. Now we take it selectively. It's not clear why xpt takes the lock selectively before calling us, though, and that's still under investigation. Reported by: avg PR: 226510 (same panic, differnt circumstances) Sponsored by: Netflix Notes: svn path=/head/; revision=331097
* Fix iSCSI target crash on session reinstation.Edward Tomasz Napierala2018-03-152-7/+32
| | | | | | | | | | | | | | | | | | | The crash scenario goes like this: there's a thread waiting on "reinstate"; because it doesn't update the timeout counter it gets terminated by the callout; at this point the maintenance thread starts the termination routine. The first thread finishes waiting, proceeds to icl_conn_handoff(), and drops the refcount, which allows the maintenance thread to free its resources. At this point another thread receives a PDU. Boom. PR: 222898, 219866 Reported by: Eugene M. Zheganin <emz at norma.perm.ru> Tested by: Eugene M. Zheganin <emz at norma.perm.ru> Reviewed by: mav@ (earlier version) MFC after: 2 weeks Sponsored by: playkey.net Notes: svn path=/head/; revision=331013
* Create a sysctl kern.cam.{,a,n}da.X.invalidateWarner Losh2018-03-145-4/+52
| | | | | | | | | | | | | | | | | | | kern.cam.{,a,n}da.X.invalidate=1 forces *daX to detach by calling cam_periph_invalidate on the underlying periph. This is for testing purposes only. Include only with options CAM_TEST_FAILURE and rename the former [AN]DA_TEST_FAILURE, and fix nda to compile with it set. We're using it at work to harden geom and the buffer cache to be resilient in the face of drive failure. Today, it far too often results in a panic. While much work was done on SIM initiated removal for the USB thumnb drive removal work, little has been done for periph initiated removal. This simulates what *daerror() does for some errors nicely: we get the same panics with it that we do with failing drives. Sponsored by: Netflix Differential Revision: https://reviews.freebsd.org/D14581 Notes: svn path=/head/; revision=330935
* Fix inverted logic that counted all completions as errors, except whenWarner Losh2018-03-141-3/+3
| | | | | | | | | they were actual errors. Sponsored by: Netflix Notes: svn path=/head/; revision=330933
* Implement trim collapsing in ndaWarner Losh2018-03-141-66/+112
| | | | | | | | | | | | When multiple trims are in the queue, collapse them as much as possible. At present, this usually results in only a few trims being collapsed together, but more work on that will make it possible to do hundreds (up to some configurable max). Sponsored by: Netflix Notes: svn path=/head/; revision=330932
* Allow NULL ccb to cam_iosched_bio_completeWarner Losh2018-03-141-1/+1
| | | | | | | | | | | | When the ccb is NULL to cam_iosched_bio_complete, just update the other statistics, but not the time. If many operations are collapsed together, this is needed to keep stats properly for the grouped bp. This should fix trim accounting. Sponsored by: Netflix Notes: svn path=/head/; revision=330931
* Reject ioctls to SCSI enclosures from 32-bit compat processes.Brooks Davis2018-03-121-0/+8
| | | | | | | | | | | | | | | The ioctl objects contain pointers and require translation and some refactoring of the infrastructure to work. For now prevent opertion on garbage values. This is very slightly overbroad in that ENCIOC_INIT is safe. Reviewed by: imp, kib Obtained from: CheriBSD Sponsored by: DARPA, AFRL Differential Revision: https://reviews.freebsd.org/D14671 Notes: svn path=/head/; revision=330820
* Reject CAMIOGET and CAMIOQUEUE ioctl's on pass(4) in 32-bit compat mode.Brooks Davis2018-03-121-0/+15
| | | | | | | | | | | | | | | | These take a union ccb argument which is full of kernel pointers. Substantial translation efforts would be required to make this work. By rejecting the request we avoid processing or returning entierly wrong data. Reviewed by: imp, ken, markj, cem Obtained from: CheriBSD MFC after: 1 week Sponsored by: DARPA, AFRL Differential Revision: https://reviews.freebsd.org/D14654 Notes: svn path=/head/; revision=330819
* Tighten up periph lock to avoid some racesWarner Losh2018-03-121-3/+32
| | | | | | | | | | | | | Make sure the periph lock is held around rmw access to softc data, espeically flags, including work flags in iosched. Add asserts for the periph lock where it should be held. PR: 226510 Sponsored by: Netflix Differential Review: https://reviews.freebsd.org/D14456 Notes: svn path=/head/; revision=330796
* nvme_da: Fix minor memory leak in error caseConrad Meyer2018-03-101-0/+1
| | | | | | | | Reported by: cppcheck Sponsored by: Dell EMC Isilon Notes: svn path=/head/; revision=330717
* Use bool instead of int for predicate functions relating to workWarner Losh2018-02-231-6/+6
| | | | | | | available. Notes: svn path=/head/; revision=329866
* NVMe: Add big-endian supportWojciech Macek2018-02-222-16/+31
| | | | | | | | | | | | | | | | Remove bitfields from defined structures as they are not portable. Instead use shift and mask macros in the driver and nvmecontrol application. NVMe is now working on powerpc64 host. Submitted by: Michal Stanek <mst@semihalf.com> Obtained from: Semihalf Reviewed by: imp, wma Sponsored by: IBM, QCM Technologies Differential revision: https://reviews.freebsd.org/D13916 Notes: svn path=/head/; revision=329824
* Revert r329814 as well. It should have been in r329819.Warner Losh2018-02-221-18/+11
| | | | Notes: svn path=/head/; revision=329821
* Backout r329818, r329816 and r329815.Warner Losh2018-02-225-106/+41
| | | | | | | | These aren't the commits I thought I was testing prior to commit. Revert until I can sort out what happened and fix it. Notes: svn path=/head/; revision=329819
* Fix typo in last commit after last rebase before commit...Warner Losh2018-02-221-1/+1
| | | | Notes: svn path=/head/; revision=329818
* Combine BIO_DELETE requests for nda devicesWarner Losh2018-02-221-22/+46
| | | | | | | | | | | | | | | | Now that we're queueing BIO_DELETE requests in the CAM I/O scheduler, it make sense to try to combine as many as possible into a single request to send down to hardware. Hopefully, lots of larger requests like this are better than lots of individual transactions. Note for future: need to limit based on total size of the trim request. Should also collapse adjacent ranges where possible to increase the size of the max payload. Sponsored by: Netflix Notes: svn path=/head/; revision=329816
* Introduce capacity flags for periphsWarner Losh2018-02-225-18/+59
| | | | | | | | | | | | | | | | | | | Introduce flags word to describe the capacities of the peripheral. First bit will describe if the periph driver allows multiple outstanding TRIMS to be active in a device. Modify the I/O scheduler so that the nda driver can queue trims for a while after the first one arrives. We'll queue until we see a I/O scheduler tick, then we'll schedule as many TRIMs as allowed by other factors (currently this is slocts in the NVMe controller). This mariginally helps the read latency issues we see with reads, but sets the stage for the nda driver to do TRIM collapsing like the da and ada drivers do today. Sponsored by: Netflix Notes: svn path=/head/; revision=329815
* Note when we tick.Warner Losh2018-02-221-11/+18
| | | | | | | | | | | To help implement a policy of 'queue all trims until next I/O sched tick' policy to help coalesce them, note when we tick so we can do something special on the first call after the tick to get more work. Sponsored by: Netflix Notes: svn path=/head/; revision=329814
* Wrap an extra long lineWarner Losh2018-02-221-1/+5
| | | | | | | | | | This debugging line is too big for even my largest xterm. wrap it at about 80 columns. Sponsored by: Netflix Notes: svn path=/head/; revision=329813
* Don't sort TRIMs.Warner Losh2018-02-221-1/+1
| | | | | | | | | | | | While the code for ada and da both assume that the trim list is ordered when doing the coaleascing the TRIMs, it turns out that creating the sorted list uses more resources than are saved by having slightly fewer trims sent to the device. Sponsored by: Netflix Notes: svn path=/head/; revision=329812
* Minor formatting nits.Warner Losh2018-02-211-11/+11
| | | | Notes: svn path=/head/; revision=329764
* Use proper buffer length (the announce_buf char pointer used to be anarray),Edward Tomasz Napierala2018-02-211-2/+3
| | | | | | | | | | | | | broken in r317143. This fixes those weird "cd0: Attempt" messages at boot. PR: 222103 Reviewed by: scottl@ MFC after: 2 weeks Sponsored by: DARPA, AFRL Differential Revision: https://reviews.freebsd.org/D14369 Notes: svn path=/head/; revision=329708
* Report the number of remaining retries when we have an error thatWarner Losh2018-02-151-2/+5
| | | | | | | we're retrying. Notes: svn path=/head/; revision=329337
* Fix cut and pasted comments to reflect differences in code from theWarner Losh2018-02-071-4/+10
| | | | | | | | | original source. Sponsored by: Netflix Notes: svn path=/head/; revision=328983
* Keep a counter for number of requests completed with an error.Warner Losh2018-02-061-1/+13
| | | | | | | Sponsored by: Netflix Notes: svn path=/head/; revision=328960
* Return a C errno for cam_periph_acquire().Scott Long2018-02-0618-71/+62
| | | | | | | | | | | | | | There's no compelling reason to return a cam_status type for this function and doing so only creates confusion with normal C coding practices. It's technically an API change, but the periph API isn't widely used. No efffective change to operation. Reviewed by: imp, mav, ken Sponsored by: Netflix Differential Revision: D14063 Notes: svn path=/head/; revision=328918
* Do the book-keeping on release before we release the reference. TheWarner Losh2018-01-291-3/+3
| | | | | | | | | | periph was going away on final release, and then returning and we started dancing in free memory. Sponsored by: Netflix Notes: svn path=/head/; revision=328554
* Finish the incomplete move of CAM_PERIPH_PRINT().Scott Long2018-01-271-6/+8
| | | | | | | Reported by: kevans Notes: svn path=/head/; revision=328464
* Move CAM_PERIPH_PRINT() to cam_periph.hScott Long2018-01-262-3/+3
| | | | Notes: svn path=/head/; revision=328455
* Fix a sleepable malloc in ndastart. We shouldn't be sleepingWarner Losh2018-01-261-1/+7
| | | | | | | | | | | | | | here. Return ENOMEM when we can't malloc a buffer for the DSM TRIM. This should fix the WITNESS warnings similar to the following: uma_zalloc_arg: zone "16" with the following non-sleepable locks held: exclusive sleep mutex CAM device lock (CAM device lock) r = 0 (0xfffff800080c34d0) locked @ /usr/src/sys/cam/nvme/nvme_da.c:351 Reviewed by: scottl@ Sponsored by: Netflix Notes: svn path=/head/; revision=328452
* Fix a cut-and-paste error in a panic messageScott Long2018-01-261-1/+1
| | | | Notes: svn path=/head/; revision=328445
* Minimum changes for ctl to build on architectures with non-matching physical andJustin Hibbits2018-01-262-3/+3
| | | | | | | | | | | | | | | | virtual address sizes Summary: Some architectures use physical addresses larger than virtual. This is the minimal changeset needed to get CAM/CTL to build on these targets. No functional changes. More changes would likely be needed for this to be fully functional on said platforms, but they can be made when needed. Reviewed By: mav, chuck Differential Revision: https://reviews.freebsd.org/D14041 Notes: svn path=/head/; revision=328425
* Track Ref / DeRef and Hold / Unhold that da is doing to track downWarner Losh2018-01-251-23/+177
| | | | | | | | | | | | | | | leaks. We assume each source can be taken / dropped only once and don't recurse. These are only enabled via DA_TRACK_REFS or INVARIANTS. There appreas to be a reference leak under extreme load, and these should help us colaberatively work it out. It also documents better the reference / holding protocol better. Reviewed by: ken@, scottl@ Sponsored by: Netflix Differential Revision: https://reviews.freebsd.org/D14040 Notes: svn path=/head/; revision=328415
* When devices are invalidated, there's some cases where ccbs for thatWarner Losh2018-01-251-4/+13
| | | | | | | | | | | | device still wind up in xpt_done after the path has been invalidated. Since we don't always need sim or devq, add some guard rails to only fail if we have to use them. Sponsored by: Netflix Differential Revision: https://reviews.freebsd.org/D14040 Notes: svn path=/head/; revision=328414
* Minor whitespace cleanup to remove leading space before tab. NoWarner Losh2018-01-251-18/+18
| | | | | | | functional changes. Notes: svn path=/head/; revision=328387
* This comment is bogus. This is a legit release.Warner Losh2018-01-221-1/+1
| | | | | | | | Reviewed by: scottl@, ken@ Sponsored by: Netflix Notes: svn path=/head/; revision=328262
* Unsign some values related to allocation.Pedro F. Giffuni2018-01-221-1/+2
| | | | | | | | | | | | | | When allocating memory through malloc(9), we always expect the amount of memory requested to be unsigned as a negative value would either stand for an error or an overflow. Unsign some values, found when considering the use of mallocarray(9), to avoid unnecessary casting. Also consider that indexes should be of at least the same size/type as the upper limit they pretend to index. MFC after: 3 weeks Notes: svn path=/head/; revision=328238
* Revert r327828, r327949, r327953, r328016-r328026, r328041:Pedro F. Giffuni2018-01-212-3/+3
| | | | | | | | | | | | | | | | | | Uses of mallocarray(9). The use of mallocarray(9) has rocketed the required swap to build FreeBSD. This is likely caused by the allocation size attributes which put extra pressure on the compiler. Given that most of these checks are superfluous we have to choose better where to use mallocarray(9). We still have more uses of mallocarray(9) but hopefully this is enough to bring swap usage to a reasonable level. Reported by: wosch PR: 225197 Notes: svn path=/head/; revision=328218
* Fix compile errors in r328165Scott Long2018-01-191-4/+2
| | | | | | | | Reported by: O. Hartmann Sponsored by: Netflix Notes: svn path=/head/; revision=328170
* Revert ABI breakage to CAM that came in with MMC/SD support in r320844.Scott Long2018-01-193-4/+8
| | | | | | | | | | | | Make it possible to retrieve mmc parameters via the XPT_GET_ADVINFO call instead. Convert camcontrol to the new scheme. Reviewed by: imp. kibab Sponsored by: Netflix Differential Revision: D13868 Notes: svn path=/head/; revision=328165
* SPDX: finish tagging sys/cam.Pedro F. Giffuni2018-01-1617-2/+34
| | | | Notes: svn path=/head/; revision=328070
* scsi_ch.c: Small cleanups to the comments.Pedro F. Giffuni2018-01-161-7/+3
| | | | | | | | | | | | Move the the NetBSD tag near to the related licence. Update it to reflect better the point where we started diverging. Use grouping parenthesis for the SPDX tag. No functional change. Notes: svn path=/head/; revision=328067
* cam: make some use of mallocarray(9).Pedro F. Giffuni2018-01-152-3/+3
| | | | | | | | | | | | | | | | Focus on code where we are doing multiplications within malloc(9). None of these ire likely to overflow, however the change is still useful as some static checkers can benefit from the allocation attributes we use for mallocarray. This initial sweep only covers malloc(9) calls with M_NOWAIT. No good reason but I started doing the changes before r327796 and at that time it was convenient to make sure the sorrounding code could handle NULL values. X-Differential revision: https://reviews.freebsd.org/D13837 Notes: svn path=/head/; revision=328022
* geom_disk / scsi_da: deny opening write-protected disks for writingAndriy Gapon2018-01-151-7/+80
| | | | | | | | | | | | | | | | | | | | | | | Ths change consists of two parts. geom_disk: deny opening a disk for writing if it's marked as write-protected. A new disk(9) flag is added to mark write protected disks. A possible alternative could be to add another parameter to d_open, so that the open mode could be passed to it and the disk drivers could make the decision internally, but the flag required less churn. scsi_da: add a new phase of disk probing to query the all pages mode sense page. We can determine if the disk is write protected using bit 7 of the device specific field in the mode parameter header returned by MODE SENSE. PR: 224037 Reviewed by: mav MFC after: 4 weeks Differential Revision: https://reviews.freebsd.org/D13360 Notes: svn path=/head/; revision=327996
* When we crash, we'll stop the scheduler before we call theWarner Losh2018-01-111-2/+8
| | | | | | | | | | | | | | | | shutdown_post_sync event. For adashutdown, this causes problems because we need to poll for completion of the commands, but we're not yet officially dumping yet, so the code from r326964 assumed we could use the interrupt-driven commands rather than the polled ones. This lead to a hang. Prevent this by also checking to see if the scheduler is stopped to do the polling. Reported by: markj@ Sponsored by: Netflix Differential Review: https://reviews.freebsd.org/D13845 Notes: svn path=/head/; revision=327805
* Release the held refcount on the probe periph when probing isScott Long2018-01-091-2/+1
| | | | | | | | | done, now that r327741 lets this happen. Obtained from: Netflix Notes: svn path=/head/; revision=327742
* Hold a refcount on the periph while running the allocationScott Long2018-01-091-0/+2
| | | | | | | | | | queue. This will allow sub-transports to release their probe pseudo-device with fewer convoluted restrictions. Obtained from: Netflix Notes: svn path=/head/; revision=327741
* Remove ccbque.h from i386/isa.Warner Losh2018-01-092-1/+114
| | | | | | | | | | | | | | | | inline ccbque.h into scsi_low.h. The file isn't MD, so shouldn't live in i386/isa. It's only used by scsi_low, so move it there so no new clients accidentally grow. scsi_low may not even still work, and the locking here is still SPL based. CAM should do the right thing, but I've received no reports of these cards still working. At least it compiles still and there's one fewer files in sys/i386/isa. While I'm here, ansify and de-splize. CCB_MWANTED appears to be a clear-only flag, but I've not changed that. Differential Review: https://reviews.freebsd.org/D13672 Notes: svn path=/head/; revision=327729
* Don't hold the periph locks during dump.Scott Long2018-01-091-6/+1
| | | | | | | Obtained from: Netflix Notes: svn path=/head/; revision=327711