All of lore.kernel.org
 help / color / mirror / Atom feed
From: hujianyang <hujianyang@huawei.com>
To: Artem Bityutskiy <dedekind1@gmail.com>
Cc: linux-mtd <linux-mtd@lists.infradead.org>, shengyong1@huawei.com
Subject: [PATCH RFC 2/2] UBIFS: scan all log lebs during log replay
Date: Thu, 25 Dec 2014 21:10:28 +0800	[thread overview]
Message-ID: <549C0CC4.9050703@huawei.com> (raw)
In-Reply-To: <549C0A10.3000201@huawei.com>

UBIFS suppose no more log lebs need to be scanned when
replay_log_leb() return %1. But it is not true because
some log lebs maybe incorrectly empty and the next leb
of this empty one may contain valid filesystem data.

This patch scan all the log lebs during log replaying
to guarantee these log lebs are in normal state.

I'm not sure if it is a valuable problem and don't know
if this patch gives a good way to solve this problem
either.

Signed-off-by: hujianyang <hujianyang@huawei.com>
---
 fs/ubifs/replay.c |   23 +++++++++++++++++++----
 1 files changed, 19 insertions(+), 4 deletions(-)

diff --git a/fs/ubifs/replay.c b/fs/ubifs/replay.c
index f13f4b2..5537b90 100644
--- a/fs/ubifs/replay.c
+++ b/fs/ubifs/replay.c
@@ -1014,7 +1014,7 @@ out:
  */
 int ubifs_replay_journal(struct ubifs_info *c)
 {
-	int err, lnum, free;
+	int err, lnum, free, end;

 	BUILD_BUG_ON(UBIFS_TRUN_KEY > 5);

@@ -1032,13 +1032,28 @@ int ubifs_replay_journal(struct ubifs_info *c)
 	dbg_mnt("start replaying the journal");
 	c->replaying = 1;
 	lnum = c->ltail_lnum = c->lhead_lnum;
+	end = 0;

 	do {
 		err = replay_log_leb(c, lnum, 0, c->sbuf);
-		if (err == 1)
+
+		/*
+		 * If @end is set, residual log lebs should be empty or
+		 * contain older ref_nodes. replay_log_leb() must return %1.
+		 */
+		if (unlikely(!err && end)) {
+			ubifs_err("LEB %d is valid but considered to be empty",
+				  lnum);
+			err = -EINVAL;
+			goto out;
+		}
+
+		if (err == 1 && !end) {
 			/* We hit the end of the log */
-			break;
-		if (err)
+			end = 1;
+		}
+
+		if (err < 0)
 			goto out;
 		lnum = ubifs_next_log_lnum(c, lnum);
 	} while (lnum != c->ltail_lnum);
-- 
1.6.0.2

  reply	other threads:[~2014-12-25 13:11 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-12-25 12:58 [PATCH RFC 1/2] UBIFS: fix empty log leb error hujianyang
2014-12-25 13:10 ` hujianyang [this message]
2015-01-31 12:46   ` [PATCH RFC 2/2] UBIFS: scan all log lebs during log replay Artem Bityutskiy
2015-02-02  2:49     ` hujianyang

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=549C0CC4.9050703@huawei.com \
    --to=hujianyang@huawei.com \
    --cc=dedekind1@gmail.com \
    --cc=linux-mtd@lists.infradead.org \
    --cc=shengyong1@huawei.com \
    /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 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.