Lines Matching refs:newfrag
122 static void jffs2_fragtree_insert(struct jffs2_node_frag *newfrag, struct jffs2_node_frag *base) in jffs2_fragtree_insert() argument
127 dbg_fragtree2("insert frag (0x%04x-0x%04x)\n", newfrag->ofs, newfrag->ofs + newfrag->size); in jffs2_fragtree_insert()
133 if (newfrag->ofs > base->ofs) in jffs2_fragtree_insert()
135 else if (newfrag->ofs < base->ofs) in jffs2_fragtree_insert()
138 JFFS2_ERROR("duplicate frag at %08x (%p,%p)\n", newfrag->ofs, newfrag, base); in jffs2_fragtree_insert()
143 rb_link_node(&newfrag->rb, &base->rb, link); in jffs2_fragtree_insert()
151 struct jffs2_node_frag *newfrag; in new_fragment() local
153 newfrag = jffs2_alloc_node_frag(); in new_fragment()
154 if (likely(newfrag)) { in new_fragment()
155 newfrag->ofs = ofs; in new_fragment()
156 newfrag->size = size; in new_fragment()
157 newfrag->node = fn; in new_fragment()
162 return newfrag; in new_fragment()
170 struct jffs2_node_frag *newfrag, in no_overlapping_node() argument
173 if (lastend < newfrag->node->ofs) { in no_overlapping_node()
177 holefrag= new_fragment(NULL, lastend, newfrag->node->ofs - lastend); in no_overlapping_node()
179 jffs2_free_node_frag(newfrag); in no_overlapping_node()
204 rb_link_node(&newfrag->rb, &this->rb, &this->rb.rb_right); in no_overlapping_node()
207 rb_link_node(&newfrag->rb, NULL, &root->rb_node); in no_overlapping_node()
209 rb_insert_color(&newfrag->rb, root); in no_overlapping_node()
215 …dd_frag_to_fragtree(struct jffs2_sb_info *c, struct rb_root *root, struct jffs2_node_frag *newfrag) in jffs2_add_frag_to_fragtree() argument
221 this = jffs2_lookup_node_frag(root, newfrag->node->ofs); in jffs2_add_frag_to_fragtree()
233 if (lastend <= newfrag->ofs) { in jffs2_add_frag_to_fragtree()
240 if (lastend && (lastend-1) >> PAGE_SHIFT == newfrag->ofs >> PAGE_SHIFT) { in jffs2_add_frag_to_fragtree()
243 mark_ref_normal(newfrag->node->raw); in jffs2_add_frag_to_fragtree()
246 return no_overlapping_node(c, root, newfrag, this, lastend); in jffs2_add_frag_to_fragtree()
260 if (newfrag->ofs > this->ofs) { in jffs2_add_frag_to_fragtree()
265 mark_ref_normal(newfrag->node->raw); in jffs2_add_frag_to_fragtree()
269 if (this->ofs + this->size > newfrag->ofs + newfrag->size) { in jffs2_add_frag_to_fragtree()
281 newfrag2 = new_fragment(this->node, newfrag->ofs + newfrag->size, in jffs2_add_frag_to_fragtree()
282 this->ofs + this->size - newfrag->ofs - newfrag->size); in jffs2_add_frag_to_fragtree()
289 this->size = newfrag->ofs - this->ofs; in jffs2_add_frag_to_fragtree()
297 jffs2_fragtree_insert(newfrag, this); in jffs2_add_frag_to_fragtree()
298 rb_insert_color(&newfrag->rb, root); in jffs2_add_frag_to_fragtree()
300 jffs2_fragtree_insert(newfrag2, newfrag); in jffs2_add_frag_to_fragtree()
306 this->size = newfrag->ofs - this->ofs; in jffs2_add_frag_to_fragtree()
309 jffs2_fragtree_insert(newfrag, this); in jffs2_add_frag_to_fragtree()
310 rb_insert_color(&newfrag->rb, root); in jffs2_add_frag_to_fragtree()
315 newfrag, newfrag->ofs, newfrag->ofs+newfrag->size, this, this->ofs, this->ofs+this->size); in jffs2_add_frag_to_fragtree()
317 rb_replace_node(&this->rb, &newfrag->rb, root); in jffs2_add_frag_to_fragtree()
319 if (newfrag->ofs + newfrag->size >= this->ofs+this->size) { in jffs2_add_frag_to_fragtree()
323 this->ofs += newfrag->size; in jffs2_add_frag_to_fragtree()
324 this->size -= newfrag->size; in jffs2_add_frag_to_fragtree()
326 jffs2_fragtree_insert(this, newfrag); in jffs2_add_frag_to_fragtree()
334 while ((this = frag_next(newfrag)) && newfrag->ofs + newfrag->size >= this->ofs + this->size) { in jffs2_add_frag_to_fragtree()
344 if (!this || newfrag->ofs + newfrag->size == this->ofs) in jffs2_add_frag_to_fragtree()
348 this->size = (this->ofs + this->size) - (newfrag->ofs + newfrag->size); in jffs2_add_frag_to_fragtree()
349 this->ofs = newfrag->ofs + newfrag->size; in jffs2_add_frag_to_fragtree()
354 mark_ref_normal(newfrag->node->raw); in jffs2_add_frag_to_fragtree()
366 struct jffs2_node_frag *newfrag; in jffs2_add_full_dnode_to_inode() local
371 newfrag = new_fragment(fn, fn->ofs, fn->size); in jffs2_add_full_dnode_to_inode()
372 if (unlikely(!newfrag)) in jffs2_add_full_dnode_to_inode()
374 newfrag->node->frags = 1; in jffs2_add_full_dnode_to_inode()
377 fn->ofs, fn->ofs+fn->size, ref_offset(fn->raw), newfrag); in jffs2_add_full_dnode_to_inode()
379 ret = jffs2_add_frag_to_fragtree(c, &f->fragtree, newfrag); in jffs2_add_full_dnode_to_inode()
385 if (newfrag->ofs & (PAGE_SIZE-1)) { in jffs2_add_full_dnode_to_inode()
386 struct jffs2_node_frag *prev = frag_prev(newfrag); in jffs2_add_full_dnode_to_inode()
394 if ((newfrag->ofs+newfrag->size) & (PAGE_SIZE-1)) { in jffs2_add_full_dnode_to_inode()
395 struct jffs2_node_frag *next = frag_next(newfrag); in jffs2_add_full_dnode_to_inode()