Hi, this is a follow up to a previous message about
the deadlock problem of a "layered" device. Basically
I want to create a virtual device that redirects I/O
requests to other real, physcial block devices. This
is kind of similar to md or LVM. My particular
problem is that I am calling the "f_op->write()" file
operations of the physical device within the
processing of write requests to the virtual device,
and it often locks up during the "write()", often in
wait_for_buffer() in buffer.c.
I am calling write() in a process context, not in an
interrupt context.
I know there are tricks to avoid calling
"f_op->write()" of the physical device during the
request functions of the virtual device, but I would
prefer to call "write()" so if possible, so I don't
have to worry about the nature of the physical device.
The attached file is called layer.c.
To compile it into a module, do the following
commands:
gcc -g -O2 -Wall -Wstrict-prototypes -Wno-trigraphs
-fomit-frame-pointer -fno-strict-aliasing -fno-common
-pipe -mpreferred-stack-boundary=2 -DMODULE
-D__KERNEL__ -DLINUX -I/lib/modules/$(shell uname
-r)/build/include layer.c
ld -r layer.o -o layered_device.o
To insert the module, do
insmod ./layered_device.o basedev=/dev/hdd1
size=102400
replace /dev/hdd1 with an empty partiton or file, and
102400 is the size of the virtual device in kbytes.
Replace 102400 with your desired size, which should be
smaller or equal to the size of the "basedev."
I used kernel 2.4.17 with this module. I tried to do
operations like
mkfs /dev/layered0
mount /dev/layered0 /mnt
dd if=/dev/zero of=/mnt/junk bs=1k count=96000
umount /mnt
Sometimes the deadlock occurs in mkfs, and other times
it occurs in dd or umount. I guess it occurs during
file "sync" operations.
Thanks for any help and advice on how to solve this
deadlock. I really appreciate it!
__________________________________________________
Do You Yahoo!?
Try FREE Yahoo! Mail - the world's greatest free email!
http://mail.yahoo.com/