[<prev] [next>] [day] [month] [year] [list]
Message-ID: <A765B125120D1346A63912DDE6D8B6310BF4CF2E@NTXXIAMBX02.xacn.micron.com>
Date: Mon, 28 Sep 2015 07:04:00 +0000
From: Bean Huo 霍斌斌 (beanhuo)
<beanhuo@...ron.com>
To: "dedekind1@...il.com" <dedekind1@...il.com>,
"adrian.hunter@...el.com" <adrian.hunter@...el.com>,
"computersforpeace@...il.com" <computersforpeace@...il.com>,
"baruch@...s.co.il" <baruch@...s.co.il>,
"asierra@...-inc.com" <asierra@...-inc.com>,
"guz.fnst@...fujitsu.com" <guz.fnst@...fujitsu.com>,
"gsi@...x.de" <gsi@...x.de>, "richard@....at" <richard@....at>,
Boris Brezillon <boris.brezillon@...e-electrons.com>
CC: Boris Brezillon <boris.brezillon@...e-electrons.com>,
David Woodhouse <dwmw2@...radead.org>,
"linux-mtd@...ts.infradead.org" <linux-mtd@...ts.infradead.org>,
Artem Bityutskiy <dedekind1@...il.com>,
Richard Weinberger <richard@....at>,
Frank Liu 刘群 (frankliu)
<frankliu@...ron.com>, Andrea Scian <rnd4@...e-tech.it>,
Peter Pan 潘栋 (peterpandong)
<peterpandong@...ron.com>,
Karl Zhang 张双锣 (karlzhang)
<karlzhang@...ron.com>,
Iwo Mergler <Iwo.Mergler@...commwireless.com>,
"Jeff Lauruhn (jlauruhn)" <jlauruhn@...ron.com>,
Stefan Roese <sr@...x.de>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: [PATCH 8/9] drivers:mtd:ubi:init UBI bakvol and recover corrupted
lower page
During UBI attach, bakvol be initialized,
And if exist corrupted lower page, recover it by its backup data in internal
Log volume.
Signed-off-by: Bean Huo <beanhuo@...ron.com>
---
drivers/mtd/ubi/attach.c | 26 +++++++++++++++++++++++++-
drivers/mtd/ubi/build.c | 7 +++++++
2 files changed, 32 insertions(+), 1 deletion(-)
diff --git a/drivers/mtd/ubi/attach.c b/drivers/mtd/ubi/attach.c
index 68eea5b..4e00d79 100644
--- a/drivers/mtd/ubi/attach.c
+++ b/drivers/mtd/ubi/attach.c
@@ -919,6 +919,17 @@ static int scan_peb(struct ubi_device *ubi, struct ubi_attach_info *ai,
err = ubi_io_read_vid_hdr(ubi, pnum, vidh, 0);
if (err < 0)
return err;
+
+#ifdef CONFIG_MTD_UBI_MLC_NAND_BAKVOL
+ /*
+ * Before ubi scan the NAND flash, call ubi_backup_volume_scan
+ * to build the backup volume first. when the ubi scan NAND and
+ * find corrupt data, then we can try to check if there is backup
+ * data in the backup volume.
+ */
+ ubi_backup_volume_scan(ubi, vidh, pnum);
+#endif
+
switch (err) {
case 0:
break;
@@ -995,7 +1006,8 @@ static int scan_peb(struct ubi_device *ubi, struct ubi_attach_info *ai,
*vid = vol_id;
if (sqnum)
*sqnum = be64_to_cpu(vidh->sqnum);
- if (vol_id > UBI_MAX_VOLUMES && vol_id != UBI_LAYOUT_VOLUME_ID) {
+ if ((vol_id > UBI_MAX_VOLUMES && vol_id != UBI_LAYOUT_VOLUME_ID)
+ && vol_id != UBI_BACKUP_VOLUME_ID) {
int lnum = be32_to_cpu(vidh->lnum);
/* Unsupported internal volume */
@@ -1408,6 +1420,12 @@ int ubi_attach(struct ubi_device *ubi, int force_scan)
if (!ai)
return -ENOMEM;
+#ifdef CONFIG_MTD_UBI_MLC_NAND_BAKVOL
+ err = ubi_backup_volume_init(ubi);
+ if (err)
+ goto out_ai;
+#endif
+
#ifdef CONFIG_MTD_UBI_FASTMAP
/* On small flash devices we disable fastmap in any case. */
if ((int)mtd_div_by_eb(ubi->mtd->size, ubi->mtd) <= UBI_FM_MAX_START) {
@@ -1449,6 +1467,12 @@ int ubi_attach(struct ubi_device *ubi, int force_scan)
if (err)
goto out_ai;
+#ifdef CONFIG_MTD_UBI_MLC_NAND_BAKVOL
+ err = ubi_backup_volume_init_tail(ubi, ai);
+ if (err)
+ goto out_ai;
+#endif
+
err = ubi_wl_init(ubi, ai);
if (err)
goto out_vtbl;
diff --git a/drivers/mtd/ubi/build.c b/drivers/mtd/ubi/build.c
index 22fd19c..05524f7 100644
--- a/drivers/mtd/ubi/build.c
+++ b/drivers/mtd/ubi/build.c
@@ -1033,6 +1033,11 @@ int ubi_attach_mtd_dev(struct mtd_info *mtd, int ubi_num,
ubi_devices[ubi_num] = ubi;
ubi_notify_all(ubi, UBI_VOLUME_ADDED, NULL);
+
+#ifdef CONFIG_MTD_UBI_MLC_NAND_BAKVOL
+ ubi_bad_data_recovery(ubi);
+#endif
+
return ubi_num;
out_debugfs:
@@ -1118,6 +1123,8 @@ int ubi_detach_mtd_dev(int ubi_num, int anyway)
*/
get_device(&ubi->dev);
+ clear_bakvol(ubi);
+
ubi_debugfs_exit_dev(ubi);
uif_close(ubi);
--
1.9.1
Powered by blists - more mailing lists