public inbox for linux-mtd@lists.infradead.org
 help / color / mirror / Atom feed
* [PATCH] UBIFS: fix master node recovery
@ 2011-07-06  9:30 Anatolij Gustschin
  2011-07-07  6:15 ` Artem Bityutskiy
                   ` (2 more replies)
  0 siblings, 3 replies; 13+ messages in thread
From: Anatolij Gustschin @ 2011-07-06  9:30 UTC (permalink / raw)
  To: linux-mtd
  Cc: Adrian Hunter, Anatolij Gustschin, Detlev Zundel,
	Artem Bityutskiy

When the 1st LEB was unmapped and written but 2nd LEB not,
the master node recovery doesn't succeed after power cut.
We see following error when mounting UBIFS partition on NOR
flash:

UBIFS error (pid 1137): ubifs_recover_master_node: failed to recover master node

Additional 2nd master node offset check is needed to fix the
problem. If the 2nd master node is at the end in the 2nd LEB,
first master node is used for recovery.

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

diff --git a/fs/ubifs/recovery.c b/fs/ubifs/recovery.c
index 783d8e0..0e951f0 100644
--- a/fs/ubifs/recovery.c
+++ b/fs/ubifs/recovery.c
@@ -274,7 +274,9 @@ int ubifs_recover_master_node(struct ubifs_info *c)
 				if (cor1)
 					goto out_err;
 				mst = mst1;
-			} else if (offs1 == 0 && offs2 + sz >= c->leb_size) {
+			} else if (offs1 == 0 &&
+				   (offs2 + sz >= c->leb_size ||
+				    (c->leb_size - offs2 - sz) < sz)) {
 				/* 1st LEB was unmapped and written, 2nd not */
 				if (cor1)
 					goto out_err;
-- 
1.7.1

^ permalink raw reply related	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2011-07-08  3:54 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-07-06  9:30 [PATCH] UBIFS: fix master node recovery Anatolij Gustschin
2011-07-07  6:15 ` Artem Bityutskiy
2011-07-07  7:36   ` Anatolij Gustschin
2011-07-07  6:26 ` Artem Bityutskiy
2011-07-07  7:43   ` Anatolij Gustschin
2011-07-07  7:57     ` Artem Bityutskiy
2011-07-07  8:44       ` Anatolij Gustschin
2011-07-07  8:57         ` Artem Bityutskiy
2011-07-07  9:05           ` Anatolij Gustschin
2011-07-07  9:51 ` [PATCH v2] " Anatolij Gustschin
2011-07-07  9:55   ` Artem Bityutskiy
2011-07-07 10:25   ` [PATCH v3] " Anatolij Gustschin
2011-07-08  3:55     ` Artem Bityutskiy

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox