sbull ldd3 example driver gets stuck

600 views Asked by At

I'm writing a block device driver and started with the sbull example from here: http://lwn.net/images/pdf/LDD3/ldd3_pdf.tar.bz2 I loaded the sbull driver successfully on my machine with kernel version 3.5.0-23. When I run this code:

int main(){
int fd;

if ((fd = open("/dev/sbulla",O_RDWR)) < 0)
{
    perror("open: ");
    exit(1);
}

lseek(fd,4096,SEEK_SET);
write(fd,"yonityoyin",10);

lseek(fd,4096*2,SEEK_SET);
write(fd,"yonityoyin",10);

close(fd);

}

The session gets stuck. If i open another session on the machine and print dmesg i get this after some time:

[56437.815570] INFO: task a.out:4640 blocked for more than 120 seconds.
[56437.822742] "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.
[56437.831563] a.out           D ffffffff8180cbe0     0  4640   4639 0x00000000
[56437.831571]  ffff880852715c08 0000000000000082 0000000000000000 0000000000000001
[56437.831580]  ffff880852715fd8 ffff880852715fd8 ffff880852715fd8 00000000000139c0
[56437.831588]  ffff8808547c0000 ffff880851bc2e00 ffff880852715be8 ffff88085fd74258
[56437.831595] Call Trace:
[56437.831623]  [<ffffffff81127220>] ? __lock_page+0x70/0x70
[56437.831638]  [<ffffffff8169d8b9>] schedule+0x29/0x70
[56437.831643]  [<ffffffff8169d98f>] io_schedule+0x8f/0xd0
[56437.831652]  [<ffffffff8112722e>] sleep_on_page+0xe/0x20
[56437.831657]  [<ffffffff8169c25f>] __wait_on_bit+0x5f/0x90
[56437.831663]  [<ffffffff81127c1b>] ? find_get_pages_tag+0xcb/0x170
[56437.831674]  [<ffffffff81127388>] wait_on_page_bit+0x78/0x80
[56437.831682]  [<ffffffff81078490>] ? autoremove_wake_function+0x40/0x40
[56437.831691]  [<ffffffff8112749c>] filemap_fdatawait_range+0x10c/0x1a0
[56437.831701]  [<ffffffff81133000>] ? do_writepages+0x20/0x40
[56437.831706]  [<ffffffff8112755b>] filemap_fdatawait+0x2b/0x30
[56437.831711]  [<ffffffff811298e4>] filemap_write_and_wait+0x44/0x60
[56437.831718]  [<ffffffff811c0091>] __sync_blockdev+0x21/0x40
[56437.831722]  [<ffffffff811c00c3>] sync_blockdev+0x13/0x20
[56437.831726]  [<ffffffff811c0139>] __blkdev_put+0x69/0x1c0
[56437.831736]  [<ffffffff811c02eb>] blkdev_put+0x5b/0x160
[56437.831740]  [<ffffffff811c0415>] blkdev_close+0x25/0x30
[56437.831750]  [<ffffffff81188afe>] __fput+0xbe/0x240
[56437.831756]  [<ffffffff81188ca5>] fput+0x25/0x30
[56437.831761]  [<ffffffff81185976>] filp_close+0x66/0x90
[56437.831766]  [<ffffffff81185a3e>] sys_close+0x9e/0x110
[56437.831775]  [<ffffffff816a7029>] system_call_fastpath+0x16/0x1b

What could be the problem with the driver? Just to be clear, I get this problem with the original sbull driver.

1

There are 1 answers

0
Wataru On

Please refer the newer example code.

https://github.com/martinezjavier/ldd3