diff mbox

[1/2] UBIFS: fix no_more_nodes() to align to max_write_size

Message ID 1297350106-16383-2-git-send-email-agust@denx.de
State New, archived
Headers show

Commit Message

Anatolij Gustschin Feb. 10, 2011, 3:01 p.m. UTC
From: Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>

This patch fixes failed recovery from following type of corruptions
on NOR flash:

UBIFS DBG (pid 1394): ubifs_scan_a_node: scanning unknown node
UBIFS DBG (pid 1394): no_more_nodes: unexpected bad common header at 42:182336
UBIFS DBG (pid 1394): ubifs_recover_leb: look at LEB 42:182336 (79680 bytes left)
UBIFS DBG (pid 1394): ubifs_scan_a_node: scanning unknown node
UBIFS error (pid 1394): ubifs_check_node: bad node type 51
UBIFS error (pid 1394): ubifs_check_node: bad node at LEB 42:182336
        magic          0x6101831
        crc            0x3c0cb370
        node_type      51 (unknown node)
        group_type     51 (unknown)
        sqnum          111611
        len            21105
node type 51 was not recognized
...
UBIFS DBG (pid 1394): no_more_nodes: unexpected bad common header at 42:182336
UBIFS error (pid 1394): ubifs_recover_leb: bad node
UBIFS error (pid 1394): ubifs_scanned_corruption: corruption at LEB 42:182336
UBIFS error (pid 1394): ubifs_scanned_corruption: first 8192 bytes from LEB 42:182336
00000000: 31181006 70b30c3c fbb30100 00000000 71520000 33330000 7b310000 f7030020
00000020: 00000000 00000000 00100000 00000000 41424331 32334142 43313233 41424331
00000040: ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff
...

Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
Signed-off-by: Anatolij Gustschin <agust@denx.de>
---
 fs/ubifs/recovery.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

Comments

Artem Bityutskiy Feb. 10, 2011, 3:06 p.m. UTC | #1
On Thu, 2011-02-10 at 16:01 +0100, ext Anatolij Gustschin wrote:
> From: Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
> 
> This patch fixes failed recovery from following type of corruptions
> on NOR flash:

Yeah, I'll push this patch, I already have it in my tree.

I'll need to work on v3 of the patch series anyway. As soon as I have
time, I'll do, then send v3 out and ask for testing. This fix will be
there as well.

Thanks!

For now, just sick to your original method please.
diff mbox

Patch

diff --git a/fs/ubifs/recovery.c b/fs/ubifs/recovery.c
index 4278ae7..65e4664 100644
--- a/fs/ubifs/recovery.c
+++ b/fs/ubifs/recovery.c
@@ -430,7 +430,7 @@  static int no_more_nodes(const struct ubifs_info *c, void *buf, int len,
 	int skip, dlen = le32_to_cpu(ch->len);
 
 	/* Check for empty space after the corrupt node's common header */
-	skip = ALIGN(offs + UBIFS_CH_SZ, c->min_io_size) - offs;
+	skip = ALIGN(offs + UBIFS_CH_SZ, c->max_write_size) - offs;
 	if (is_empty(buf + skip, len - skip))
 		return 1;
 	/*
@@ -442,7 +442,7 @@  static int no_more_nodes(const struct ubifs_info *c, void *buf, int len,
 		return 0;
 	}
 	/* Now we know the corrupt node's length we can skip over it */
-	skip = ALIGN(offs + dlen, c->min_io_size) - offs;
+	skip = ALIGN(offs + dlen, c->max_write_size) - offs;
 	/* After which there should be empty space */
 	if (is_empty(buf + skip, len - skip))
 		return 1;