From: Artem Bityutskiy <dedekind1@gmail.com>
To: Anatolij Gustschin <agust@denx.de>
Cc: linux-mtd@lists.infradead.org, Detlev Zundel <dzu@denx.de>,
Adrian Hunter <adrian.hunter@nokia.com>
Subject: Re: [PATCH] UBIFS: fix master node recovery
Date: Thu, 07 Jul 2011 09:26:26 +0300 [thread overview]
Message-ID: <1310019990.3149.105.camel@sauron> (raw)
In-Reply-To: <1309944626-30195-1-git-send-email-agust@denx.de>
On Wed, 2011-07-06 at 11:30 +0200, Anatolij Gustschin wrote:
> 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)) {
Hmm, ok, so we have situation like this I guess:
First LEB: |M_______|
Second LEB: |MMMMMMM_|
1234567
Where M - valid master node, _ - just free space.
So offs1 is 0, and offs2 is the position where the 7th M _starts_.
What we want to check is that there is no room for another master node
in the second LEB. We have to take offs2, add sz, and make sure that LEB
size minus that is less than sz, i.e., exactly what you have done.
And offs2 + sz >= c->leb_size seems to be completely incorrect and
should be removed, AFAICS. Can you confirm that?
> /* 1st LEB was unmapped and written, 2nd not */
> if (cor1)
> goto out_err;
--
Best Regards,
Artem Bityutskiy
next prev parent reply other threads:[~2011-07-07 6:25 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
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
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=1310019990.3149.105.camel@sauron \
--to=dedekind1@gmail.com \
--cc=adrian.hunter@nokia.com \
--cc=agust@denx.de \
--cc=dzu@denx.de \
--cc=linux-mtd@lists.infradead.org \
/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