Chinaunix首页 | 论坛 | 博客
  • 博客访问: 55383
  • 博文数量: 8
  • 博客积分: 1598
  • 博客等级: 上尉
  • 技术积分: 90
  • 用 户 组: 普通用户
  • 注册时间: 2009-07-09 15:35
文章分类

全部博文(8)

文章存档

2010年(1)

2009年(7)

我的朋友

分类: LINUX

2010-01-13 21:32:16

IO operation part 3: how libata connects to SCSI layer

scsi_request_fn -> scsi_dispatch_cmd -> queuecommand (ata_scsi_queuecmd)
-> __ata_scsi_queuecmd -> ata_scsi_translate -> ata_qc_issue
-> ahci_qc_prep ahci_qc_issue

scsi_request_fn
Each block device has a request_queue associated with it, the IO
requests from kernel block layer (bio, block layer will try to merge
bio according to the elevator algorithm, bios which request data in the
near area are merged into one struct request in request_queue) are
collected on this queue. Block driver needs to provide a request_fn
to handle the requests (for SCSI deivce, it is scsi_request_fn)

scsi_request_fn -> scsi_dispatch_cmd
scsi_host_template:queuecommand(scsi_cmnd, scsi_done)
Through this function call, the SCSI layer will call into lower level
driver (f.e ata_scsi_queuecmd to the libata layer).
scsi_done() will be called when the scsi_cmnd is finished by the lower
level driver, and through this function the lower level driver calls
back to the SCSI layer.

ata_scsi_queuecmd
Find the corresponding ata_port and ata_deivce and call
__ata_scsi_queuecmd to do the real work.

ata_scsi_queuecmd -> __ata_scsi_queuecmd
Find appropriate translate function used for translating scsi command
block to ata command (ata_taskfile) f.e ata_scsi_rw_xlat translates
SCSI r/w command into an ATA one. In libata layer, a command for an ATA
device is represented by a ata_qeueued_cmd.

ata_scsi_queuecmd -> __ata_scsi_queuecmd -> ata_scsi_translate
Find an empty command slot (ata_queued_cmd) in ata_port and init this
ata_queued_cmd from the scsi_cmnd, including memory buffer address used
for DMA
    qc->scsidone = scsi_done
    qc->complete_fn = ata_scsi_qc_complete
    When the ata command is finished, complete_fn will be called
        (which will call scsidone to call back to SCSI layer).

ata_qc_issue() -> ata_port_operations:qc_prep qc_issue
This will call into ATA host controller driver, f.e for ahci controller
driver to do command setup and command issue. For ahci driver, it needs
to setup the command table, including command FIS, dma address..
(see ahci_qc_prep ahci_qc_issue for details).
阅读(2666) | 评论(0) | 转发(0) |
0

上一篇:RCU-based dcache lookup

下一篇:没有了

给主人留下些什么吧!~~