mtd/fs/jffs2 readinode.c,1.78,1.79
David Woodhouse
dwmw2 at infradead.org
Tue Sep 3 13:17:55 EDT 2002
- Previous message: mtd/fs/jffs2 GNUmakefile,1.5,1.6 nodelist.c,1.50,1.51 nodelist.h,1.78,1.79 readinode.c,1.77,1.78
- Next message: mtd/fs/jffs2 readinode.c,1.79,1.80
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Update of /home/cvs/mtd/fs/jffs2
In directory phoenix.infradead.org:/tmp/cvs-serv18565
Modified Files:
readinode.c
Log Message:
another attempt
Index: readinode.c
===================================================================
RCS file: /home/cvs/mtd/fs/jffs2/readinode.c,v
retrieving revision 1.78
retrieving revision 1.79
diff -u -r1.78 -r1.79
--- readinode.c 3 Sep 2002 16:38:24 -0000 1.78
+++ readinode.c 3 Sep 2002 17:17:53 -0000 1.79
@@ -26,9 +26,9 @@
while(this) {
if (this->node)
- printk(KERN_DEBUG "frag %04x-%04x: 0x%08x on flash (*%p)\n", this->ofs, this->ofs+this->size, this->node->raw->flash_offset &~3, this);
+ printk(KERN_DEBUG "frag %04x-%04x: 0x%08x on flash (*%p). left (%p), right (%p), parent (%p)\n", this->ofs, this->ofs+this->size, this->node->raw->flash_offset &~3, this, frag_left(this), frag_right(this), frag_parent(this));
else
- printk(KERN_DEBUG "frag %04x-%04x: hole (*%p)\n", this->ofs, this->ofs+this->size, this);
+ printk(KERN_DEBUG "frag %04x-%04x: hole (*%p). left (%p} right (%p), parent (%p)\n", this->ofs, this->ofs+this->size, this, frag_left(this), frag_right(this), frag_parent(this));
this = frag_next(this);
}
})
@@ -184,8 +184,6 @@
/* Adjust size of original 'this' */
this->size = newfrag->ofs - this->ofs;
- printk("After munging of existing nodes:\n");
- D1(jffs2_print_fragtree(list));
/* Now, we know there's no node with offset
greater than this->ofs but smaller than
@@ -195,13 +193,9 @@
from newfrag to insert newfrag2. */
jffs2_fragtree_insert(newfrag, this);
rb_insert_color(&newfrag->rb, list);
- printk("After inserting newfrag:\n");
- D1(jffs2_print_fragtree(list));
jffs2_fragtree_insert(newfrag2, newfrag);
rb_insert_color(&newfrag2->rb, list);
- printk("After inserting newfrag2:\n");
- D1(jffs2_print_fragtree(list));
return 0;
}
@@ -214,7 +208,7 @@
} else {
/* New frag starts at the same point as 'this' used to. Replace
it in the tree without doing a delete and insertion */
- D2(printk(KERN_DEBUG "Inserting newfrag (*%p) in before 'this' (*%p)\n", newfrag, this));
+ D1(printk(KERN_DEBUG "Inserting newfrag (*%p) in before 'this' (*%p)\n", newfrag, this));
struct jffs2_node_frag *parent = frag_parent(this);
if (this == frag_left(parent))
@@ -222,8 +216,27 @@
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;
- jffs2_obsolete_node_frag(c, this);
+
+
+ if (newfrag->ofs + newfrag->size >= this->ofs+this->size)
+ jffs2_obsolete_node_frag(c, this);
+ else {
+ this->ofs += newfrag->size;
+ this->size -= newfrag->size;
+ printk("before inserting new shrunk frag %d-%d:\n", this->ofs, this->ofs+this->size);
+ jffs2_print_fragtree(list);
+ jffs2_fragtree_insert(this, newfrag);
+ printk("inserted:\n");
+ jffs2_print_fragtree(list);
+ rb_insert_color(&this->rb, list);
+ return 0;
+ }
}
/* OK, now we have newfrag added in the correct place in the tree, but
frag_next(newfrag) may be a fragment which is overlapped by it
@@ -239,7 +252,7 @@
if (!this || newfrag->ofs + newfrag->size == this->ofs) {
return 0;
}
- /* Still some overlap */
+ /* Still some overlap but we don't need to move it in the tree */
this->size = (this->ofs + this->size) - (newfrag->ofs + newfrag->size);
this->ofs = newfrag->ofs + newfrag->size;
- Previous message: mtd/fs/jffs2 GNUmakefile,1.5,1.6 nodelist.c,1.50,1.51 nodelist.h,1.78,1.79 readinode.c,1.77,1.78
- Next message: mtd/fs/jffs2 readinode.c,1.79,1.80
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the linux-mtd-cvs
mailing list