我正在研究 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_next
为 NULL
。
有没有办法在将多个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/