* [PATCH] block2mtd oops in erase function.
@ 2007-02-19 21:29 Felix Fietkau
2007-02-19 22:20 ` Jörn Engel
0 siblings, 1 reply; 12+ messages in thread
From: Felix Fietkau @ 2007-02-19 21:29 UTC (permalink / raw)
To: linux-mtd
Hi, I have a small fix for a crash that happened when I was using jffs2
in combination with block2mtd.c
In the erase function when checking the block to see if it's already
erased, the limit is to be set to the page_address(page) + PAGE_SIZE,
but because the variable has the type (ulong *), it gets set to
PAGE_SIZE*sizeof(ulong), which makes the kernel oops when the page is
very close to the end of RAM.
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
--- linux.dev/drivers/mtd/devices/block2mtd.c.old 2007-02-18 14:08:59.519952312 +0100
+++ linux.dev/drivers/mtd/devices/block2mtd.c 2007-02-18 14:09:04.219237912 +0100
@@ -111,7 +111,7 @@
if (IS_ERR(page))
return PTR_ERR(page);
- max = (u_long*)page_address(page) + PAGE_SIZE;
+ max = (u_long*) ((u8 *) page_address(page) + PAGE_SIZE);
for (p=(u_long*)page_address(page); p<max; p++)
if (*p != -1UL) {
lock_page(page);
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH] block2mtd oops in erase function.
2007-02-19 21:29 [PATCH] block2mtd oops in erase function Felix Fietkau
@ 2007-02-19 22:20 ` Jörn Engel
2007-02-19 22:30 ` Jörn Engel
0 siblings, 1 reply; 12+ messages in thread
From: Jörn Engel @ 2007-02-19 22:20 UTC (permalink / raw)
To: Felix Fietkau; +Cc: linux-mtd
On Mon, 19 February 2007 22:29:39 +0100, Felix Fietkau wrote:
>
> Hi, I have a small fix for a crash that happened when I was using jffs2
> in combination with block2mtd.c
>
> In the erase function when checking the block to see if it's already
> erased, the limit is to be set to the page_address(page) + PAGE_SIZE,
> but because the variable has the type (ulong *), it gets set to
> PAGE_SIZE*sizeof(ulong), which makes the kernel oops when the page is
> very close to the end of RAM.
Good catch! What a twisted little piece of code you've found.
> Signed-off-by: Felix Fietkau <nbd@openwrt.org>
>
> --- linux.dev/drivers/mtd/devices/block2mtd.c.old 2007-02-18 14:08:59.519952312 +0100
> +++ linux.dev/drivers/mtd/devices/block2mtd.c 2007-02-18 14:09:04.219237912 +0100
> @@ -111,7 +111,7 @@
> if (IS_ERR(page))
> return PTR_ERR(page);
>
> - max = (u_long*)page_address(page) + PAGE_SIZE;
> + max = (u_long*) ((u8 *) page_address(page) + PAGE_SIZE);
> for (p=(u_long*)page_address(page); p<max; p++)
> if (*p != -1UL) {
> lock_page(page);
The proper fix would be to remove the cast instead of adding yet
another. I wonder when those got added.
Jörn
--
He who knows others is wise.
He who knows himself is enlightened.
-- Lao Tsu
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH] block2mtd oops in erase function.
2007-02-19 22:20 ` Jörn Engel
@ 2007-02-19 22:30 ` Jörn Engel
2007-02-20 2:27 ` Felix Fietkau
0 siblings, 1 reply; 12+ messages in thread
From: Jörn Engel @ 2007-02-19 22:30 UTC (permalink / raw)
To: Felix Fietkau; +Cc: linux-mtd
On Mon, 19 February 2007 22:20:41 +0000, Jörn Engel wrote:
>
> The proper fix would be to remove the cast instead of adding yet
> another. I wonder when those got added.
On December 21st 2004 by none other than me. How embarrassing!
http://lists.infradead.org/pipermail/linux-mtd/2004-December/011236.html
Can you test this patch?
diff --git a/drivers/mtd/devices/block2mtd.c b/drivers/mtd/devices/block2mtd.c
index f9f2ce7..6a9fb80 100644
--- a/drivers/mtd/devices/block2mtd.c
+++ b/drivers/mtd/devices/block2mtd.c
@@ -111,8 +111,8 @@ static int _block2mtd_erase(struct block
if (IS_ERR(page))
return PTR_ERR(page);
- max = (u_long*)page_address(page) + PAGE_SIZE;
- for (p=(u_long*)page_address(page); p<max; p++)
+ max = page_address(page) + PAGE_SIZE;
+ for (p=page_address(page); p<max; p++)
if (*p != -1UL) {
lock_page(page);
memset(page_address(page), 0xff, PAGE_SIZE);
Jörn
--
"[One] doesn't need to know [...] how to cause a headache in order
to take an aspirin."
-- Scott Culp, Manager of the Microsoft Security Response Center, 2001
^ permalink raw reply related [flat|nested] 12+ messages in thread
* Re: [PATCH] block2mtd oops in erase function.
2007-02-19 22:30 ` Jörn Engel
@ 2007-02-20 2:27 ` Felix Fietkau
2007-02-20 10:53 ` Jörn Engel
0 siblings, 1 reply; 12+ messages in thread
From: Felix Fietkau @ 2007-02-20 2:27 UTC (permalink / raw)
To: Jörn Engel; +Cc: linux-mtd
On Mon, 2007-02-19 at 22:30 +0000, Jörn Engel wrote:
> On December 21st 2004 by none other than me. How embarrassing!
> http://lists.infradead.org/pipermail/linux-mtd/2004-December/011236.html
>
> Can you test this patch?
>
> diff --git a/drivers/mtd/devices/block2mtd.c b/drivers/mtd/devices/block2mtd.c
> [...]
Works :)
- Felix
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH] block2mtd oops in erase function.
2007-02-20 2:27 ` Felix Fietkau
@ 2007-02-20 10:53 ` Jörn Engel
2007-02-20 21:35 ` Jason Lunz
0 siblings, 1 reply; 12+ messages in thread
From: Jörn Engel @ 2007-02-20 10:53 UTC (permalink / raw)
To: Felix Fietkau; +Cc: linux-mtd
On Tue, 20 February 2007 03:27:09 +0100, Felix Fietkau wrote:
> On Mon, 2007-02-19 at 22:30 +0000, Jörn Engel wrote:
> > On December 21st 2004 by none other than me. How embarrassing!
> > http://lists.infradead.org/pipermail/linux-mtd/2004-December/011236.html
> >
> > Can you test this patch?
> >
> > diff --git a/drivers/mtd/devices/block2mtd.c b/drivers/mtd/devices/block2mtd.c
> > [...]
>
> Works :)
Cool! Would you mind also trying two more patches? One of them just
removes a compile warning if CONFIG_MODULE=n, the other rips out the
readahead code, which should give a nice performance boost on USB
sticks, MMC/SD, etc. Mounting JFFS2 in particular should be faster.
Jörn
--
It does not matter how slowly you go, so long as you do not stop.
-- Confucius
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH] block2mtd oops in erase function.
2007-02-20 10:53 ` Jörn Engel
@ 2007-02-20 21:35 ` Jason Lunz
2007-02-20 21:55 ` Jörn Engel
0 siblings, 1 reply; 12+ messages in thread
From: Jason Lunz @ 2007-02-20 21:35 UTC (permalink / raw)
To: Jörn Engel; +Cc: Felix Fietkau, linux-mtd
On Tue, Feb 20, 2007 at 10:53:07AM +0000, Jörn Engel wrote:
> Cool! Would you mind also trying two more patches? One of them just
> removes a compile warning if CONFIG_MODULE=n, the other rips out the
> readahead code, which should give a nice performance boost on USB
> sticks, MMC/SD, etc. Mounting JFFS2 in particular should be faster.
I'm using jffs2 on block2mtd. I'd be happy to test any patches you have.
The readahead-disable one in particular is interesting - i ended up
patching the source to get rid of the warning about readahead past
end-of-disk. And mounting jffs2-on-block2mtd-on-ide-flash is quite slow.
Jason
---
drivers/mtd/devices/block2mtd.c | 1 -
1 file changed, 1 deletion(-)
Index: linux-2.6.20-rc5-uml/drivers/mtd/devices/block2mtd.c
===================================================================
--- linux-2.6.20-rc5-uml.orig/drivers/mtd/devices/block2mtd.c
+++ linux-2.6.20-rc5-uml/drivers/mtd/devices/block2mtd.c
@@ -63,7 +63,6 @@
for (i = 0; i < PAGE_READAHEAD; i++) {
pagei = index + i;
if (pagei > end_index) {
- INFO("Overrun end of disk in cache readahead\n");
break;
}
page = radix_tree_lookup(&mapping->page_tree, pagei);
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH] block2mtd oops in erase function.
2007-02-20 21:35 ` Jason Lunz
@ 2007-02-20 21:55 ` Jörn Engel
[not found] ` <20070221030254.GA11044@avocado.homenet>
0 siblings, 1 reply; 12+ messages in thread
From: Jörn Engel @ 2007-02-20 21:55 UTC (permalink / raw)
To: Jason Lunz; +Cc: Felix Fietkau, linux-mtd
On Tue, 20 February 2007 16:35:29 -0500, Jason Lunz wrote:
>
> I'm using jffs2 on block2mtd. I'd be happy to test any patches you have.
Is it ok if I just pass this URL?
http://kernel.org/git/?p=linux/kernel/git/joern/misc.git
The top three patches are test-worthy.
> The readahead-disable one in particular is interesting - i ended up
> patching the source to get rid of the warning about readahead past
> end-of-disk. And mounting jffs2-on-block2mtd-on-ide-flash is quite slow.
If it works for you and improves mount time, that would be good results.
Jörn
--
I've never met a human being who would want to read 17,000 pages of
documentation, and if there was, I'd kill him to get him out of the
gene pool.
-- Joseph Costello
^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2007-02-21 21:46 UTC | newest]
Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-02-19 21:29 [PATCH] block2mtd oops in erase function Felix Fietkau
2007-02-19 22:20 ` Jörn Engel
2007-02-19 22:30 ` Jörn Engel
2007-02-20 2:27 ` Felix Fietkau
2007-02-20 10:53 ` Jörn Engel
2007-02-20 21:35 ` Jason Lunz
2007-02-20 21:55 ` Jörn Engel
[not found] ` <20070221030254.GA11044@avocado.homenet>
2007-02-21 14:47 ` Jörn Engel
2007-02-21 15:42 ` Jason Lunz
2007-02-21 16:02 ` Jörn Engel
2007-02-21 20:26 ` Jason Lunz
2007-02-21 21:43 ` Jörn Engel
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.