public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* How to setup a buffer_head in a driver
@ 2003-01-14 22:35 Brian Kelly
  2003-01-14 23:14 ` Andrew Morton
  0 siblings, 1 reply; 3+ messages in thread
From: Brian Kelly @ 2003-01-14 22:35 UTC (permalink / raw)
  To: linux-kernel

Hi,
I'm writing a device driver that among other things needs to write data,
manufactured by the driver itself, to a block device.

I have this data in block sized kmalloc()'d chunks. So what I'm doing is
allocating a struct buffer_head, initialising it, fill out it's various
fields and send it to generic_make_request(). Something like the following
[inspired by looking at various drivers like loop and ram]:

	do {
		if((bh = kmem_cache_alloc(bh_cachep, SLAB_NOIO)) != NULL){
			break;
		}
		run_task_queue(&tq_disk);
		schedule_timeout(HZ);
	} while (1);

	memset(bh, 0, sizeof(*bh));

	bh->b_size = size;
	bh->b_dev = dev;
	bh->b_rdev = dev;
	bh->b_data = data;
	init_waitqueue_head(&bh->b_wait);
	bh->b_rsector = sect;
	bh->b_end_io = write_done;
	bh->b_private = NULL;
	generic_make_request(WRITE, bh);


Now this causes a panic in ll_rw_blk.c because the b_state isn't set
correctly. I experimented with this a little but decided I needed some
proper direction on this whole endeavour.

Soooo, what do I really need to do? What's the correct way to do what I want
to do or could someone point me at an existing driver that does this
sort of thing.

Thanks,

Brian
-- 
bkelly@sulaco.com

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2003-01-16  6:50 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-01-14 22:35 How to setup a buffer_head in a driver Brian Kelly
2003-01-14 23:14 ` Andrew Morton
2003-01-16  6:59   ` Brian Kelly

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox