Commit 781c5717 authored by Ben Gardiner's avatar Ben Gardiner Committed by Artem Bityutskiy

UBIFS: intialize LPT earlier

The current 'mount_ubifs()' implementation does not initialize the LPT until the
the master node is marked dirty. Move the LPT initialization to before marking
the master node dirty. This is a preparation for the next patch which will move
the free-space-fixup check to before marking the master node dirty, because we
have to fix-up the free space before doing any writes.

Artem: massaged the patch and commit message.
Signed-off-by: default avatarBen Gardiner <bengardiner@nanometrics.ca>
Reviewed-by: default avatarMatthew L. Creech <mlcreech@gmail.com>
Signed-off-by: default avatarArtem Bityutskiy <Artem.Bityutskiy@nokia.com>
parent 4f1ab9b0
...@@ -1282,17 +1282,24 @@ static int mount_ubifs(struct ubifs_info *c) ...@@ -1282,17 +1282,24 @@ 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;
if (!c->ro_mount) { }
err = ubifs_recover_inl_heads(c, c->sbuf);
if (err) init_constants_master(c);
goto out_master;
} if (c->need_recovery && !c->ro_mount) {
} else if (!c->ro_mount) { err = ubifs_recover_inl_heads(c, c->sbuf);
if (err)
goto out_master;
}
err = ubifs_lpt_init(c, 1, !c->ro_mount);
if (err)
goto out_master;
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
* will notice this immediately on the next mount. * will notice this immediately on the next mount.
...@@ -1300,13 +1307,9 @@ static int mount_ubifs(struct ubifs_info *c) ...@@ -1300,13 +1307,9 @@ static int mount_ubifs(struct ubifs_info *c)
c->mst_node->flags |= cpu_to_le32(UBIFS_MST_DIRTY); c->mst_node->flags |= cpu_to_le32(UBIFS_MST_DIRTY);
err = ubifs_write_master(c); err = ubifs_write_master(c);
if (err) if (err)
goto out_master; goto out_lpt;
} }
err = ubifs_lpt_init(c, 1, !c->ro_mount);
if (err)
goto out_lpt;
err = dbg_check_idx_size(c, c->bi.old_idx_sz); err = dbg_check_idx_size(c, c->bi.old_idx_sz);
if (err) if (err)
goto out_lpt; goto out_lpt;
......
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