aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorCody P Schafer <cody@linux.vnet.ibm.com>2014-01-23 18:56:11 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2014-01-23 19:37:03 -0500
commite8bbeeb755a077cfc0f814b07739f9225642d65c (patch)
tree8ce2b9c384ae6a64bb90e9947cbcaa3b386ee3f8 /fs
parentd1866bd06101eb8ab2bb9d180b47c052c04b7cee (diff)
fs/jffs2: use rbtree postorder iteration helper instead of opencoding
Use rbtree_postorder_for_each_entry_safe() to destroy the rbtree instead of opencoding an alternate postorder iteration that modifies the tree Signed-off-by: Cody P Schafer <cody@linux.vnet.ibm.com> Cc: Michel Lespinasse <walken@google.com> Cc: Jan Kara <jack@suse.cz> Cc: David Woodhouse <dwmw2@infradead.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'fs')
-rw-r--r--fs/jffs2/nodelist.c28
-rw-r--r--fs/jffs2/readinode.c26
2 files changed, 5 insertions, 49 deletions
diff --git a/fs/jffs2/nodelist.c b/fs/jffs2/nodelist.c
index 975a1f562c10..9a5449bc3afb 100644
--- a/fs/jffs2/nodelist.c
+++ b/fs/jffs2/nodelist.c
@@ -564,25 +564,10 @@ struct jffs2_node_frag *jffs2_lookup_node_frag(struct rb_root *fragtree, uint32_
564 they're killed. */ 564 they're killed. */
565void jffs2_kill_fragtree(struct rb_root *root, struct jffs2_sb_info *c) 565void jffs2_kill_fragtree(struct rb_root *root, struct jffs2_sb_info *c)
566{ 566{
567 struct jffs2_node_frag *frag; 567 struct jffs2_node_frag *frag, *next;
568 struct jffs2_node_frag *parent;
569
570 if (!root->rb_node)
571 return;
572 568
573 dbg_fragtree("killing\n"); 569 dbg_fragtree("killing\n");
574 570 rbtree_postorder_for_each_entry_safe(frag, next, root, rb) {
575 frag = (rb_entry(root->rb_node, struct jffs2_node_frag, rb));
576 while(frag) {
577 if (frag->rb.rb_left) {
578 frag = frag_left(frag);
579 continue;
580 }
581 if (frag->rb.rb_right) {
582 frag = frag_right(frag);
583 continue;
584 }
585
586 if (frag->node && !(--frag->node->frags)) { 571 if (frag->node && !(--frag->node->frags)) {
587 /* Not a hole, and it's the final remaining frag 572 /* Not a hole, and it's the final remaining frag
588 of this node. Free the node */ 573 of this node. Free the node */
@@ -591,17 +576,8 @@ void jffs2_kill_fragtree(struct rb_root *root, struct jffs2_sb_info *c)
591 576
592 jffs2_free_full_dnode(frag->node); 577 jffs2_free_full_dnode(frag->node);
593 } 578 }
594 parent = frag_parent(frag);
595 if (parent) {
596 if (frag_left(parent) == frag)
597 parent->rb.rb_left = NULL;
598 else
599 parent->rb.rb_right = NULL;
600 }
601 579
602 jffs2_free_node_frag(frag); 580 jffs2_free_node_frag(frag);
603 frag = parent;
604
605 cond_resched(); 581 cond_resched();
606 } 582 }
607} 583}
diff --git a/fs/jffs2/readinode.c b/fs/jffs2/readinode.c
index ae81b01e6fd7..386303dca382 100644
--- a/fs/jffs2/readinode.c
+++ b/fs/jffs2/readinode.c
@@ -543,33 +543,13 @@ static int jffs2_build_inode_fragtree(struct jffs2_sb_info *c,
543 543
544static void jffs2_free_tmp_dnode_info_list(struct rb_root *list) 544static void jffs2_free_tmp_dnode_info_list(struct rb_root *list)
545{ 545{
546 struct rb_node *this; 546 struct jffs2_tmp_dnode_info *tn, *next;
547 struct jffs2_tmp_dnode_info *tn;
548
549 this = list->rb_node;
550 547
551 /* Now at bottom of tree */ 548 rbtree_postorder_for_each_entry_safe(tn, next, list, rb) {
552 while (this) {
553 if (this->rb_left)
554 this = this->rb_left;
555 else if (this->rb_right)
556 this = this->rb_right;
557 else {
558 tn = rb_entry(this, struct jffs2_tmp_dnode_info, rb);
559 jffs2_free_full_dnode(tn->fn); 549 jffs2_free_full_dnode(tn->fn);
560 jffs2_free_tmp_dnode_info(tn); 550 jffs2_free_tmp_dnode_info(tn);
561
562 this = rb_parent(this);
563 if (!this)
564 break;
565
566 if (this->rb_left == &tn->rb)
567 this->rb_left = NULL;
568 else if (this->rb_right == &tn->rb)
569 this->rb_right = NULL;
570 else BUG();
571 }
572 } 551 }
552
573 *list = RB_ROOT; 553 *list = RB_ROOT;
574} 554}
575 555