diff mbox

[U-Boot] Unreadable UBIFS partition after power cuts

Message ID CANCpNEJs8=PxDU+6p9EB6mWtsYnPRcbHy4Ozhvh9YpW84fP5YQ@mail.gmail.com
State Superseded
Delegated to: Heiko Schocher
Headers show

Commit Message

Anton Habegger Jan. 19, 2015, 11:29 a.m. UTC
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@delta-es.com>
---
 fs/ubifs/replay.c | 8 ++++----
 fs/ubifs/super.c  | 4 +---
 2 files changed, 5 insertions(+), 7 deletions(-)

Comments

Heiko Schocher Jan. 20, 2015, 7:26 a.m. UTC | #1
Hello Anton,

Am 19.01.2015 12:29, schrieb Anton Habegger:
> Hello Heiko
>
> I was able to enable the uibfs_replay_journal, and so far this solved my issue.

Great to hear!

> 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.

Yes and no ... We have no processes or threads in U-Boot, so we should
have no concurrency here, but you should introduce atomic_long_read()
instead, so we have no difference to linux code. There is already in
U-Boot code atomic.h ... but atomic_long_read() is missing ... so, it
should not so difficult to intriduce this missing function, thanks!

> 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?

Yes, you are on the right way ... thanks for your work!

bye,
Heiko
diff mbox

Patch

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: