Driver porting: Request Queues I
Posted Jan 8, 2005 1:15 UTC (Sat) by roman
Parent article: Driver porting: Request Queues I
It was not initially obvious to me that you can't iterate through a request's BIOs with rq_for_each_bio(bio, req) and call end_that_request_first() in the loop. The problem is that end_that_request_first() may free the current BIO when it is completed, but rq_for_each_bio() will still dereference bio which points to the possibly freed BIO.
I'm working on a programmed I/O driver, and the easiest way to deal with it turns out to be to use a simple while (req->bio != NULL) loop. Each time around the loop it transfers bio_cur_sectors(req->bio) worth and calls end_that_request_first() for that much. This keeps the BIO and the request updated nicely, and terminates when the last BIO has been finished.
to post comments)