wait_for_completion为make_request中的submit_bio没有返回

时间:2013-07-23 19:31:10

标签: linux-kernel kernel linux-device-driver device-driver block-device

我正在Linux内核和make_request例程中编写自定义块驱动程序,在写入时我需要在写入新数据之前读取bio的指定扇区(来自物理驱动器)的数据。我的下面的摘录展示了我想要完成的大部分内容,但无论出于何种原因,我都没有从wait_for_completion获得回报。一旦I / O执行到块设备。它在submit_bio之后挂起,永远不会继续。每隔120秒,我会得到一个堆栈转储和消息,说明任务是如何被阻止的。有任何想法吗?想法?

... in make_request ....

if(rw != READ){
    struct completion event;
    struct bio *biow = bio_alloc(GFP_NOIO, bio_segments(bio));
    biow->bi_bdev = bio->bi_bdev;
    biow->bi_sector = bio->sector;
    biow->bi_rw = READ_SYNC;
    biow->bi_vcnt = bio_segments(bio);
    biow->bi_size = bio->bi_size;
    init_completion(&event);
    biow->bi_private = &event;
    biow->bi_end_io = bi_complete;
    submit_bio(READ_SYNC, biow);
    wait_for_completion(&event);
    .... some more magic occurs here ....
}
generic_make_request(bio);

0 个答案:

没有答案