"layered" block devices and deadlock problems
Hi, I have been trying to write a kernel driver for a "layered" block device, that is, a virtual device which sits on top of actual physical devices and redirects read/write requests to them. To avoid problems in the interrupt context I save the requests in a queue in the request function and have a kernel thread pulling the requests out of the queue and then in turn calling read() or write() functions of the physical block device.
However, I keep running into deadlocks. Sometimes the kernel thread will hang on waiting for free request structures. Other times it will hang in wait_for_buffer() in buffer.c. In both cases the system won't respond to any new shell commands I typed in. (But existing processes like xosview and top continue to run) Since I am not familiar with the internal workings of the buffer cache, can anyone give me hints on how to avoid deadlocks in layered drivers?
Or pointers to useful documentation for this kind of
tasks are also appreciated.
Thanks.
__________________________________________________
Do You Yahoo!?
Try FREE Yahoo! Mail - the world's greatest free email!
http://mail.yahoo.com/
Quoted 4 lines · Andy Tai
Hi, I have been trying to write a kernel driver for a "layered" block device, that is, a virtual device which sits on top of actual physical devices and redirects read/write requests to them.
There are three examples of this that you can look at: software raid (drivers/md/md.c), LVM (drivers/md/lvm*.c), and the device mapper (ftp://ftp.sistina.com/pub/LVM2/device-mapper). I'm biased so would recommend starting with dm.c in device-mapper.
- Joe