From: Linus Torvalds <torvalds@transmeta.com>
To: torrey.hoffman@myrio.com, linux-kernel@vger.kernel.org,
Alexander Viro <viro@math.psu.edu>,
Marcelo Tosatti <marcelo@conectiva.com.br>
Subject: Re: ramdisk corruption problems - was: RE: pivot_root and initrd kern el panic woes
Date: Thu, 20 Dec 2001 11:46:23 -0800 [thread overview]
Message-ID: <200112201946.fBKJkNw01262@penguin.transmeta.com> (raw)
In-Reply-To: <D52B19A7284D32459CF20D579C4B0C0211CB0F@mail0.myrio.com>
In article <D52B19A7284D32459CF20D579C4B0C0211CB0F@mail0.myrio.com> you write:
>Yes, this does fix the problem. Thank you very much!
>
>Hopefully something like this will make it into 2.4.18?
This does not seem quite right.
>Tachino Nobuhiro (tachino@open.nm.fujitsu.co.jp) wrote:
>> 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.
The problem is that having buffers doesn't necessarily always mean that
they are valid, nor that _all_ of them are valid.
Also, if the ramdisk "readpage" code is wrong, then so is the
"prepare_write" code. They share the same logic, which basically says
that "if the page isn't up-to-date, then it is zero". Which is always
true for normal read/write accesses, but as you found out it's not true
when parts of the page have been accessed by filesystems through the
buffers.
So the code _should_ use a common helper, something like
static void ramdisk_updatepage(struct page * page)
{
if (!Page_Uptodate(page)) {
struct buffer_head *bh = page->buffers;
void * address = page_address(page);
if (bh) {
struct buffer_head *tmp = bh;
do {
if (!buffer_uptodate(tmp)) {
memset(address, 0, tmp->b_size);
set_buffer_uptodate(tmp);
}
address += tmp->b_size;
tmp = tmp->b_this_page;
} while (tmp != bh);
} else
memset(address, 0, PAGE_SIZE);
flush_dcache_page(page);
SetPageUptodate(page);
}
}
and then ramdisk_readpage() would just be
kmap(page);
ramdisk_updatepage(page);
UnlockPage(page);
kunmap(page);
return 0;
while ramdisk_prepare_write() would be
ramdisk_updatepage(page);
SetPageDirty(page);
return 0;
NOTE NOTE NOTE! This is untested. Please somebody test it, and in
particular verify that there aren't any stupid highmem bugs, and
resubmit the patch to me and Marcelo, ok?
Linus
next prev parent reply other threads:[~2001-12-20 19:47 UTC|newest]
Thread overview: 37+ messages / expand[flat|nested] mbox.gz Atom feed top
2001-12-20 19:06 Torrey Hoffman
2001-12-20 19:46 ` Linus Torvalds [this message]
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-30 10:15 ` ramdisk corruption problems - was: RE: pivot_root and initrd Alan Cox
2001-12-31 0:08 ` ramdisk corruption problems - was: RE: pivot_root and initrd kern el panic woes Andrea Arcangeli
2001-12-30 7:08 ` Andrew Morton
2001-12-30 7:29 ` Alexander Viro
2001-12-30 7:59 ` ramdisk corruption problems - was: RE: pivot_root and initrdkern " Andrew Morton
2001-12-30 17:40 ` Linus Torvalds
2001-12-31 0:28 ` Andrea Arcangeli
2001-12-31 0:35 ` Linus Torvalds
2001-12-31 1:00 ` Andrea Arcangeli
2001-12-31 0:05 ` ramdisk corruption problems - was: RE: pivot_root and initrd kern " 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-21 1:51 ` Everyone else but TWO Andre Hedrick
[not found] <Pine.GSO.4.21.0112210151020.15555-100000@weyl.math.psu.edu>
2001-12-21 23:11 ` ramdisk corruption problems - was: RE: pivot_root and initrd kern el panic woes Linus Torvalds
2001-12-21 23:39 ` Alexander Viro
-- strict thread matches above, loose matches on Subject: below --
2001-12-18 20:14 Torrey Hoffman
2001-12-20 12:19 ` 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=200112201946.fBKJkNw01262@penguin.transmeta.com \
--to=torvalds@transmeta.com \
--cc=linux-kernel@vger.kernel.org \
--cc=marcelo@conectiva.com.br \
--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
Powered by JetHome