[PATCH v2 15/17] fs:ubifs:enable bakvol module and recover operation
From: Bean Huo
Date: Mon Feb 01 2016 - 21:36:30 EST
From: Bean Huo <beanhuo@xxxxxxxxxx>
Before mounting, bakvol will do recovery operaion according to
master node flag(clearly unmount or not). If corrupted page damaged by
power loss exists, bakvol will reocover it through its backup page data.
bakvol module will be enable after ubifs mount successfully.
Signed-off-by: BeanHuo <beanhuo@xxxxxxxxxx>
---
fs/ubifs/super.c | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/fs/ubifs/super.c b/fs/ubifs/super.c
index 9547a278..0aaeafa 100644
--- a/fs/ubifs/super.c
+++ b/fs/ubifs/super.c
@@ -1270,6 +1270,11 @@ static int mount_ubifs(struct ubifs_info *c)
c->need_recovery = 1;
}
+#ifdef CONFIG_MTD_UBI_MLC_NAND_BAKVOL
+ if (c->need_recovery)
+ ubi_corrupted_data_recovery(c->ubi);
+#endif
+
if (c->need_recovery && !c->ro_mount) {
err = ubifs_recover_inl_heads(c, c->sbuf);
if (err)
@@ -1463,6 +1468,8 @@ static int mount_ubifs(struct ubifs_info *c)
dbg_gen("max. seq. number: %llu", c->max_sqnum);
dbg_gen("commit number: %llu", c->cmt_no);
+ init_bakvol(c->ubi, 1);
+
return 0;
out_infos:
@@ -1774,6 +1781,10 @@ static void ubifs_put_super(struct super_block *sb)
* the mutex is locked.
*/
mutex_lock(&c->umount_mutex);
+
+ /* Disable ubi MLC power loss backup function */
+ init_bakvol(c->ubi, 0);
+
if (!c->ro_mount) {
/*
* First of all kill the background thread to make sure it does
--
1.9.1