Re: BIO usage questions

Jens Axboe (axboe@suse.de)
Sat, 26 Jan 2002 00:06:00 +0100


On Fri, Jan 25 2002, Badari Pulavarty wrote:
> Hi,
>
> I have few questions on usage of "bio" in 2.5.X.
>
> 1) It is acceptable to use "bio" instead of "kio" for doing RAW IO
> and direct IO ? Currently, "kio" are getting converted to "bio"
> anywhy. why not use "bio" directly ?
>
> I am planning to do this. But I was wondering what are the issues
> here.

Sure you can do that, you would probably have to provide quite a bit of
the mapping infrastructure (or make it generic, probably Ben's work in
this area would be the best way forward). But bio is a generic container
for block I/O, and you are allowed to use it directly.

> 2) I don't see how to wait for a "bio" to complete. I don't see any
> wait_queue in bio structure. How can I wait for bio to complete ?

allocate a private bio, and you 'own' the bi_private and bi_end_io. So
you could do something ala

DECLARE_COMPLETION(wait);

bio = bio_alloc(GFP_XXX, 1);
/* fill in bvec, target, etc */
bio->bi_private = &wait;
bio->bi_end_io = my_end_io;

...

wait_for_completion(&wait);

int my_end_io(struct bio *bio, int nr_sectors)
{
struct completion *wait = bio->bi_private;

/* do end i/o stuff */
...

/* wake up waiters */
complete(wait);
return 0;
}

-- 
Jens Axboe

- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/