aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Woodhouse <dwmw2@infradead.org>2007-06-01 15:04:43 -0400
committerDavid Woodhouse <dwmw2@infradead.org>2007-06-01 15:04:43 -0400
commit0477d24e2a87a9077b62298b01b031929f5cf2a2 (patch)
tree3c9c925bbdfb1d2b77559653ef30c1b734e331ef
parent718ea8361b15aec5f4cb559d63ba34bc5a58d8f9 (diff)
[JFFS2] Fix obsoletion of metadata nodes in jffs2_add_tn_to_tree()
We should keep the mdata node with higher version number, not just the one we happen to find latest. Doh. Signed-off-by: David Woodhouse <dwmw2@infradead.org>
-rw-r--r--fs/jffs2/readinode.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/fs/jffs2/readinode.c b/fs/jffs2/readinode.c
index 5663e8c7a959..12e83f67eee4 100644
--- a/fs/jffs2/readinode.c
+++ b/fs/jffs2/readinode.c
@@ -229,9 +229,16 @@ static int jffs2_add_tn_to_tree(struct jffs2_sb_info *c,
229 check anyway. */ 229 check anyway. */
230 if (!tn->fn->size) { 230 if (!tn->fn->size) {
231 if (rii->mdata_tn) { 231 if (rii->mdata_tn) {
232 /* We had a candidate mdata node already */ 232 if (rii->mdata_tn->version < tn->version) {
233 dbg_readinode("kill old mdata with ver %d\n", rii->mdata_tn->version); 233 /* We had a candidate mdata node already */
234 jffs2_kill_tn(c, rii->mdata_tn); 234 dbg_readinode("kill old mdata with ver %d\n", rii->mdata_tn->version);
235 jffs2_kill_tn(c, rii->mdata_tn);
236 } else {
237 dbg_readinode("kill new mdata with ver %d (older than existing %d\n",
238 tn->version, rii->mdata_tn->version);
239 jffs2_kill_tn(c, tn);
240 return 0;
241 }
235 } 242 }
236 rii->mdata_tn = tn; 243 rii->mdata_tn = tn;
237 dbg_readinode("keep new mdata with ver %d\n", tn->version); 244 dbg_readinode("keep new mdata with ver %d\n", tn->version);