Hi Sandeep, Thanks a lot for your reply On Tue, Jul 21, 2009 at 4:12 PM, SandeepKsinha<sandeepksinha@xxxxxxxxx> wrote: > Hi Prasad, > > On Tue, Jul 21, 2009 at 12:14 PM, Prasad Joshi <prasadjoshi124@xxxxxxxxx> > wrote: >> >> Hi All, >> >> I am working on a block device (something similar to the loop device). The >> block device is associated with a file. So every write or read on block >> device is intern scheduled to the backing file. Very much similar to the >> loop device. >> >> But, I also need to submit a page full of IOs from the kernel mode. For >> time being, to make sure it works correctly, I wrote an IOCTL which will >> create a page, attach buffer heads with it and then call submit_bh(write, >> bh); to schedule a request to the block device. >> >> This is a part of the code >> >> int iftl_ioctl (struct block_device *bdev, fmode_t mode, unsigned cmd, >> unsigned long arg) >> { >> struct iftl_device *dev = bdev->bd_disk->private_data; >> struct buffer_head *bh = NULL, *head = NULL; >> struct file *file = NULL; >> int error = 0; >> >> .... >> .... >> >> case IFTL_WRITEBLOCK: >> if (!page) { >> page = alloc_page(GFP_KERNEL); >> if (!page) { >> page = ERR_PTR(-ENOMEM); >> } >> if (IS_ERR(page)) { >> goto ERROR; >> } >> } >> >> if (!page_has_buffers(page)) { >> create_empty_buffers(page, PAGE_SIZE, 0); >> } >> >> bh = head = page_buffers(page); >> fill_data(page); >> >> bh->b_blocknr = 0; >> bh->b_bdev = dev->bdev; >> bh->b_end_io = end_page_write; >> >> set_buffer_locked(bh); >> set_buffer_mapped(bh); >> >> // mark_buffer_dirty(bh); >> >> submit_bh(WRITE, bh); >> break; >> default: >> error = -EINVAL; >> goto ERROR; >> } >> ERROR: >> return error; >> } >> >> But the code fails in generic_make_request() that is called from the >> submit_bh(). Can someone help? > > What exactly does fails or whats the error code that is being returned. > I suspect playing with some data members of bh. But if you provide the exact > error ( console logs + dmesg ), it will really be helpful. Corresponding messages from /var/log/messages file. Jul 21 01:14:56 anup-laptop kernel: [ 5151.712119] *pde = 00000000 Jul 21 01:14:57 anup-laptop kernel: [ 5151.712119] Modules linked in: iftl af_packet binfmt_misc sco bridge stp bnep rfcomm l2cap bluetooth ppdev ipv6 cpufreq_ondemand cpufreq_conservative cpufreq_stats cpufreq_userspace cpufreq_powersave freq_table sbs video output processor sbshc container pci_slot iptable_filter ip_tables x_tables lp snd_intel8x0 snd_ac97_codec ac97_bus snd_pcm_oss snd_mixer_oss snd_pcm snd_seq_dummy evdev snd_seq_oss snd_seq_midi snd_rawmidi snd_seq_midi_event parport_pc snd_seq serio_raw psmouse parport battery ac snd_timer snd_seq_device snd button pcspkr i2c_piix4 soundcore i2c_core snd_page_alloc ext3 jbd mbcache sd_mod crc_t10dif sr_mod cdrom sg pata_acpi ata_piix ata_generic ohci_hcd ehci_hcd libata floppy usbcore pcnet32 mii scsi_mod thermal fan fuse [last unloaded: iftl] Jul 21 01:14:57 anup-laptop kernel: [ 5151.712119] Jul 21 01:14:57 anup-laptop kernel: [ 5151.712119] Pid: 5238, comm: a.out Tainted: G D (2.6.30-rc4 #1) VirtualBox Jul 21 01:14:57 anup-laptop kernel: [ 5151.712119] EIP: 0060:[<c0252931>] EFLAGS: 00010202 CPU: 0 Jul 21 01:14:57 anup-laptop kernel: [ 5151.712119] EIP is at generic_make_request+0xa1/0x5b0 Jul 21 01:14:57 anup-laptop kernel: [ 5151.712119] EAX: 00000008 EBX: d4a6bf00 ECX: 00000000 EDX: 00000575 Jul 21 01:14:57 anup-laptop kernel: [ 5151.712119] ESI: d4a6bf00 EDI: 00000000 EBP: df92fd00 ESP: df92fc28 Jul 21 01:14:57 anup-laptop kernel: [ 5151.712119] DS: 007b ES: 007b FS: 00d8 GS: 0033 SS: 0069 Jul 21 01:14:57 anup-laptop kernel: [ 5151.712119] 0000080e 00e69000 ff0726f3 0000000a 00000012 00e69000 0000270f 0000270f Jul 21 01:14:59 anup-laptop kernel: [ 5151.933190] ---[ end trace e9f702dc2ed6eebd ]--- Instead of filling buffer_heads and passing it to the submit_bh(), I created the BIO structure passed a page through it. It worked fr me. Thanks a lot, Prasad > > >> >> As the page that I have allocated is not attached with an address_space >> (mapping) could it be reason for the failure? >> Do every page used in disk IO needs an associated mapping? > > IMO, No. > >> >> Thanks and Regards, >> Prasad > > -- To unsubscribe from this list: send an email with "unsubscribe kernelnewbies" to ecartis@xxxxxxxxxxxx Please read the FAQ at http://kernelnewbies.org/FAQ