diff options
author | Artem Bityutskiy <Artem.Bityutskiy@nokia.com> | 2009-06-29 12:27:14 -0400 |
---|---|---|
committer | Artem Bityutskiy <Artem.Bityutskiy@nokia.com> | 2009-07-09 02:19:39 -0400 |
commit | 061125476039a9a998878468a6abe235b1cee347 (patch) | |
tree | 5acf6d6bc38cfd96c3d0ba4dc101d7e6a2606d16 /fs | |
parent | 431102fed3effe4e4e19678830ddab7f05c34bf9 (diff) |
UBIFS: fix corruption dump
In the 'ubifs_recover_leb()' function, when we find corrupted
empty space, we dump 8K starting from the offset where the last
node ends. This is OK if the corrupted empty space is somewhere
near that offset. But if the corruption is far at the end of the
LEB, we will dump all 0xFF bytes and complitely ignore the
interesting data. This is observed on a PPC ("kilauea") with
NOR flash.
This patch changes the behavior and teaches UBIFS to print only
interesting data. I.e., now we find where corruption starts and
start dumping from that offset.
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
Reviewed-by: Adrian Hunter <Adrian.Hunter@nokia.com>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/ubifs/recovery.c | 28 |
1 files changed, 26 insertions, 2 deletions
diff --git a/fs/ubifs/recovery.c b/fs/ubifs/recovery.c index fe7af9f676b0..e5f6cf8a1155 100644 --- a/fs/ubifs/recovery.c +++ b/fs/ubifs/recovery.c | |||
@@ -53,6 +53,25 @@ static int is_empty(void *buf, int len) | |||
53 | } | 53 | } |
54 | 54 | ||
55 | /** | 55 | /** |
56 | * first_non_ff - find offset of the first non-0xff byte. | ||
57 | * @buf: buffer to search in | ||
58 | * @len: length of buffer | ||
59 | * | ||
60 | * This function returns offset of the first non-0xff byte in @buf or %-1 if | ||
61 | * the buffer contains only 0xff bytes. | ||
62 | */ | ||
63 | static int first_non_ff(void *buf, int len) | ||
64 | { | ||
65 | uint8_t *p = buf; | ||
66 | int i; | ||
67 | |||
68 | for (i = 0; i < len; i++) | ||
69 | if (*p++ != 0xff) | ||
70 | return i; | ||
71 | return -1; | ||
72 | } | ||
73 | |||
74 | /** | ||
56 | * get_master_node - get the last valid master node allowing for corruption. | 75 | * get_master_node - get the last valid master node allowing for corruption. |
57 | * @c: UBIFS file-system description object | 76 | * @c: UBIFS file-system description object |
58 | * @lnum: LEB number | 77 | * @lnum: LEB number |
@@ -649,8 +668,13 @@ struct ubifs_scan_leb *ubifs_recover_leb(struct ubifs_info *c, int lnum, | |||
649 | clean_buf(c, &buf, lnum, &offs, &len); | 668 | clean_buf(c, &buf, lnum, &offs, &len); |
650 | need_clean = 1; | 669 | need_clean = 1; |
651 | } else { | 670 | } else { |
652 | ubifs_err("corrupt empty space at LEB %d:%d", | 671 | int corruption = first_non_ff(buf, len); |
653 | lnum, offs); | 672 | |
673 | ubifs_err("corrupt empty space LEB %d:%d, corruption " | ||
674 | "starts at %d", lnum, offs, corruption); | ||
675 | /* Make sure we dump interesting non-0xFF data */ | ||
676 | offs = corruption; | ||
677 | buf += corruption; | ||
654 | goto corrupted; | 678 | goto corrupted; |
655 | } | 679 | } |
656 | } | 680 | } |