SlideShare a Scribd company logo
1 of 6
Download to read offline
User-mode API for Tape Libraries
Aram Khalili
Computer Science Department
University of Maryland Baltimore County
1000 Hilltop Circle
Baltimore, MD 21250
akhali1@umbc.edu
Abstract
Tape libraries are becoming more commonplace
in various installations, whether they are used for
automatic backups, archive or on-line storage. This
work represents a freely distributable user-mode C-
library that implements various SCSI commands of
the Exabyte EXB-210 unit.
1 Introduction
Tape libraries are becoming more and more
common in installations where large amounts of data
need to be stored but also retrieved often for anal-
ysis. Up until recently mass storage systems were
used only at scienti c facilities but due to the de-
velopment of new applications such as digital li-
braries, and electronic commerce the demands for
storing enormous amounts of information while at
the same time providing e cient access to this in-
formation is becoming commonplace. The original
project at the Laboratory for Information Systems
Technology called for development of a le system
that integrates tape libraries with disk storage in a
transparent manner. The project has been stopped,
but our results are freely available. We chose Linux
as the operating system to support this project since
access to the source code, internals documentation,
and a large support group were necessary require-
ments 2, 5].
In order to understand the behavior, in terms
of performance, of the robotic arm that performs the
mount operations in our Exabyte EXB-210 tape li-
brary we developed a user mode API for access to
the SCSI medium changer command set 3]. Our
interface is built on top of the generic SCSI inter-
face (sg driver) presently available in the Linux ker-
nel. Based on our knowledge there is currently no
other driver or utility available for any of the public
domain Unix operating systems for managing auto-
mated tape libraries.
2 The library's SCSI Interface
The SCSI-2 Interface standard 1] is a standard
that enables a host computer and peripheral devices,
such as this tape library and its tape drives, to com-
municate. The library and tape drives are indepen-
dent SCSI devices, and each supports an indepen-
dent set of SCSI commands.
2.1 Architecture of the SCSI Inter-
face
The physical components of a SCSI system con-
sist of the following:
host adapter: A device which connects between a
host system and the SCSI bus. The device usu-
ally performs the lowest layers of the SCSI pro-
tocol and normally operates in the initiator role.
initiator: A computer equipped with a SCSI host
adapter card enabling it to send commands,
messages and data across the SCSI bus to tar-
gets. The initiator can also receive data, mes-
sages and status information from the targets.
targets: Devices capable of receiving commands
from an initiator. The tape library and the tape
drives are independent targets. The library is
the target for cartridgeinventoryand movement
commands, while the tape drive(s) is the target
for read and write operations.
1
SCSI bus: The SCSI cables that connect initiators
and targets.
2.2 Architecture of the tape library
The tape library includes the following types of
components:
medium changer element: This is the robotic
arm that moves the tapes. There is exactly
one medium changer element in this unit. The
medium changer is also called the cartridge han-
dling mechanism (CHM) and the transport ele-
ment.
data transfer element: This is a tape drive, of
which there can be one or two in our unit.
storage element: This is a cartridge holder.
There are either 11 or 21 storage elements in
a EXB-210 tape library. It is also called stor-
age location. The structure that contains 10 of
the storage elements is called a magazine or a
cartridge magazine.
cartridge: Tapes. There can be 0 to 21 tapes in
the library (plus 3 for two tape drives and one
medium changer, theoretically).
bar code scanner: A bar code scanner that may
be mounted on the medium changer. This com-
ponent is optional, i.e. there can be 0 or 1 bar
code scanner in the unit. It scans bar code la-
bels (if installed) on the cartridges.
2.3 SCSI commands supported by
the library
The EXB-210 unit has two kinds of SCSI de-
vices, the tape drive(s) and the medium changer,
each supporting a di erent SCSI command set. Out
of the list of commands that the tape library sup-
ports (see 4]) we have implemented this subset of
commands: INQUIRY, MODE SENSE, MODE SE-
LECT, INITIALIZE ELEMENT STATUS, MOVE
MEDIUM, POSITION TO ELEMENT and READ
ELEMENT STATUS.
2.4 INQUIRY
The INQUIRY command requests that the li-
brary sends information regarding its static parame-
ters to the initiator. INQUIRY is used to obtain in-
formation such as vendor and product ID, rmware
code revision levels, serial number, availability of an
optional barcode scanner in the library and support
of various SCSI-2 and other options.
2.5 MODE SENSE
The MODE SENSE command is used to dis-
cover the current operating mode parameters of the
library. It can return useful information such as
the number and addresses of tape storage locations
(11,21), the number of medium changers (1), and
the number of tape drives (1-2). It gives information
about the parameters that are valid for the MOVE
MEDIUM command, i.e. which types of moves the
library supports, whether LCD security mode (ac-
cess restrictions) is enabled, the LCD, and whether
SCSI bus parity is enabled. It can also be used to
determine default settings, and currently saved (in
non-volatile memory) settings.
2.6 MODE SELECT
MODE SELECT allows one to de ne the cur-
rent operating parameters for the library. It allows
one to set the parameters which can be discoveredby
MODE SENSE. Note that parameters are constant
and cannot be changed.
2.7 INITIALIZE ELEMENT STA-
TUS
This command causes the library to check all
elements for tapes, and the tape's barcodes, if a bar-
code reader is installed. This includes the tape drive
and the medium changer, although no action is taken
on an INITIALIZE ELEMENT STATUS targeting
the medium changer, since this information is always
maintained and assumed to be accurate. Checking
is done in increasing element address order.
2
2.8 POSITION TO ELEMENT
This command requests the medium changer to
position itself vertically (for a standalone unit; hor-
izontally for rack mounted systems) in front of the
requested address. If the medium changer's element
address is given as the destination, the changer po-
sitions itself in a park position, giving (manual) ac-
cess to the tape drive(s) and tape magazine(s). This
command can also be used to reduce travel time if
the next move command's source address can be pre-
dicted, or to position the changer at a place where
the average distance to any location is minimized.
2.9 MOVE MEDIUM
The MOVE MEDIUM command causes the
medium changer, if possible, to move the cartridge
from the source to the destination address. Nor-
mally this is between the tape magazine and the tape
drive(s), but one could also exchange the magazine
location of a tape, to minimize the travel distance
for frequently used tapes. If the destination address
is one of a tape drive, the library will insert the car-
tridge. Valid source and destination element com-
binations can be discovered by the MODE SENSE
command.
2.10 READ ELEMENT STATUS
This command allows one to discover the sta-
tus of the elements of the library. Elements are the
tape drive, the medium changer, and the storage
locations. Information that can be obtained about
the elements include whether they are in a normal
state, the location of the transport element, whether
a storage slot is lled with a tape and whether a tape
drive or the medium changer contains a tape.
3 Linux's SCSI Interface
Probably ever since its inception Linux in-
cluded support for SCSI devices. The main function-
ality used in the command library (mid-level) lies
in /usr/src/linux/drivers/scsi/scsi.c and (higher
level) in /usr/src/linux/drivers/scsi/sg.c It was
not necessary to explicitly call hardware-level code
(adapter drivers). The purpose of this interface is
to provide a simple and consistent abstraction of
a SCSI device that allows user-process control and
follows le-system command syntax. Scsi.c facil-
itates the kernel with the mechanisms to scan the
SCSI bus for devices (using INQUIRY), issue and
queue commands to these devices and maintains the
kernel data structures about them. It also imple-
ments exception handlers, such as SCSI time-out,
abort and reset routines, and re-entrance prevention
for the low-level driver. It also supplies functions
for registering and removing removing drivers and
modules.
On top of scsi.c sit sg.c, sd.c and st.c. Sg.c
provides the le-system interface for generic SCSI
devices utilizing the scsi.c functions. It implements
the open, close, read, write and ioctl calls that ab-
stract the SCSI devices as les. Linux uses this to
create the special device les /dev/sg*, where a let-
ter corresponding to the device's discovery during
intial scan follows the sg, e.g. /dev/sga for the rst
discovered device (the one with the lowest SCSI ID).
These device les can be accessed through the nor-
mal le operations. An open system call will return
the usual le descriptor, which can be passed to write
to issue commands to the device. The data for the
command is the actual SCSI command appended to
an sg header structure, which the user has to pro-
vide. The structure includes information about the
command, a return value eld and a bu er with the
command descriptor block. After the write nishes,
a read is used to read back the results.
Sd.c and st.c provide similar abstraction for
disk and tape devices, respectively. They were not
used for this part of the project which only deals
with the medium changer device.
4 Tape Library API
The functions we developed for access to the
medium changer command set are the following:
int inquiry(int fd, inquiry_t *inq,
u_char type);
int mode_sense(int fd,
__u16 pagecontrol,
__u16 pagecode,
elt_addr_assgn_t *eas,
tgd_t *tgd,
3
dev_cap_t *dcp,
LCD_t *LCD,
parity_t *par);
int mode_select(int fd, __u16 save,
elt_addr_assgn_t *eas,
LCD_t *LCD,
parity_t *par);
int init_elt_status(int fd, __u18 nbl);
int move_medium(int fd, __u16 tea,
__u16 src, __u16 dest);
int position_elt(int fd, __u16 tea,
__u16 dest);
int read_elt_stat(int fd,
elt_stat_req_t *esr,
elt_stat_data_t *esd,
elt_stat_page_t **esp,
stor_elt_desc_t **sed,
data_transf_elt_desc_t **dted,
med_transp_elt_desc_t **mted);
4.1 inquiry
Inquiry takes as arguments the le descriptor
to the special device le, a pointer to a pre-allocated
inquiry t structure for the data that the command
should return, and the type of inquiry requested.
Valid values for the type are 0 for standard inquiry
data, 1 for the Supported Vital Product Data page,
and 2 for the Unit Serial Number page. It returns
the number of bytes read from the SCSI bus.
4.2 mode sense
Mode sense takes as argument the le descrip-
tor to the special device le, the control type, the
page code, and pointers to elt addr assg t, tgd t,
dev cap t, LCD t and parity t. Valid control type
arguments are 0 for the current operating values of
the library, 1 for a changeable value mask, which sets
all bits of unchangeable values to 0 and all bits of
changeable values to 1, and 2 for the default values.
The page code holds information about the type of
pages requested. The following values are valid:
1Dh - Element Address Assignment page.
1Eh - Transport Geometry Descriptor
page.
1Fh - Device Capabilities page.
22h - LCD mode page.
00h - Parity page.
3Fh - All pages in above order.
The pointers to the structures need only be pre-
allocated if the corresponding page is requested, oth-
erwise NULL may be passed. Mode sense returns the
number of bytes read from the SCSI bus.
4.3 mode select
Mode select's arguments are similar to those for
mode sense, except that mode select includes the op-
tion to save the sent values to non-volatile memory
(1 to save, 0 otherwise), and that only structures
that can be modi ed are passed. They need to be
pre-allocated and set to the desired values if one
wants to change their values, otherwise they may
be NULL. Mode select returns the number of bytes
read from the SCSI bus.
4.4 init elt status
Init elt status takes the le descriptor and an
indicator of whether the library should attempt to
scan bar codes as arguments. Set nbl to 0 scan for
bar codes labels, and to 1 to omit. It returns the
number of bytes read from the SCSI bus.
4.5 move medium
Move medium takes the le descriptor and the
element addresses of the transport element, and the
source and destination addresses. It returns the
number of bytes read from the SCSI bus.
4.6 position elt
Position elt takes as arguments the le descrip-
tor and the element addresses of the transport ele-
ment and its destination. It returns the number of
bytes read from the SCSI bus.
4
4.7 read elt status
Read elt status takes the le descriptor, and
pointers to various structures as arguments.
elt stat req t describes the type of request, i.e.
whether bar code information should be returned
(0 for no, 1 for yes), and which type of elements
should be reported on, 0 for all, 1 for the trans-
port element, 2 for the storage elements, and 4 for
the data transfer elements. Upon successful com-
pletion, elt stat data t will hold the element address
of the rst element, the number of elements, and
the number of bytes returned. Elt stat page t holds
the type of element reported, the length in bytes
of information per element, and the total number
of bytes of information. Up to three records, one
record per element type will, will be returned, hence
the double pointer. The next structures hold infor-
mation on a particular element. Multiple records
may be returned. The structure pointers passed to
read elt status should not be pre-allocated. It re-
turns 1 for success and 0 for failure.
4.8 Additional functionality
In addition to the above implementation of the
meadium changer's SCSI commands we found it nec-
essary or useful to write the following routines and
programs. The routines are for the control of the
tape drive of the library, and the programs encap-
sulate some of these functions to be more useable.
The routines are
int load(int fd, int luflag);
long get_position(int fd);
long set_position(int fd, long pos);
int rewind_tape(int fd);
int set_block_length(int fd, int blocksize);
All functions take as their rst argument the
le descriptor for the special device le. Load takes
a load/unload ag as an additional argument. Set-
ting the ag to 1 causes the tape drive to load a
tape inside of it, 0 causes it to unload. If tape drive
is not in auto-load mode, one needs to load a tape,
once it has been inserted into the drive, before one
can perform I/O on it. An unload will eject the
tape. The command returns the number of bytes
read from the SCSI bus. Get position takes no ad-
ditional arguments and returns the current o set in
blocks of the tape. Set position takes an o set as
another argument and seeks the tape to the desired
location. It returns the number of bytes returned by
the ioctl command. Set block length takesthe integer
blocksize as an additional argument and tries to set
the current blocsize to the desired value. Valid val-
ues depend on the blocksizes supported by the tape
drive. It also returns the number of bytes returned
by the ioctl call.
At this point the following programs exist:
move <device> <src> <dest>
load <device> load/unload flag]
eject <device>
position <device> <dest>
read_stat <device>
All the programs take the device le as their
rst argument. Additonal argumentspassed to move
are the source and destination element addresses.
It assumes the default transport element address of
86. Load takes an optional load/unload ag. If it
is ommitted a load is performed on the device, if
it is given, it is passed to the load function, which
will load on a 1 and unload on a 0. Eject is just
a more familiar form of load hdevicei 0. Position
takes the block o set as another parameter and seek
to the speci ed block. Read stat takes no additional
arguments and implements the READ ELEMENT
STATUS command for all elements.
For a more detailed discussion of the functions
and their data structures we direct the reader to the
source code and accompanying material, which will
be available at ftp://ftp.cs.umbc.edu/pub/exb210/.
4.9 Use of the API
We used the API functions to collect perfor-
mance measurements of the unit. We generated a
workload of le accesses using a uniform distribution
5
over the interval 0,8] in seconds for interarrival time
of successive requests, a uniform distribution over
the interval 1,40] in kilobytes for le sizes, uniform
distribution over 1,10] of tape IDs. One process
read the simulated workload and issued requests to
another process, which interpreted the request and,
using the API calls, fetched the right tape, loaded it,
seeked to the given location, read or wrote the speci-
ed number of blocks, and collected timing informa-
tion. Reads and writes were done using Linux's st
interface, seeks with our set position function. When
we ran it, one thing we immediately noticed is that
the library cannot service requests coming in at such
a high rate, so in our next workload we changed
the interarrival time to a uniform distribution over
0,40], which the device could handle. This indicates
that this device by itself will not give adequate inter-
active on-line performance, but will work well as an
automatic backup device. The most expensive oper-
ation time-wise was an eject. The manual does not
give information about the device's caching scheme,
and other things relevant to the performance of the
individual commands, so we are left guessing as to
why the unit behaves as it does. Another observa-
tion we made is that in sequential reads, if a 32 block
boundary is crossed, the read command will take 2
orders of magnitude longer complete. A similar phe-
nomenon happens during writing. Otherwise read
and write completion time vary by a small amount.
5 Conclusion
We have developed a freely distributable library
of functions that implement SCSI commands on a
EXB-210 tape library and used it to collect perfor-
mance measurements of the device. We see our li-
brary as a helpful tool to other programmersdesiring
to write programsthat accessthe functionality of the
EXB-210 unit for application development, and we
have included some command encapsulation for use
in such things as automatic backup scripts.
References
1] ANSI, Small Computer Systems Interface-2
(SCSI-2), X3T9/89-042
2] M. Beck, H. Bohme, M. Dziadzka, U. Kunitz,
R. Magnus, and D. Verworner, Linux Kernel
Internals", Addison-Wesley, 1996.
3] Exabyte Corporation, Installation and Oper-
ation", 1994.
4] Exabyte Corporation, EXB-210 and EXB-220
8mm libraries: SCSI Reference", 1996.
5] David Rusling, The Linux Kernel", The Linux
Documentation Project, 1996.
6] Friedhelm Schmidt, The SCSI Bus and IDE
Interface: Protocols, Applications, and Pro-
gramming", Addison-Wesley, 1996.
6

More Related Content

What's hot

Lecture 5 Kernel Development
Lecture 5 Kernel DevelopmentLecture 5 Kernel Development
Lecture 5 Kernel DevelopmentMohammed Farrag
 
How to design a file system
How to design a file systemHow to design a file system
How to design a file systemNikhil Anurag VN
 
SCSI(small computer system interface)
SCSI(small computer system interface)SCSI(small computer system interface)
SCSI(small computer system interface)Niraj Lamichhane
 
Introduction to Kernel and Device Drivers
Introduction to Kernel and Device DriversIntroduction to Kernel and Device Drivers
Introduction to Kernel and Device DriversRajKumar Rampelli
 
Linux Initialization Process (1)
Linux Initialization Process (1)Linux Initialization Process (1)
Linux Initialization Process (1)shimosawa
 
SCSI Vs. SATA Vs. IDE
SCSI Vs. SATA Vs. IDESCSI Vs. SATA Vs. IDE
SCSI Vs. SATA Vs. IDEnullhate7543
 
Linux Char Device Driver
Linux Char Device DriverLinux Char Device Driver
Linux Char Device DriverGary Yeh
 
The structure of process
The structure of processThe structure of process
The structure of processAbhaysinh Surve
 
OMFW 2012: Analyzing Linux Kernel Rootkits with Volatlity
OMFW 2012: Analyzing Linux Kernel Rootkits with VolatlityOMFW 2012: Analyzing Linux Kernel Rootkits with Volatlity
OMFW 2012: Analyzing Linux Kernel Rootkits with VolatlityAndrew Case
 
CASPUR Staging System II
CASPUR Staging System IICASPUR Staging System II
CASPUR Staging System IIAndrea PETRUCCI
 
Writing Character driver (loadable module) in linux
Writing Character driver (loadable module) in linuxWriting Character driver (loadable module) in linux
Writing Character driver (loadable module) in linuxRajKumar Rampelli
 
De-Anonymizing Live CDs through Physical Memory Analysis
De-Anonymizing Live CDs through Physical Memory AnalysisDe-Anonymizing Live CDs through Physical Memory Analysis
De-Anonymizing Live CDs through Physical Memory AnalysisAndrew Case
 
Linux Kernel Tour
Linux Kernel TourLinux Kernel Tour
Linux Kernel Toursamrat das
 

What's hot (20)

Lecture 5 Kernel Development
Lecture 5 Kernel DevelopmentLecture 5 Kernel Development
Lecture 5 Kernel Development
 
How to design a file system
How to design a file systemHow to design a file system
How to design a file system
 
SCSI(small computer system interface)
SCSI(small computer system interface)SCSI(small computer system interface)
SCSI(small computer system interface)
 
Ch04
Ch04Ch04
Ch04
 
os
osos
os
 
[ArabBSD] Unix Basics
[ArabBSD] Unix Basics[ArabBSD] Unix Basics
[ArabBSD] Unix Basics
 
Lecture1 Introduction
Lecture1  IntroductionLecture1  Introduction
Lecture1 Introduction
 
Introduction to Kernel and Device Drivers
Introduction to Kernel and Device DriversIntroduction to Kernel and Device Drivers
Introduction to Kernel and Device Drivers
 
Linux Initialization Process (1)
Linux Initialization Process (1)Linux Initialization Process (1)
Linux Initialization Process (1)
 
SCSI Vs. SATA Vs. IDE
SCSI Vs. SATA Vs. IDESCSI Vs. SATA Vs. IDE
SCSI Vs. SATA Vs. IDE
 
Scsi
ScsiScsi
Scsi
 
Linux Char Device Driver
Linux Char Device DriverLinux Char Device Driver
Linux Char Device Driver
 
The structure of process
The structure of processThe structure of process
The structure of process
 
OMFW 2012: Analyzing Linux Kernel Rootkits with Volatlity
OMFW 2012: Analyzing Linux Kernel Rootkits with VolatlityOMFW 2012: Analyzing Linux Kernel Rootkits with Volatlity
OMFW 2012: Analyzing Linux Kernel Rootkits with Volatlity
 
Linux introduction
Linux introductionLinux introduction
Linux introduction
 
CASPUR Staging System II
CASPUR Staging System IICASPUR Staging System II
CASPUR Staging System II
 
Writing Character driver (loadable module) in linux
Writing Character driver (loadable module) in linuxWriting Character driver (loadable module) in linux
Writing Character driver (loadable module) in linux
 
Linux Kernel I/O Schedulers
Linux Kernel I/O SchedulersLinux Kernel I/O Schedulers
Linux Kernel I/O Schedulers
 
De-Anonymizing Live CDs through Physical Memory Analysis
De-Anonymizing Live CDs through Physical Memory AnalysisDe-Anonymizing Live CDs through Physical Memory Analysis
De-Anonymizing Live CDs through Physical Memory Analysis
 
Linux Kernel Tour
Linux Kernel TourLinux Kernel Tour
Linux Kernel Tour
 

Viewers also liked

знаходження площ фігур за допомогою визначеного інтегралу
знаходження площ фігур за допомогою визначеного інтегралу знаходження площ фігур за допомогою визначеного інтегралу
знаходження площ фігур за допомогою визначеного інтегралу Olexandr Lazarets
 
Matriks X
Matriks XMatriks X
Matriks XKet Ket
 
Dia mundial da ecologia e meio ambiente 2010
Dia mundial da ecologia e meio ambiente   2010Dia mundial da ecologia e meio ambiente   2010
Dia mundial da ecologia e meio ambiente 2010profa2011
 
Wordpress 主题教程
Wordpress 主题教程Wordpress 主题教程
Wordpress 主题教程ma7601467
 
Smart CV - Startup Weekend Shanghai November 2011
Smart CV - Startup Weekend Shanghai November 2011Smart CV - Startup Weekend Shanghai November 2011
Smart CV - Startup Weekend Shanghai November 2011TechRice
 
D.g..act3.lina giraldo
D.g..act3.lina giraldoD.g..act3.lina giraldo
D.g..act3.lina giraldodavidgj1981
 
How to design sustainable multi-organizations
How to design sustainable multi-organizationsHow to design sustainable multi-organizations
How to design sustainable multi-organizationsMasanari Motohasi
 
Круглый стол - Дмитрий Шупик
Круглый стол - Дмитрий ШупикКруглый стол - Дмитрий Шупик
Круглый стол - Дмитрий Шупикikraikra
 
Modul bc(1)
Modul bc(1)Modul bc(1)
Modul bc(1)Jiung Jia
 
Evaluation question 1
Evaluation question 1Evaluation question 1
Evaluation question 1ae11152
 
Elektronayin %40ntercaran v karine
Elektronayin %40ntercaran v karineElektronayin %40ntercaran v karine
Elektronayin %40ntercaran v karinenordprocmskh
 
Шолохов М.А. Жизнь и творчество.
Шолохов М.А.  Жизнь и творчество.Шолохов М.А.  Жизнь и творчество.
Шолохов М.А. Жизнь и творчество.Sonia Mysaeva
 

Viewers also liked (20)

знаходження площ фігур за допомогою визначеного інтегралу
знаходження площ фігур за допомогою визначеного інтегралу знаходження площ фігур за допомогою визначеного інтегралу
знаходження площ фігур за допомогою визначеного інтегралу
 
Las apps
Las appsLas apps
Las apps
 
Tema 4.1 cultura
Tema 4.1   culturaTema 4.1   cultura
Tema 4.1 cultura
 
Matriks X
Matriks XMatriks X
Matriks X
 
Dia mundial da ecologia e meio ambiente 2010
Dia mundial da ecologia e meio ambiente   2010Dia mundial da ecologia e meio ambiente   2010
Dia mundial da ecologia e meio ambiente 2010
 
Slide michela
Slide michelaSlide michela
Slide michela
 
Now We Remain
Now We RemainNow We Remain
Now We Remain
 
Wordpress 主题教程
Wordpress 主题教程Wordpress 主题教程
Wordpress 主题教程
 
Smart CV - Startup Weekend Shanghai November 2011
Smart CV - Startup Weekend Shanghai November 2011Smart CV - Startup Weekend Shanghai November 2011
Smart CV - Startup Weekend Shanghai November 2011
 
D.g..act3.lina giraldo
D.g..act3.lina giraldoD.g..act3.lina giraldo
D.g..act3.lina giraldo
 
Days the week
Days the weekDays the week
Days the week
 
How to design sustainable multi-organizations
How to design sustainable multi-organizationsHow to design sustainable multi-organizations
How to design sustainable multi-organizations
 
Круглый стол - Дмитрий Шупик
Круглый стол - Дмитрий ШупикКруглый стол - Дмитрий Шупик
Круглый стол - Дмитрий Шупик
 
Modul bc(1)
Modul bc(1)Modul bc(1)
Modul bc(1)
 
Evaluation question 1
Evaluation question 1Evaluation question 1
Evaluation question 1
 
Elektronayin %40ntercaran v karine
Elektronayin %40ntercaran v karineElektronayin %40ntercaran v karine
Elektronayin %40ntercaran v karine
 
Шолохов М.А. Жизнь и творчество.
Шолохов М.А.  Жизнь и творчество.Шолохов М.А.  Жизнь и творчество.
Шолохов М.А. Жизнь и творчество.
 
Jolas Motak
Jolas MotakJolas Motak
Jolas Motak
 
Phase1 review ws-intro-2_km&julian
Phase1 review ws-intro-2_km&julianPhase1 review ws-intro-2_km&julian
Phase1 review ws-intro-2_km&julian
 
Cientificos
CientificosCientificos
Cientificos
 

Similar to User-Mode API for Tape Library SCSI Commands

Operation System
Operation SystemOperation System
Operation SystemANANTHI1997
 
Study notes for CompTIA Certified Advanced Security Practitioner (ver2)
Study notes for CompTIA Certified Advanced Security Practitioner  (ver2)Study notes for CompTIA Certified Advanced Security Practitioner  (ver2)
Study notes for CompTIA Certified Advanced Security Practitioner (ver2)David Sweigert
 
Study notes for CompTIA Certified Advanced Security Practitioner
Study notes for CompTIA Certified Advanced Security PractitionerStudy notes for CompTIA Certified Advanced Security Practitioner
Study notes for CompTIA Certified Advanced Security PractitionerDavid Sweigert
 
OS Slide Ch12 13
OS Slide Ch12 13OS Slide Ch12 13
OS Slide Ch12 13庭緯 陳
 
I/O System and Case study
I/O System and Case studyI/O System and Case study
I/O System and Case studyLavanya G
 
Scsi drives
Scsi drivesScsi drives
Scsi drivesBits
 
Mass storage structurefinal
Mass storage structurefinalMass storage structurefinal
Mass storage structurefinalmarangburu42
 
The sysfs Filesystem
The sysfs FilesystemThe sysfs Filesystem
The sysfs FilesystemJeff Yana
 
Real Time Operating System
Real Time Operating SystemReal Time Operating System
Real Time Operating SystemSharad Pandey
 

Similar to User-Mode API for Tape Library SCSI Commands (20)

Operation System
Operation SystemOperation System
Operation System
 
Operation System
Operation SystemOperation System
Operation System
 
Hp docs
Hp docsHp docs
Hp docs
 
Study notes for CompTIA Certified Advanced Security Practitioner (ver2)
Study notes for CompTIA Certified Advanced Security Practitioner  (ver2)Study notes for CompTIA Certified Advanced Security Practitioner  (ver2)
Study notes for CompTIA Certified Advanced Security Practitioner (ver2)
 
Storage
StorageStorage
Storage
 
Ch07 system administration
Ch07 system administration Ch07 system administration
Ch07 system administration
 
Operating system ppt
Operating system pptOperating system ppt
Operating system ppt
 
Operating system ppt
Operating system pptOperating system ppt
Operating system ppt
 
Operating system ppt
Operating system pptOperating system ppt
Operating system ppt
 
Operating system ppt
Operating system pptOperating system ppt
Operating system ppt
 
Study notes for CompTIA Certified Advanced Security Practitioner
Study notes for CompTIA Certified Advanced Security PractitionerStudy notes for CompTIA Certified Advanced Security Practitioner
Study notes for CompTIA Certified Advanced Security Practitioner
 
OS Slide Ch12 13
OS Slide Ch12 13OS Slide Ch12 13
OS Slide Ch12 13
 
I/O System and Case study
I/O System and Case studyI/O System and Case study
I/O System and Case study
 
CASPUR Tape Dispatcher
CASPUR Tape DispatcherCASPUR Tape Dispatcher
CASPUR Tape Dispatcher
 
SCSI Interfaces
SCSI InterfacesSCSI Interfaces
SCSI Interfaces
 
Scsi drives
Scsi drivesScsi drives
Scsi drives
 
Mass storage structurefinal
Mass storage structurefinalMass storage structurefinal
Mass storage structurefinal
 
The sysfs Filesystem
The sysfs FilesystemThe sysfs Filesystem
The sysfs Filesystem
 
Detailed iSCSI presentation
Detailed iSCSI presentationDetailed iSCSI presentation
Detailed iSCSI presentation
 
Real Time Operating System
Real Time Operating SystemReal Time Operating System
Real Time Operating System
 

User-Mode API for Tape Library SCSI Commands

  • 1. User-mode API for Tape Libraries Aram Khalili Computer Science Department University of Maryland Baltimore County 1000 Hilltop Circle Baltimore, MD 21250 akhali1@umbc.edu Abstract Tape libraries are becoming more commonplace in various installations, whether they are used for automatic backups, archive or on-line storage. This work represents a freely distributable user-mode C- library that implements various SCSI commands of the Exabyte EXB-210 unit. 1 Introduction Tape libraries are becoming more and more common in installations where large amounts of data need to be stored but also retrieved often for anal- ysis. Up until recently mass storage systems were used only at scienti c facilities but due to the de- velopment of new applications such as digital li- braries, and electronic commerce the demands for storing enormous amounts of information while at the same time providing e cient access to this in- formation is becoming commonplace. The original project at the Laboratory for Information Systems Technology called for development of a le system that integrates tape libraries with disk storage in a transparent manner. The project has been stopped, but our results are freely available. We chose Linux as the operating system to support this project since access to the source code, internals documentation, and a large support group were necessary require- ments 2, 5]. In order to understand the behavior, in terms of performance, of the robotic arm that performs the mount operations in our Exabyte EXB-210 tape li- brary we developed a user mode API for access to the SCSI medium changer command set 3]. Our interface is built on top of the generic SCSI inter- face (sg driver) presently available in the Linux ker- nel. Based on our knowledge there is currently no other driver or utility available for any of the public domain Unix operating systems for managing auto- mated tape libraries. 2 The library's SCSI Interface The SCSI-2 Interface standard 1] is a standard that enables a host computer and peripheral devices, such as this tape library and its tape drives, to com- municate. The library and tape drives are indepen- dent SCSI devices, and each supports an indepen- dent set of SCSI commands. 2.1 Architecture of the SCSI Inter- face The physical components of a SCSI system con- sist of the following: host adapter: A device which connects between a host system and the SCSI bus. The device usu- ally performs the lowest layers of the SCSI pro- tocol and normally operates in the initiator role. initiator: A computer equipped with a SCSI host adapter card enabling it to send commands, messages and data across the SCSI bus to tar- gets. The initiator can also receive data, mes- sages and status information from the targets. targets: Devices capable of receiving commands from an initiator. The tape library and the tape drives are independent targets. The library is the target for cartridgeinventoryand movement commands, while the tape drive(s) is the target for read and write operations. 1
  • 2. SCSI bus: The SCSI cables that connect initiators and targets. 2.2 Architecture of the tape library The tape library includes the following types of components: medium changer element: This is the robotic arm that moves the tapes. There is exactly one medium changer element in this unit. The medium changer is also called the cartridge han- dling mechanism (CHM) and the transport ele- ment. data transfer element: This is a tape drive, of which there can be one or two in our unit. storage element: This is a cartridge holder. There are either 11 or 21 storage elements in a EXB-210 tape library. It is also called stor- age location. The structure that contains 10 of the storage elements is called a magazine or a cartridge magazine. cartridge: Tapes. There can be 0 to 21 tapes in the library (plus 3 for two tape drives and one medium changer, theoretically). bar code scanner: A bar code scanner that may be mounted on the medium changer. This com- ponent is optional, i.e. there can be 0 or 1 bar code scanner in the unit. It scans bar code la- bels (if installed) on the cartridges. 2.3 SCSI commands supported by the library The EXB-210 unit has two kinds of SCSI de- vices, the tape drive(s) and the medium changer, each supporting a di erent SCSI command set. Out of the list of commands that the tape library sup- ports (see 4]) we have implemented this subset of commands: INQUIRY, MODE SENSE, MODE SE- LECT, INITIALIZE ELEMENT STATUS, MOVE MEDIUM, POSITION TO ELEMENT and READ ELEMENT STATUS. 2.4 INQUIRY The INQUIRY command requests that the li- brary sends information regarding its static parame- ters to the initiator. INQUIRY is used to obtain in- formation such as vendor and product ID, rmware code revision levels, serial number, availability of an optional barcode scanner in the library and support of various SCSI-2 and other options. 2.5 MODE SENSE The MODE SENSE command is used to dis- cover the current operating mode parameters of the library. It can return useful information such as the number and addresses of tape storage locations (11,21), the number of medium changers (1), and the number of tape drives (1-2). It gives information about the parameters that are valid for the MOVE MEDIUM command, i.e. which types of moves the library supports, whether LCD security mode (ac- cess restrictions) is enabled, the LCD, and whether SCSI bus parity is enabled. It can also be used to determine default settings, and currently saved (in non-volatile memory) settings. 2.6 MODE SELECT MODE SELECT allows one to de ne the cur- rent operating parameters for the library. It allows one to set the parameters which can be discoveredby MODE SENSE. Note that parameters are constant and cannot be changed. 2.7 INITIALIZE ELEMENT STA- TUS This command causes the library to check all elements for tapes, and the tape's barcodes, if a bar- code reader is installed. This includes the tape drive and the medium changer, although no action is taken on an INITIALIZE ELEMENT STATUS targeting the medium changer, since this information is always maintained and assumed to be accurate. Checking is done in increasing element address order. 2
  • 3. 2.8 POSITION TO ELEMENT This command requests the medium changer to position itself vertically (for a standalone unit; hor- izontally for rack mounted systems) in front of the requested address. If the medium changer's element address is given as the destination, the changer po- sitions itself in a park position, giving (manual) ac- cess to the tape drive(s) and tape magazine(s). This command can also be used to reduce travel time if the next move command's source address can be pre- dicted, or to position the changer at a place where the average distance to any location is minimized. 2.9 MOVE MEDIUM The MOVE MEDIUM command causes the medium changer, if possible, to move the cartridge from the source to the destination address. Nor- mally this is between the tape magazine and the tape drive(s), but one could also exchange the magazine location of a tape, to minimize the travel distance for frequently used tapes. If the destination address is one of a tape drive, the library will insert the car- tridge. Valid source and destination element com- binations can be discovered by the MODE SENSE command. 2.10 READ ELEMENT STATUS This command allows one to discover the sta- tus of the elements of the library. Elements are the tape drive, the medium changer, and the storage locations. Information that can be obtained about the elements include whether they are in a normal state, the location of the transport element, whether a storage slot is lled with a tape and whether a tape drive or the medium changer contains a tape. 3 Linux's SCSI Interface Probably ever since its inception Linux in- cluded support for SCSI devices. The main function- ality used in the command library (mid-level) lies in /usr/src/linux/drivers/scsi/scsi.c and (higher level) in /usr/src/linux/drivers/scsi/sg.c It was not necessary to explicitly call hardware-level code (adapter drivers). The purpose of this interface is to provide a simple and consistent abstraction of a SCSI device that allows user-process control and follows le-system command syntax. Scsi.c facil- itates the kernel with the mechanisms to scan the SCSI bus for devices (using INQUIRY), issue and queue commands to these devices and maintains the kernel data structures about them. It also imple- ments exception handlers, such as SCSI time-out, abort and reset routines, and re-entrance prevention for the low-level driver. It also supplies functions for registering and removing removing drivers and modules. On top of scsi.c sit sg.c, sd.c and st.c. Sg.c provides the le-system interface for generic SCSI devices utilizing the scsi.c functions. It implements the open, close, read, write and ioctl calls that ab- stract the SCSI devices as les. Linux uses this to create the special device les /dev/sg*, where a let- ter corresponding to the device's discovery during intial scan follows the sg, e.g. /dev/sga for the rst discovered device (the one with the lowest SCSI ID). These device les can be accessed through the nor- mal le operations. An open system call will return the usual le descriptor, which can be passed to write to issue commands to the device. The data for the command is the actual SCSI command appended to an sg header structure, which the user has to pro- vide. The structure includes information about the command, a return value eld and a bu er with the command descriptor block. After the write nishes, a read is used to read back the results. Sd.c and st.c provide similar abstraction for disk and tape devices, respectively. They were not used for this part of the project which only deals with the medium changer device. 4 Tape Library API The functions we developed for access to the medium changer command set are the following: int inquiry(int fd, inquiry_t *inq, u_char type); int mode_sense(int fd, __u16 pagecontrol, __u16 pagecode, elt_addr_assgn_t *eas, tgd_t *tgd, 3
  • 4. dev_cap_t *dcp, LCD_t *LCD, parity_t *par); int mode_select(int fd, __u16 save, elt_addr_assgn_t *eas, LCD_t *LCD, parity_t *par); int init_elt_status(int fd, __u18 nbl); int move_medium(int fd, __u16 tea, __u16 src, __u16 dest); int position_elt(int fd, __u16 tea, __u16 dest); int read_elt_stat(int fd, elt_stat_req_t *esr, elt_stat_data_t *esd, elt_stat_page_t **esp, stor_elt_desc_t **sed, data_transf_elt_desc_t **dted, med_transp_elt_desc_t **mted); 4.1 inquiry Inquiry takes as arguments the le descriptor to the special device le, a pointer to a pre-allocated inquiry t structure for the data that the command should return, and the type of inquiry requested. Valid values for the type are 0 for standard inquiry data, 1 for the Supported Vital Product Data page, and 2 for the Unit Serial Number page. It returns the number of bytes read from the SCSI bus. 4.2 mode sense Mode sense takes as argument the le descrip- tor to the special device le, the control type, the page code, and pointers to elt addr assg t, tgd t, dev cap t, LCD t and parity t. Valid control type arguments are 0 for the current operating values of the library, 1 for a changeable value mask, which sets all bits of unchangeable values to 0 and all bits of changeable values to 1, and 2 for the default values. The page code holds information about the type of pages requested. The following values are valid: 1Dh - Element Address Assignment page. 1Eh - Transport Geometry Descriptor page. 1Fh - Device Capabilities page. 22h - LCD mode page. 00h - Parity page. 3Fh - All pages in above order. The pointers to the structures need only be pre- allocated if the corresponding page is requested, oth- erwise NULL may be passed. Mode sense returns the number of bytes read from the SCSI bus. 4.3 mode select Mode select's arguments are similar to those for mode sense, except that mode select includes the op- tion to save the sent values to non-volatile memory (1 to save, 0 otherwise), and that only structures that can be modi ed are passed. They need to be pre-allocated and set to the desired values if one wants to change their values, otherwise they may be NULL. Mode select returns the number of bytes read from the SCSI bus. 4.4 init elt status Init elt status takes the le descriptor and an indicator of whether the library should attempt to scan bar codes as arguments. Set nbl to 0 scan for bar codes labels, and to 1 to omit. It returns the number of bytes read from the SCSI bus. 4.5 move medium Move medium takes the le descriptor and the element addresses of the transport element, and the source and destination addresses. It returns the number of bytes read from the SCSI bus. 4.6 position elt Position elt takes as arguments the le descrip- tor and the element addresses of the transport ele- ment and its destination. It returns the number of bytes read from the SCSI bus. 4
  • 5. 4.7 read elt status Read elt status takes the le descriptor, and pointers to various structures as arguments. elt stat req t describes the type of request, i.e. whether bar code information should be returned (0 for no, 1 for yes), and which type of elements should be reported on, 0 for all, 1 for the trans- port element, 2 for the storage elements, and 4 for the data transfer elements. Upon successful com- pletion, elt stat data t will hold the element address of the rst element, the number of elements, and the number of bytes returned. Elt stat page t holds the type of element reported, the length in bytes of information per element, and the total number of bytes of information. Up to three records, one record per element type will, will be returned, hence the double pointer. The next structures hold infor- mation on a particular element. Multiple records may be returned. The structure pointers passed to read elt status should not be pre-allocated. It re- turns 1 for success and 0 for failure. 4.8 Additional functionality In addition to the above implementation of the meadium changer's SCSI commands we found it nec- essary or useful to write the following routines and programs. The routines are for the control of the tape drive of the library, and the programs encap- sulate some of these functions to be more useable. The routines are int load(int fd, int luflag); long get_position(int fd); long set_position(int fd, long pos); int rewind_tape(int fd); int set_block_length(int fd, int blocksize); All functions take as their rst argument the le descriptor for the special device le. Load takes a load/unload ag as an additional argument. Set- ting the ag to 1 causes the tape drive to load a tape inside of it, 0 causes it to unload. If tape drive is not in auto-load mode, one needs to load a tape, once it has been inserted into the drive, before one can perform I/O on it. An unload will eject the tape. The command returns the number of bytes read from the SCSI bus. Get position takes no ad- ditional arguments and returns the current o set in blocks of the tape. Set position takes an o set as another argument and seeks the tape to the desired location. It returns the number of bytes returned by the ioctl command. Set block length takesthe integer blocksize as an additional argument and tries to set the current blocsize to the desired value. Valid val- ues depend on the blocksizes supported by the tape drive. It also returns the number of bytes returned by the ioctl call. At this point the following programs exist: move <device> <src> <dest> load <device> load/unload flag] eject <device> position <device> <dest> read_stat <device> All the programs take the device le as their rst argument. Additonal argumentspassed to move are the source and destination element addresses. It assumes the default transport element address of 86. Load takes an optional load/unload ag. If it is ommitted a load is performed on the device, if it is given, it is passed to the load function, which will load on a 1 and unload on a 0. Eject is just a more familiar form of load hdevicei 0. Position takes the block o set as another parameter and seek to the speci ed block. Read stat takes no additional arguments and implements the READ ELEMENT STATUS command for all elements. For a more detailed discussion of the functions and their data structures we direct the reader to the source code and accompanying material, which will be available at ftp://ftp.cs.umbc.edu/pub/exb210/. 4.9 Use of the API We used the API functions to collect perfor- mance measurements of the unit. We generated a workload of le accesses using a uniform distribution 5
  • 6. over the interval 0,8] in seconds for interarrival time of successive requests, a uniform distribution over the interval 1,40] in kilobytes for le sizes, uniform distribution over 1,10] of tape IDs. One process read the simulated workload and issued requests to another process, which interpreted the request and, using the API calls, fetched the right tape, loaded it, seeked to the given location, read or wrote the speci- ed number of blocks, and collected timing informa- tion. Reads and writes were done using Linux's st interface, seeks with our set position function. When we ran it, one thing we immediately noticed is that the library cannot service requests coming in at such a high rate, so in our next workload we changed the interarrival time to a uniform distribution over 0,40], which the device could handle. This indicates that this device by itself will not give adequate inter- active on-line performance, but will work well as an automatic backup device. The most expensive oper- ation time-wise was an eject. The manual does not give information about the device's caching scheme, and other things relevant to the performance of the individual commands, so we are left guessing as to why the unit behaves as it does. Another observa- tion we made is that in sequential reads, if a 32 block boundary is crossed, the read command will take 2 orders of magnitude longer complete. A similar phe- nomenon happens during writing. Otherwise read and write completion time vary by a small amount. 5 Conclusion We have developed a freely distributable library of functions that implement SCSI commands on a EXB-210 tape library and used it to collect perfor- mance measurements of the device. We see our li- brary as a helpful tool to other programmersdesiring to write programsthat accessthe functionality of the EXB-210 unit for application development, and we have included some command encapsulation for use in such things as automatic backup scripts. References 1] ANSI, Small Computer Systems Interface-2 (SCSI-2), X3T9/89-042 2] M. Beck, H. Bohme, M. Dziadzka, U. Kunitz, R. Magnus, and D. Verworner, Linux Kernel Internals", Addison-Wesley, 1996. 3] Exabyte Corporation, Installation and Oper- ation", 1994. 4] Exabyte Corporation, EXB-210 and EXB-220 8mm libraries: SCSI Reference", 1996. 5] David Rusling, The Linux Kernel", The Linux Documentation Project, 1996. 6] Friedhelm Schmidt, The SCSI Bus and IDE Interface: Protocols, Applications, and Pro- gramming", Addison-Wesley, 1996. 6