From: Tachino Nobuhiro <tachino@open.nm.fujitsu.co.jp>
To: Torrey Hoffman <torrey.hoffman@myrio.com>
Cc: "'andersen@codepoet.org'" <andersen@codepoet.org>,
linux-kernel <linux-kernel@vger.kernel.org>,
"'viro@math.psu.edu'" <viro@math.psu.edu>
Subject: Re: ramdisk corruption problems - was: RE: pivot_root and initrd kern el panic woes
Date: Thu, 20 Dec 2001 21:19:36 +0900 [thread overview]
Message-ID: <n10e3wyv.wl@nisaaru.dvs.cs.fujitsu.co.jp> (raw)
In-Reply-To: <D52B19A7284D32459CF20D579C4B0C0211CB09@mail0.myrio.com>
In-Reply-To: <D52B19A7284D32459CF20D579C4B0C0211CB09@mail0.myrio.com>
Hello,
Following patch may fix your problem.
diff -r -u linux-2.4.17-rc2.org/drivers/block/rd.c linux-2.4.17-rc2/drivers/block/rd.c
--- linux-2.4.17-rc2.org/drivers/block/rd.c Thu Dec 20 20:30:57 2001
+++ linux-2.4.17-rc2/drivers/block/rd.c Thu Dec 20 20:46:53 2001
@@ -194,9 +194,11 @@
static int ramdisk_readpage(struct file *file, struct page * page)
{
if (!Page_Uptodate(page)) {
- memset(kmap(page), 0, PAGE_CACHE_SIZE);
- kunmap(page);
- flush_dcache_page(page);
+ if (!page->buffers) {
+ memset(kmap(page), 0, PAGE_CACHE_SIZE);
+ kunmap(page);
+ flush_dcache_page(page);
+ }
SetPageUptodate(page);
}
UnlockPage(page);
grow_dev_page() creates not Uptodate page which has valid buffers, so
it is wrong that ramdisk_readpage() clears whole page unconditionally.
At Tue, 18 Dec 2001 12:14:49 -0800,
Torrey Hoffman wrote:
>
> More information! And a workaround!
>
> I conjecture that the ramdisk driver (post 2.4.9) only grabs
> VM pages properly if it is accessed directly, as a dd to
> /dev/ram0 does. I further conjecture that accessing the
> ramdisk through a mounted filesystem does not grab pages
> properly.
>
> The reason I believe this is that removing the call to
> "freeramdisk" from my original script avoids corruption.
>
> Another way to avoid ramdisk corruption is to
> "dd if=/dev/zero of=/dev/ram0 bs=1k count=4000"
> immediately after the call to freeramdisk.
>
> If my conjecture is right, then the corruption is caused
> because mke2fs on a "freed" /dev/ram0 doesn't touch every
> block of the fs, leaving "holes" where pages are not properly
> grabbed from the VM. The resulting filesystem appears to work,
> but dd'ing from /dev/ram0 gets a broken filesystem image.
>
> Note that "freeramdisk /dev/ram0" is pretty much just:
> #define FLKFLSBUF _IO(0x12,97) /* flush buffer cache */
> f = open("/dev/ram0", O_RDWR);
> ioctl(f, BLKFLSBUF);
>
> To experiment for yourself, stick the following script in
> a subdirectory which also contains a "testdir" directory
> with about 3 MB of data.
>
> - - - - - - - -
> #!/bin/bash
>
> # to tickle the bug, do the freeramdisk but not the
> # dd from /dev/zero to /dev/ram0.
>
> freeramdisk /dev/ram0
> #dd if=/dev/zero of=/dev/ram0 bs=1k count=4000
>
> mke2fs -m0 /dev/ram0 4000
> mount -t ext2 /dev/ram0 /mnt/ramdisk
> rm -rf /mnt/ramdisk/*
>
> cp -a ./testdir /mnt/ramdisk
> umount /dev/ram0
>
> dd if=/dev/ram0 of=ram0.img bs=1k count=4000
> dd if=ram0.img of=/dev/ram0 bs=1k count=4000
>
> mount -t ext2 /dev/ram0 /mnt/ramdisk
> diff -q -r ./testdir /mnt/ramdisk/testdir
>
> # If diff reports mismatches, you saw the bug.
>
> umount /dev/ram0
> - - - - - - - -
>
> If the gods of the VM and VFS don't bother to look at
> it, I might take a peek at the relevant kernel code myself.
> Might take two months of study before I know enough though.
>
> Torrey
>
> -
> 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/
next prev parent reply other threads:[~2001-12-20 12:20 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2001-12-18 20:14 Torrey Hoffman
2001-12-20 12:19 ` Tachino Nobuhiro [this message]
[not found] <Pine.GSO.4.21.0112210151020.15555-100000@weyl.math.psu.edu>
2001-12-21 23:11 ` Linus Torvalds
2001-12-21 23:39 ` Alexander Viro
-- strict thread matches above, loose matches on Subject: below --
2001-12-20 19:06 Torrey Hoffman
2001-12-20 19:46 ` Linus Torvalds
2001-12-20 22:56 ` Alexander Viro
2001-12-20 23:42 ` Andrea Arcangeli
2001-12-21 1:49 ` Andrea Arcangeli
[not found] ` <3C22CF16.C78B1F19@zip.com.au>
2001-12-29 15:40 ` Andrea Arcangeli
2001-12-30 6:19 ` Andrew Morton
2001-12-30 6:33 ` Alexander Viro
2001-12-30 6:38 ` Andrew Morton
2001-12-30 7:17 ` Alexander Viro
2001-12-31 0:08 ` Andrea Arcangeli
2001-12-30 7:08 ` Andrew Morton
2001-12-30 7:29 ` Alexander Viro
2001-12-31 0:05 ` Andrea Arcangeli
2002-01-05 11:43 ` Andrew Morton
2002-01-07 3:08 ` Andrea Arcangeli
2002-01-07 3:49 ` Andrew Morton
2002-01-07 4:31 ` Andrea Arcangeli
2002-01-05 14:04 ` Trond Myklebust
2001-12-30 23:56 ` Andrea Arcangeli
2001-12-31 10:06 ` Daniel Phillips
2002-01-04 16:38 ` Stephen C. Tweedie
2002-01-05 7:53 ` Andrew Morton
2002-01-07 1:08 ` Andrea Arcangeli
2001-12-21 1:38 ` Tachino Nobuhiro
2001-12-18 1:44 Torrey Hoffman
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=n10e3wyv.wl@nisaaru.dvs.cs.fujitsu.co.jp \
--to=tachino@open.nm.fujitsu.co.jp \
--cc=andersen@codepoet.org \
--cc=linux-kernel@vger.kernel.org \
--cc=torrey.hoffman@myrio.com \
--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®