public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Brian Kelly <bkelly@sulaco.com>
To: linux-kernel@vger.kernel.org
Subject: How to setup a buffer_head in a driver
Date: Tue, 14 Jan 2003 17:35:45 -0500	[thread overview]
Message-ID: <200301142235.RAA23806@temetra.com> (raw)

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

             reply	other threads:[~2003-01-14 22:26 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-01-14 22:35 Brian Kelly [this message]
2003-01-14 23:14 ` How to setup a buffer_head in a driver Andrew Morton
2003-01-16  6:59   ` Brian Kelly

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200301142235.RAA23806@temetra.com \
    --to=bkelly@sulaco.com \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox