From patchwork Wed Sep 30 07:09:20 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Artem Bityutskiy X-Patchwork-Id: 34517 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from bombadil.infradead.org (bombadil.infradead.org [18.85.46.34]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 095DDB7BEC for ; Wed, 30 Sep 2009 17:12:26 +1000 (EST) Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.69 #1 (Red Hat Linux)) id 1MstKF-0004af-1x; Wed, 30 Sep 2009 07:10:11 +0000 Received: from smtp.nokia.com ([192.100.105.134] helo=mgw-mx09.nokia.com) by bombadil.infradead.org with esmtps (Exim 4.69 #1 (Red Hat Linux)) id 1MstK8-00046V-N4 for linux-mtd@lists.infradead.org; Wed, 30 Sep 2009 07:10:09 +0000 Received: from esebh105.NOE.Nokia.com (esebh105.ntc.nokia.com [172.21.138.211]) by mgw-mx09.nokia.com (Switch-3.3.3/Switch-3.3.3) with ESMTP id n8U7953n009283; Wed, 30 Sep 2009 02:09:08 -0500 Received: from vaebh104.NOE.Nokia.com ([10.160.244.30]) by esebh105.NOE.Nokia.com with Microsoft SMTPSVC(6.0.3790.3959); Wed, 30 Sep 2009 10:09:29 +0300 Received: from mgw-da02.ext.nokia.com ([147.243.128.26]) by vaebh104.NOE.Nokia.com over TLS secured channel with Microsoft SMTPSVC(6.0.3790.3959); Wed, 30 Sep 2009 10:09:27 +0300 Received: from localhost.localdomain (esdhcp040120.research.nokia.com [172.21.40.120]) by mgw-da02.ext.nokia.com (Switch-3.3.3/Switch-3.3.3) with ESMTP id n8U79HNn006726; Wed, 30 Sep 2009 10:09:18 +0300 From: Artem Bityutskiy To: Sven Luther Subject: [PATCH] UBI: fix backward compatibility Date: Wed, 30 Sep 2009 10:09:20 +0300 Message-Id: <1254294560-6884-1-git-send-email-Artem.Bityutskiy@nokia.com> X-Mailer: git-send-email 1.6.2.5 X-OriginalArrivalTime: 30 Sep 2009 07:09:27.0879 (UTC) FILETIME=[F2DD8D70:01CA419C] X-Nokia-AV: Clean X-CRM114-Version: 20090807-BlameThorstenAndJenny ( TRE 0.7.6 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20090930_031004_848653_468663FC X-CRM114-Status: GOOD ( 16.52 ) X-Spam-Score: -4.0 (----) X-Spam-Report: SpamAssassin version 3.2.5 on bombadil.infradead.org summary: Content analysis details: (-4.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- -4.0 RCVD_IN_DNSWL_MED RBL: Sender listed at http://www.dnswl.org/, medium trust [192.100.105.134 listed in list.dnswl.org] Cc: linux-mtd@lists.infradead.org, adrian.hunter@nokia.com X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: linux-mtd-bounces@lists.infradead.org Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org Commit 32bc4820287a1a03982979515949e8ea56eac641 did not fully fix the backward compatibility issues. We still fail to properly handle situations when the first PEB contains non-zero image sequence number, but one of the following PEBs contains zero image sequence number. For example, this may happen if we mount a new image with an old kernel, and then try to mount it in the new kernel. This patch should fix the issue. Signed-off-by: Artem Bityutskiy --- drivers/mtd/ubi/scan.c | 7 +++---- drivers/mtd/ubi/scan.h | 2 -- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/drivers/mtd/ubi/scan.c b/drivers/mtd/ubi/scan.c index b847745..6db7ce5 100644 --- a/drivers/mtd/ubi/scan.c +++ b/drivers/mtd/ubi/scan.c @@ -793,16 +793,15 @@ static int process_eb(struct ubi_device *ubi, struct ubi_scan_info *si, * number. */ image_seq = be32_to_cpu(ech->image_seq); - if (!si->image_seq_set) { + if (!ubi->image_seq && image_seq) ubi->image_seq = image_seq; - si->image_seq_set = 1; - } else if (ubi->image_seq && ubi->image_seq != image_seq) { + if (ubi->image_seq && image_seq && + ubi->image_seq != image_seq) { ubi_err("bad image sequence number %d in PEB %d, " "expected %d", image_seq, pnum, ubi->image_seq); ubi_dbg_dump_ec_hdr(ech); return -EINVAL; } - } /* OK, we've done with the EC header, let's look at the VID header */ diff --git a/drivers/mtd/ubi/scan.h b/drivers/mtd/ubi/scan.h index 1017cf1..61df208 100644 --- a/drivers/mtd/ubi/scan.h +++ b/drivers/mtd/ubi/scan.h @@ -102,7 +102,6 @@ struct ubi_scan_volume { * @mean_ec: mean erase counter value * @ec_sum: a temporary variable used when calculating @mean_ec * @ec_count: a temporary variable used when calculating @mean_ec - * @image_seq_set: indicates @ubi->image_seq is known * * This data structure contains the result of scanning and may be used by other * UBI sub-systems to build final UBI data structures, further error-recovery @@ -125,7 +124,6 @@ struct ubi_scan_info { int mean_ec; uint64_t ec_sum; int ec_count; - int image_seq_set; }; struct ubi_device;