linux - sbull ldd3 示例驱动程序卡住

标签 linux linux-kernel linux-device-driver kernel-module block-device

我正在编写一个 block 设备驱动程序,并从这里的 sbull 示例开始: http://lwn.net/images/pdf/LDD3/ldd3_pdf.tar.bz2 我在内核版本为 3.5.0-23 的机器上成功加载了 sbull 驱动程序。 当我运行此代码时:

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);

}

session 卡住。 如果我在机器上打开另一个 session 并打印 dmesg,我会在一段时间后收到此消息:

[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

驱动程序可能存在什么问题? 需要明确的是,我在使用原始 sbull 驱动程序时遇到了这个问题。

最佳答案

请引用较新的示例代码。

https://github.com/martinezjavier/ldd3

关于linux - sbull ldd3 示例驱动程序卡住,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26881983/

相关文章:

python - 如何找到网络接口(interface)传输性能?

c - 字符设备与终端设备与流之间的区别

c - 如何在 Linux 上附加到另一个驱动程序中的设备上下文

php - VI编辑器_将文件夹从Windows移动到Web服务器

linux - 如果我们想在版本化的源代码中搜索,使用 git grep 比使用普通 grep 更好吗?

linux-kernel - 动态更改 eBPF 映射大小

c - Linux DMA : Using the DMAengine for scatter-gather transactions

Linux 内核和我的内核模块

mysql - mongodb 和 mysql 的性能测试器

android - 这个内核源码能用吗?