How to combine several structural BIOs into one structure request?

I am working on a Linux kernel version 2.6.39.1 and am developing a block device driver. In this regard, I want to combine several struct bio into one struct request , which is then added to request_queue for processing by the device driver, namely scsi_request_fn() .

I tried using the field ->bi_next struct bio to bind a few struct bio that I wrote by creating a linked list of struct bio s. When I call submit_bio() to send the biography to the block device level for I / O, this BUG_ON() triggered because the code expects bio->bi_next be NULL .

Is there a way to associate multiple struct bio with one struct request before sending it to lower levels for maintenance?

+4
source share
2 answers

Thanks for the answer, @ctuffli. I decided to use a structure similar to that described here . Basically, I struct packet_data that will contain pointers to all struct bio that must be combined to form one single struct bio (and later one, one struct request ). In addition, I store some information about the drivers, as well as this struct packet_data . Then I highlight the new struct bio (lets call it "merged_bio"), copy all the pages from the list of source merged_bio->bi_private and then make merged_bio->bi_private pointer to struct packet_data . This last hack will allow me to keep track of the source BIO list, and also call bio_endio() to complete the I / O for all individual merged_bio after the successful merged_bio transfer.

Not sure if this is the smartest way to do this, but it does what I intended !: ^)

0
source

I'm not sure how to combine multiple struct bio , but you can take a look at the implementation of the "task collector" in libsas and aic94xx for an alternative approach. There is little documentation, but libsas documentation describes it as

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

In task collector mode, the SAS level will be a natural way of combining tasks, and at the appropriate moment, call your driver in the DMA for more than one task in one HA interrupt. DMBS may want to use this with insmod / modprobe by setting lldd_max_execute_num to something greater than 1.

Effectively, this allows the block layer (aka BIO) to remain unchanged, but several requests are accumulated at the driver level and sent together.

0
source

All Articles