⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 st.txt

📁 linux 内核源代码
💻 TXT
📖 第 1 页 / 共 2 页
字号:
This file contains brief information about the SCSI tape driver.The driver is currently maintained by Kai Mäkisara (emailKai.Makisara@kolumbus.fi)Last modified: Mon Mar  7 21:14:44 2005 by kai.makisaraBASICSThe driver is generic, i.e., it does not contain any code tailoredto any specific tape drive. The tape parameters can be specified withone of the following three methods:1. Each user can specify the tape parameters he/she wants to usedirectly with ioctls. This is administratively a very simple andflexible method and applicable to single-user workstations. However,in a multiuser environment the next user finds the tape parameters instate the previous user left them.2. The system manager (root) can define default values for some tapeparameters, like block size and density using the MTSETDRVBUFFER ioctl.These parameters can be programmed to come into effect either when anew tape is loaded into the drive or if writing begins at thebeginning of the tape. The second method is applicable if the tapedrive performs auto-detection of the tape format well (like someQIC-drives). The result is that any tape can be read, writing can becontinued using existing format, and the default format is used ifthe tape is rewritten from the beginning (or a new tape is writtenfor the first time). The first method is applicable if the drivedoes not perform auto-detection well enough and there is a single"sensible" mode for the device. An example is a DAT drive that isused only in variable block mode (I don't know if this is sensibleor not :-).The user can override the parameters defined by the systemmanager. The changes persist until the defaults again come intoeffect.3. By default, up to four modes can be defined and selected using the minornumber (bits 5 and 6). The number of modes can be changed by changingST_NBR_MODE_BITS in st.h. Mode 0 corresponds to the defaults discussedabove. Additional modes are dormant until they are defined by thesystem manager (root). When specification of a new mode is started,the configuration of mode 0 is used to provide a starting point fordefinition of the new mode.Using the modes allows the system manager to give the users choicesover some of the buffering parameters not directly accessible to theusers (buffered and asynchronous writes). The modes also allow choicesbetween formats in multi-tape operations (the explicitly overriddenparameters are reset when a new tape is loaded).If more than one mode is used, all modes should contain definitionsfor the same set of parameters.Many Unices contain internal tables that associate different modes tosupported devices. The Linux SCSI tape driver does not contain suchtables (and will not do that in future). Instead of that, a utilityprogram can be made that fetches the inquiry data sent by the device,scans its database, and sets up the modes using the ioctls. Anotheralternative is to make a small script that uses mt to set the defaultstailored to the system.The driver supports fixed and variable block size (within bufferlimits). Both the auto-rewind (minor equals device number) andnon-rewind devices (minor is 128 + device number) are implemented.In variable block mode, the byte count in write() determines the sizeof the physical block on tape. When reading, the drive reads the nexttape block and returns to the user the data if the read() byte countis at least the block size. Otherwise, error ENOMEM is returned.In fixed block mode, the data transfer between the drive and thedriver is in multiples of the block size. The write() byte count mustbe a multiple of the block size. This is not required when reading butmay be advisable for portability.Support is provided for changing the tape partition and partitioningof the tape with one or two partitions. By default support forpartitioned tape is disabled for each driver and it can be enabledwith the ioctl MTSETDRVBUFFER.By default the driver writes one filemark when the device is closed afterwriting and the last operation has been a write. Two filemarks can beoptionally written. In both cases end of data is signified byreturning zero bytes for two consecutive reads.If rewind, offline, bsf, or seek is done and previous tape operation waswrite, a filemark is written before moving tape.The compile options are defined in the file linux/drivers/scsi/st_options.h.4. If the open option O_NONBLOCK is used, open succeeds even if thedrive is not ready. If O_NONBLOCK is not used, the driver waits forthe drive to become ready. If this does not happen in ST_BLOCK_SECONDSseconds, open fails with the errno value EIO. With O_NONBLOCK thedevice can be opened for writing even if there is a write protectedtape in the drive (commands trying to write something return error ifattempted).MINOR NUMBERSThe tape driver currently supports 128 drives by default. This numbercan be increased by editing st.h and recompiling the driver ifnecessary. The upper limit is 2^17 drives if 4 modes for each driveare used.The minor numbers consist of the following bit fields:dev_upper non-rew mode dev-lower  20 -  8     7    6 5  4      0The non-rewind bit is always bit 7 (the uppermost bit in the lowermostbyte). The bits defining the mode are below the non-rewind bit. Theremaining bits define the tape device number. This numbering isbackward compatible with the numbering used when the minor number wasonly 8 bits wide.SYSFS SUPPORTThe driver creates the directory /sys/class/scsi_tape and populates it withdirectories corresponding to the existing tape devices. There are autorewindand non-rewind entries for each mode. The names are stxy and nstxy, where xis the tape number and y a character corresponding to the mode (none, l, m,a). For example, the directories for the first tape device are (assuming fourmodes): st0  nst0  st0l  nst0l  st0m  nst0m  st0a  nst0a.Each directory contains the entries: default_blksize  default_compressiondefault_density  defined  dev  device  driver. The file 'defined' contains 1if the mode is defined and zero if not defined. The files 'default_*' containthe defaults set by the user. The value -1 means the default is not set. Thefile 'dev' contains the device numbers corresponding to this device. The links'device' and 'driver' point to the SCSI device and driver entries.A link named 'tape' is made from the SCSI device directory to the classdirectory corresponding to the mode 0 auto-rewind device (e.g., st0). BSD AND SYS V SEMANTICSThe user can choose between these two behaviours of the tape driver bydefining the value of the symbol ST_SYSV. The semantics differ when afile being read is closed. The BSD semantics leaves the tape where itcurrently is whereas the SYS V semantics moves the tape past the nextfilemark unless the filemark has just been crossed.The default is BSD semantics.BUFFERINGThe driver tries to do transfers directly to/from user space. If thisis not possible, a driver buffer allocated at run-time is used. Ifdirect i/o is not possible for the whole transfer, the driver bufferis used (i.e., bounce buffers for individual pages are notused). Direct i/o can be impossible because of several reasons, e.g.:- one or more pages are at addresses not reachable by the HBA- the number of pages in the transfer exceeds the number of  scatter/gather segments permitted by the HBA- one or more pages can't be locked into memory (should not happen in  any reasonable situation)The size of the driver buffers is always at least one tape block. In fixedblock mode, the minimum buffer size is defined (in 1024 byte units) byST_FIXED_BUFFER_BLOCKS. With small block size this allows buffering ofseveral blocks and using one SCSI read or write to transfer all of theblocks. Buffering of data across write calls in fixed block mode isallowed if ST_BUFFER_WRITES is non-zero and direct i/o is not used.Buffer allocation uses chunks of memory having sizes 2^n * (pagesize). Because of this the actual buffer size may be larger than theminimum allowable buffer size.NOTE that if direct i/o is used, the small writes are not buffered. This maycause a surprise when moving from 2.4. There small writes (e.g., tar without-b option) may have had good throughput but this is not true any more with2.6. Direct i/o can be turned off to solve this problem but a better solutionis to use bigger write() byte counts (e.g., tar -b 64).Asynchronous writing. Writing the buffer contents to the tape isstarted and the write call returns immediately. The status is checkedat the next tape operation. Asynchronous writes are not done withdirect i/o and not in fixed block mode.Buffered writes and asynchronous writes may in some rare cases causeproblems in multivolume operations if there is not enough space on thetape after the early-warning mark to flush the driver buffer.Read ahead for fixed block mode (ST_READ_AHEAD). Filling the buffer isattempted even if the user does not want to get all of the data atthis read command. Should be disabled for those drives that don't likea filemark to truncate a read request or that don't like backspacing.Scatter/gather buffers (buffers that consist of chunks non-contiguousin the physical memory) are used if contiguous buffers can't beallocated. To support all SCSI adapters (including those notsupporting scatter/gather), buffer allocation is using the followingthree kinds of chunks:1. The initial segment that is used for all SCSI adapters includingthose not supporting scatter/gather. The size of this buffer will be(PAGE_SIZE << ST_FIRST_ORDER) bytes if the system can give a chunk ofthis size (and it is not larger than the buffer size specified byST_BUFFER_BLOCKS). If this size is not available, the driver halvesthe size and tries again until the size of one page. The defaultsettings in st_options.h make the driver to try to allocate all of thebuffer as one chunk.2. The scatter/gather segments to fill the specified buffer size areallocated so that as many segments as possible are used but the numberof segments does not exceed ST_FIRST_SG.3. The remaining segments between ST_MAX_SG (or the module parametermax_sg_segs) and the number of segments used in phases 1 and 2are used to extend the buffer at run-time if this is necessary. Thenumber of scatter/gather segments allowed for the SCSI adapter is notexceeded if it is smaller than the maximum number of scatter/gathersegments specified. If the maximum number allowed for the SCSI adapteris smaller than the number of segments used in phases 1 and 2,extending the buffer will always fail.EOM BEHAVIOUR WHEN WRITINGWhen the end of medium early warning is encountered, the current writeis finished and the number of bytes is returned. The next writereturns -1 and errno is set to ENOSPC. To enable writing a trailer,the next write is allowed to proceed and, if successful, the number ofbytes is returned. After this, -1 and the number of bytes arealternately returned until the physical end of medium (or some othererror) is encountered.MODULE PARAMETERSThe buffer size, write threshold, and the maximum number of allocated buffersare configurable when the driver is loaded as a module. The keywords are:buffer_kbs=xxx             the buffer size for fixed block mode is set			   to xxx kilobyteswrite_threshold_kbs=xxx    the write threshold in kilobytes set to xxxmax_sg_segs=xxx		   the maximum number of scatter/gather			   segmentstry_direct_io=x		   try direct transfer between user buffer and			   tape drive if this is non-zeroNote that if the buffer size is changed but the write threshold is notset, the write threshold is set to the new buffer size - 2 kB.BOOT TIME CONFIGURATIONIf the driver is compiled into the kernel, the same parameters can be

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -