Re: generic_make_request

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

 



Does anyone know how to do this?

All I need to do is, for a read request I need to read some sector off of
another block device.  I'm using 2.4.18.  I've been through the kernel
source and looked at the multi-device stuff.  There are too many other
details to sort it all out. I just want to find some
help on creating buffer_head's, calling generic_make_request() and
completing the original buffer_head request when the request I created has
completed?

Does anyone know how to do this?  If not, how do I found out?  Do I need
to post to the kernel development mailing list?

This is what I've tried so far:

In my make_request() function I do this:

	newBh = get_unused_buffer_head(1);
	if (!newBh)
	{
        bh->b_end_io(bh, 0);
		return 0;
	}

	memcpy(newBh, bh, sizeof(struct buffer_head));
	newBh->b_rsector = sectorNum;
	newBh->b_rdev = MKDEV(3, 0);
	newBh->b_blocknr = newBh->b_rsector / 2; // My blocks are 512
bytes, hard disks are 1024
	newBh->b_dev = newBh->b_rdev;
	newBh->b_end_io = vdisk_end_io;

	generic_make_request(rw, newBh);

	return 0;


In my vdisk_end_io() function I do this:

	struct buffer_head* masterBh = (struct buffer_head*)bh->b_private;

	mark_buffer_uptodate(bh, uptodate);
	masterBh->b_end_io(bh, uptodate);

	put_unused_buffer_head(bh);

Thanks for any help.


On Fri, 23 Aug 2002, Jonathan Ludwig wrote:

> 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/
>
>

--
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