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()
308 int jffs2_scan_classify_jeb(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb) in jffs2_scan_classify_jeb() argument
310 if ((jeb->used_size + jeb->unchecked_size) == PAD(c->cleanmarker_size) && !jeb->dirty_size in jffs2_scan_classify_jeb()
311 && (!jeb->first_node || !ref_next(jeb->first_node)) ) in jffs2_scan_classify_jeb()
315 else if (!ISDIRTY(c->sector_size - (jeb->used_size + jeb->unchecked_size))) { in jffs2_scan_classify_jeb()
316 c->dirty_size -= jeb->dirty_size; in jffs2_scan_classify_jeb()
317 c->wasted_size += jeb->dirty_size; in jffs2_scan_classify_jeb()
318 jeb->wasted_size += jeb->dirty_size; in jffs2_scan_classify_jeb()
319 jeb->dirty_size = 0; in jffs2_scan_classify_jeb()
321 } else if (jeb->used_size || jeb->unchecked_size) in jffs2_scan_classify_jeb()
328 static int jffs2_scan_xattr_node(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb, in jffs2_scan_xattr_node() argument
340 if ((err = jffs2_scan_dirty_space(c, jeb, je32_to_cpu(rx->totlen)))) in jffs2_scan_xattr_node()
353 if ((err = jffs2_scan_dirty_space(c, jeb, je32_to_cpu(rx->totlen)))) in jffs2_scan_xattr_node()
364 = jffs2_link_node_ref(c, jeb, ofs | REF_PRISTINE, totlen, NULL); in jffs2_scan_xattr_node()
374 jffs2_link_node_ref(c, jeb, ofs | REF_PRISTINE, totlen, (void *)xd); in jffs2_scan_xattr_node()
378 jffs2_sum_add_xattr_mem(s, rx, ofs - jeb->offset); in jffs2_scan_xattr_node()
384 static int jffs2_scan_xref_node(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb, in jffs2_scan_xref_node() argument
396 if ((err = jffs2_scan_dirty_space(c, jeb, PAD(je32_to_cpu(rr->totlen))))) in jffs2_scan_xref_node()
405 if ((err = jffs2_scan_dirty_space(c, jeb, je32_to_cpu(rr->totlen)))) in jffs2_scan_xref_node()
431 jffs2_link_node_ref(c, jeb, ofs | REF_PRISTINE, PAD(je32_to_cpu(rr->totlen)), (void *)ref); in jffs2_scan_xref_node()
434 jffs2_sum_add_xref_mem(s, rr, ofs - jeb->offset); in jffs2_scan_xref_node()
443 static int jffs2_scan_eraseblock (struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb, in jffs2_scan_eraseblock() argument
457 ofs = jeb->offset; in jffs2_scan_eraseblock()
458 prevofs = jeb->offset - 1; in jffs2_scan_eraseblock()
466 if (mtd_block_isbad(c->mtd, jeb->offset)) in jffs2_scan_eraseblock()
469 ret = jffs2_check_nand_cleanmarker(c, jeb); in jffs2_scan_eraseblock()
504 jeb->offset + c->sector_size - buf_len, in jffs2_scan_eraseblock()
529 jeb->offset + c->sector_size - sumlen, in jffs2_scan_eraseblock()
542 err = jffs2_sum_scan_sumnode(c, jeb, sumptr, sumlen, &pseudo_random); in jffs2_scan_eraseblock()
556 buf_ofs = jeb->offset; in jffs2_scan_eraseblock()
579 int ret = jffs2_check_oob_empty(c, jeb, cleanmarkerfound); in jffs2_scan_eraseblock()
590 jeb->offset); in jffs2_scan_eraseblock()
597 jffs2_dbg(1, "Free space at %08x ends at %08x\n", jeb->offset, in jffs2_scan_eraseblock()
598 jeb->offset + ofs); in jffs2_scan_eraseblock()
599 if ((err = jffs2_prealloc_raw_node_refs(c, jeb, 1))) in jffs2_scan_eraseblock()
601 if ((err = jffs2_scan_dirty_space(c, jeb, ofs))) in jffs2_scan_eraseblock()
606 ofs += jeb->offset; in jffs2_scan_eraseblock()
610 dbg_summary("no summary found in jeb 0x%08x. Apply original scan.\n",jeb->offset); in jffs2_scan_eraseblock()
613 while(ofs < jeb->offset + c->sector_size) { in jffs2_scan_eraseblock()
615 jffs2_dbg_acct_paranoia_check_nolock(c, jeb); in jffs2_scan_eraseblock()
618 err = jffs2_prealloc_raw_node_refs(c, jeb, 2); in jffs2_scan_eraseblock()
632 if ((err = jffs2_scan_dirty_space(c, jeb, 4))) in jffs2_scan_eraseblock()
639 if (jeb->offset + c->sector_size < ofs + sizeof(*node)) { in jffs2_scan_eraseblock()
642 jeb->offset, c->sector_size, ofs, in jffs2_scan_eraseblock()
644 if ((err = jffs2_scan_dirty_space(c, jeb, (jeb->offset + c->sector_size)-ofs))) in jffs2_scan_eraseblock()
650 buf_len = min_t(uint32_t, buf_size, jeb->offset + c->sector_size - ofs); in jffs2_scan_eraseblock()
677 if ((err = jffs2_scan_dirty_space(c, jeb, ofs-empty_start))) in jffs2_scan_eraseblock()
691 if (buf_ofs == jeb->offset && jeb->used_size == PAD(c->cleanmarker_size) && in jffs2_scan_eraseblock()
692 c->cleanmarker_size && !jeb->dirty_size && !ref_next(jeb->first_node)) { in jffs2_scan_eraseblock()
703 buf_len = min_t(uint32_t, buf_size, jeb->offset + c->sector_size - ofs); in jffs2_scan_eraseblock()
722 if (ofs == jeb->offset && je16_to_cpu(node->magic) == KSAMTIB_CIGAM_2SFFJ) { in jffs2_scan_eraseblock()
725 if ((err = jffs2_scan_dirty_space(c, jeb, 4))) in jffs2_scan_eraseblock()
732 if ((err = jffs2_scan_dirty_space(c, jeb, 4))) in jffs2_scan_eraseblock()
740 if ((err = jffs2_scan_dirty_space(c, jeb, 4))) in jffs2_scan_eraseblock()
751 if ((err = jffs2_scan_dirty_space(c, jeb, 4))) in jffs2_scan_eraseblock()
770 if ((err = jffs2_scan_dirty_space(c, jeb, 4))) in jffs2_scan_eraseblock()
776 if (ofs + je32_to_cpu(node->totlen) > jeb->offset + c->sector_size) { in jffs2_scan_eraseblock()
781 if ((err = jffs2_scan_dirty_space(c, jeb, 4))) in jffs2_scan_eraseblock()
791 if ((err = jffs2_scan_dirty_space(c, jeb, PAD(je32_to_cpu(node->totlen))))) in jffs2_scan_eraseblock()
800 buf_len = min_t(uint32_t, buf_size, jeb->offset + c->sector_size - ofs); in jffs2_scan_eraseblock()
810 err = jffs2_scan_inode_node(c, jeb, (void *)node, ofs, s); in jffs2_scan_eraseblock()
817 buf_len = min_t(uint32_t, buf_size, jeb->offset + c->sector_size - ofs); in jffs2_scan_eraseblock()
827 err = jffs2_scan_dirent_node(c, jeb, (void *)node, ofs, s); in jffs2_scan_eraseblock()
835 buf_len = min_t(uint32_t, buf_size, jeb->offset + c->sector_size - ofs); in jffs2_scan_eraseblock()
845 err = jffs2_scan_xattr_node(c, jeb, (void *)node, ofs, s); in jffs2_scan_eraseblock()
852 buf_len = min_t(uint32_t, buf_size, jeb->offset + c->sector_size - ofs); in jffs2_scan_eraseblock()
862 err = jffs2_scan_xref_node(c, jeb, (void *)node, ofs, s); in jffs2_scan_eraseblock()
875 if ((err = jffs2_scan_dirty_space(c, jeb, PAD(sizeof(struct jffs2_unknown_node))))) in jffs2_scan_eraseblock()
878 } else if (jeb->first_node) { in jffs2_scan_eraseblock()
880 ofs, jeb->offset); in jffs2_scan_eraseblock()
881 if ((err = jffs2_scan_dirty_space(c, jeb, PAD(sizeof(struct jffs2_unknown_node))))) in jffs2_scan_eraseblock()
885 jffs2_link_node_ref(c, jeb, ofs | REF_NORMAL, c->cleanmarker_size, NULL); in jffs2_scan_eraseblock()
894 if ((err = jffs2_scan_dirty_space(c, jeb, PAD(je32_to_cpu(node->totlen))))) in jffs2_scan_eraseblock()
907 if ((err = jffs2_scan_dirty_space(c, jeb, PAD(je32_to_cpu(node->totlen))))) in jffs2_scan_eraseblock()
920 if ((err = jffs2_scan_dirty_space(c, jeb, PAD(je32_to_cpu(node->totlen))))) in jffs2_scan_eraseblock()
929 jffs2_link_node_ref(c, jeb, ofs | REF_PRISTINE, PAD(je32_to_cpu(node->totlen)), NULL); in jffs2_scan_eraseblock()
941 if (PAD(s->sum_size + JFFS2_SUMMARY_FRAME_SIZE) > jeb->free_size) { in jffs2_scan_eraseblock()
949 jeb->offset, jeb->free_size, jeb->dirty_size, in jffs2_scan_eraseblock()
950 jeb->unchecked_size, jeb->used_size, jeb->wasted_size); in jffs2_scan_eraseblock()
953 if (jeb->wasted_size) { in jffs2_scan_eraseblock()
954 jeb->dirty_size += jeb->wasted_size; in jffs2_scan_eraseblock()
955 c->dirty_size += jeb->wasted_size; in jffs2_scan_eraseblock()
956 c->wasted_size -= jeb->wasted_size; in jffs2_scan_eraseblock()
957 jeb->wasted_size = 0; in jffs2_scan_eraseblock()
960 return jffs2_scan_classify_jeb(c, jeb); in jffs2_scan_eraseblock()
989 static int jffs2_scan_inode_node(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb, in jffs2_scan_inode_node() argument
1015 return jffs2_scan_dirty_space(c, jeb, in jffs2_scan_inode_node()
1027 jffs2_link_node_ref(c, jeb, ofs | REF_UNCHECKED, PAD(je32_to_cpu(ri->totlen)), ic); in jffs2_scan_inode_node()
1037 jffs2_sum_add_inode_mem(s, ri, ofs - jeb->offset); in jffs2_scan_inode_node()
1043 static int jffs2_scan_dirent_node(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb, in jffs2_scan_dirent_node() argument
1062 if ((err = jffs2_scan_dirty_space(c, jeb, PAD(je32_to_cpu(rd->totlen))))) in jffs2_scan_dirent_node()
1091 if ((err = jffs2_scan_dirty_space(c, jeb, PAD(je32_to_cpu(rd->totlen))))) in jffs2_scan_dirent_node()
1101 fd->raw = jffs2_link_node_ref(c, jeb, ofs | dirent_node_state(rd), in jffs2_scan_dirent_node()
1112 jffs2_sum_add_dirent_mem(s, rd, ofs - jeb->offset); in jffs2_scan_dirent_node()