1a77a7ee0SJulian Elischer.\" Copyright (c) 1996 2eddc45e7SJeroen Ruigrok van der Werven.\" Julian Elischer <julian@FreeBSD.org>. All rights reserved. 3a77a7ee0SJulian Elischer.\" 4a77a7ee0SJulian Elischer.\" Redistribution and use in source and binary forms, with or without 5a77a7ee0SJulian Elischer.\" modification, are permitted provided that the following conditions 6a77a7ee0SJulian Elischer.\" are met: 7a77a7ee0SJulian Elischer.\" 1. Redistributions of source code must retain the above copyright 8a77a7ee0SJulian Elischer.\" notice, this list of conditions and the following disclaimer. 9a77a7ee0SJulian Elischer.\" 10a77a7ee0SJulian Elischer.\" 2. Redistributions in binary form must reproduce the above copyright 11a77a7ee0SJulian Elischer.\" notice, this list of conditions and the following disclaimer in the 12a77a7ee0SJulian Elischer.\" documentation and/or other materials provided with the distribution. 13a77a7ee0SJulian Elischer.\" 14a77a7ee0SJulian Elischer.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15a77a7ee0SJulian Elischer.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16a77a7ee0SJulian Elischer.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17a77a7ee0SJulian Elischer.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18a77a7ee0SJulian Elischer.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19a77a7ee0SJulian Elischer.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20a77a7ee0SJulian Elischer.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21a77a7ee0SJulian Elischer.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22a77a7ee0SJulian Elischer.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23a77a7ee0SJulian Elischer.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24a77a7ee0SJulian Elischer.\" SUCH DAMAGE. 25a77a7ee0SJulian Elischer.\" 26*53af9c23SFelix Johnson.Dd September 10, 2022 27c70e20d8SKenneth D. Merry.Dt DA 4 283d45e180SRuslan Ermilov.Os 29db35f309SDavid Greenman.Sh NAME 30c70e20d8SKenneth D. Merry.Nm da 31eb083802SRuslan Ermilov.Nd SCSI Direct Access device driver 32db35f309SDavid Greenman.Sh SYNOPSIS 336b713d58SJeroen Ruigrok van der Werven.Cd device da 34db35f309SDavid Greenman.Sh DESCRIPTION 35db35f309SDavid GreenmanThe 364b66483fSRuslan Ermilov.Nm 37c70e20d8SKenneth D. Merrydriver provides support for all 3835fe659dSGarrett Wollman.Tn SCSI 39c70e20d8SKenneth D. Merrydevices of the direct access class that are attached to the system 40c70e20d8SKenneth D. Merrythrough a supported 41c70e20d8SKenneth D. Merry.Tn SCSI 42c70e20d8SKenneth D. MerryHost Adapter. 43c70e20d8SKenneth D. MerryThe direct access class includes disk, magneto-optical, 44c70e20d8SKenneth D. Merryand solid-state devices. 45db35f309SDavid Greenman.Pp 4635fe659dSGarrett WollmanA 4735fe659dSGarrett Wollman.Tn SCSI 48c70e20d8SKenneth D. MerryHost 4935fe659dSGarrett Wollmanadapter must also be separately configured into the system 5035fe659dSGarrett Wollmanbefore a 5135fe659dSGarrett Wollman.Tn SCSI 52c70e20d8SKenneth D. Merrydirect access device can be configured. 53c70e20d8SKenneth D. Merry.Sh CACHE EFFECTS 54d732587cSTim VanderhoekMany direct access devices are equipped with read and/or write caches. 55c70e20d8SKenneth D. MerryParameters affecting the device's cache are stored in mode page 8, 56b5e7e999SRuslan Ermilovthe caching control page. 57b5e7e999SRuslan ErmilovMode pages can be examined and modified via the 58c70e20d8SKenneth D. Merry.Xr camcontrol 8 59c70e20d8SKenneth D. Merryutility. 60b5c508fbSRuslan Ermilov.Pp 61d732587cSTim VanderhoekThe read cache is used to store data from device-initiated read ahead 62b5e7e999SRuslan Ermilovoperations as well as frequently used data. 63b5e7e999SRuslan ErmilovThe read cache is transparent 645203edcdSRuslan Ermilovto the user and can be enabled without any adverse effect. 655203edcdSRuslan ErmilovMost devices 66b5e7e999SRuslan Ermilovwith a read cache come from the factory with it enabled. 67b5e7e999SRuslan ErmilovThe read cache can be disabled by setting the 68c70e20d8SKenneth D. Merry.Tn RCD 69c70e20d8SKenneth D. Merry(Read Cache Disable) bit in the caching control mode page. 70b5c508fbSRuslan Ermilov.Pp 71c70e20d8SKenneth D. MerryThe write cache can greatly decrease the latency of write operations 72c70e20d8SKenneth D. Merryand allows the device to reorganize writes to increase efficiency and 73b5e7e999SRuslan Ermilovperformance. 74b5e7e999SRuslan ErmilovThis performance gain comes at a price. 75b5e7e999SRuslan ErmilovShould the device 76c70e20d8SKenneth D. Merrylose power while its cache contains uncommitted write operations, these 77b5e7e999SRuslan Ermilovwrites will be lost. 78b5e7e999SRuslan ErmilovThe effect of a loss of write transactions on 79b5e7e999SRuslan Ermilova file system is non-deterministic and can cause corruption. 80b5e7e999SRuslan ErmilovMost 81c70e20d8SKenneth D. Merrydevices age write transactions to limit vulnerability to a few transactions 82c70e20d8SKenneth D. Merryrecently reported as complete, but it is none-the-less recommended that 83c70e20d8SKenneth D. Merrysystems with write cache enabled devices reside on an Uninterruptible 84b5e7e999SRuslan ErmilovPower Supply (UPS). 85b5e7e999SRuslan ErmilovThe 864b66483fSRuslan Ermilov.Nm 87c70e20d8SKenneth D. Merrydevice driver ensures that the cache and media are synchronized upon 88b5e7e999SRuslan Ermilovfinal close of the device or an unexpected shutdown (panic) event. 89b5e7e999SRuslan ErmilovThis ensures that it is safe to disconnect power once the operating system 90b5e7e999SRuslan Ermilovhas reported that it has halted. 91b5e7e999SRuslan ErmilovThe write cache can be enabled by setting the 92c70e20d8SKenneth D. Merry.Tn WCE 93c70e20d8SKenneth D. Merry(Write Cache Enable) bit in the caching control mode page. 94c70e20d8SKenneth D. Merry.Sh TAGGED QUEUING 95c70e20d8SKenneth D. MerryThe 964b66483fSRuslan Ermilov.Nm 97c70e20d8SKenneth D. Merrydevice driver will take full advantage of the SCSI feature known as tagged 98b5e7e999SRuslan Ermilovqueueing. 99b5e7e999SRuslan ErmilovTagged queueing allows the device to process multiple transactions 100c70e20d8SKenneth D. Merryconcurrently, often re-ordering them to reduce the number and length of 101b5e7e999SRuslan Ermilovseeks. 102b5e7e999SRuslan ErmilovTo ensure that transactions to distant portions of the media, 103c70e20d8SKenneth D. Merrywhich may be deferred indefinitely by servicing requests nearer the current 104c70e20d8SKenneth D. Merryhead position, are completed in a timely fashion, an ordered tagged 105c70e20d8SKenneth D. Merrytransaction is sent every 15 seconds during continuous device operation. 106c70e20d8SKenneth D. Merry.Sh BAD BLOCK RECOVERY 107c70e20d8SKenneth D. MerryDirect Access devices have the capability of mapping out portions of 108b5e7e999SRuslan Ermilovdefective media. 109b5e7e999SRuslan ErmilovMedia recovery parameters are located in mode page 1, 110b5e7e999SRuslan Ermilovthe Read-Write Error Recovery mode page. 111b5e7e999SRuslan ErmilovThe most important media 112c70e20d8SKenneth D. Merryremapping features are 'Auto Write Reallocation' and 'Auto Read 113c70e20d8SKenneth D. MerryReallocation' which can be enabled via the AWRE and ARRE bits, 114d732587cSTim Vanderhoekrespectively, of the Read-Write Error Recovery page. 115c70e20d8SKenneth D. MerryMany devices do not ship from the factory with these feature enabled. 116f87717faSMike PritchardMode pages can be examined and modified 117c70e20d8SKenneth D. Merryvia the 118c70e20d8SKenneth D. Merry.Xr camcontrol 8 119c70e20d8SKenneth D. Merryutility. 120db35f309SDavid Greenman.Sh KERNEL CONFIGURATION 12135fe659dSGarrett WollmanIt is only necessary to explicitly configure one 1224b66483fSRuslan Ermilov.Nm 12335fe659dSGarrett Wollmandevice; data structures are dynamically allocated as disks are found 12435fe659dSGarrett Wollmanon the 12535fe659dSGarrett Wollman.Tn SCSI 12635fe659dSGarrett Wollmanbus. 127cb32189eSKenneth D. Merry.Sh SYSCTL VARIABLES 128cb32189eSKenneth D. MerryThe following variables are available as both 129cb32189eSKenneth D. Merry.Xr sysctl 8 130cb32189eSKenneth D. Merryvariables and 131cb32189eSKenneth D. Merry.Xr loader 8 132cb32189eSKenneth D. Merrytunables: 133cb32189eSKenneth D. Merry.Bl -tag -width 12 134*53af9c23SFelix Johnson.It Va kern.cam.da.default_timeout 135*53af9c23SFelix JohnsonThis variable determines how long the 136*53af9c23SFelix Johnson.Nm 137*53af9c23SFelix Johnsondriver will wait before timing out an outstanding command. 138*53af9c23SFelix JohnsonThe units for this value are seconds, and the default is currently 60 139*53af9c23SFelix Johnsonseconds. 140*53af9c23SFelix Johnson.It Va kern.cam.da.disable_wp_protection 141*53af9c23SFelix JohnsonDisable detection of write-protected disks. 142*53af9c23SFelix JohnsonDefault is disabled. 143*53af9c23SFelix Johnson.Po 144*53af9c23SFelix Johnsondetection of write-protected disks is enabled 145*53af9c23SFelix Johnson.Pc . 146*53af9c23SFelix Johnson.It Va kern.cam.da.enable_biospeedup 147*53af9c23SFelix JohnsonEnable 148*53af9c23SFelix Johnson.Dv BIO_SPEEDUP 149*53af9c23SFelix Johnsonprocessing. 150*53af9c23SFelix JohnsonDefault is enabled. 151*53af9c23SFelix Johnson.It Va kern.cam.da.enable_uma_ccbs 152*53af9c23SFelix JohnsonUse UMA for CCBs. 153*53af9c23SFelix JohnsonDefault is enabled. 154*53af9c23SFelix Johnson.It Va kern.cam.da.poll_period 155*53af9c23SFelix JohnsonMedia polling period in seconds. 156*53af9c23SFelix JohnsonDefault is 3 seconds. 1570ac03010SAlexander Motin.It Va kern.cam.da.retry_count 158cb32189eSKenneth D. MerryThis variable determines how many times the 159cb32189eSKenneth D. Merry.Nm 160cb32189eSKenneth D. Merrydriver will retry a READ or WRITE command. 161cb32189eSKenneth D. MerryThis does not affect the number of retries used during probe time or for 162cb32189eSKenneth D. Merrythe 163cb32189eSKenneth D. Merry.Nm 164cb32189eSKenneth D. Merrydriver dump routine. 165cb32189eSKenneth D. MerryThis value currently defaults to 4. 166*53af9c23SFelix Johnson.It Va kern.cam.da.send_ordered 167*53af9c23SFelix JohnsonSend Ordered Tags. 168*53af9c23SFelix JohnsonOn shutdown, step through all the 169cb32189eSKenneth D. Merry.Nm 170*53af9c23SFelix Johnsonperipheral drivers, and if the device is still open, 171*53af9c23SFelix Johnsonsync the disk to physical media. 172*53af9c23SFelix JohnsonDefault is enabled. 1734f8244bbSAlexander Motin.It Va kern.cam.sort_io_queue 1744f8244bbSAlexander Motin.It Va kern.cam.da . Ns Ar X Ns Va .sort_io_queue 1754f8244bbSAlexander MotinThese variables determine whether request queue should be sorted trying 1764f8244bbSAlexander Motinto optimize head seeks. 1774f8244bbSAlexander MotinSet to 1 to enable sorting, 0 to disable, -1 to leave it as-is. 1784f8244bbSAlexander MotinThe default is sorting enabled for HDDs and disabled for SSDs. 1790ac03010SAlexander Motin.It Va kern.cam.da . Ns Ar X Ns Va .delete_method 1800ac03010SAlexander MotinThis variable specifies method to handle BIO_DELETE requests: 181fe3a3f3aSEnji Cooper.Bl -tag -width "ATA_TRIM" 1820ac03010SAlexander Motin.It ATA_TRIM 1830ac03010SAlexander MotinATA TRIM via ATA COMMAND PASS THROUGH command, 1840ac03010SAlexander Motin.It UNMAP 1850ac03010SAlexander MotinUNMAP command, 1860ac03010SAlexander Motin.It WS16 1870ac03010SAlexander MotinWRITE SAME(16) command with UNMAP flag, 1880ac03010SAlexander Motin.It WS10 1890ac03010SAlexander MotinWRITE SAME(10) command with UNMAP flag, 1900ac03010SAlexander Motin.It ZERO 1910ac03010SAlexander MotinWRITE SAME(10) command without UNMAP flag, 1920ac03010SAlexander Motin.It DISABLE 1930ac03010SAlexander Motindisable BIO_DELETE support. 1940ac03010SAlexander Motin.El 1950ac03010SAlexander Motin.It Va kern.cam.da . Ns Ar X Ns Va .minimum_cmd_size 196cb32189eSKenneth D. MerryThis variable determines what the minimum READ/WRITE CDB size is for a 197cb32189eSKenneth D. Merrygiven 198cb32189eSKenneth D. Merry.Nm 199cb32189eSKenneth D. Merryunit. 200cb32189eSKenneth D. MerryValid minimum command size values are 6, 10, 12 and 16 bytes. 201cb32189eSKenneth D. MerryThe default is 6 bytes. 202cb32189eSKenneth D. Merry.Pp 203cb32189eSKenneth D. MerryThe 204cb32189eSKenneth D. Merry.Nm 205cb32189eSKenneth D. Merrydriver issues a CAM Path Inquiry CCB at probe time to determine whether the 2060227791bSRuslan Ermilovprotocol the device in question speaks (e.g.\& ATAPI) typically does not allow 207cb32189eSKenneth D. Merry6 byte commands. 2080227791bSRuslan ErmilovIf it does not, the 209cb32189eSKenneth D. Merry.Nm 210cb32189eSKenneth D. Merrydriver will default to using at least 10 byte CDBs. 211cb32189eSKenneth D. MerryIf a 6 byte READ or WRITE fails with an ILLEGAL REQUEST error, the 212cb32189eSKenneth D. Merry.Nm 213cb32189eSKenneth D. Merrydriver will then increase the default CDB size for the device to 10 bytes and 214cb32189eSKenneth D. Merryretry the command. 215cb32189eSKenneth D. MerryCDB size is always 216cb32189eSKenneth D. Merrychosen as the smallest READ/WRITE CDB that will satisfy the specified minimum 217cb32189eSKenneth D. Merrycommand size, and the LBA and length of the READ or WRITE in question. 218cb32189eSKenneth D. Merry(e.g., a write to an LBA larger than 2^32 will require a 16 byte CDB.) 219cb32189eSKenneth D. Merry.El 220db35f309SDavid Greenman.Sh NOTES 221d732587cSTim VanderhoekIf a device becomes invalidated (media is removed, device becomes unresponsive) 222c70e20d8SKenneth D. Merrythe disklabel and information held within the kernel about the device will 223b5e7e999SRuslan Ermilovbe invalidated. 224b5e7e999SRuslan ErmilovTo avoid corruption of a newly inserted piece of media or 225c70e20d8SKenneth D. Merrya replacement device, all accesses to the device will be discarded until 226b5e7e999SRuslan Ermilovthe last file descriptor referencing the old device is closed. 227b5e7e999SRuslan ErmilovDuring this period, all new open attempts will be rejected. 228db35f309SDavid Greenman.Sh FILES 22981ae4b8dSRuslan Ermilov.Bl -tag -width ".Pa /dev/da*" -compact 230ab6258cfSJohn Baldwin.It Pa /dev/da* 231ab6258cfSJohn BaldwinSCSI disk device nodes 232db35f309SDavid Greenman.El 233db35f309SDavid Greenman.Sh DIAGNOSTICS 234db35f309SDavid GreenmanNone. 235db35f309SDavid Greenman.Sh SEE ALSO 236814b16baSGlen Barber.Xr ada 4 , 2372baf3a13SAlexander Motin.Xr cam 4 , 238ab6258cfSJohn Baldwin.Xr geom 4 , 2394d21bbd1SWarner Losh.Xr nda 4 , 240b8c19fd7SEdward Tomasz Napierala.Xr gpart 8 241db35f309SDavid Greenman.Sh HISTORY 242db35f309SDavid GreenmanThe 243db35f309SDavid Greenman.Nm 244c70e20d8SKenneth D. Merrydriver was written for the 245c70e20d8SKenneth D. Merry.Tn CAM 246c70e20d8SKenneth D. Merry.Tn SCSI 2472865e1d5SAlexey Zelkinsubsystem by 2482865e1d5SAlexey Zelkin.An Justin T. Gibbs . 249c70e20d8SKenneth D. MerryMany ideas were gleaned from the 250c70e20d8SKenneth D. Merry.Nm sd 251c70e20d8SKenneth D. Merrydevice driver written and ported from 25235fe659dSGarrett Wollman.Tn Mach 253c70e20d8SKenneth D. Merry2.5 254547be285SAlexey Zelkinby 255547be285SAlexey Zelkin.An Julian Elischer . 256