All of lore.kernel.org
 help / color / mirror / Atom feed
* Reading page from given block device
@ 2002-05-08 20:48 Pavel Machek
  2002-05-08 21:21 ` Andrew Morton
  0 siblings, 1 reply; 10+ messages in thread
From: Pavel Machek @ 2002-05-08 20:48 UTC (permalink / raw)
  To: kernel list

Hi!

For swsusp, I kind of need to read 4K from given block device.

Here's my attempt:

static int bdev_read_page(kdev_t dev, long pos, void *buf)
{
        struct buffer_head *bh;
        struct block_device *bdev;

        if (pos%PAGE_SIZE) panic("Sorry, dave, I can't let you do
that!\n");
        bdev = bdget(kdev_t_to_nr(dev));
        if (!bdev) {
                printk("No block device for %s\n", __bdevname(dev));
                BUG();
        }
        printk("C");
        bh = __bread(bdev, pos/PAGE_SIZE, PAGE_SIZE);
        printk("D");
        bdput(bdev);
        if (!bh || (!bh->b_data)) {
                return -1;
        }
        memcpy(buf, bh->b_data, PAGE_SIZE);
        bforget(bh);                    /* FIXME: maybe bforget should
be here */
        return 0;
}

It works *once*, second time it deadlocks in __bread(). I tried both
bforget() and brelse(). Kernel is 2.5.13. What am I doing wrong/what's
wrong?

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

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

end of thread, other threads:[~2002-05-09 21:46 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-05-08 20:48 Reading page from given block device Pavel Machek
2002-05-08 21:21 ` Andrew Morton
2002-05-08 21:30   ` Andrew Morton
2002-05-08 22:56   ` Pavel Machek
     [not found]     ` <3CD9AE15.114D13E3@zip.com.au>
2002-05-08 23:15       ` Pavel Machek
2002-05-09  0:07         ` Andrew Morton
2002-05-09  4:42     ` Alexander Viro
2002-05-09 21:36       ` Pavel Machek
2002-05-09 21:45         ` Alexander Viro
2002-05-08 22:59   ` Pavel Machek

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.