On Tue, Jul 21, 2009 at 12:14 PM, Prasad Joshi <prasadjoshi124@xxxxxxxxx> wrote:
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.
IMO, No.
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.
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