Lines Matching refs:tn
31 static int check_node_data(struct jffs2_sb_info *c, struct jffs2_tmp_dnode_info *tn) in check_node_data() argument
33 struct jffs2_raw_node_ref *ref = tn->fn->raw; in check_node_data()
40 BUG_ON(tn->csize == 0); in check_node_data()
44 len = tn->csize; in check_node_data()
51 if (adj >= tn->csize) { in check_node_data()
53 ref_offset(ref), tn->csize, ofs); in check_node_data()
62 ref_offset(ref), tn->csize, tn->partial_crc, tn->data_crc, ofs - len, ofs, len); in check_node_data()
69 JFFS2_WARNING("MTD point returned len too short: %zu instead of %u.\n", retlen, tn->csize); in check_node_data()
99 crc = crc32(tn->partial_crc, buffer, len); in check_node_data()
107 if (crc != tn->data_crc) { in check_node_data()
109 ref_offset(ref), tn->data_crc, crc); in check_node_data()
150 static int check_tn_node(struct jffs2_sb_info *c, struct jffs2_tmp_dnode_info *tn) in check_tn_node() argument
154 BUG_ON(ref_obsolete(tn->fn->raw)); in check_tn_node()
157 if (ref_flags(tn->fn->raw) != REF_UNCHECKED) in check_tn_node()
161 tn->fn->ofs, tn->fn->ofs + tn->fn->size, ref_offset(tn->fn->raw)); in check_tn_node()
163 ret = check_node_data(c, tn); in check_tn_node()
169 jffs2_mark_node_obsolete(c, tn->fn->raw); in check_tn_node()
178 struct jffs2_tmp_dnode_info *tn = NULL; in jffs2_lookup_tn() local
185 tn = rb_entry(next, struct jffs2_tmp_dnode_info, rb); in jffs2_lookup_tn()
187 if (tn->fn->ofs < offset) in jffs2_lookup_tn()
188 next = tn->rb.rb_right; in jffs2_lookup_tn()
189 else if (tn->fn->ofs >= offset) in jffs2_lookup_tn()
190 next = tn->rb.rb_left; in jffs2_lookup_tn()
195 return tn; in jffs2_lookup_tn()
199 static void jffs2_kill_tn(struct jffs2_sb_info *c, struct jffs2_tmp_dnode_info *tn) in jffs2_kill_tn() argument
201 jffs2_mark_node_obsolete(c, tn->fn->raw); in jffs2_kill_tn()
202 jffs2_free_full_dnode(tn->fn); in jffs2_kill_tn()
203 jffs2_free_tmp_dnode_info(tn); in jffs2_kill_tn()
220 struct jffs2_tmp_dnode_info *tn) in jffs2_add_tn_to_tree() argument
222 uint32_t fn_end = tn->fn->ofs + tn->fn->size; in jffs2_add_tn_to_tree()
225 …ode("insert fragment %#04x-%#04x, ver %u at %08x\n", tn->fn->ofs, fn_end, tn->version, ref_offset(… in jffs2_add_tn_to_tree()
231 if (!tn->fn->size) { in jffs2_add_tn_to_tree()
233 if (rii->mdata_tn->version < tn->version) { in jffs2_add_tn_to_tree()
239 tn->version, rii->mdata_tn->version); in jffs2_add_tn_to_tree()
240 jffs2_kill_tn(c, tn); in jffs2_add_tn_to_tree()
244 rii->mdata_tn = tn; in jffs2_add_tn_to_tree()
245 dbg_readinode("keep new mdata with ver %d\n", tn->version); in jffs2_add_tn_to_tree()
250 this = jffs2_lookup_tn(&rii->tn_root, tn->fn->ofs); in jffs2_add_tn_to_tree()
275 if (this->version == tn->version) { in jffs2_add_tn_to_tree()
281 jffs2_kill_tn(c, tn); in jffs2_add_tn_to_tree()
286 rb_replace_node(&this->rb, &tn->rb, &rii->tn_root); in jffs2_add_tn_to_tree()
292 if (this->version < tn->version && in jffs2_add_tn_to_tree()
293 this->fn->ofs >= tn->fn->ofs && in jffs2_add_tn_to_tree()
296 if (check_tn_node(c, tn)) { in jffs2_add_tn_to_tree()
298 jffs2_kill_tn(c, tn); in jffs2_add_tn_to_tree()
304 if (this->version < tn->version) { in jffs2_add_tn_to_tree()
316 if (this->version > tn->version && in jffs2_add_tn_to_tree()
317 this->fn->ofs <= tn->fn->ofs && in jffs2_add_tn_to_tree()
322 jffs2_kill_tn(c, tn); in jffs2_add_tn_to_tree()
345 if (tn->fn->ofs > insert_point->fn->ofs) in jffs2_add_tn_to_tree()
347 else if (tn->fn->ofs < insert_point->fn->ofs || in jffs2_add_tn_to_tree()
348 tn->fn->size < insert_point->fn->size) in jffs2_add_tn_to_tree()
353 rb_link_node(&tn->rb, &insert_point->rb, link); in jffs2_add_tn_to_tree()
354 rb_insert_color(&tn->rb, &rii->tn_root); in jffs2_add_tn_to_tree()
358 this = tn_prev(tn); in jffs2_add_tn_to_tree()
361 if (this->fn->ofs + this->fn->size > tn->fn->ofs) { in jffs2_add_tn_to_tree()
365 tn->overlapped = 1; in jffs2_add_tn_to_tree()
385 this = tn_next(tn); in jffs2_add_tn_to_tree()
424 static void ver_insert(struct rb_root *ver_root, struct jffs2_tmp_dnode_info *tn) in ver_insert() argument
434 if (tn->version > this_tn->version) in ver_insert()
440 rb_link_node(&tn->rb, parent, link); in ver_insert()
441 rb_insert_color(&tn->rb, ver_root); in ver_insert()
546 struct jffs2_tmp_dnode_info *tn, *next; in jffs2_free_tmp_dnode_info_list() local
548 rbtree_postorder_for_each_entry_safe(tn, next, list, rb) { in jffs2_free_tmp_dnode_info_list()
549 jffs2_free_full_dnode(tn->fn); in jffs2_free_tmp_dnode_info_list()
550 jffs2_free_tmp_dnode_info(tn); in jffs2_free_tmp_dnode_info_list()
717 struct jffs2_tmp_dnode_info *tn; in read_dnode() local
733 tn = jffs2_alloc_tmp_dnode_info(); in read_dnode()
734 if (!tn) { in read_dnode()
735 JFFS2_ERROR("failed to allocate tn (%zu bytes).\n", sizeof(*tn)); in read_dnode()
739 tn->partial_crc = 0; in read_dnode()
796 tn->partial_crc = crc32(0, buf, len); in read_dnode()
798 dbg_readinode("Calculates CRC (%#08x) for %d bytes, csize %d\n", tn->partial_crc, len, csize); in read_dnode()
802 if (len >= csize && unlikely(tn->partial_crc != je32_to_cpu(rd->data_crc))) { in read_dnode()
804 ref_offset(ref), tn->partial_crc, je32_to_cpu(rd->data_crc)); in read_dnode()
832 tn->fn = jffs2_alloc_full_dnode(); in read_dnode()
833 if (!tn->fn) { in read_dnode()
839 tn->version = je32_to_cpu(rd->version); in read_dnode()
840 tn->fn->ofs = je32_to_cpu(rd->offset); in read_dnode()
841 tn->data_crc = je32_to_cpu(rd->data_crc); in read_dnode()
842 tn->csize = csize; in read_dnode()
843 tn->fn->raw = ref; in read_dnode()
844 tn->overlapped = 0; in read_dnode()
846 if (tn->version > rii->highest_version) in read_dnode()
847 rii->highest_version = tn->version; in read_dnode()
852 tn->fn->size = csize; in read_dnode()
854 tn->fn->size = je32_to_cpu(rd->dsize); in read_dnode()
860 ret = jffs2_add_tn_to_tree(c, rii, tn); in read_dnode()
863 jffs2_free_full_dnode(tn->fn); in read_dnode()
865 jffs2_free_tmp_dnode_info(tn); in read_dnode()
870 tn = tn_first(&rii->tn_root); in read_dnode()
871 while (tn) { in read_dnode()
873 tn, tn->version, tn->fn->ofs, in read_dnode()
874 tn->fn->ofs+tn->fn->size, tn->overlapped); in read_dnode()
875 tn = tn_next(tn); in read_dnode()