generic_make_request

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I want to call generic_make_request to do i/o on block drivers.  I'm
trying to figure out how to create buffer_head's to do i/o.  I foung some
code in the jbd source that creates a buffer_head for synchronous i/o; I
want to do it asynchronously.  I
want to see if there is some documentation on how to do this.  Does any
one know of any documentation on this?

I think it would go something like this:

DoRead(unsigned long sector, unsinged numSectors, void* buffer)
{
	struct page* newPage = virt_to_page(buffer);
	unsigned int newOffset = virt_to_offset(buffer);
	struct  buffer_head* bh = get_unused_buffer_head(1);
	bh->b_prev_free = 0;
	bh->b_next_free = 0;
	init_buffer(bh, driver_end_io, NULL /* ?? Context ?? */);
	atomic_set(&bh->b_count, 1);
	set_bh_page(bh, newPage, newOffset);
	bh->b_size = numSectors; /* ?? bytes or sectors ?? */
	bh->b_dev = MAKEDEV(major, minor);
	bh->b_blocknr = sector;
	bh->b_state |= (1 << BH_Mapped) | (1 << BH_Dirty);

	generic_make_request(READ, bh);
}

I'm just guessing on this.  Can anyone help me figure this out or refer me
to a good source?

Thanks

--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           http://kernelnewbies.org/faq/


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux