在提供块设备请求时从网络写入/读取

时间:2013-09-17 22:16:48

标签: linux linux-kernel linux-device-driver

我为ramdisk修改了一个块设备驱动程序(类似于这里的http://www.linuxforu.com/2012/02/device-drivers-disk-on-ram-block-drivers/),以便驱动程序从网络读取/写入。我基本上删除了memcpy并将其替换为内核网络套接字读/写。

以下是我得到的:警告irqs被禁用。警告从函数WARN_ON_ONCE(in_irq() || irqs_disabled());内的行_local_bh_enable_ip抛出。

我的理解是我所做的工作应该有效,因为所有磁盘请求都在gendisk中提供的工作队列中排队。并且将从典型的内核上下文中调用作业处理程序(在调用blk_init_queue()时提供),其中应启用irqs。但我想我错了。

任何人都可以帮忙解决问题?

以下是内核拼写的堆栈跟踪的顶部部分:

[  697.480153]  [<ffffffff8105931f>] warn_slowpath_common+0x7f/0xc0
[  697.480159]  [<ffffffff8105937a>] warn_slowpath_null+0x1a/0x20
[  697.480166]  [<ffffffff8106172a>] local_bh_enable+0x7a/0xa0
[  697.480175]  [<ffffffff815974b3>] lock_sock_nested+0x53/0x60
[  697.480183]  [<ffffffff815eedfc>] tcp_sendmsg+0x2c/0xe60
[  697.480197]  [<ffffffff8134226c>] ? vsnprintf+0x35c/0x640
[  697.480207]  [<ffffffff81618331>] inet_sendmsg+0x61/0xb0
[  697.480216]  [<ffffffff81592912>] sock_sendmsg+0xd2/0xf0
[  697.480226]  [<ffffffff8133708e>] k_send+0x6e/0x80
[  697.480236]  [<ffffffffa02b34ee>] ramdevice_read+0x5e/0xd0 [dor]
[  697.480244]  [<ffffffffa02b31a3>] rb_request+0x133/0x1b0 [dor]

更新: 正如Peter L.建议的那样。我更改了它,以便在一个tasklet中完成套接字读/写。这就是我得到的:

[  138.711263]  [<ffffffff816dbedc>] __schedule_bug+0x4d/0x59
[  138.711266]  [<ffffffff816f27b8>] __schedule+0x628/0x6b0
[  138.711269]  [<ffffffff816f2b59>] schedule+0x29/0x70
[  138.711273]  [<ffffffff816f12d5>] schedule_timeout+0x1e5/0x250
[  138.711276]  [<ffffffff81045cd9>] ? default_spin_lock_flags+0x9/0x10
[  138.711280]  [<ffffffff815d1361>] sk_wait_data+0xd1/0xe0
[  138.711284]  [<ffffffff8107fd70>] ? add_wait_queue+0x60/0x60
[  138.711286]  [<ffffffff816277f2>] tcp_recvmsg+0x502/0xb60
[  138.711289]  [<ffffffff8164e7fb>] inet_recvmsg+0x6b/0x80
[  138.711292]  [<ffffffff8164e871>] ? inet_sendmsg+0x61/0xb0
[  138.711294]  [<ffffffff815ca180>] sock_recvmsg+0xe0/0x100
[  138.711299]  [<ffffffff8105b30a>] ? console_unlock+0x1a/0x30
[  138.711302]  [<ffffffffa027f42b>] k_recv+0x6b/0x80 [ksocket]
[  138.711306]  [<ffffffffa02a066d>] ramdevice_read+0x7d/0xd0 [dor]
[  138.711309]  [<ffffffffa02a0360>] my_tasklet_func+0x60/0x80 [dor]
[  138.711312]  [<ffffffff81062ae4>] tasklet_action+0x64/0xe0
[  138.711315]  [<ffffffff81062620>] __do_softirq+0xc0/0x240
[  138.711318]  [<ffffffff810627d8>] run_ksoftirqd+0x38/0x50
[  138.711321]  [<ffffffff8108804d>] smpboot_thread_fn+0xfd/0x180
[  138.711325]  [<ffffffff81087f50>] ? lg_global_lock+0x70/0x70
[  138.711328]  [<ffffffff8107f1b0>] kthread+0xc0/0xd0
[  138.711332]  [<ffffffff8107f0f0>] ? flush_kthread_worker+0xb0/0xb0
[  138.711335]  [<ffffffff816fc82c>] ret_from_fork+0x7c/0xb0
[  138.711339]  [<ffffffff8107f0f0>] ? flush_kthread_worker+0xb0/0xb0

0 个答案:

没有答案