diff options
author | David Woodhouse <dwmw2@infradead.org> | 2007-05-06 09:41:40 -0400 |
---|---|---|
committer | David Woodhouse <dwmw2@infradead.org> | 2007-05-06 09:41:40 -0400 |
commit | 96dd8d25d1ca8c233bd47752349d27a631c18719 (patch) | |
tree | e76be6a42fe3396d02762d78383aec10edd68456 /fs | |
parent | 1123e2a85941c7f506bd42c91c7e9ab74fc42d79 (diff) |
[JFFS2] Remove broken insert_point optimisation in jffs2_add_tn_to_tree()
The original code would remember, during the first pass over the tree,
a suitable place to start the insertion from when we eventually come
to add a new node.
The optimisation was broken, and we sometimes ended up inserting a new
node in the wrong place because we started the insertion from the wrong
point.
Just ditch the optimisation and start the insertion from the root of the
tree, for now. I'll try it again when I'm feeling cleverer.
Signed-off-by: David Woodhouse <dwmw2@infradead.org>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/jffs2/readinode.c | 25 |
1 files changed, 7 insertions, 18 deletions
diff --git a/fs/jffs2/readinode.c b/fs/jffs2/readinode.c index b0645ac7769a..f461604cf01f 100644 --- a/fs/jffs2/readinode.c +++ b/fs/jffs2/readinode.c | |||
@@ -219,7 +219,7 @@ static int jffs2_add_tn_to_tree(struct jffs2_sb_info *c, | |||
219 | struct jffs2_tmp_dnode_info *tn) | 219 | struct jffs2_tmp_dnode_info *tn) |
220 | { | 220 | { |
221 | uint32_t fn_end = tn->fn->ofs + tn->fn->size; | 221 | uint32_t fn_end = tn->fn->ofs + tn->fn->size; |
222 | struct jffs2_tmp_dnode_info *insert_point = NULL, *this; | 222 | struct jffs2_tmp_dnode_info *this; |
223 | 223 | ||
224 | dbg_readinode("insert fragment %#04x-%#04x, ver %u\n", tn->fn->ofs, fn_end, tn->version); | 224 | dbg_readinode("insert fragment %#04x-%#04x, ver %u\n", tn->fn->ofs, fn_end, tn->version); |
225 | 225 | ||
@@ -248,9 +248,6 @@ static int jffs2_add_tn_to_tree(struct jffs2_sb_info *c, | |||
248 | return 0; | 248 | return 0; |
249 | } | 249 | } |
250 | 250 | ||
251 | /* If we add a new node it'll be somewhere under here. */ | ||
252 | insert_point = this; | ||
253 | |||
254 | /* If the node is coincident with another at a lower address, | 251 | /* If the node is coincident with another at a lower address, |
255 | back up until the other node is found. It may be relevant */ | 252 | back up until the other node is found. It may be relevant */ |
256 | while (tn->overlapped) | 253 | while (tn->overlapped) |
@@ -325,24 +322,16 @@ static int jffs2_add_tn_to_tree(struct jffs2_sb_info *c, | |||
325 | jffs2_kill_tn(c, this); | 322 | jffs2_kill_tn(c, this); |
326 | return 0; | 323 | return 0; |
327 | } | 324 | } |
328 | /* We want to be inserted under the last node which is | ||
329 | either at a lower offset _or_ has a smaller range */ | ||
330 | if (this->fn->ofs < tn->fn->ofs || | ||
331 | (this->fn->ofs == tn->fn->ofs && | ||
332 | this->fn->size <= tn->fn->size)) | ||
333 | insert_point = this; | ||
334 | 325 | ||
335 | this = tn_next(this); | 326 | this = tn_next(this); |
336 | } | 327 | } |
337 | dbg_readinode("insert_point %p, ver %d, 0x%x-0x%x, ov %d\n", | 328 | |
338 | insert_point, insert_point->version, insert_point->fn->ofs, | ||
339 | insert_point->fn->ofs+insert_point->fn->size, | ||
340 | insert_point->overlapped); | ||
341 | /* We neither completely obsoleted nor were completely | 329 | /* We neither completely obsoleted nor were completely |
342 | obsoleted by an earlier node. Insert under insert_point */ | 330 | obsoleted by an earlier node. Insert into the tree */ |
343 | { | 331 | { |
344 | struct rb_node *parent = &insert_point->rb; | 332 | struct rb_node *parent; |
345 | struct rb_node **link = &parent; | 333 | struct rb_node **link = &rii->tn_root.rb_node; |
334 | struct jffs2_tmp_dnode_info *insert_point; | ||
346 | 335 | ||
347 | while (*link) { | 336 | while (*link) { |
348 | parent = *link; | 337 | parent = *link; |
@@ -458,7 +447,7 @@ static int jffs2_build_inode_fragtree(struct jffs2_sb_info *c, | |||
458 | this = tn_last(&rii->tn_root); | 447 | this = tn_last(&rii->tn_root); |
459 | while (this) { | 448 | while (this) { |
460 | dbg_readinode("tn %p ver %d range 0x%x-0x%x ov %d\n", this, this->version, this->fn->ofs, | 449 | dbg_readinode("tn %p ver %d range 0x%x-0x%x ov %d\n", this, this->version, this->fn->ofs, |
461 | this->fn->ofs+this->fn->size, this->overlapped); | 450 | this->fn->ofs+this->fn->size, this->overlapped); |
462 | this = tn_prev(this); | 451 | this = tn_prev(this); |
463 | } | 452 | } |
464 | #endif | 453 | #endif |