H A D | nodelist.c | 122 static void jffs2_fragtree_insert(struct jffs2_node_frag *newfrag, struct jffs2_node_frag *base) jffs2_fragtree_insert() argument 127 dbg_fragtree2("insert frag (0x%04x-0x%04x)\n", newfrag->ofs, newfrag->ofs + newfrag->size); jffs2_fragtree_insert() 133 if (newfrag->ofs > base->ofs) jffs2_fragtree_insert() 135 else if (newfrag->ofs < base->ofs) jffs2_fragtree_insert() 138 JFFS2_ERROR("duplicate frag at %08x (%p,%p)\n", newfrag->ofs, newfrag, base); jffs2_fragtree_insert() 143 rb_link_node(&newfrag->rb, &base->rb, link); jffs2_fragtree_insert() 151 struct jffs2_node_frag *newfrag; new_fragment() local 153 newfrag = jffs2_alloc_node_frag(); new_fragment() 154 if (likely(newfrag)) { new_fragment() 155 newfrag->ofs = ofs; new_fragment() 156 newfrag->size = size; new_fragment() 157 newfrag->node = fn; new_fragment() 162 return newfrag; new_fragment() 170 struct jffs2_node_frag *newfrag, no_overlapping_node() 173 if (lastend < newfrag->node->ofs) { no_overlapping_node() 177 holefrag= new_fragment(NULL, lastend, newfrag->node->ofs - lastend); no_overlapping_node() 179 jffs2_free_node_frag(newfrag); no_overlapping_node() 204 rb_link_node(&newfrag->rb, &this->rb, &this->rb.rb_right); no_overlapping_node() 207 rb_link_node(&newfrag->rb, NULL, &root->rb_node); no_overlapping_node() 209 rb_insert_color(&newfrag->rb, root); no_overlapping_node() 215 static int jffs2_add_frag_to_fragtree(struct jffs2_sb_info *c, struct rb_root *root, struct jffs2_node_frag *newfrag) jffs2_add_frag_to_fragtree() argument 221 this = jffs2_lookup_node_frag(root, newfrag->node->ofs); jffs2_add_frag_to_fragtree() 233 if (lastend <= newfrag->ofs) { jffs2_add_frag_to_fragtree() 240 if (lastend && (lastend-1) >> PAGE_CACHE_SHIFT == newfrag->ofs >> PAGE_CACHE_SHIFT) { jffs2_add_frag_to_fragtree() 243 mark_ref_normal(newfrag->node->raw); jffs2_add_frag_to_fragtree() 246 return no_overlapping_node(c, root, newfrag, this, lastend); jffs2_add_frag_to_fragtree() 257 /* OK. 'this' is pointing at the first frag that newfrag->ofs at least partially obsoletes, jffs2_add_frag_to_fragtree() 258 * - i.e. newfrag->ofs < this->ofs+this->size && newfrag->ofs >= this->ofs jffs2_add_frag_to_fragtree() 260 if (newfrag->ofs > this->ofs) { jffs2_add_frag_to_fragtree() 265 mark_ref_normal(newfrag->node->raw); jffs2_add_frag_to_fragtree() 269 if (this->ofs + this->size > newfrag->ofs + newfrag->size) { jffs2_add_frag_to_fragtree() 281 newfrag2 = new_fragment(this->node, newfrag->ofs + newfrag->size, jffs2_add_frag_to_fragtree() 282 this->ofs + this->size - newfrag->ofs - newfrag->size); jffs2_add_frag_to_fragtree() 289 this->size = newfrag->ofs - this->ofs; jffs2_add_frag_to_fragtree() 293 newfrag2->ofs or newfrag->ofs, for obvious jffs2_add_frag_to_fragtree() 295 'this' to insert newfrag, and a tree insert jffs2_add_frag_to_fragtree() 296 from newfrag to insert newfrag2. */ jffs2_add_frag_to_fragtree() 297 jffs2_fragtree_insert(newfrag, this); jffs2_add_frag_to_fragtree() 298 rb_insert_color(&newfrag->rb, root); jffs2_add_frag_to_fragtree() 300 jffs2_fragtree_insert(newfrag2, newfrag); jffs2_add_frag_to_fragtree() 306 this->size = newfrag->ofs - this->ofs; jffs2_add_frag_to_fragtree() 309 jffs2_fragtree_insert(newfrag, this); jffs2_add_frag_to_fragtree() 310 rb_insert_color(&newfrag->rb, root); jffs2_add_frag_to_fragtree() 314 dbg_fragtree2("inserting newfrag (*%p),%d-%d in before 'this' (*%p),%d-%d\n", jffs2_add_frag_to_fragtree() 315 newfrag, newfrag->ofs, newfrag->ofs+newfrag->size, this, this->ofs, this->ofs+this->size); jffs2_add_frag_to_fragtree() 317 rb_replace_node(&this->rb, &newfrag->rb, root); jffs2_add_frag_to_fragtree() 319 if (newfrag->ofs + newfrag->size >= this->ofs+this->size) { jffs2_add_frag_to_fragtree() 323 this->ofs += newfrag->size; jffs2_add_frag_to_fragtree() 324 this->size -= newfrag->size; jffs2_add_frag_to_fragtree() 326 jffs2_fragtree_insert(this, newfrag); jffs2_add_frag_to_fragtree() 331 /* OK, now we have newfrag added in the correct place in the tree, but jffs2_add_frag_to_fragtree() 332 frag_next(newfrag) may be a fragment which is overlapped by it jffs2_add_frag_to_fragtree() 334 while ((this = frag_next(newfrag)) && newfrag->ofs + newfrag->size >= this->ofs + this->size) { jffs2_add_frag_to_fragtree() 344 if (!this || newfrag->ofs + newfrag->size == this->ofs) jffs2_add_frag_to_fragtree() 348 this->size = (this->ofs + this->size) - (newfrag->ofs + newfrag->size); jffs2_add_frag_to_fragtree() 349 this->ofs = newfrag->ofs + newfrag->size; jffs2_add_frag_to_fragtree() 354 mark_ref_normal(newfrag->node->raw); jffs2_add_frag_to_fragtree() 366 struct jffs2_node_frag *newfrag; jffs2_add_full_dnode_to_inode() local 371 newfrag = new_fragment(fn, fn->ofs, fn->size); jffs2_add_full_dnode_to_inode() 372 if (unlikely(!newfrag)) jffs2_add_full_dnode_to_inode() 374 newfrag->node->frags = 1; jffs2_add_full_dnode_to_inode() 376 dbg_fragtree("adding node %#04x-%#04x @0x%08x on flash, newfrag *%p\n", jffs2_add_full_dnode_to_inode() 377 fn->ofs, fn->ofs+fn->size, ref_offset(fn->raw), newfrag); jffs2_add_full_dnode_to_inode() 379 ret = jffs2_add_frag_to_fragtree(c, &f->fragtree, newfrag); jffs2_add_full_dnode_to_inode() 385 if (newfrag->ofs & (PAGE_CACHE_SIZE-1)) { jffs2_add_full_dnode_to_inode() 386 struct jffs2_node_frag *prev = frag_prev(newfrag); jffs2_add_full_dnode_to_inode() 394 if ((newfrag->ofs+newfrag->size) & (PAGE_CACHE_SIZE-1)) { jffs2_add_full_dnode_to_inode() 395 struct jffs2_node_frag *next = frag_next(newfrag); jffs2_add_full_dnode_to_inode() 169 no_overlapping_node(struct jffs2_sb_info *c, struct rb_root *root, struct jffs2_node_frag *newfrag, struct jffs2_node_frag *this, uint32_t lastend) no_overlapping_node() argument
|