linux - 如何将多个结构 BIO 组合成一个结构请求?

标签 linux linux-kernel storage linux-device-driver block-device

我正在研究 Linux 内核版本 2.6.39.1,并且正在开发 block 设备驱动程序。对此,我想将多个struct bio组合成一个struct request,然后加入到request_queue中,由设备驱动程序,即 -- scsi_request_fn()

我尝试使用 struct bio->bi_next 字段链接多个我编写的 struct bio ,从而创建链接struct bio 列表。当我调用 submit_bio() 将 bio 提交到 block 设备层以进行 I/O 时,this BUG_ON() 被触发是因为代码期望 bio->bi_nextNULL

有没有办法在将多个struct bio链接到一个struct request中,然后再将其发送到较低层进行服务?

最佳答案

我不确定如何将多个 struct bio 串在一起,但您可能想看看 libsas 中的“任务收集器”实现和 aic94xx替代方法的驱动程序。没有太多文档,但是 libsas documentation描述为

Some hardware (e.g. aic94xx) has the capability to DMA more than one task at a time (interrupt) from host memory. Task Collector Mode is an optional feature for HAs which support this in their hardware. (Again, it is completely optional even if your hardware supports it.)

In Task Collector Mode, the SAS Layer would do natural coalescing of tasks and at the appropriate moment it would call your driver to DMA more than one task in a single HA interrupt. DMBS may want to use this by insmod/modprobe setting the lldd_max_execute_num to something greater than 1.

实际上,这让 block 层(又名 BIO)保持不变,但多个请求在驱动层累积并一起提交。

关于linux - 如何将多个结构 BIO 组合成一个结构请求?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6665717/

相关文章:

c - 为什么操作系统需要/维护内核线程?

linux - DMA 缓存一致性管理

android - 为什么我的存储空间不断填满?

mysql - 优化存储空间 : Many rows & columns with the same values

linux - 将变量的内容写入文件

linux - 安装驱动程序会增加 linux 内核内存占用吗?

linux - 调度器的工作

python - 使用 numpy 加载和存储稀疏数据的性能

linux - expect的 'spawn'命令传参是否安全?

linux - Mac 上的 mmap 可以返回 null 吗?