Lines Matching refs:c
65 static int jffs2_do_reserve_space(struct jffs2_sb_info *c, __u32 minsize, __u32 *ofs, __u32 *len);
67 int jffs2_reserve_space(struct jffs2_sb_info *c, __u32 minsize, __u32 *ofs, __u32 *len, int prio) in jffs2_reserve_space() argument
78 down(&c->alloc_sem); in jffs2_reserve_space()
82 spin_lock_bh(&c->erase_completion_lock); in jffs2_reserve_space()
86 while(c->nr_free_blocks + c->nr_erasing_blocks < blocksneeded) { in jffs2_reserve_space()
89 up(&c->alloc_sem); in jffs2_reserve_space()
90 if (c->dirty_size < c->sector_size) { in jffs2_reserve_space()
91 …e, but total dirty size 0x%08x < sector size 0x%08x, so -ENOSPC\n", c->dirty_size, c->sector_size)… in jffs2_reserve_space()
92 spin_unlock_bh(&c->erase_completion_lock); in jffs2_reserve_space()
96 …c->nr_free_blocks, c->nr_erasing_blocks, c->free_size, c->dirty_size, c->used_size, c->erasing_siz… in jffs2_reserve_space()
97 c->free_size + c->dirty_size + c->used_size + c->erasing_size + c->bad_size, c->flash_size)); in jffs2_reserve_space()
98 spin_unlock_bh(&c->erase_completion_lock); in jffs2_reserve_space()
100 ret = jffs2_garbage_collect_pass(c); in jffs2_reserve_space()
110 down(&c->alloc_sem); in jffs2_reserve_space()
111 spin_lock_bh(&c->erase_completion_lock); in jffs2_reserve_space()
114 ret = jffs2_do_reserve_space(c, minsize, ofs, len); in jffs2_reserve_space()
119 spin_unlock_bh(&c->erase_completion_lock); in jffs2_reserve_space()
121 up(&c->alloc_sem); in jffs2_reserve_space()
125 int jffs2_reserve_space_gc(struct jffs2_sb_info *c, __u32 minsize, __u32 *ofs, __u32 *len) in jffs2_reserve_space_gc() argument
132 spin_lock_bh(&c->erase_completion_lock); in jffs2_reserve_space_gc()
134 ret = jffs2_do_reserve_space(c, minsize, ofs, len); in jffs2_reserve_space_gc()
139 spin_unlock_bh(&c->erase_completion_lock); in jffs2_reserve_space_gc()
144 static int jffs2_do_reserve_space(struct jffs2_sb_info *c, __u32 minsize, __u32 *ofs, __u32 *len) in jffs2_do_reserve_space() argument
146 struct jffs2_eraseblock *jeb = c->nextblock; in jffs2_do_reserve_space()
151 c->dirty_size += jeb->free_size; in jffs2_do_reserve_space()
152 c->free_size -= jeb->free_size; in jffs2_do_reserve_space()
157 list_add_tail(&jeb->list, &c->dirty_list); in jffs2_do_reserve_space()
158 c->nextblock = jeb = NULL; in jffs2_do_reserve_space()
165 if (list_empty(&c->free_list)) { in jffs2_do_reserve_space()
169 if (!c->nr_erasing_blocks) { in jffs2_do_reserve_space()
174 …c->nr_erasing_blocks, c->nr_free_blocks, list_empty(&c->erasing_list)?"yes":"no", list_empty(&c->e… in jffs2_do_reserve_space()
180 add_wait_queue(&c->erase_wait, &wait); in jffs2_do_reserve_space()
182 …c->nr_erasing_blocks, list_empty(&c->erasing_list)?"yes":"no", list_empty(&c->erase_pending_list)?… in jffs2_do_reserve_space()
183 if (!list_empty(&c->erase_pending_list)) { in jffs2_do_reserve_space()
185 jffs2_erase_pending_trigger(c); in jffs2_do_reserve_space()
187 spin_unlock_bh(&c->erase_completion_lock); in jffs2_do_reserve_space()
189 remove_wait_queue(&c->erase_wait, &wait); in jffs2_do_reserve_space()
190 spin_lock_bh(&c->erase_completion_lock); in jffs2_do_reserve_space()
200 next = c->free_list.next; in jffs2_do_reserve_space()
202 c->nextblock = jeb = list_entry(next, struct jffs2_eraseblock, list); in jffs2_do_reserve_space()
203 c->nr_free_blocks--; in jffs2_do_reserve_space()
204 if (jeb->free_size != c->sector_size - sizeof(struct jffs2_unknown_node)) { in jffs2_do_reserve_space()
211 *ofs = jeb->offset + (c->sector_size - jeb->free_size); in jffs2_do_reserve_space()
230 int jffs2_add_physical_node_ref(struct jffs2_sb_info *c, struct jffs2_raw_node_ref *new, __u32 len,… in jffs2_add_physical_node_ref() argument
235 jeb = &c->blocks[(new->flash_offset & ~3) / c->sector_size]; in jffs2_add_physical_node_ref()
238 …if (jeb != c->nextblock || (new->flash_offset & ~3) != jeb->offset + (c->sector_size - jeb->free_s… in jffs2_add_physical_node_ref()
250 spin_lock_bh(&c->erase_completion_lock); in jffs2_add_physical_node_ref()
252 c->free_size -= len; in jffs2_add_physical_node_ref()
256 c->dirty_size += len; in jffs2_add_physical_node_ref()
259 c->used_size += len; in jffs2_add_physical_node_ref()
261 spin_unlock_bh(&c->erase_completion_lock); in jffs2_add_physical_node_ref()
266 list_add_tail(&jeb->list, &c->clean_list); in jffs2_add_physical_node_ref()
267 c->nextblock = NULL; in jffs2_add_physical_node_ref()
269 ACCT_SANITY_CHECK(c,jeb); in jffs2_add_physical_node_ref()
276 void jffs2_complete_reservation(struct jffs2_sb_info *c) in jffs2_complete_reservation() argument
279 jffs2_garbage_collect_trigger(c); in jffs2_complete_reservation()
280 up(&c->alloc_sem); in jffs2_complete_reservation()
283 void jffs2_mark_node_obsolete(struct jffs2_sb_info *c, struct jffs2_raw_node_ref *ref) in jffs2_mark_node_obsolete() argument
299 blocknr = ref->flash_offset / c->sector_size; in jffs2_mark_node_obsolete()
300 if (blocknr >= c->nr_blocks) { in jffs2_mark_node_obsolete()
304 jeb = &c->blocks[blocknr]; in jffs2_mark_node_obsolete()
311 spin_lock_bh(&c->erase_completion_lock); in jffs2_mark_node_obsolete()
314 c->used_size -= ref->totlen; in jffs2_mark_node_obsolete()
315 c->dirty_size += ref->totlen; in jffs2_mark_node_obsolete()
318 ACCT_SANITY_CHECK(c, jeb); in jffs2_mark_node_obsolete()
322 if (c->flags & JFFS2_SB_FLAG_MOUNTING) { in jffs2_mark_node_obsolete()
328 spin_unlock_bh(&c->erase_completion_lock); in jffs2_mark_node_obsolete()
331 if (jeb == c->nextblock) { in jffs2_mark_node_obsolete()
333 } else if (jeb == c->gcblock) { in jffs2_mark_node_obsolete()
345 list_add_tail(&jeb->list, &c->erase_pending_list); in jffs2_mark_node_obsolete()
346 c->nr_erasing_blocks++; in jffs2_mark_node_obsolete()
347 jffs2_erase_pending_trigger(c); in jffs2_mark_node_obsolete()
355 list_add_tail(&jeb->list, &c->dirty_list); in jffs2_mark_node_obsolete()
357 spin_unlock_bh(&c->erase_completion_lock); in jffs2_mark_node_obsolete()
359 if (c->mtd->type != MTD_NORFLASH && c->mtd->type != MTD_RAM) in jffs2_mark_node_obsolete()
361 if (OFNI_BS_2SFFJ(c)->s_flags & MS_RDONLY) in jffs2_mark_node_obsolete()
365 ret = c->mtd->read(c->mtd, ref->flash_offset &~3, sizeof(n), &retlen, (char *)&n); in jffs2_mark_node_obsolete()
383 ret = c->mtd->write(c->mtd, ref->flash_offset&~3, sizeof(n), &retlen, (char *)&n); in jffs2_mark_node_obsolete()