3

我想创建一个块设备来获取具有 n 扇区请求的 bio 并将其拆分为具有 1 个扇区的 n bio。我用过bio_split,但它不起作用并达到BUG_ON.

有什么功能可以做这样的事情吗?

如果没有人可以帮我写一个函数来做到这一点?具有将 bio 拆分为 4k bios 的功能也很好。

4

1 回答 1

4

The split_bio() function only works for bios with a single page (when bi_vcnt field is exactly 1).

To deal with bios with multiple pages - and I suspect you deal with these most of the time - you have to create new bios and set them up so that they contain only a single sector.

Tip: If the sector size is the same as the page size (currently 4K), and your block driver tells the kernel to supply no less than this size, than you only have to put each page from the incoming bio to the new bio. If the sector size is less then the page size, than the logic will be a bit more complicated.

Use bio_kmalloc to allocate the new bios and copy the data onto the memory pages in them manually.

于 2012-05-17T09:25:29.950 回答