mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Christoph Hellwig <hch@infradead.org>
To: Mikael Pettersson <mikpe@csd.uu.se>
Cc: viro@math.psu.edu, linux-kernel@vger.kernel.org
Subject: Re: [RFC] possible fix for broken floppy driver since 2.5.13
Date: Tue, 21 May 2002 13:51:08 +0100	[thread overview]
Message-ID: <20020521135108.A14298@infradead.org> (raw)
In-Reply-To: <200205201701.TAA04143@harpo.it.uu.se> <20020521132451.A13419@infradead.org> <15594.16140.857729.697091@kim.it.uu.se>

On Tue, May 21, 2002 at 02:35:24PM +0200, Mikael Pettersson wrote:
> I haven't got a clue on how to program Linux' block I/O interfaces.
> Show me how to do a modern equivalent of getblk(dev,0,1024) + waiting
> for the operation to complete and I'll update the patch ASAP.

I think something like the following should do it.
(WARNING: entirely untested)



static void io_done(struct bio *bio)
{
	complete((struct completion *)bio->bi_private);
}

static int doio(struct block_device *bdev, size_t size)
{
	struct completion comp;
	struct page * page;
	struct bio * bio;

	bio = bio_alloc(GFP_KERNEL, 1);
	if (!bio)
		return -ENOMEM;

	page = alloc_page(GFP_KERNEL);
	if (!page) {
		bio_put(bio);
		return -ENOMEM;
	}

	bio->bi_sector = 0;
	bio->bi_bdev = bdev;
	bio->bi_io_vec[0].bv_page = page;
	bio->bi_io_vec[0].bv_len = size;
	bio->bi_io_vec[0].bv_offset = 0;

	bio->bi_vcnt = 1;
	bio->bi_idx = 0;
	bio->bi_size = LOGPSIZE;

	bio->bi_end_io = io_done;
	bio->bi_private = &complete;

	submit_bio(READ, bio);
	run_task_queue(&tq_disk);

	wait_for_completion(&comp);

	bio_put(bio);
	__free_page(page);

	return 0;
}


  reply	other threads:[~2002-05-21 12:51 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-05-20 17:01 Mikael Pettersson
2002-05-21 12:24 ` Christoph Hellwig
2002-05-21 12:35   ` Mikael Pettersson
2002-05-21 12:51     ` Christoph Hellwig [this message]
2002-05-26 14:19       ` Pavel Machek

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=20020521135108.A14298@infradead.org \
    --to=hch@infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mikpe@csd.uu.se \
    --cc=viro@math.psu.edu \
    /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

all inboxes | Powered by JetHome®