Commit Graph

1209 Commits

Author SHA1 Message Date
Steven Hartland
ef27aa40a5 Corrected ATA Passthrough defines from decimal to hex
Reviewed by:	scottl
MFC after:	1 week
2013-06-20 21:38:08 +00:00
Scott Long
683f808e34 Fix an unfortunate typo with the compat shims
Obtained from:	Netflix
MFC after:	now
2013-06-19 05:11:30 +00:00
Scott Long
25a2902c04 Add infrastructure for doing compatibility shims, as has been sorely
needed for the last 10 years.  Far too much of the internal API is
exposed, and every small adjustment causes applications to stop working.
To kick this off, bump the API version to 0x17 as should have been done
with r246713, but add shims to compensate.  Thanks to the shims, there
should be no visible change in application behavior.

I have plans to do a significant overhaul of the API to harnen it for
the future, but until then, I welcome others to add shims for older
versions of the API.

Obtained from:	Netflix
2013-06-17 08:57:09 +00:00
Alexander Motin
2f87dfb0db Restore use of polling mode for disk cache flush in case of kernel panic.
While I am not sure that any extra hardware access is a good idea after
panic, that is an existing behaviour that should better work correctly.
2013-06-15 12:46:38 +00:00
Alexander Motin
967206bde7 Revert r251649:
ken@ noticed that with recently added d_gone() disk method GEOM already
holds reference on the periph, so we don't need another one.
2013-06-13 08:34:23 +00:00
Alexander Motin
ccba710262 Make CAM return and GEOM DISK pass through new GEOM::lunid attribute.
SPC-4 specification states that serial number may be property of device,
but not a specific logical unit.  People reported about FC storages using
serial number in that way, making it unusable for purposes of LUN multipath
detection.  SPC-4 states that designators associated with logical unit from
the VPD page 83h "Device Identification" should be used for that purpose.
Report first of them in the new attribute in such preference order: NAA,
EUI-64, T10 and SCSI name string.

While there, make GEOM DISK properly report GEOM::ident in XML output also
using d_getattr() method, if available.  This fixes serial numbers reporting
for SCSI disks in `geom disk list` output and confxml.

Discussed with:	gibbs, ken
Sponsored by:	iXsystems, Inc.
MFC after:	2 weeks
2013-06-12 13:36:20 +00:00
Alexander Motin
7912f917ca Acquire periph reference when handling d_getattr() method call.
While GEOM in general has provider opened while sending BIO_GETATTR,
GEOM DISK does not really need to open disk to read medium-unrelated
attributes for own use.

Proposed by:	ken
2013-06-12 09:07:15 +00:00
Scott Long
95fbded695 Simplify the checking of flags for cam_periph_mapmem(). This gets rid of
a lot of code redundancy and grossness at very minor expense.

Reviewed by:	smh
Obtained from:	Netflix
MFC after:	3 days
2013-06-07 00:22:38 +00:00
Steven Hartland
32fe0ef7ac Added missing SCSI quirks from r241784
Re-ordered SSD quirks alphabetically so they are easier to maintain.

Removed my email and PR reference from comments on each quirk.

Added quirks for more SSDs:
* Crucial M4
* Corsair Force GT
* Intel 520 Series
* Kingston E100 Series
* Samsung 830 Series

Reviewed by:	pjd (mentor)
Approved by:	pjd (mentor)
MFC after:	1 week
2013-05-28 14:44:37 +00:00
Steven Hartland
190b967447 Enforce validation on the selected delete method via sysctl.
This prevents users from selecting a delete method which may cause
corruption e.g. MPS WS16 on pre P14 firmware.

Reviewed by:	pjd (mentor)
Approved by:	pjd (mentor)
MFC after:	2 days
2013-05-24 11:27:06 +00:00
Steven Hartland
6fb5c84ea2 Added output of device QUIRKS for CAM and AHCI devices during boot.
Reviewed by:	mav
Approved by:	pjd (mentor)
MFC after:	2 weeks
2013-05-18 23:36:21 +00:00
Alexander Motin
60065e47cd Suppress error printing for "PREVENT ALLOW MEDIUM REMOVAL" on da open.
Change at r250208 exposed more errors here, hidden before.  The same flag
is used in cd driver.
2013-05-12 09:33:33 +00:00
Eitan Adler
883db1c1d9 Intel's 320-series and 510-series SSDs advertise 512-byte sectors
sizes for both logical and physical. Add ADA_Q_4K quirks
for both.

PR:		kern/178040
Submitted by:	Jeremy Chadwick <jdc@koitsu.org>
2013-05-11 23:13:49 +00:00
Alexander Motin
2406f9e41b Disable sending Early R_OK on SiI3726/SiI3826 port multipliers.
With "cached read" HDD testing and multiple ports busy on a SATA
host controller, 3726/3826 PMP will very rarely drop a deferred
R_OK that was intended for the host. Symptom will be all 5 drives
under test will timeout, get reset, and recover.

Submitted by:	Rich Futyma <rich.futyma@sanmina.com>
MFC after:	2 weeks
2013-05-11 13:21:31 +00:00
Eitan Adler
7a2b450ff8 Fxi a bunch of typos.
PR:	misc/174625
Submitted by:	Jeremy Chadwick <jdc@koitsu.org>
2013-05-10 16:41:26 +00:00
Alexander Motin
3d6dd54e2f Rework r250298 in more correct way. 2013-05-06 16:50:39 +00:00
Alexander Motin
5ab64734f3 Fix byte order of ATA WWN when converting it to SCSI LUN ID. 2013-05-06 15:58:53 +00:00
Alexander Motin
d067905faa Tune support for removable media in da driver:
- remove DA_FLAG_SAW_MEDIA flag, almost opposite to DA_FLAG_PACK_INVALID,
using the last instead.
 - allow opening device with no media present, reporting zero media size
and non-zero sector size, as geom/notes suggests.  That allow to read
device attributes and potentially do other things, not related to media.
2013-05-03 11:53:06 +00:00
Steven Hartland
7e6b858f4a Enable CAM SCSI to choice ATA TRIM during autodetection and correct method
names after increasing the priority of ATA TRIM.

Reviewed by:	mav
Approved by:	pjd (mentor)
MFC after:	1 week
2013-05-02 15:03:30 +00:00
Steven Hartland
a428909068 Use the existence of ATA Information VPD to determine if we should attempt
to query ATA functionality via ATA Pass-Through (16) as this page is defined
as "must" for SATL devices, hence indicating that the device is at least
likely to support Pass-Through (16).

This eliminates errors produced by CTL when ATA Pass-Through (16) fails.

Switch ATA probe daerror call to SF_NO_PRINT to avoid errors printing out
for devices which return invalid errors.

Output details about supported and choosen delete method when verbose booted.

Reviewed by:	mav
Approved by:	pjd (mentor)
MFC after:	 1 week
2013-05-02 14:37:23 +00:00
Steven Hartland
dcf0e9d179 Fix probe in progress check in dareprobe
Reviewed by:	mav
Approved by:	pjd (mentor)
MFC after:	1 week
2013-05-02 14:19:42 +00:00
Steven Hartland
f68008595b Update probe flow so that devices with lbp can also disable disksort.
Ensure that delete_available is reset so re-probes after a media change,
to one with different delete characteristics, will result in the correct
methods being flagged as available.

Make all ccb state changes use a consistent flow:
* free()
* xpt_release_ccb()
* softc->state = <new state>
* xpt_schedule()

Reviewed by:	mav
Approved by:	pjd (mentor)
MFC after:	1 week
2013-05-02 14:14:57 +00:00
Eitan Adler
578acad37e Correct a few sizeof()s
Submitted by:	swildner@DragonFlyBSD.org
Reviewed by:	alfred
2013-05-01 04:37:34 +00:00
Steven Hartland
62cc3a6314 Correct comment typo's
Add missing comment

Reviewed by:	pjd (mentor)
Approved by:	pjd (mentor)
MFC after:	2 weeks
2013-04-28 21:14:23 +00:00
Alexander Motin
e746842845 Add some cam_freeze_devq()'s missed at r249466.
This makes number of freezes match the number of releases.

Reported by:	dim
2013-04-28 18:12:43 +00:00
Alexander Motin
7338ef1a6b MFprojects/camlock r249542:
Remove ADA_FLAG_PACK_INVALID flag. Since ATA disks have no concept of media
change it only duplicates CAM_PERIPH_INVALID flag, so we can use last one.

Slightly cleanup DA_FLAG_PACK_INVALID use.
2013-04-27 12:46:04 +00:00
Alexander Motin
d38c0e53a8 MFprojects/camlock r249541:
Give periph validity flag own periph reference.  That slightly simplifies
the release logic and covers hypothetical case if lock is dropped inside
the periph_oninval() method.
2013-04-27 12:39:28 +00:00
Steven Hartland
90edda31ba Added automatic detection of non-rotating media which disables the
use of BIO queue sorting, hence optimising performance for devices
such as SSD's

Reviewed by:	scottl
Approved by:	pjd (mentor)
MFC after:	2 weeks
2013-04-26 16:31:03 +00:00
Steven Hartland
9fe9ba5bef Teach GEOM and CAM about the difference between the max "size" of r/w and delete
requests.

sys/geom/geom_disk.h:
        - Added d_delmaxsize which represents the maximum size of individual
          device delete requests in bytes. This can be used by devices to
          inform geom of their size limitations regarding delete operations
          which are generally different from the read / write limits as data
          is not usually transferred from the host to physical device.

sys/geom/geom_disk.c:
        - Use new d_delmaxsize to calculate the size of chunks passed through to
          the underlying strategy during deletes instead of using read / write
          optimised values. This defaults to d_maxsize if unset (0).

        - Moved d_maxsize default up so it can be used to default d_delmaxsize

sys/cam/ata/ata_da.c:
        - Added d_delmaxsize calculations for TRIM and CFA

sys/cam/scsi/scsi_da.c:
        - Added re-calculation of d_delmaxsize whenever delete_method is set.

        - Added kern.cam.da.X.delete_max sysctl which allows the max size for
          delete requests to be limited. This is useful in preventing timeouts
          on devices who's delete methods are slow. It should be noted that
          this limit is reset then the device delete method is changed and
          that it can only be lowered not increased from the device max.

Reviewed by:	mav
Approved by:	pjd (mentor)
2013-04-26 16:22:54 +00:00
Steven Hartland
da98dc7f43 Added available delete methods discovery during device probe, including the
maximum sizes for said methods, which are used when processing BIO_DELETE
requests. This includes updating UNMAP support discovery to be based on
SBC-3 T10/1799-D Revision 31 specification.

Added ATA TRIM support to cam scsi devices via ATA Pass-Through(16)

sys/cam/scsi/scsi_da.c:
        - Added ATA Data Set Management TRIM support via ATA Pass-Through(16)
          as a delete_method

        - Added four new probe states used to identity available methods and their
          limits for the processing of BIO_DELETE commands via both UNMAP and the
          new ATA TRIM commands.

        - Renamed Probe states to better indicate their use

        - Added delete method descriptions used when informing user of issues.

        - Added automatic calculation of the optimum delete mode based on which
          method presents the largest maximum request size as this is most likely
          to result in the best performance.

        - Added WRITE SAME max block limits

        - Updated UNMAP range generation to mirror that used by ATA TRIM, this
          optimises the generation of ranges and fixes a potential overflow
          issue in the count when combining multiple BIO_DELETE requests

        - Added output of warnings about short deletes. This should only ever
          be triggered on devices that fail to correctly advertise their supported
          delete modes / max sizes.

        - Fixed WS16 requests being incorrectly limited to 65535 in length.

Reviewed by:	mav
Approved by:	pjd (mentor)
MFC after:	2 weeks
2013-04-26 16:17:04 +00:00
Steven Hartland
e88aa3fd2c Refactored scsi_xpt use of device_has_vpd to generic scsi_vpd_supported_page
so its available for use in generic scsi code.

This is a pre-requirement for using VPD queries to determine available SCSI
delete methods within scsi_da.

Reviewed by:	mav
Approved by:	pjd (mentor)
MFC after:	2 weeks
2013-04-26 16:11:03 +00:00
Steven Hartland
c213c55153 Updated TRIM calculations in cam/ata to be based off ATA_DSM_* defines
Reviewed by:	mav
Approved by:	pjd (mentor)
MFC after:	2 weeks
2013-04-26 15:59:19 +00:00
Steven Hartland
b1da0a9868 Added the ability to send ATA identify and Data Set Management (DSM) TRIM
commands to an ATA device attached via a SCSI control.

sys/cam/scsi/scsi_all.c:
        - Added scsi_ata_identify, scsi_ata_trim
          Which use ATA Pass-Through to send commands to the attached disk.

sys/cam/scsi/scsi_all.h:
        - Added defines for all missing ATA Pass-Through commands values.

        - Added scsi_ata_identify, scsi_ata_trim methods used in ATA TRIM
          support.

        - Added scsi_vpd_logical_block_prov structure used when querying for
          the supported sizes UNMAP commands.

        - Added scsi_vpd_block_limits structure used when querying for the
          supported sizes of the UNMAP command.

Reviewed by:	mav
Approved by:	pjd (mentor)
MFC after:	2 weeks
2013-04-26 15:53:22 +00:00
Steven Hartland
6225bf48ae Removed unneeded tests in dadeletemethodset changing it to return void
Reviewed by:	mav
Approved by:	pjd (mentor)
MFC after:	2 weeks
2013-04-26 15:31:52 +00:00
Kenneth D. Merry
e1ee2f21d9 Fix compilation.
Pointy hat to:	ken
2013-04-20 14:33:55 +00:00
Sean Bruno
6b156f6137 Expose CAM_BOOT_DELAY as a kernel conf item now.
This allows users who boot without loader to adjust their environments
around slightly buggy or slow hardware.

PR:	kern/161809
Submitted by:	rozhuk.im@gmail.com
MFC after:	2 weeks
2013-04-20 00:33:37 +00:00
Kenneth D. Merry
21b6ee96fc Update chio(1) and ch(4) to support reporting element designators.
This allows mapping a tape drive in a changer (as reported by
'chio status') to a sa(4) driver instance by comparing the
serial numbers.

The designators can be ASCII (which is printed out directly), binary
(which is printed in hex format) or UTF-8, which is printed in either
native UTF-8 format if the terminal can support it, or in %XX notation
for non-ASCII characters.  Thanks to Hiroki Sato <hrs@> for the
explaining UTF-8 printing and example UTF-8 printing code.

chio.h:		Modify the changer_element_status structure to add new
		fields and definitions from the SMC3r16 spec.

		Rename the original CHIOGSTATUS ioctl to OCHIOGTATUS and
		define a new CHIOGSTATUS ioctl.

		Clean up some tab/space issues.

chio.c: 	For the 'status' subcommand, print the designator field
		if it is supplied by a device.

scsi_ch.h:	Add new flags for DVCID and CURDATA to the READ
		ELEMENT STATUS command structure.

		Add a read_element_status_device_id structure
		for the data fields in the new standard. Add new
		unions, dt_or_obsolete and voltage_devid, to hold
		and address data from either SCSI-2 or newer devices.

scsi_ch.c:	Implement support for fetching device IDs with READ
		ELEMENT STATUS data.

		Add new arguments to scsi_read_element_status() to
		allow the user to request the DVCID and CURDATA bits.
		This isn't compiled into libcam (it's only an internal
		kernel interface), so we don't need any special
		handling for the API change.

		If the user issues the new CHIOGSTATUS ioctl, copy all of
		the available element status data out.  If he issues the
		OCHIOGSTATUS ioctl, we don't copy the new fields in the
		structure.

		Fix a bug in chopen() that would result in the peripheral
		never getting unheld if chgetparams() failed.

Sponsored by:	Spectra Logic
Submitted by:	Po-Li Soong
MFC After:	1 week
2013-04-19 20:03:51 +00:00
Gabor Kovesdan
8fb3bbe770 - Corrrect mispellings of word useful
Submitted by:	Christoph Mallon <christoph.mallon@gmx.de> (via private mail)
2013-04-17 11:45:15 +00:00
Gabor Kovesdan
ab3f6b347e - Correct mispellings of the word occurrence
Submitted by:	Christoph Mallon <christoph.mallon@gmx.de> (via private mail)
2013-04-17 11:40:10 +00:00
Alexander Motin
1268d4813e Remove some more pieces of multilevel freeze mechanism, missed in r249466. 2013-04-14 18:09:08 +00:00
Alexander Motin
d442caf633 Remove owner field from struct cam_ed, unused at least since FreeBSD 7. 2013-04-14 10:14:26 +00:00
Alexander Motin
e5dfa058da MFprojects/camlock r248982:
Stop abusing xpt_periph in random plases that really have no periph related
to CCB, for example, bus scanning.  NULL value is fine in such cases and it
is correctly logged in debug messages as "noperiph".  If at some point we
need some real XPT periphs (alike to pmpX now), quite likely they will be
per-bus, and not a single global instance as xpt_periph now.
2013-04-14 09:55:48 +00:00
Alexander Motin
cccf422080 MFprojects/camlock r248890, r248897, r248898, r248900, r248903, r248905,
r248917, r248918, r248978, r249001, r249014, r249030:

Remove multilevel freezing mechanism, implemented to handle specifics of
the ATA/SATA error recovery, when post-reset recovery commands should be
allocated when queues are already full of payload requests.  Instead of
removing frozen CCBs with specified range of priorities from the queue
to provide free openings, use simple hack, allowing explicit CCBs over-
allocation for requests with priority higher (numerically lower) then
CAM_PRIORITY_OOB threshold.

Simplify CCB allocation logic by removing SIM-level allocation queue.
After that SIM-level queue manages only CCBs execution, while allocation
logic is localized within each single device.

Suggested by:	gibbs
2013-04-14 09:28:14 +00:00
Alexander Motin
a4f17f083f MFprojects/camlock r248894:
Use full freeze while PMP does hard reset. This is only cosmetical change.
2013-04-13 14:03:44 +00:00
Edward Tomasz Napierala
8ed9860914 Remove ctl(4) from GENERIC. Also remove 'options CTL_DISABLE'
and kern.cam.ctl.disable tunable; those were introduced as a workaround
to make it possible to boot GENERIC on low memory machines.

With ctl(4) being built as a module and automatically loaded by ctladm(8),
this makes CTL work out of the box.

Reviewed by:	ken
Sponsored by:	FreeBSD Foundation
2013-04-12 16:25:03 +00:00
Alexander Motin
b2565f51fc Do not sent 120 TEST UNIT READY requests on generic NOT READY statuses.
Some failing disks tend to return vendor-specific ASC/ASCQ codes with
NOT READY sense key.  It caused extremely long recovery attempts, repeating
these 120 TURs (it takes at least 1 minute) for every I/O request.
Instead of that use default error handling, doing just few retries.

Reviewed by:	ken, gibbs
MFC after:	1 month
2013-04-11 06:34:41 +00:00
Kenneth D. Merry
0ba1e4d063 Add a callback to the ada(4) driver so that it knows when GEOM has released
references to it.

This is the functional equivalent to change r237518, which added this
functionality to the cd(4) and da(4) drivers.

This fix prevents a panic caused by GEOM calling adaopen() while the device
is going away.  We now keep the device around until GEOM has finished
cleaning up its state.

ata_da.c:	In adaregister(), add a d_gone callback to the GEOM disk
		structure registered for the ada driver.  Increment the
		peripheral reference count for GEOM.

		Add a new callback, adadiskgonecb(), that GEOM calls when
		it is done with its resources.  This callback releases the
		reference acquired in adaregister().

Submitted by:	Po-Li Soong
Sponsored by:	Spectra Logic
MFC After:	5 days
2013-04-10 22:12:21 +00:00
Kenneth D. Merry
1fe2e04bb6 Fix a memory leak that showed up when we delete LUNs. The memory used for
the LUN was never freed.

ctl.c:		Adjust ctl_alloc_lun() to make sure we don't clear the
		CTL_LUN_MALLOCED flag.

Reported by:	Sreenivasa Honnur <shonnur@chelsio.com>
Sponsored by:	Spectra Logic
MFC after:	3 days
2013-04-08 15:36:26 +00:00
Alexander Motin
4b38708189 Remove extra semicolons from CAM_SIM_[UN]LOCK() macros. 2013-04-07 06:47:44 +00:00
Marius Strobl
d2ce15bd43 - With the demise of !ATA_CAM, ATA_STATIC_ID is the only ata(4) related
option left but actually consumed by ada(4), so move it to opt_ada.h
  and get rid of opt_ata.h.
- Fix stand-alone build of atacore(4) by adding opt_cam.h.
- Use __FBSDID.
- Use DEVMETHOD_END.
- Use NULL instead of 0 for pointers.
2013-04-06 19:12:49 +00:00