From: Pavel Machek <pavel@ucw.cz>
To: Christoph Hellwig <hch@infradead.org>,
Mikael Pettersson <mikpe@csd.uu.se>,
viro@math.psu.edu, linux-kernel@vger.kernel.org
Subject: Re: [RFC] possible fix for broken floppy driver since 2.5.13
Date: Sun, 26 May 2002 16:19:23 +0200 [thread overview]
Message-ID: <20020526141922.GA4756@elf.ucw.cz> (raw)
In-Reply-To: <200205201701.TAA04143@harpo.it.uu.se> <20020521132451.A13419@infradead.org> <15594.16140.857729.697091@kim.it.uu.se> <20020521135108.A14298@infradead.org>
Hi!
> > 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)
This looks pretty complicated... Maybe bread() is worth being put back
for 2.5?
Pavel
> 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;
> }
>
> -
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at http://www.tux.org/lkml/
--
(about SSSCA) "I don't say this lightly. However, I really think that the U.S.
no longer is classifiable as a democracy, but rather as a plutocracy." --hpa
prev parent reply other threads:[~2002-05-26 16:47 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
2002-05-26 14:19 ` Pavel Machek [this message]
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=20020526141922.GA4756@elf.ucw.cz \
--to=pavel@ucw.cz \
--cc=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®