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