Commit 09801194 authored by Ben Gardiner's avatar Ben Gardiner Committed by Artem Bityutskiy

UBIFS: fix-up free space earlier

The free space fixup is currently initiated during mount after the call to
ubifs_write_master() which results in a write to PEBs; this has been observed
with the patch 'assert no fixup when writing a node' applied:

Move the free space fixup on mount to before the calls to
ubifs_recover_inl_heads() and ubifs_write_master(). This results in no
assertions with the previously mentioned patch applied.

Artem: tweaked the patch a bit
Signed-off-by: default avatarBen Gardiner <bengardiner@nanometrics>
Reviewed-by: default avatarMatthew L. Creech <mlcreech@gmail.com>
Signed-off-by: default avatarArtem Bityutskiy <Artem.Bityutskiy@nokia.com>
parent 781c5717
...@@ -1282,13 +1282,13 @@ static int mount_ubifs(struct ubifs_info *c) ...@@ -1282,13 +1282,13 @@ static int mount_ubifs(struct ubifs_info *c)
if (err) if (err)
goto out_master; goto out_master;
init_constants_master(c);
if ((c->mst_node->flags & cpu_to_le32(UBIFS_MST_DIRTY)) != 0) { if ((c->mst_node->flags & cpu_to_le32(UBIFS_MST_DIRTY)) != 0) {
ubifs_msg("recovery needed"); ubifs_msg("recovery needed");
c->need_recovery = 1; c->need_recovery = 1;
} }
init_constants_master(c);
if (c->need_recovery && !c->ro_mount) { if (c->need_recovery && !c->ro_mount) {
err = ubifs_recover_inl_heads(c, c->sbuf); err = ubifs_recover_inl_heads(c, c->sbuf);
if (err) if (err)
...@@ -1299,6 +1299,12 @@ static int mount_ubifs(struct ubifs_info *c) ...@@ -1299,6 +1299,12 @@ static int mount_ubifs(struct ubifs_info *c)
if (err) if (err)
goto out_master; goto out_master;
if (!c->ro_mount && c->space_fixup) {
err = ubifs_fixup_free_space(c);
if (err)
goto out_master;
}
if (!c->ro_mount) { if (!c->ro_mount) {
/* /*
* Set the "dirty" flag so that if we reboot uncleanly we * Set the "dirty" flag so that if we reboot uncleanly we
...@@ -1402,12 +1408,6 @@ static int mount_ubifs(struct ubifs_info *c) ...@@ -1402,12 +1408,6 @@ static int mount_ubifs(struct ubifs_info *c)
} else } else
ubifs_assert(c->lst.taken_empty_lebs > 0); 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); err = dbg_check_filesystem(c);
if (err) if (err)
goto out_infos; goto out_infos;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment