SD(4)

NAME
sd - SCSI disk controller

SYNOPSIS
device sd0 at sec? doneq 50 req 50 bin 5 unit 0 target 0 # embedded SCSI device sd0 at sec? doneq 50 req 50 bin 5 unit 0 target 6 # target adapter

DESCRIPTION
This device driver controls both SCSI disk target adapters and SCSI disks with embedded targets ("embedded SCSI" disks). It supports up to eight disks per target adapter, with a maximum of seven target adapters per SCED board, or it can support a maximum of seven embedded SCSI disks per SCED board. The device driver can support a maximum of 32 disk drives per system. Mixing of embedded SCSI and target adapters is not allowed on one system.

The lower 3 bits of the minor of the special file refers to partitions 0-7 while the next 8 bits refers to the drive number, the remaining 5 bits complete the partition number. Special files with minor partition numbers 0-15 and unit number 0 refer to partitions a-p on drive ``sd0'' (the first drive listed in the kernel configuration file), minor partition numbers 0-15 unit number 1 refer to ``sd1'', and so on. Standard device names are of the form ``sdnx'', where n is the drive number and x is the partition name (a-p).

Block devices access the disk via the system's normal buffering mechanism, and may be read and written without regard to physical disk records. There is also a ``raw'' interface that provides for direct transmission between the disk and the user's read or write buffer. A single read or write call results in exactly one I/O operation, and therefore raw I/O is considerably more efficient when many words are transmitted. The names of the raw special files conventionally begin with an extra ``r'' — e.g., ``rsd0a''. Raw transfers are limited to a maximum of 254 512-byte sectors because of the SCSI command structure. In raw I/O, counts must be a multiple of 512 bytes, and must begin on 16-byte aligned memory addresses. Likewise, lseek calls should specify a multiple of 512 bytes.

CONFIGURATION
Before attempting to add a new disk or target adapter, read the disk and target adapter manuals thoroughly. The main information needed is how to set the target adapter number and drive-select cabling.

The driver will recognise drives with and without VTOC (Volume Table of Contents). If the disk does not contain a VTOC the driver will use the compatibility information hard coded in the driver.

COMPATIBILITY BINARY CONFIGURATION

Table of disk units.
The ``sdbconf'' array in the device driver binary configuration file (/sys/conf/conf_sd.c) must contain an entry for each drive that may be configured; the entries must be in the same order as the ``device'' entries in the kernel configuration file (kernel configuration files are described in the article ``Building DYNIX Systems with Config'' in Volume 2). When adding a new drive, make sure that the corresponding entry in ``sdbconf'' points to the partition table for the appropriate drive type. (As installed, ``sdbconf'' has entries for 8 drives, all using the same partition table. Superfluous entries are ignored; you must add more entries if you have more than 8 drives.)

Partition tables.
The binary configuration file contains one or more partition tables, defined as arrays of 8 ``sd_partition'' structures. Each partition table gives the starting address and size (in 512-byte sectors) of the 8 partitions on a particular type of disk. To support a new disk layout, add a new partition table to the binary configuration file, using an existing table as a template.

TUNING PARAMETERS
The following tuning parameters are defined for each drive in the ``sdbconf'' array of the binary configuration file: (1) the buffer size for ioctl operations, (2) the number of IATs (indirect access table entries, used for scatter/gather I/O), and (3) water marks to lessen the interrupt load on the SCED board.

IATs.
An indirect access table is used to map a contiguous I/O buffer in virtual memory to the corresponding pages scattered throughout physical memory. Each table entry (IAT) can map up to 2048 bytes. The number of IATs directly affects the total number of of outstanding requests that the device driver can queue to the SCED board. Groups of IATs are allocated on a per-transfer basis, and there must be enough entries to handle at least one request.

Water marks.
The water marks are ``low'' and ``thresh(hold)''. The device driver will queue up a maximum of ``thresh'' requests in a drive's device output queue before interrupting the SCED board to handle the requests. The ``low'' water mark is used when the device input queue has been filled and is draining off. The device driver does not begin queuing requests again until the ``low'' water mark has been reached. (The size of a drive's device input and output queues is defined by the ``doneq'' and ``req'' fields of the corresponding ``device'' entry in the kernel configuration file.)

FILES
/dev/sd?[a-h]    block files
/dev/rsd?[a-h]    raw files
/dev/rsd?    raw whole disk
/sys/conf/conf_sd.c    binary configuration file

STAND-ALONE EQUIVALENCE
The convention for specifing a SCSI disk from stand-alone code is:
        sd(u,p)
where u refers to the unit number and p refers to the partition number. Each SCSI controller may have 8 unit numbers There may be 8 controllers on a SCSI bus. The assignment of unit number depends on whether the target adapter is embedded or not. The partition is a number 0-256, (partition 256 refers to the whole disk).
Separate target adapter:
	u = SCED board number x 512
		  + SCSI target adapter type x 64
	          + SCSI target number x 8
		  + SCSI unit number
	p = partition number.
Note that type is currently always 0, and the adapter starts at 6 and decreases to 0;
Separate target adapter:
	u = SCED board number x 512
	          + SCSI target number x 8
	p = partition number.

SEE ALSO
df(1), diskpart(8), newfs(8), sdformat(8S), format(8), prtvtoc(8), mkvtoc(8), vtoc(5),

DIAGNOSTICS
See the ANSI X3T9.2 (SCSI) specification.

BUGS
In raw I/O, read(2) and write(2) truncate file offsets to 512-byte block boundaries, and write scribbles on the tail of incomplete blocks. Thus, in programs that access raw devices, read, write, and lseek(2) should always deal in 512-byte multiples.

A program to analyze the logged error information (even in its present reduced form) is needed. Error messages should be more consistent.

The partition tables for the file systems should be read off of each disk, as they are never quite what any single installation would prefer, and this would make disks more portable.

The kernel ``milliseconds per seek'' statistic is not kept for this device; thus, iostat(1) always reports zero for this statistic.

When a request to the disk accesses past the end of media (for example, a non-existent block number), the device driver will report soft errors followed by a hard error in the same way that a bad block is treated. There is no special handling of the volume overflow sense error code for disks.