I'm implementing a block device driver based on current Loop device.
One synchronization thread for the block device is needed which keeps
reading dirty pages and transfers them over network. So in the sync-
thread, I allocate a page as follow:
struct page * page = alloc_page(GFP_KERNEL);
And implement another function sbd_make_sync_request, which just
create a bio object and use make_request to insert this bio into the
device bio list. Here is the problem, when I try to add the page into
this bio, it goes wrong:
bio = bio_alloc(GFP_KERNEL, 1);
bio->bi_bdev = dev->sbd_device;
bio->bi_rw = rw;
bio->bi_sector = ***;
if (bio_add_page(bio, page, PAGE_SIZE, 0) != PAGE_SIZE) {
****
}
The kernel error message is as follows:
Dec 9 11:43:01 nath-serv kernel: [ 189.971322] PGD 7bdb8067 PUD
7bdb1067 PMD 0
Dec 9 11:43:01 nath-serv kernel: [ 189.971334] CPU 1
Dec 9 11:43:01 nath-serv kernel: [ 189.971337] Modules linked in: sbd
ipv6 iptable_filter ip_tables x_tables ac parport_pc lp parport loop
pcspkr psmouse serio_raw evdev snd_hda_intel snd_pcm snd_timer snd
button soundcore snd_page_alloc intel_agp iTCO_wdt iTCO_vendor_support
shpchp pci_hotplug ext3 jbd mbcache sd_mod crc_t10dif sr_mod cdrom sg
ata_piix 8139too pata_acpi usbhid hid 8139cp mii ata_generic libata
scsi_mod dock skge r8169 ehci_hcd uhci_hcd usbcore thermal processor
fan fuse vesafb fbcon tileblit font bitblit softcursor
Dec 9 11:43:01 nath-serv kernel: [ 189.971403] Pid: 4673, comm:
sbd0_sync Not tainted 2.6.27-7-server #1
Dec 9 11:43:01 nath-serv kernel: [ 189.971407] RIP: 0010:
[<ffffffff80318c02>] [<ffffffff80318c02>] bio_add_page+0x22/0x40
Dec 9 11:43:01 nath-serv kernel: [ 189.971414] RSP:
0018:ffff88007b8b3e90 EFLAGS: 00010246
Dec 9 11:43:01 nath-serv kernel: [ 189.971417] RAX: 0000000000000000
RBX: 000000000000030e RCX: 0000000000001000
Dec 9 11:43:01 nath-serv kernel: [ 189.971420] RDX: ffffe20001ea7680
RSI: ffff88007c49d300 RDI: ffff88007c49d300
Dec 9 11:43:01 nath-serv kernel: [ 189.971423] RBP: ffff88007b8b3e90
R08: 0000000000000000 R09: 0000000000000006
Dec 9 11:43:01 nath-serv kernel: [ 189.971432] R10: ffff88007c49d300
R11: ffff8800fb8b3d3f R12: 000000000000030e
Dec 9 11:43:01 nath-serv kernel: [ 189.971434] R13: ffff88007c99b300
R14: 000000000030e000 R15: ffffe20001ea7680
Dec 9 11:43:01 nath-serv kernel: [ 189.971436] FS: 0000000000000000
(0000) GS:ffff88007f402880(0000) knlGS:0000000000000000
Dec 9 11:43:01 nath-serv kernel: [ 189.971438] CS: 0010 DS: 0018 ES:
0018 CR0: 000000008005003b
Dec 9 11:43:01 nath-serv kernel: [ 189.971440] CR2: 0000000000000040
CR3: 000000007d1f6000 CR4: 00000000000006e0
Dec 9 11:43:01 nath-serv kernel: [ 189.971442] DR0: 0000000000000000
DR1: 0000000000000000 DR2: 0000000000000000
Dec 9 11:43:01 nath-serv kernel: [ 189.971444] DR3: 0000000000000000
DR6: 00000000ffff0ff0 DR7: 0000000000000400
Dec 9 11:43:01 nath-serv kernel: [ 189.971446] Process sbd0_sync (pid:
4673, threadinfo ffff88007b8b2000, task ffff88007aa40000)
Dec 9 11:43:01 nath-serv kernel: [ 189.971448] Stack: ffff88007b8b3f20
ffffffffa037805c ffffffff807a3400 ffff88007b8b3ec8
Dec 9 11:43:01 nath-serv kernel: [ 189.971453] ffff88007b8b3ed0
ffff88007c49d300 ffffe20001ea7680 ffffffff00000000
Dec 9 11:43:01 nath-serv kernel: [ 189.971456] ffff880000000303
ffff88007b8b3ed8 ffff88007b8b3ed8 ffff880000000000
Dec 9 11:43:01 nath-serv kernel: [ 189.971459] Call Trace:
Dec 9 11:43:01 nath-serv kernel: [ 189.971465] [<ffffffffa037805c>]
sbd_sync+0x1cc/0x240 [sbd]
Dec 9 11:43:01 nath-serv kernel: [ 189.971468] [<ffffffffa0377e90>] ?
sbd_sync+0x0/0x240 [sbd]
Dec 9 11:43:01 nath-serv kernel: [ 189.971472] [<ffffffff80266b7e>]
kthread+0x4e/0x90
Dec 9 11:43:01 nath-serv kernel: [ 189.971475] [<ffffffff80213c99>]
child_rip+0xa/0x11
Dec 9 11:43:01 nath-serv kernel: [ 189.971477] [<ffffffff80266b30>] ?
kthread+0x0/0x90
Dec 9 11:43:01 nath-serv kernel: [ 189.971479] [<ffffffff80213c8f>] ?
child_rip+0x0/0x11
Dec 9 11:43:01 nath-serv kernel: [ 189.971480]
Dec 9 11:43:01 nath-serv kernel: [ 189.971481]
Dec 9 11:43:01 nath-serv kernel: [ 189.971516] RSP <ffff88007b8b3e90>
Dec 9 11:43:01 nath-serv kernel: [ 189.971519] ---[ end trace
fc6aa548928cd737 ]---
Can anyone help me with this problem ? Thanks very much
> bio = bio_alloc(GFP_KERNEL, 1);
> bio->bi_bdev = dev->sbd_device;
> bio->bi_rw = rw;
> bio->bi_sector = ***;
> if (bio_add_page(bio, page, PAGE_SIZE, 0) != PAGE_SIZE) {
> ****
>
> }
> Dec 9 11:43:01 nath-serv kernel: [ 189.971407] RIP: 0010:
> [<ffffffff80318c02>] [<ffffffff80318c02>] bio_add_page+0x22/0x40
The first thing I'd check is whether bdev_get_queue(dev->skd_device)
succeeds. If not, you can't add a page to the queue. If that call
succeeds, try calling queue_max_hw_sectors with that queue. Add debug
messages. If those two calls succeed, then bio_add_page should
succeed.
DS
Thanks very much. It turns out that bdev_get_queue fails.
> Thanks very much. It turns out that bdev_get_queue fails.
Okay, so the next question: Does the block device have an associated
gendisk device in the 'bd_disk' pointer of its 'block_device' object?
And, if so, does that gendisk device have an associated queue?
DS