[U-Boot] Unreadable UBIFS partition after power cuts

Anton Habegger anton.habegger at gmail.com
Mon Jan 19 12:29:29 CET 2015


Hello Heiko

I was able to enable the uibfs_replay_journal, and so far this solved my issue.

Below the patch. I'm not sure about the U-Boot replacement for
atomic_long_read? I assume U-Boot has no concurrency, then maybe it is
safe, just to assign the  long direct.
Is this correct?
Furthermore I wasn't able to enable the error case,
ubifs_destroy_journal, because there
is a dependency to the garbage collector gc.c. So far I didn't found
time to integrate this stuff.
What do you think, Is this the right way to fix this issue?

Signed-off-by: Anton Habegger <anton.habegger at delta-es.com>
---
 fs/ubifs/replay.c | 8 ++++----
 fs/ubifs/super.c  | 4 +---
 2 files changed, 5 insertions(+), 7 deletions(-)

diff --git a/fs/ubifs/replay.c b/fs/ubifs/replay.c
index 7268b37..75b92ac 100644
--- a/fs/ubifs/replay.c
+++ b/fs/ubifs/replay.c
@@ -78,7 +78,6 @@ struct bud_entry {
        int dirty;
 };

-#ifndef __UBOOT__
 /**
  * set_bud_lprops - set free and dirty space used by a bud.
  * @c: UBIFS file-system description object
@@ -432,7 +431,6 @@ static int insert_dent(struct ubifs_info *c, int
lnum, int offs, int len,
        list_add_tail(&r->list, &c->replay_list);
        return 0;
 }
-#endif

 /**
  * ubifs_validate_entry - validate directory or extended attribute entry node.
@@ -466,7 +464,6 @@ int ubifs_validate_entry(struct ubifs_info *c,
        return 0;
 }

-#ifndef __UBOOT__
 /**
  * is_last_bud - check if the bud is the last in the journal head.
  * @c: UBIFS file-system description object
@@ -1050,7 +1047,11 @@ int ubifs_replay_journal(struct ubifs_info *c)
         * depend on it. This means we have to initialize it to make sure
         * budgeting works properly.
         */
+#ifndef __UBOOT__
        c->bi.uncommitted_idx = atomic_long_read(&c->dirty_zn_cnt);
+#else
+       c->bi.uncommitted_idx = c->dirty_zn_cnt;
+#endif
        c->bi.uncommitted_idx *= c->max_idx_node_sz;

        ubifs_assert(c->bud_bytes <= c->max_bud_bytes || c->need_recovery);
@@ -1063,4 +1064,3 @@ out:
        c->replaying = 0;
        return err;
 }
-#endif
diff --git a/fs/ubifs/super.c b/fs/ubifs/super.c
index 01d449a..e65f743 100644
--- a/fs/ubifs/super.c
+++ b/fs/ubifs/super.c
@@ -1502,11 +1502,9 @@ static int mount_ubifs(struct ubifs_info *c)
        if (err)
                goto out_lpt;

-#ifndef __UBOOT__
        err = ubifs_replay_journal(c);
        if (err)
                goto out_journal;
-#endif

        /* Calculate 'min_idx_lebs' after journal replay */
        c->bi.min_idx_lebs = ubifs_calc_min_idx_lebs(c);
@@ -1678,8 +1676,8 @@ out_infos:
        spin_unlock(&ubifs_infos_lock);
 out_orphans:
        free_orphans(c);
-#ifndef __UBOOT__
 out_journal:
+#ifndef __UBOOT__
        destroy_journal(c);
 #endif
 out_lpt:
-- 

Anton


More information about the U-Boot mailing list