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/
--0-2092529281-1015842974=:52661
Content-Type: application/octet-stream; name="layer.c"
Content-Transfer-Encoding: base64
Content-Description: layer.c
Content-Disposition: attachment; filename="layer.c"
LyoKICAgCiAgIGJhc2VkIG9uIGNvZGUgZnJvbSAiTGludXggRGV2aWNlCiAg
IERyaXZlcnMiIGJ5IEFsZXNzYW5kcm8gUnViaW5pIGFuZCBKb25hdGhhbiBD
b3JiZXQsIDJuZCBlZGl0aW9uLCBwdWJsaXNoZWQK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gV2Ugc2V0IHRoZQoJICogc3RhcnQgb2YgZGF0YSBhdCBz
ZWN0b3IgZm91ci4KICAgICAgICAgKi8KICAgICAgICBlcnIgPSAhIGFjY2Vz
c19vayhWRVJJRllfV1JJVEUsIGFyZywgc2l6ZW9mKGdlbykpOwogICAgICAg
IGlmIChlcnIpIHJldHVybiAtRUZBVUxUOwogICAgICAgIHNpemUgPSBsYXll
cmVkX3NpemUgKiBibGtzaXplIC8gbGF5ZXJlZF9oYXJkc2VjdDsKICAgICAg
ICBnZW8uY3lsaW5kZXJzID0gKHNpemUgJiB+MHgzZikgPj4gNjsKCSAgICBn
ZW8uaGVhZHMgPSA0OwoJICAgIGdlby5zZWN0b3JzID0gMTY7CgkgICAgZ2Vv
LnN0YXJ0ID0gNDsKCSAgICBpZiAoY29weV90b191c2VyKCh2b2lkICopIGFy
ZywgJmdlbywgc2l6ZW9mKGdlbykpKQoJICAgIHJldHVybiAtRUZBVUxUOwog
ICAgICAgIHJldHVybiAwOwoKICAgICAgZGVmYXVsdDoKICAgICAgICAvKgog
ICAgICAgICAqIEZvciBpb2N0bHMgd2UgZG9uJ3QgdW5kZXJzdGFuZCwgbGV0
IHRoZSBibG9jayBsYXllcmVkIGhhbmRsZSB0aGVtLgogICAgICAgICAqLwog
ICAgICAgIHJldHVybiBibGtfaW9jdGwoaW5vZGUtPmlfcmRldiwgY21kLCBh
cmcpOwogICAgfQogICAgcmV0dXJuIC1FTk9UVFk7IC8qIHVua25vd24gY29t
bWFuZCAqLwp9CgppbnQgbGF5ZXJlZF9jaGVja19tZWRpYV9jaGFuZ2Uoa2Rl
dl90IGtkZXYpCnsKICAgIGludCBtaW5vciA9IE1JTk9SKGtkZXYpOwoKICAg
IGlmIChtaW5vciA+PSBsYXllcmVkX2RldnMpIC8qIHBhcmFub2lkICovIAog
ICAgewogICAgICAgIHJldHVybiAwOyAgICAgICAgICAgICAgICAgICAgICAg
ICAgIAogICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICA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I7Cn0KCnN0YXRpYyBz
aXplX3Qgd3JpdGUoc3RydWN0IGZpbGUgKiBmLCBjb25zdCBjaGFyICpiLCBz
aXplX3Qgcywgb2ZmX3QgbykKewogICAgaW50IGkgOwogICAgbG9mZl90IHBv
czsKICAgIG1tX3NlZ21lbnRfdCBmczsKCiAgICBzaXplX3QgciA9IDA7CiAg
ICBpZiAoIShmKSkKICAgIHsKICAgICAgICByZXR1cm4gLUVCQURGOwogICAg
fQogICAgaSA9IFBUUl9FUlIoZik7CiAgICBpZiAoSVNfRVJSKGYpKQogICAg
ewogICAgICAgIHJldHVybiBpOwogICAgfQoKICAgIHBvcyA9IGYtPmZfcG9z
ID0gbzsKICAgIGZzID0gZ2V0X2ZzKCk7CnByaW50aygiPDE+IHB3cml0ZTY0
IDNcbiIpOwogICAgc2V0X2ZzKGdldF9kcygpKTsKcHJpbnRrKCI8MT4gcHdy
aXRlNjQgNFxuIik7CiAgICByID0gZi0+Zl9vcC0+d3JpdGUoZiwgKGNvbnN0
IGNoYXIgKikgYiwgcywgJnBvcyk7CnByaW50aygiPDE+IHB3cml0ZTY0IDVc
biIpOwogICAgc2V0X2ZzKGZzKTsKcHJpbnRrKCI8MT4gcHdyaXRlNjQgNlxu
Iik7CgogICAgLy9mc3luY19kZXYoZi0+Zl9kZW50cnktPmRfaW5vZGUtPmlf
cmRldik7ICAgIAogICAgcmV0dXJuIHI7Cn0KCgoKbW9kdWxlX2luaXQoaW5p
dF9sYXllcmVkKQptb2R1bGVfZXhpdChleGl0X2xheWVyZWQpCgo=
--0-2092529281-1015842974=:52661--
-
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/