Lines Matching refs:fmc
26 static int jffs_mark_obsolete(struct jffs_fmcontrol *fmc, __u32 fm_offset);
36 struct jffs_fmcontrol *fmc; in jffs_build_begin() local
40 fmc = (struct jffs_fmcontrol *)kmalloc(sizeof(struct jffs_fmcontrol), in jffs_build_begin()
42 if (!fmc) { in jffs_build_begin()
52 kfree(fmc); in jffs_build_begin()
58 fmc->flash_size = mtd->size; in jffs_build_begin()
59 D3(printk(" fmc->flash_size = %d bytes\n", fmc->flash_size)); in jffs_build_begin()
61 fmc->used_size = 0; in jffs_build_begin()
62 fmc->dirty_size = 0; in jffs_build_begin()
63 fmc->free_size = mtd->size; in jffs_build_begin()
64 fmc->sector_size = mtd->erasesize; in jffs_build_begin()
65 fmc->max_chunk_size = fmc->sector_size >> 1; in jffs_build_begin()
78 fmc->min_free_size = fmc->sector_size << 2; in jffs_build_begin()
79 fmc->mtd = mtd; in jffs_build_begin()
80 fmc->c = c; in jffs_build_begin()
81 fmc->head = 0; in jffs_build_begin()
82 fmc->tail = 0; in jffs_build_begin()
83 fmc->head_extra = 0; in jffs_build_begin()
84 fmc->tail_extra = 0; in jffs_build_begin()
85 init_MUTEX(&fmc->biglock); in jffs_build_begin()
86 return fmc; in jffs_build_begin()
93 jffs_build_end(struct jffs_fmcontrol *fmc) in jffs_build_end() argument
97 if (!fmc->head) { in jffs_build_end()
98 fmc->head = fmc->head_extra; in jffs_build_end()
99 fmc->tail = fmc->tail_extra; in jffs_build_end()
101 else if (fmc->head_extra) { in jffs_build_end()
102 fmc->tail_extra->next = fmc->head; in jffs_build_end()
103 fmc->head->prev = fmc->tail_extra; in jffs_build_end()
104 fmc->head = fmc->head_extra; in jffs_build_end()
106 fmc->head_extra = 0; /* These two instructions should be omitted. */ in jffs_build_end()
107 fmc->tail_extra = 0; in jffs_build_end()
108 D3(jffs_print_fmcontrol(fmc)); in jffs_build_end()
115 jffs_cleanup_fmcontrol(struct jffs_fmcontrol *fmc) in jffs_cleanup_fmcontrol() argument
117 if (fmc) { in jffs_cleanup_fmcontrol()
119 struct jffs_fm *next = fmc->head; in jffs_cleanup_fmcontrol()
125 put_mtd_device(fmc->mtd); in jffs_cleanup_fmcontrol()
126 kfree(fmc); in jffs_cleanup_fmcontrol()
136 jffs_free_size1(struct jffs_fmcontrol *fmc) in jffs_free_size1() argument
140 __u32 end = fmc->flash_size; in jffs_free_size1()
142 if (!fmc->head) { in jffs_free_size1()
144 return fmc->flash_size; in jffs_free_size1()
148 head = fmc->head->offset; in jffs_free_size1()
149 tail = fmc->tail->offset + fmc->tail->size; in jffs_free_size1()
178 jffs_free_size2(struct jffs_fmcontrol *fmc) in jffs_free_size2() argument
180 if (fmc->head) { in jffs_free_size2()
181 __u32 head = fmc->head->offset; in jffs_free_size2()
182 __u32 tail = fmc->tail->offset + fmc->tail->size; in jffs_free_size2()
183 if (tail == fmc->flash_size) { in jffs_free_size2()
199 jffs_fmalloc(struct jffs_fmcontrol *fmc, __u32 size, struct jffs_node *node, in jffs_fmalloc() argument
207 "node = 0x%p\n", fmc, size, node)); in jffs_fmalloc()
216 free_chunk_size1 = jffs_free_size1(fmc); in jffs_fmalloc()
217 free_chunk_size2 = jffs_free_size2(fmc); in jffs_fmalloc()
218 if (free_chunk_size1 + free_chunk_size2 != fmc->free_size) { in jffs_fmalloc()
220 …hunk_size2 == 0x%x, fmc->free_size == 0x%x\n", free_chunk_size1, free_chunk_size2, fmc->free_size); in jffs_fmalloc()
239 if (fmc->tail) { in jffs_fmalloc()
240 fm->offset = fmc->tail->offset + fmc->tail->size; in jffs_fmalloc()
241 if (fm->offset == fmc->flash_size) { in jffs_fmalloc()
244 ASSERT(else if (fm->offset > fmc->flash_size) { in jffs_fmalloc()
256 fmc->free_size -= size; in jffs_fmalloc()
257 fmc->used_size += size; in jffs_fmalloc()
266 fm->offset = fmc->tail->offset + fmc->tail->size; in jffs_fmalloc()
269 fmc->free_size -= fm->size; in jffs_fmalloc()
270 fmc->dirty_size += fm->size; /* Changed by simonk. This seemingly fixes a in jffs_fmalloc()
278 if (!fmc->head) { in jffs_fmalloc()
280 fmc->head = fm; in jffs_fmalloc()
281 fmc->tail = fm; in jffs_fmalloc()
284 fm->prev = fmc->tail; in jffs_fmalloc()
285 fmc->tail->next = fm; in jffs_fmalloc()
286 fmc->tail = fm; in jffs_fmalloc()
289 D3(jffs_print_fmcontrol(fmc)); in jffs_fmalloc()
301 jffs_fmfree(struct jffs_fmcontrol *fmc, struct jffs_fm *fm, struct jffs_node *node) in jffs_fmfree() argument
310 ASSERT(if (!fmc || !fm || !fm->nodes) { in jffs_fmfree()
313 fmc, fm, (fm ? fm->nodes : 0)); in jffs_fmfree()
339 fmc->used_size -= fm->size; in jffs_fmfree()
340 fmc->dirty_size += fm->size; in jffs_fmfree()
342 if (jffs_mark_obsolete(fmc, fm->offset) < 0) { in jffs_fmfree()
362 jffs_fmalloced(struct jffs_fmcontrol *fmc, __u32 offset, __u32 size, in jffs_fmalloced() argument
371 fmc, offset, size, node)); in jffs_fmalloced()
392 fmc->used_size += size; in jffs_fmalloced()
393 fmc->free_size -= size; in jffs_fmalloced()
397 fmc->dirty_size += size; in jffs_fmalloced()
398 fmc->free_size -= size; in jffs_fmalloced()
401 if (fmc->head_extra) { in jffs_fmalloced()
402 fm->prev = fmc->tail_extra; in jffs_fmalloced()
403 fmc->tail_extra->next = fm; in jffs_fmalloced()
404 fmc->tail_extra = fm; in jffs_fmalloced()
406 else if (!fmc->head) { in jffs_fmalloced()
407 fmc->head = fm; in jffs_fmalloced()
408 fmc->tail = fm; in jffs_fmalloced()
410 else if (fmc->tail->offset + fmc->tail->size < offset) { in jffs_fmalloced()
411 fmc->head_extra = fm; in jffs_fmalloced()
412 fmc->tail_extra = fm; in jffs_fmalloced()
415 fm->prev = fmc->tail; in jffs_fmalloced()
416 fmc->tail->next = fm; in jffs_fmalloced()
417 fmc->tail = fm; in jffs_fmalloced()
419 D3(jffs_print_fmcontrol(fmc)); in jffs_fmalloced()
448 jffs_fmfree_partly(struct jffs_fmcontrol *fmc, struct jffs_fm *fm, __u32 size) in jffs_fmfree_partly() argument
460 fmc->used_size -= fm->size; in jffs_fmfree_partly()
461 if (fm == fmc->tail) { in jffs_fmfree_partly()
463 fmc->free_size += size; in jffs_fmfree_partly()
465 fmc->dirty_size += fm->size; in jffs_fmfree_partly()
474 jffs_cut_node(struct jffs_fmcontrol *fmc, __u32 size) in jffs_cut_node() argument
483 ASSERT(if (!fmc) { in jffs_cut_node()
488 fm = fmc->head; in jffs_cut_node()
510 jffs_sync_erase(struct jffs_fmcontrol *fmc, int erased_size) in jffs_sync_erase() argument
515 ASSERT(if (!fmc) { in jffs_sync_erase()
520 fmc->dirty_size -= erased_size; in jffs_sync_erase()
521 fmc->free_size += erased_size; in jffs_sync_erase()
523 for (fm = fmc->head; fm && (erased_size > 0);) { in jffs_sync_erase()
529 fmc->head = fm; in jffs_sync_erase()
543 jffs_get_oldest_node(struct jffs_fmcontrol *fmc) in jffs_get_oldest_node() argument
549 ASSERT(if (!fmc) { in jffs_get_oldest_node()
554 for (fm = fmc->head; fm && !fm->nodes; fm = fm->next); in jffs_get_oldest_node()
581 jffs_mark_obsolete(struct jffs_fmcontrol *fmc, __u32 fm_offset) in jffs_mark_obsolete() argument
591 ASSERT(if (!fmc) { in jffs_mark_obsolete()
598 MTD_WRITE(fmc->mtd, accurate_pos, 1, &len, &zero); in jffs_mark_obsolete()
639 jffs_erasable_size(struct jffs_fmcontrol *fmc) in jffs_erasable_size() argument
645 ASSERT(if (!fmc) { in jffs_erasable_size()
650 if (!fmc->head) { in jffs_erasable_size()
657 for (fm = fmc->head; fm && !fm->nodes; fm = fm->next) { in jffs_erasable_size()
668 ret = jffs_flash_erasable_size(fmc->mtd, fmc->head->offset, size); in jffs_erasable_size()
674 fmc->head->offset); in jffs_erasable_size()
686 struct jffs_fm *head = fmc->head; in jffs_erasable_size()
746 jffs_print_fmcontrol(struct jffs_fmcontrol *fmc) in jffs_print_fmcontrol() argument
748 D(printk("struct jffs_fmcontrol: 0x%p\n", fmc)); in jffs_print_fmcontrol()
750 D(printk(" %u, /* flash_size */\n", fmc->flash_size)); in jffs_print_fmcontrol()
751 D(printk(" %u, /* used_size */\n", fmc->used_size)); in jffs_print_fmcontrol()
752 D(printk(" %u, /* dirty_size */\n", fmc->dirty_size)); in jffs_print_fmcontrol()
753 D(printk(" %u, /* free_size */\n", fmc->free_size)); in jffs_print_fmcontrol()
754 D(printk(" %u, /* sector_size */\n", fmc->sector_size)); in jffs_print_fmcontrol()
755 D(printk(" %u, /* min_free_size */\n", fmc->min_free_size)); in jffs_print_fmcontrol()
756 D(printk(" %u, /* max_chunk_size */\n", fmc->max_chunk_size)); in jffs_print_fmcontrol()
757 D(printk(" 0x%p, /* mtd */\n", fmc->mtd)); in jffs_print_fmcontrol()
760 fmc->head, (fmc->head ? fmc->head->offset : 0))); in jffs_print_fmcontrol()
763 fmc->tail, in jffs_print_fmcontrol()
764 (fmc->tail ? fmc->tail->offset + fmc->tail->size : 0))); in jffs_print_fmcontrol()
765 D(printk(" 0x%p, /* head_extra */\n", fmc->head_extra)); in jffs_print_fmcontrol()
766 D(printk(" 0x%p, /* tail_extra */\n", fmc->tail_extra)); in jffs_print_fmcontrol()