Patchwork [v3,3/3] ubifs: fix-up free space on mount if flag is set

login
register
mail settings
Submitter Matthew L. Creech
Date May 5, 2011, 8:33 p.m.
Message ID <BANLkTi=Sc5nVic0eBSwv38x8JB5F-sAztQ@mail.gmail.com>
Download mbox | patch
Permalink /patch/94318/
State New
Headers show

Comments

Matthew L. Creech - May 5, 2011, 8:33 p.m.
If a UBIFS filesystem is being mounted read-write, or is being remounted
from read-only to read-write, check for the "space_fixup" flag and fix all
LEBs containing empty space if necessary.

Signed-off-by: Matthew L. Creech <mlcreech@gmail.com>
---
 fs/ubifs/super.c |   12 ++++++++++++
 1 files changed, 12 insertions(+), 0 deletions(-)

Patch

diff --git a/fs/ubifs/super.c b/fs/ubifs/super.c
index c75f613..f7f25a3 100644
--- a/fs/ubifs/super.c
+++ b/fs/ubifs/super.c
@@ -1396,6 +1396,12 @@  static int mount_ubifs(struct ubifs_info *c)
 	} else
 		ubifs_assert(c->lst.taken_empty_lebs > 0);

+	if (!c->ro_mount && c->space_fixup) {
+		err = ubifs_fixup_free_space(c);
+		if (err)
+			goto out_infos;
+	}
+
 	err = dbg_check_filesystem(c);
 	if (err)
 		goto out_infos;
@@ -1676,6 +1682,12 @@  static int ubifs_remount_rw(struct ubifs_info *c)
 		ubifs_msg("deferred recovery completed");
 	}

+	if (c->space_fixup) {
+		err = ubifs_fixup_free_space(c);
+		if (err)
+			goto out;
+	}
+
 	dbg_gen("re-mounted read-write");
 	c->remounting_rw = 0;
 	err = dbg_check_space_info(c);