From: Rohit B on
Hi,
I am trying to implement a block driver and facing an issue. Please find
attached a simple code snippet which reproduces this hang. I have used and
modified the Simple Block driver(sbull) example from Linux Device Drivers (3rd
Ed)
to simulate the problem. The example has been modified to use a file as the
back-end instead of memory.

The problem that I see with this example is that, when an attempt is made to
read
the block device using dd, the vfs_read function call in thesbull_make_request
hangs.
This sometimes causes the insmod of sbull to hang. And almost always causes the
dd command to hang. This hang is only observed in the linux kernel version
2.6.27.45-0.1 (SLES 11). I have also tried the same code example on
Liunx 2.6.16.46-0.12 (SLES 10 and its service packs), but the hang is not
observed there. While I understand that this is not a normal use-case, a block
driver will not use a file as a back-end, I wanted to understand how to fix my
example code to solve this hang problem for the latest kernel. Any help in this
regard is highly appreciated.

Distribution Used SLES 11
Kernels checked: 2.6.27.45-0.1
Description of the Source Attached: This attached source uses the simple
no-queue version and defines a make-request. The make-request reads the file for

the data and services the bio.

Steps to reproduce the problem:
1. untar the sbull.tar.gz and cd into sbull and do a make. Make also
creates a 512MB file in the current
directory which is used as the back-end.
2. insmod sbull.ko, a block device /dev/sbulla is created.
3. dd if=/dev/sbulla of=./file (hangs)

Stack Trace of the Hang:
crash> bt 4289
PID: 4289 TASK: ffff880026120200 CPU: 1 COMMAND: "dd"
#0 [ffff8800260a15c8] schedule at ffffffff8049c0a7
#1 [ffff8800260a16d0] io_schedule at ffffffff8049c1c6
#2 [ffff8800260a16f0] sync_page at ffffffff80282d5d
#3 [ffff8800260a1700] __lock_page_killable at ffffffff8028305f
#4 [ffff8800260a1760] do_generic_file_read at ffffffff80283e84
#5 [ffff8800260a17f0] generic_file_aio_read at ffffffff80284a94
#6 [ffff8800260a1880] do_sync_read at ffffffff802b1880
#7 [ffff8800260a19b0] vfs_read at ffffffff802b227a
#8 [ffff8800260a19e0] sbull_make_request at ffffffffa02bd3f3
#9 [ffff8800260a1a40] generic_make_request at ffffffff8033a7f8
#10 [ffff8800260a1ae0] submit_bio at ffffffff8033a901
#11 [ffff8800260a1b20] submit_bh at ffffffff802d2ae2
#12 [ffff8800260a1b40] block_read_full_page at ffffffff802d5b08
#13 [ffff8800260a1c00] __do_page_cache_readahead at ffffffff8028aeed
#14 [ffff8800260a1c80] ondemand_readahead at ffffffff8028b22b
#15 [ffff8800260a1cc0] do_generic_file_read at ffffffff80283d52
#16 [ffff8800260a1d50] generic_file_aio_read at ffffffff80284a94
#17 [ffff8800260a1de0] do_sync_read at ffffffff802b1880
#18 [ffff8800260a1f10] vfs_read at ffffffff802b227a
#19 [ffff8800260a1f40] sys_read at ffffffff802b23df
#20 [ffff8800260a1f80] system_call_fastpath at ffffffff8020bffb
RIP: 00007ffabd782ee0 RSP: 00007fff3b4131f8 RFLAGS: 00000217
RAX: 0000000000000000 RBX: ffffffff8020bffb RCX: 00007ffabd782ee0
RDX: 0000000000000200 RSI: 0000000000611000 RDI: 0000000000000000
RBP: 0000000000000000 R8: 0000000000000000 R9: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000611000
R13: 0000000000000200 R14: 0000000000000800 R15: 0000000000000000
ORIG_RAX: 0000000000000000 CS: 0033 SS: 002b
crash>


Rgds,
Rohit