|
Driver porting: Request Queues IDriver porting: Request Queues IPosted Jan 8, 2005 1:15 UTC (Sat) by roman (subscriber, #24157)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.
(Log in to post comments)
|
Copyright © 2008, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds
Powered by Rackspace Managed Hosting.