没有合适的资源?快使用搜索试试~ 我知道了~
首页Guide to the implementation of SCSI in Linux 2.6.X kernel
Guide to the implementation of SCSI in Linux 2.6.X kernel

SCSI has emerged as a popular protocol in the storage world. This document is a guide to understanding the implementation of SCSI in the Linux 2.6.X kernel. This project analyzes the code implementing the SCSI protocol, provides the big picture involving the IO, explains the entry points, data structures and the exported functions. The project is intended as a reference for experimenters and developers who would be working on the SCSI module in Linux.
资源详情
资源评论
资源推荐

Guide to the implementation of SCSI in Linux 2.6.X kernel
By
Samdeep Nayak
Revision History:

Rev No Date Comments Author
0.1 12/11/2004 Initial Draft
Samdeep Nayak
With feedback from Amir A Vetry and
Randy Dunlap
0.2 01/08/05
Implemented Machtelt Garrels
suggestions on the document style
Samdeep nayak with feedback from
Machtelt Garrels
Abstract
SCSI has emerged as a popular protocol in the storage world. This document is a
guide to understanding the implementation of SCSI in the Linux 2.6.X kernel. This
project analyzes the code implementing the SCSI protocol, provides the big picture
involving the IO, explains the entry points, data structures and the exported functions.
The project is intended as a reference for experimenters and developers who would be
working on the SCSI module in Linux.

Table of Contents
1.0 Introduction.................................................................................................................................................6
1.1 Document Assumptions and Conventions..............................................................................................6
1.2 Copyright, License and Disclaimer.........................................................................................................6
1.3 Acknowledgments...................................................................................................................................7
1.4 Feedback.................................................................................................................................................7
2.0 Linux Overview of Block Data Transfer....................................................................................................8
2.1 Block Device Driver Upper Entry points...............................................................................................9
2.2 Block Device Driver Lower Entry points.............................................................................................10
2.3 Flow of an IO in the block device driver..............................................................................................11
2.4 Block Device Driver Data Structures...................................................................................................11
2.4.1 Struct block_device_operations.....................................................................................................11
2.4.2 Struct request_queue......................................................................................................................12
3.0 Overview of Linux SCSI Subsystem – Layered Architecture...................................................................14
4.0 Overview of SCSI Disk Driver (SD) – Upper Layer................................................................................16
4.1 SD functionality....................................................................................................................................16

4.1.1 sd_probe........................................................................................................................................17
4.1.2 sd_remove......................................................................................................................................17
4.1.3 sd_shutdown..................................................................................................................................17
4.1.4 sd_init_command...........................................................................................................................18
4.1.5 sd_open..........................................................................................................................................18
4.1.6 sd_release.......................................................................................................................................18
4.1.7 sd_ioctl...........................................................................................................................................18
4.1.8 sd_media_change...........................................................................................................................19
4.1.9 sd_revalidate_disk.........................................................................................................................19
4.1.10 sd_rw_intr....................................................................................................................................19
4.2 SD Provided Entry points for the mid layer SCSI................................................................................19
4.3 SD Provided Entry points for the block device....................................................................................19
4.4 SD used Entry points from the mid layer SCSI....................................................................................20
4.5 SD used Entry points from the block device........................................................................................20
4.6 SD data structures.................................................................................................................................20
5.0 Overview of SCSI Unifying Mid Layer....................................................................................................22
5.1 SCSI Initialization................................................................................................................................22
5.2 SCSI BUS Scan ...................................................................................................................................22
5.3 IO Functionality....................................................................................................................................23
5.3.1 scsi_prep_fn...................................................................................................................................23
5.3.2 scsi_request_function....................................................................................................................24
5.3.3 scsi_done.......................................................................................................................................24
5.4 Error Handling Functionality................................................................................................................25
5.5 Data Structures......................................................................................................................................27
6.0 SCSI Low Level Driver............................................................................................................................41
6.1 SCSI Low Level Driver functional entry points...................................................................................42
6.1.1 bios_param.....................................................................................................................................42
6.1.2 detect..............................................................................................................................................42
6.1.3 eh_timed_out.................................................................................................................................42
6.1.4 eh_abort_handler...........................................................................................................................43
6.1.5 eh_bus_reset_handler....................................................................................................................43
6.1.6 eh_device_reset_handler................................................................................................................43
6.1.7 eh_host_reset_handler...................................................................................................................43
6.1.8 eh_strategy_handler.......................................................................................................................43
6.1.9 info.................................................................................................................................................44
6.1.10 ioctl..............................................................................................................................................44
6.1.11 proc_info......................................................................................................................................44
6.1.12 queuecommand............................................................................................................................44
6.1.13 release..........................................................................................................................................45
6.1.14 slave_alloc...................................................................................................................................45
6.1.15 slave_configure............................................................................................................................45
6.1.16 slave_destroy...............................................................................................................................45
6.2 Important Scsi_Host parameters set by the LLD..................................................................................46
6.3 Important Scsi_Cmnd parameters provided by SCSI mid layer...........................................................46
6.4 SCSI mid layer functions exported to LLD..........................................................................................48
References.......................................................................................................................................................49
List of Figures
Figure 1 - Linux File IO Transfer Overview.....................................................................................................8
Figure 2 - High-level overview of an IO transfer using block device driver..................................................11
Figure 3 - Linux SCSI SubSystem - Layered architecture..............................................................................14
Figure 4 - IO transfer using all the three layers..............................................................................................15
Figure 5 - SCSI Bus Scan...............................................................................................................................23
Figure 6 - SCSI IO Low and Midlevel IO transfer.........................................................................................41

List of Tables
Table 1 - Block Initialization entry points........................................................................................................9
Table 2 - Block IO entry points......................................................................................................................10
Table 3 - Block Device Driver Entry Points...................................................................................................10
Table 4 - SD Provided entry points to Mid Layer...........................................................................................19
Table 5 - SD Provided Entry points for the block device...............................................................................20
Table 6 - SD used Entry points from the mid layer SCSI...............................................................................20
Table 7 - SD used Entry points from the block device...................................................................................20
Table 8 - Scsi_Host parameters set by LLD...................................................................................................46
Table 9 - Scsi_Cmnd parameters provided by SCSI mid layer.......................................................................48
Table 10 - MidLayer exported functions to LLD............................................................................................48
1.0 Introduction
This document describes the internals of SCSI in 2.6.X Linux kernel. This
provides the internal view of the SCSI subsystem as seen from the current
implementation. The document covers all the three layers of Linux SCSI implementation
and tries to provide a top down view of the modules. The discussion revolves around the
overview of the block driver interface, three layer SCSI architecture, SCSI upper layer
(SD in specific), SCSI mid layer and Low Level driver interface. Each of the sections
begin with a big picture, interfaces to the adjoining layers, functional flow, description of
the important functions and the important data structures involved with the layer.
1.1 Document Assumptions and Conventions
It is assumed that the reader understands C programming language and is
acquainted with bit of SCSI protocol. More documentation describing the SCSI
architecture and model can be found at www.t10.org.
The file references in the document are in italics. The data structures are in a
reduced font to identify them from rest of the document.
1.2 Copyright, License and Disclaimer
剩余44页未读,继续阅读















安全验证
文档复制为VIP权益,开通VIP直接复制

评论3