1.\" Copyright (c) 2009 Alexander Motin <mav@FreeBSD.org> 2.\" All rights reserved. 3.\" 4.\" Redistribution and use in source and binary forms, with or without 5.\" modification, are permitted provided that the following conditions 6.\" are met: 7.\" 1. Redistributions of source code must retain the above copyright 8.\" notice, this list of conditions and the following disclaimer. 9.\" 10.\" 2. Redistributions in binary form must reproduce the above copyright 11.\" notice, this list of conditions and the following disclaimer in the 12.\" documentation and/or other materials provided with the distribution. 13.\" 14.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24.\" SUCH DAMAGE. 25.\" 26.Dd December 20, 2017 27.Dt ADA 4 28.Os 29.Sh NAME 30.Nm ada 31.Nd ATA Direct Access device driver 32.Sh SYNOPSIS 33.Cd device ada 34.Sh DESCRIPTION 35The 36.Nm 37driver provides support for direct access devices, implementing the 38.Tn ATA 39command protocol, that are attached to the system through a host adapter 40supported by the CAM subsystem. 41.Pp 42The host adapter must also be separately configured into the system before an 43.Tn ATA 44direct access device can be configured. 45.Sh COMMAND QUEUING 46Command queuing allows the device to process multiple transactions 47concurrently, often re-ordering them to reduce the number and length of 48seeks. 49.Tn ATA 50defines two types of queuing: 51.Tn TCQ (Tagged Command Queuing, PATA legacy) 52and 53.Tn NCQ (Native Command Queuing, SATA) . 54The 55.Nm 56device driver takes full advantage of NCQ, when supported. 57To ensure that transactions to distant parts of the media, 58which may be deferred indefinitely by servicing requests closer to the current 59head position, are completed in a timely fashion, an ordered 60transaction is sent every 7 seconds during continuous device operation. 61.Sh CACHE EFFECTS 62Many direct access devices are equipped with read and/or write caches. 63Parameters affecting the device's cache are reported in device IDENTIFY data 64and can be examined and modified via the 65.Xr camcontrol 8 66utility. 67.Pp 68The read cache is used to store data from device-initiated read ahead 69operations as well as frequently used data. 70The read cache is transparent 71to the user and can be enabled without any adverse effect. 72Most devices 73with a read cache come from the factory with it enabled. 74.Pp 75The write cache can greatly decrease the latency of write operations 76and allows the device to reorganize writes to increase efficiency and 77performance. 78This performance gain comes at a price. 79Should the device 80lose power while its cache contains uncommitted write operations, these 81writes will be lost. 82The effect of a loss of write transactions on 83a file system is non-deterministic and can cause corruption. 84Most 85devices age write transactions to limit the vulnerability to a few transactions 86recently reported as complete, but it is nonetheless recommended that 87systems with write cache enabled devices reside on an Uninterruptible 88Power Supply (UPS). 89The 90.Nm 91device driver ensures that the cache and media are synchronized upon 92final close of the device or an unexpected shutdown (panic) event. 93This ensures that it is safe to disconnect power once the operating system 94has reported that it has halted. 95.Sh SYSCTL VARIABLES 96The following variables are available as both 97.Xr sysctl 8 98variables and 99.Xr loader 8 100tunables: 101.Bl -tag -width 12 102.It Va kern.cam.ada.retry_count 103.Pp 104This variable determines how many times the 105.Nm 106driver will retry a READ or WRITE command. 107This does not affect the number of retries used during probe time or for 108the 109.Nm 110driver dump routine. 111This value currently defaults to 4. 112.It Va kern.cam.ada.default_timeout 113.Pp 114This variable determines how long the 115.Nm 116driver will wait before timing out an outstanding command. 117The units for this value are seconds, and the default is currently 30 118seconds. 119.It Va kern.cam.ada.spindown_shutdown 120.Pp 121This variable determines whether to spin-down disks when shutting down. 122Set to 1 to enable spin-down, 0 to disable. 123The default is currently enabled. 124.It Va kern.cam.sort_io_queue 125.It Va kern.cam.ada. Ns Ar X Ns Va .sort_io_queue 126.Pp 127These variables determine whether request queue should be sorted trying 128to optimize head seeks. 129Set to 1 to enable sorting, 0 to disable, -1 to leave it as-is. 130The default is sorting enabled for HDDs and disabled SSDs. 131.It Va kern.cam.ada.read_ahead 132.It Va kern.cam.ada. Ns Ar X Ns Va .read_ahead 133.It Va kern.cam.ada.write_cache 134.It Va kern.cam.ada. Ns Ar X Ns Va .write_cache 135.Pp 136These variables determine whether device read-ahead and write caches 137should be enabled globally or per-device or disabled. 138Set to 1 to enable write cache, 0 to disable, -1 to leave it as-is. 139Values modified at runtime take effect only after device reset 140.Pq using the reset subcommand of Xr camcontrol 8 . 141Because of that, this setting should be changed in 142.Pa /boot/loader.conf 143instead of 144.Pa /etc/sysctl.conf . 145The global default is currently 1. 146The per-device default is to leave it as-is (follow global setting). 147.El 148.Sh FILES 149.Bl -tag -width ".Pa /dev/ada*" -compact 150.It Pa /dev/ada* 151ATA device nodes 152.El 153.Sh SEE ALSO 154.Xr ahci 4 , 155.Xr cam 4 , 156.Xr da 4 , 157.Xr mvs 4 , 158.Xr nda 4 , 159.Xr siis 4 160.Sh HISTORY 161The 162.Nm 163driver first appeared in 164.Fx 8.0 . 165.Sh AUTHORS 166.An Alexander Motin Aq Mt mav@FreeBSD.org 167