mtd/fs/jffs2 nodelist.c,1.51,1.52 nodelist.h,1.79,1.80 readinode.c,1.80,1.81

David Woodhouse dwmw2 at infradead.org
Tue Sep 3 17:43:20 EDT 2002


Update of /home/cvs/mtd/fs/jffs2
In directory phoenix.infradead.org:/tmp/cvs-serv29137

Modified Files:
	nodelist.c nodelist.h readinode.c 
Log Message:
Add rb_replace_node and stop the damn thing from following pointers in the
replacement node to its new surrounding nodes before actually copying 
said pointers from the victim. Twonk.


Index: nodelist.c
===================================================================
RCS file: /home/cvs/mtd/fs/jffs2/nodelist.c,v
retrieving revision 1.51
retrieving revision 1.52
diff -u -r1.51 -r1.52
--- nodelist.c	3 Sep 2002 16:38:24 -0000	1.51
+++ nodelist.c	3 Sep 2002 21:43:17 -0000	1.52
@@ -533,3 +533,20 @@
 
 	return node->rb_parent;
 }
+
+void rb_replace_node(rb_node_t *victim, rb_node_t *new)
+{
+	rb_node_t *parent = victim->rb_parent;
+
+	if (victim == parent->rb_left)
+		parent->rb_left = new;
+	else
+		parent->rb_right = new;
+
+	new = victim;
+
+	if (victim->rb_left)
+		victim->rb_left->rb_parent = new;
+	if (victim->rb_right)
+		victim->rb_right->rb_parent = new;
+}

Index: nodelist.h
===================================================================
RCS file: /home/cvs/mtd/fs/jffs2/nodelist.h,v
retrieving revision 1.79
retrieving revision 1.80
diff -u -r1.79 -r1.80
--- nodelist.h	3 Sep 2002 16:38:24 -0000	1.79
+++ nodelist.h	3 Sep 2002 21:43:17 -0000	1.80
@@ -269,6 +269,7 @@
 void jffs2_kill_fragtree(rb_root_t *root, struct jffs2_sb_info *c_delete);
 void jffs2_fragtree_insert(struct jffs2_node_frag *newfrag, struct jffs2_node_frag *base);
 rb_node_t *rb_next(rb_node_t *);
+void rb_replace_node(rb_node_t *victim, rb_node_t *new);
 
 /* nodemgmt.c */
 int jffs2_reserve_space(struct jffs2_sb_info *c, uint32_t minsize, uint32_t *ofs, uint32_t *len, int prio);

Index: readinode.c
===================================================================
RCS file: /home/cvs/mtd/fs/jffs2/readinode.c,v
retrieving revision 1.80
retrieving revision 1.81
diff -u -r1.80 -r1.81
--- readinode.c	3 Sep 2002 20:51:25 -0000	1.80
+++ readinode.c	3 Sep 2002 21:43:17 -0000	1.81
@@ -211,19 +211,8 @@
 		struct jffs2_node_frag *parent = frag_parent(this);
 
 		D1(printk(KERN_DEBUG "Inserting newfrag (*%p) in before 'this' (*%p)\n", newfrag, this));
-		
-		if (this == frag_left(parent))
-			parent->rb.rb_left = &newfrag->rb;
-		else
-			parent->rb.rb_right = &newfrag->rb;
-
-		if (this->rb.rb_left)
-			newfrag->rb.rb_left->rb_parent = &newfrag->rb;
-		if (this->rb.rb_right)
-			newfrag->rb.rb_right->rb_parent = &newfrag->rb;
-
-		newfrag->rb = this->rb;
-
+	
+		rb_replace_node(&this->rb, &newfrag->rb);
 
 		if (newfrag->ofs + newfrag->size >= this->ofs+this->size)
 			jffs2_obsolete_node_frag(c, this);





More information about the linux-mtd-cvs mailing list