Lines Matching refs:jeb
39 static int jffs2_scan_eraseblock (struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb,
46 static int jffs2_scan_inode_node(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb,
48 static int jffs2_scan_dirent_node(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb,
69 static int file_dirty(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb) in file_dirty() argument
73 if ((ret = jffs2_prealloc_raw_node_refs(c, jeb, 1))) in file_dirty()
75 if ((ret = jffs2_scan_dirty_space(c, jeb, jeb->free_size))) in file_dirty()
79 jeb->dirty_size += jeb->wasted_size; in file_dirty()
80 c->dirty_size += jeb->wasted_size; in file_dirty()
81 c->wasted_size -= jeb->wasted_size; in file_dirty()
82 jeb->wasted_size = 0; in file_dirty()
83 if (VERYDIRTY(c, jeb->dirty_size)) { in file_dirty()
84 list_add(&jeb->list, &c->very_dirty_list); in file_dirty()
86 list_add(&jeb->list, &c->dirty_list); in file_dirty()
144 struct jffs2_eraseblock *jeb = &c->blocks[i]; in jffs2_scan_medium() local
151 ret = jffs2_scan_eraseblock(c, jeb, buf_size?flashbuf:(flashbuf+jeb->offset), in jffs2_scan_medium()
157 jffs2_dbg_acct_paranoia_check_nolock(c, jeb); in jffs2_scan_medium()
170 list_add(&jeb->list, &c->erase_pending_list); in jffs2_scan_medium()
176 if (!jeb->dirty_size) { in jffs2_scan_medium()
178 list_add(&jeb->list, &c->free_list); in jffs2_scan_medium()
183 jeb->offset); in jffs2_scan_medium()
184 list_add(&jeb->list, &c->erase_pending_list); in jffs2_scan_medium()
191 list_add(&jeb->list, &c->clean_list); in jffs2_scan_medium()
198 if (jeb->free_size > min_free(c) && in jffs2_scan_medium()
199 (!c->nextblock || c->nextblock->free_size < jeb->free_size)) { in jffs2_scan_medium()
211 __func__, jeb->offset); in jffs2_scan_medium()
212 c->nextblock = jeb; in jffs2_scan_medium()
214 ret = file_dirty(c, jeb); in jffs2_scan_medium()
224 jeb->offset); in jffs2_scan_medium()
225 list_add(&jeb->list, &c->erase_pending_list); in jffs2_scan_medium()
230 jffs2_dbg(1, "Block at 0x%08x is bad\n", jeb->offset); in jffs2_scan_medium()
231 list_add(&jeb->list, &c->bad_list); in jffs2_scan_medium()
310 int jffs2_scan_classify_jeb(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb) in jffs2_scan_classify_jeb() argument
312 if ((jeb->used_size + jeb->unchecked_size) == PAD(c->cleanmarker_size) && !jeb->dirty_size in jffs2_scan_classify_jeb()
313 && (!jeb->first_node || !ref_next(jeb->first_node)) ) in jffs2_scan_classify_jeb()
317 else if (!ISDIRTY(c->sector_size - (jeb->used_size + jeb->unchecked_size))) { in jffs2_scan_classify_jeb()
318 c->dirty_size -= jeb->dirty_size; in jffs2_scan_classify_jeb()
319 c->wasted_size += jeb->dirty_size; in jffs2_scan_classify_jeb()
320 jeb->wasted_size += jeb->dirty_size; in jffs2_scan_classify_jeb()
321 jeb->dirty_size = 0; in jffs2_scan_classify_jeb()
323 } else if (jeb->used_size || jeb->unchecked_size) in jffs2_scan_classify_jeb()
330 static int jffs2_scan_xattr_node(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb, in jffs2_scan_xattr_node() argument
342 if ((err = jffs2_scan_dirty_space(c, jeb, je32_to_cpu(rx->totlen)))) in jffs2_scan_xattr_node()
355 if ((err = jffs2_scan_dirty_space(c, jeb, je32_to_cpu(rx->totlen)))) in jffs2_scan_xattr_node()
366 = jffs2_link_node_ref(c, jeb, ofs | REF_PRISTINE, totlen, NULL); in jffs2_scan_xattr_node()
376 jffs2_link_node_ref(c, jeb, ofs | REF_PRISTINE, totlen, (void *)xd); in jffs2_scan_xattr_node()
380 jffs2_sum_add_xattr_mem(s, rx, ofs - jeb->offset); in jffs2_scan_xattr_node()
386 static int jffs2_scan_xref_node(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb, in jffs2_scan_xref_node() argument
398 if ((err = jffs2_scan_dirty_space(c, jeb, PAD(je32_to_cpu(rr->totlen))))) in jffs2_scan_xref_node()
407 if ((err = jffs2_scan_dirty_space(c, jeb, je32_to_cpu(rr->totlen)))) in jffs2_scan_xref_node()
433 jffs2_link_node_ref(c, jeb, ofs | REF_PRISTINE, PAD(je32_to_cpu(rr->totlen)), (void *)ref); in jffs2_scan_xref_node()
436 jffs2_sum_add_xref_mem(s, rr, ofs - jeb->offset); in jffs2_scan_xref_node()
445 static int jffs2_scan_eraseblock (struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb, in jffs2_scan_eraseblock() argument
459 ofs = jeb->offset; in jffs2_scan_eraseblock()
460 prevofs = jeb->offset - 1; in jffs2_scan_eraseblock()
468 if (mtd_block_isbad(c->mtd, jeb->offset)) in jffs2_scan_eraseblock()
471 ret = jffs2_check_nand_cleanmarker(c, jeb); in jffs2_scan_eraseblock()
506 jeb->offset + c->sector_size - buf_len, in jffs2_scan_eraseblock()
531 jeb->offset + c->sector_size - sumlen, in jffs2_scan_eraseblock()
544 err = jffs2_sum_scan_sumnode(c, jeb, sumptr, sumlen, &pseudo_random); in jffs2_scan_eraseblock()
558 buf_ofs = jeb->offset; in jffs2_scan_eraseblock()
581 int ret = jffs2_check_oob_empty(c, jeb, cleanmarkerfound); in jffs2_scan_eraseblock()
592 jeb->offset); in jffs2_scan_eraseblock()
599 jffs2_dbg(1, "Free space at %08x ends at %08x\n", jeb->offset, in jffs2_scan_eraseblock()
600 jeb->offset + ofs); in jffs2_scan_eraseblock()
601 if ((err = jffs2_prealloc_raw_node_refs(c, jeb, 1))) in jffs2_scan_eraseblock()
603 if ((err = jffs2_scan_dirty_space(c, jeb, ofs))) in jffs2_scan_eraseblock()
608 ofs += jeb->offset; in jffs2_scan_eraseblock()
612 dbg_summary("no summary found in jeb 0x%08x. Apply original scan.\n",jeb->offset); in jffs2_scan_eraseblock()
615 while(ofs < jeb->offset + c->sector_size) { in jffs2_scan_eraseblock()
617 jffs2_dbg_acct_paranoia_check_nolock(c, jeb); in jffs2_scan_eraseblock()
620 err = jffs2_prealloc_raw_node_refs(c, jeb, 2); in jffs2_scan_eraseblock()
634 if ((err = jffs2_scan_dirty_space(c, jeb, 4))) in jffs2_scan_eraseblock()
641 if (jeb->offset + c->sector_size < ofs + sizeof(*node)) { in jffs2_scan_eraseblock()
644 jeb->offset, c->sector_size, ofs, in jffs2_scan_eraseblock()
646 if ((err = jffs2_scan_dirty_space(c, jeb, (jeb->offset + c->sector_size)-ofs))) in jffs2_scan_eraseblock()
652 buf_len = min_t(uint32_t, buf_size, jeb->offset + c->sector_size - ofs); in jffs2_scan_eraseblock()
679 if ((err = jffs2_scan_dirty_space(c, jeb, ofs-empty_start))) in jffs2_scan_eraseblock()
693 if (buf_ofs == jeb->offset && jeb->used_size == PAD(c->cleanmarker_size) && in jffs2_scan_eraseblock()
694 c->cleanmarker_size && !jeb->dirty_size && !ref_next(jeb->first_node)) { in jffs2_scan_eraseblock()
705 buf_len = min_t(uint32_t, buf_size, jeb->offset + c->sector_size - ofs); in jffs2_scan_eraseblock()
724 if (ofs == jeb->offset && je16_to_cpu(node->magic) == KSAMTIB_CIGAM_2SFFJ) { in jffs2_scan_eraseblock()
727 if ((err = jffs2_scan_dirty_space(c, jeb, 4))) in jffs2_scan_eraseblock()
734 if ((err = jffs2_scan_dirty_space(c, jeb, 4))) in jffs2_scan_eraseblock()
742 if ((err = jffs2_scan_dirty_space(c, jeb, 4))) in jffs2_scan_eraseblock()
753 if ((err = jffs2_scan_dirty_space(c, jeb, 4))) in jffs2_scan_eraseblock()
772 if ((err = jffs2_scan_dirty_space(c, jeb, 4))) in jffs2_scan_eraseblock()
778 if (ofs + je32_to_cpu(node->totlen) > jeb->offset + c->sector_size) { in jffs2_scan_eraseblock()
783 if ((err = jffs2_scan_dirty_space(c, jeb, 4))) in jffs2_scan_eraseblock()
793 if ((err = jffs2_scan_dirty_space(c, jeb, PAD(je32_to_cpu(node->totlen))))) in jffs2_scan_eraseblock()
802 buf_len = min_t(uint32_t, buf_size, jeb->offset + c->sector_size - ofs); in jffs2_scan_eraseblock()
812 err = jffs2_scan_inode_node(c, jeb, (void *)node, ofs, s); in jffs2_scan_eraseblock()
819 buf_len = min_t(uint32_t, buf_size, jeb->offset + c->sector_size - ofs); in jffs2_scan_eraseblock()
829 err = jffs2_scan_dirent_node(c, jeb, (void *)node, ofs, s); in jffs2_scan_eraseblock()
837 buf_len = min_t(uint32_t, buf_size, jeb->offset + c->sector_size - ofs); in jffs2_scan_eraseblock()
847 err = jffs2_scan_xattr_node(c, jeb, (void *)node, ofs, s); in jffs2_scan_eraseblock()
854 buf_len = min_t(uint32_t, buf_size, jeb->offset + c->sector_size - ofs); in jffs2_scan_eraseblock()
864 err = jffs2_scan_xref_node(c, jeb, (void *)node, ofs, s); in jffs2_scan_eraseblock()
877 if ((err = jffs2_scan_dirty_space(c, jeb, PAD(sizeof(struct jffs2_unknown_node))))) in jffs2_scan_eraseblock()
880 } else if (jeb->first_node) { in jffs2_scan_eraseblock()
882 ofs, jeb->offset); in jffs2_scan_eraseblock()
883 if ((err = jffs2_scan_dirty_space(c, jeb, PAD(sizeof(struct jffs2_unknown_node))))) in jffs2_scan_eraseblock()
887 jffs2_link_node_ref(c, jeb, ofs | REF_NORMAL, c->cleanmarker_size, NULL); in jffs2_scan_eraseblock()
896 if ((err = jffs2_scan_dirty_space(c, jeb, PAD(je32_to_cpu(node->totlen))))) in jffs2_scan_eraseblock()
909 if ((err = jffs2_scan_dirty_space(c, jeb, PAD(je32_to_cpu(node->totlen))))) in jffs2_scan_eraseblock()
922 if ((err = jffs2_scan_dirty_space(c, jeb, PAD(je32_to_cpu(node->totlen))))) in jffs2_scan_eraseblock()
931 jffs2_link_node_ref(c, jeb, ofs | REF_PRISTINE, PAD(je32_to_cpu(node->totlen)), NULL); in jffs2_scan_eraseblock()
943 if (PAD(s->sum_size + JFFS2_SUMMARY_FRAME_SIZE) > jeb->free_size) { in jffs2_scan_eraseblock()
951 jeb->offset, jeb->free_size, jeb->dirty_size, in jffs2_scan_eraseblock()
952 jeb->unchecked_size, jeb->used_size, jeb->wasted_size); in jffs2_scan_eraseblock()
955 if (jeb->wasted_size) { in jffs2_scan_eraseblock()
956 jeb->dirty_size += jeb->wasted_size; in jffs2_scan_eraseblock()
957 c->dirty_size += jeb->wasted_size; in jffs2_scan_eraseblock()
958 c->wasted_size -= jeb->wasted_size; in jffs2_scan_eraseblock()
959 jeb->wasted_size = 0; in jffs2_scan_eraseblock()
962 return jffs2_scan_classify_jeb(c, jeb); in jffs2_scan_eraseblock()
991 static int jffs2_scan_inode_node(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb, in jffs2_scan_inode_node() argument
1017 return jffs2_scan_dirty_space(c, jeb, in jffs2_scan_inode_node()
1029 jffs2_link_node_ref(c, jeb, ofs | REF_UNCHECKED, PAD(je32_to_cpu(ri->totlen)), ic); in jffs2_scan_inode_node()
1039 jffs2_sum_add_inode_mem(s, ri, ofs - jeb->offset); in jffs2_scan_inode_node()
1045 static int jffs2_scan_dirent_node(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb, in jffs2_scan_dirent_node() argument
1064 if ((err = jffs2_scan_dirty_space(c, jeb, PAD(je32_to_cpu(rd->totlen))))) in jffs2_scan_dirent_node()
1093 if ((err = jffs2_scan_dirty_space(c, jeb, PAD(je32_to_cpu(rd->totlen))))) in jffs2_scan_dirent_node()
1103 fd->raw = jffs2_link_node_ref(c, jeb, ofs | dirent_node_state(rd), in jffs2_scan_dirent_node()
1114 jffs2_sum_add_dirent_mem(s, rd, ofs - jeb->offset); in jffs2_scan_dirent_node()