I’m working on Linux kernel version 2.6.39.1, and am developing a block device driver. In this regard, I want to combine multiple struct bios into a single struct request, which is then added to the request_queue for processing by the device driver, namely — scsi_request_fn().
I tried using the ->bi_next field of struct bio to link multiple struct bios that I have composed, thereby creating a linked list of struct bios. When I call submit_bio() to submit a bio to the block device layer for I/O, this BUG_ON() is triggered because the code expects bio->bi_next to be NULL.
Is there a way to link several struct bios into a single struct request before sending it to lower layers for servicing?
Thanks for the reply, @ctuffli. I’ve decided to use a structure similar to the one described here. Basically, I allocate a
struct packet_datawhich would contain pointers to allstruct bios that should be merged to form one singlestruct bio(and later on, one singlestruct request). In addition, I store some driver related information as well in thisstruct packet_data. Next, I allocate a newstruct bio(lets call it “merged_bio”), copy all the pages from the list of original BIOs and then make themerged_bio->bi_privatepoint to thestruct packet_data. This last hack would allow me to keep track of the list of original BIOs, and also callbio_endio()to end I/O on all individual BIOs once themerged_biohas been successfully transferred.Not sure if this is the smartest way to do this, but it does what I intended! :^)