I think something like the following should do it.
(WARNING: entirely untested)
static void io_done(struct bio *bio)
{
complete((struct completion *)bio->bi_private);
}
static int doio(struct block_device *bdev, size_t size)
{
struct completion comp;
struct page * page;
struct bio * bio;
bio = bio_alloc(GFP_KERNEL, 1);
if (!bio)
return -ENOMEM;
page = alloc_page(GFP_KERNEL);
if (!page) {
bio_put(bio);
return -ENOMEM;
}
bio->bi_sector = 0;
bio->bi_bdev = bdev;
bio->bi_io_vec[0].bv_page = page;
bio->bi_io_vec[0].bv_len = size;
bio->bi_io_vec[0].bv_offset = 0;
bio->bi_vcnt = 1;
bio->bi_idx = 0;
bio->bi_size = LOGPSIZE;
bio->bi_end_io = io_done;
bio->bi_private = &complete;
submit_bio(READ, bio);
run_task_queue(&tq_disk);
wait_for_completion(&comp);
bio_put(bio);
__free_page(page);
return 0;
}
-
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/