Lines Matching refs:jeb

37 static int jffs2_scan_eraseblock (struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb,
44 static int jffs2_scan_inode_node(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb,
46 static int jffs2_scan_dirent_node(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb,
67 static int file_dirty(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb) in file_dirty() argument
71 if ((ret = jffs2_prealloc_raw_node_refs(c, jeb, 1))) in file_dirty()
73 if ((ret = jffs2_scan_dirty_space(c, jeb, jeb->free_size))) in file_dirty()
77 jeb->dirty_size += jeb->wasted_size; in file_dirty()
78 c->dirty_size += jeb->wasted_size; in file_dirty()
79 c->wasted_size -= jeb->wasted_size; in file_dirty()
80 jeb->wasted_size = 0; in file_dirty()
81 if (VERYDIRTY(c, jeb->dirty_size)) { in file_dirty()
82 list_add(&jeb->list, &c->very_dirty_list); in file_dirty()
84 list_add(&jeb->list, &c->dirty_list); in file_dirty()
140 struct jffs2_eraseblock *jeb = &c->blocks[i]; in jffs2_scan_medium() local
147 ret = jffs2_scan_eraseblock(c, jeb, buf_size?flashbuf:(flashbuf+jeb->offset), in jffs2_scan_medium()
153 jffs2_dbg_acct_paranoia_check_nolock(c, jeb); in jffs2_scan_medium()
166 list_add(&jeb->list, &c->erase_pending_list); in jffs2_scan_medium()
172 if (!jeb->dirty_size) { in jffs2_scan_medium()
174 list_add(&jeb->list, &c->free_list); in jffs2_scan_medium()
178 D1(printk(KERN_DEBUG "Adding all-dirty block at 0x%08x to erase_pending_list\n", jeb->offset)); in jffs2_scan_medium()
179 list_add(&jeb->list, &c->erase_pending_list); in jffs2_scan_medium()
186 list_add(&jeb->list, &c->clean_list); in jffs2_scan_medium()
193 if (jeb->free_size > min_free(c) && in jffs2_scan_medium()
194 (!c->nextblock || c->nextblock->free_size < jeb->free_size)) { in jffs2_scan_medium()
205 D1(printk(KERN_DEBUG "jffs2_scan_medium(): new nextblock = 0x%08x\n", jeb->offset)); in jffs2_scan_medium()
206 c->nextblock = jeb; in jffs2_scan_medium()
208 ret = file_dirty(c, jeb); in jffs2_scan_medium()
217 …D1(printk(KERN_NOTICE "JFFS2: Erase block at 0x%08x is not formatted. It will be erased\n", jeb->o… in jffs2_scan_medium()
218 list_add(&jeb->list, &c->erase_pending_list); in jffs2_scan_medium()
223 D1(printk(KERN_NOTICE "JFFS2: Block at 0x%08x is bad\n", jeb->offset)); in jffs2_scan_medium()
224 list_add(&jeb->list, &c->bad_list); in jffs2_scan_medium()
299 int jffs2_scan_classify_jeb(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb) in jffs2_scan_classify_jeb() argument
301 if ((jeb->used_size + jeb->unchecked_size) == PAD(c->cleanmarker_size) && !jeb->dirty_size in jffs2_scan_classify_jeb()
302 && (!jeb->first_node || !ref_next(jeb->first_node)) ) in jffs2_scan_classify_jeb()
306 else if (!ISDIRTY(c->sector_size - (jeb->used_size + jeb->unchecked_size))) { in jffs2_scan_classify_jeb()
307 c->dirty_size -= jeb->dirty_size; in jffs2_scan_classify_jeb()
308 c->wasted_size += jeb->dirty_size; in jffs2_scan_classify_jeb()
309 jeb->wasted_size += jeb->dirty_size; in jffs2_scan_classify_jeb()
310 jeb->dirty_size = 0; in jffs2_scan_classify_jeb()
312 } else if (jeb->used_size || jeb->unchecked_size) in jffs2_scan_classify_jeb()
319 static int jffs2_scan_xattr_node(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb, in jffs2_scan_xattr_node() argument
331 if ((err = jffs2_scan_dirty_space(c, jeb, je32_to_cpu(rx->totlen)))) in jffs2_scan_xattr_node()
344 if ((err = jffs2_scan_dirty_space(c, jeb, je32_to_cpu(rx->totlen)))) in jffs2_scan_xattr_node()
355 = jffs2_link_node_ref(c, jeb, ofs | REF_PRISTINE, totlen, NULL); in jffs2_scan_xattr_node()
365 jffs2_link_node_ref(c, jeb, ofs | REF_PRISTINE, totlen, (void *)xd); in jffs2_scan_xattr_node()
369 jffs2_sum_add_xattr_mem(s, rx, ofs - jeb->offset); in jffs2_scan_xattr_node()
375 static int jffs2_scan_xref_node(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb, in jffs2_scan_xref_node() argument
387 if ((err = jffs2_scan_dirty_space(c, jeb, PAD(je32_to_cpu(rr->totlen))))) in jffs2_scan_xref_node()
396 if ((err = jffs2_scan_dirty_space(c, jeb, je32_to_cpu(rr->totlen)))) in jffs2_scan_xref_node()
422 jffs2_link_node_ref(c, jeb, ofs | REF_PRISTINE, PAD(je32_to_cpu(rr->totlen)), (void *)ref); in jffs2_scan_xref_node()
425 jffs2_sum_add_xref_mem(s, rr, ofs - jeb->offset); in jffs2_scan_xref_node()
434 static int jffs2_scan_eraseblock (struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb, in jffs2_scan_eraseblock() argument
448 ofs = jeb->offset; in jffs2_scan_eraseblock()
449 prevofs = jeb->offset - 1; in jffs2_scan_eraseblock()
457 if (c->mtd->block_isbad(c->mtd, jeb->offset)) in jffs2_scan_eraseblock()
460 ret = jffs2_check_nand_cleanmarker(c, jeb); in jffs2_scan_eraseblock()
495 jeb->offset + c->sector_size - buf_len, in jffs2_scan_eraseblock()
516 jeb->offset + c->sector_size - sumlen, in jffs2_scan_eraseblock()
526 err = jffs2_sum_scan_sumnode(c, jeb, sumptr, sumlen, &pseudo_random); in jffs2_scan_eraseblock()
539 buf_ofs = jeb->offset; in jffs2_scan_eraseblock()
562 int ret = jffs2_check_oob_empty(c, jeb, cleanmarkerfound); in jffs2_scan_eraseblock()
571 D1(printk(KERN_DEBUG "Block at 0x%08x is empty (erased)\n", jeb->offset)); in jffs2_scan_eraseblock()
578 D1(printk(KERN_DEBUG "Free space at %08x ends at %08x\n", jeb->offset, in jffs2_scan_eraseblock()
579 jeb->offset + ofs)); in jffs2_scan_eraseblock()
580 if ((err = jffs2_prealloc_raw_node_refs(c, jeb, 1))) in jffs2_scan_eraseblock()
582 if ((err = jffs2_scan_dirty_space(c, jeb, ofs))) in jffs2_scan_eraseblock()
587 ofs += jeb->offset; in jffs2_scan_eraseblock()
591 dbg_summary("no summary found in jeb 0x%08x. Apply original scan.\n",jeb->offset); in jffs2_scan_eraseblock()
594 while(ofs < jeb->offset + c->sector_size) { in jffs2_scan_eraseblock()
596 jffs2_dbg_acct_paranoia_check_nolock(c, jeb); in jffs2_scan_eraseblock()
599 err = jffs2_prealloc_raw_node_refs(c, jeb, 2); in jffs2_scan_eraseblock()
612 if ((err = jffs2_scan_dirty_space(c, jeb, 4))) in jffs2_scan_eraseblock()
619 if (jeb->offset + c->sector_size < ofs + sizeof(*node)) { in jffs2_scan_eraseblock()
621 jeb->offset, c->sector_size, ofs, sizeof(*node))); in jffs2_scan_eraseblock()
622 if ((err = jffs2_scan_dirty_space(c, jeb, (jeb->offset + c->sector_size)-ofs))) in jffs2_scan_eraseblock()
628 buf_len = min_t(uint32_t, buf_size, jeb->offset + c->sector_size - ofs); in jffs2_scan_eraseblock()
654 if ((err = jffs2_scan_dirty_space(c, jeb, ofs-empty_start))) in jffs2_scan_eraseblock()
667 if (buf_ofs == jeb->offset && jeb->used_size == PAD(c->cleanmarker_size) && in jffs2_scan_eraseblock()
668 c->cleanmarker_size && !jeb->dirty_size && !ref_next(jeb->first_node)) { in jffs2_scan_eraseblock()
678 buf_len = min_t(uint32_t, buf_size, jeb->offset + c->sector_size - ofs); in jffs2_scan_eraseblock()
696 if (ofs == jeb->offset && je16_to_cpu(node->magic) == KSAMTIB_CIGAM_2SFFJ) { in jffs2_scan_eraseblock()
698 if ((err = jffs2_scan_dirty_space(c, jeb, 4))) in jffs2_scan_eraseblock()
705 if ((err = jffs2_scan_dirty_space(c, jeb, 4))) in jffs2_scan_eraseblock()
713 if ((err = jffs2_scan_dirty_space(c, jeb, 4))) in jffs2_scan_eraseblock()
723 if ((err = jffs2_scan_dirty_space(c, jeb, 4))) in jffs2_scan_eraseblock()
741 if ((err = jffs2_scan_dirty_space(c, jeb, 4))) in jffs2_scan_eraseblock()
747 if (ofs + je32_to_cpu(node->totlen) > jeb->offset + c->sector_size) { in jffs2_scan_eraseblock()
752 if ((err = jffs2_scan_dirty_space(c, jeb, 4))) in jffs2_scan_eraseblock()
761 if ((err = jffs2_scan_dirty_space(c, jeb, PAD(je32_to_cpu(node->totlen))))) in jffs2_scan_eraseblock()
770 buf_len = min_t(uint32_t, buf_size, jeb->offset + c->sector_size - ofs); in jffs2_scan_eraseblock()
779 err = jffs2_scan_inode_node(c, jeb, (void *)node, ofs, s); in jffs2_scan_eraseblock()
786 buf_len = min_t(uint32_t, buf_size, jeb->offset + c->sector_size - ofs); in jffs2_scan_eraseblock()
795 err = jffs2_scan_dirent_node(c, jeb, (void *)node, ofs, s); in jffs2_scan_eraseblock()
803 buf_len = min_t(uint32_t, buf_size, jeb->offset + c->sector_size - ofs); in jffs2_scan_eraseblock()
813 err = jffs2_scan_xattr_node(c, jeb, (void *)node, ofs, s); in jffs2_scan_eraseblock()
820 buf_len = min_t(uint32_t, buf_size, jeb->offset + c->sector_size - ofs); in jffs2_scan_eraseblock()
830 err = jffs2_scan_xref_node(c, jeb, (void *)node, ofs, s); in jffs2_scan_eraseblock()
842 if ((err = jffs2_scan_dirty_space(c, jeb, PAD(sizeof(struct jffs2_unknown_node))))) in jffs2_scan_eraseblock()
845 } else if (jeb->first_node) { in jffs2_scan_eraseblock()
846 …N_NOTICE "CLEANMARKER node found at 0x%08x, not first node in block (0x%08x)\n", ofs, jeb->offset); in jffs2_scan_eraseblock()
847 if ((err = jffs2_scan_dirty_space(c, jeb, PAD(sizeof(struct jffs2_unknown_node))))) in jffs2_scan_eraseblock()
851 jffs2_link_node_ref(c, jeb, ofs | REF_NORMAL, c->cleanmarker_size, NULL); in jffs2_scan_eraseblock()
860 if ((err = jffs2_scan_dirty_space(c, jeb, PAD(je32_to_cpu(node->totlen))))) in jffs2_scan_eraseblock()
872 if ((err = jffs2_scan_dirty_space(c, jeb, PAD(je32_to_cpu(node->totlen))))) in jffs2_scan_eraseblock()
883 if ((err = jffs2_scan_dirty_space(c, jeb, PAD(je32_to_cpu(node->totlen))))) in jffs2_scan_eraseblock()
891 jffs2_link_node_ref(c, jeb, ofs | REF_PRISTINE, PAD(je32_to_cpu(node->totlen)), NULL); in jffs2_scan_eraseblock()
903 if (PAD(s->sum_size + JFFS2_SUMMARY_FRAME_SIZE) > jeb->free_size) { in jffs2_scan_eraseblock()
911jeb->offset,jeb->free_size, jeb->dirty_size, jeb->unchecked_size, jeb->used_size, jeb->wasted_size… in jffs2_scan_eraseblock()
914 if (jeb->wasted_size) { in jffs2_scan_eraseblock()
915 jeb->dirty_size += jeb->wasted_size; in jffs2_scan_eraseblock()
916 c->dirty_size += jeb->wasted_size; in jffs2_scan_eraseblock()
917 c->wasted_size -= jeb->wasted_size; in jffs2_scan_eraseblock()
918 jeb->wasted_size = 0; in jffs2_scan_eraseblock()
921 return jffs2_scan_classify_jeb(c, jeb); in jffs2_scan_eraseblock()
950 static int jffs2_scan_inode_node(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb, in jffs2_scan_inode_node() argument
977 return jffs2_scan_dirty_space(c, jeb, in jffs2_scan_inode_node()
989 jffs2_link_node_ref(c, jeb, ofs | REF_UNCHECKED, PAD(je32_to_cpu(ri->totlen)), ic); in jffs2_scan_inode_node()
999 jffs2_sum_add_inode_mem(s, ri, ofs - jeb->offset); in jffs2_scan_inode_node()
1005 static int jffs2_scan_dirent_node(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb, in jffs2_scan_dirent_node() argument
1024 if ((err = jffs2_scan_dirty_space(c, jeb, PAD(je32_to_cpu(rd->totlen))))) in jffs2_scan_dirent_node()
1052 if ((err = jffs2_scan_dirty_space(c, jeb, PAD(je32_to_cpu(rd->totlen))))) in jffs2_scan_dirent_node()
1062 fd->raw = jffs2_link_node_ref(c, jeb, ofs | dirent_node_state(rd), in jffs2_scan_dirent_node()
1073 jffs2_sum_add_dirent_mem(s, rd, ofs - jeb->offset); in jffs2_scan_dirent_node()