Lines Matching +full:offset +full:- +full:x
2 * JFFS2 -- Journalling Flash File System, Version 2.
4 * Copyright © 2001-2007 Red Hat, Inc.
5 * Copyright © 2004-2010 David Woodhouse <dwmw2@infradead.org>
39 bad_offset = jeb->offset; in jffs2_erase_block()
43 jffs2_dbg(1, "%s(): erase block %#08x (range %#08x-%#08x)\n", in jffs2_erase_block()
45 jeb->offset, jeb->offset, jeb->offset + c->sector_size); in jffs2_erase_block()
49 mutex_lock(&c->erase_free_sem); in jffs2_erase_block()
50 spin_lock(&c->erase_completion_lock); in jffs2_erase_block()
51 list_move(&jeb->list, &c->erase_pending_list); in jffs2_erase_block()
52 c->erasing_size -= c->sector_size; in jffs2_erase_block()
53 c->dirty_size += c->sector_size; in jffs2_erase_block()
54 jeb->dirty_size = c->sector_size; in jffs2_erase_block()
55 spin_unlock(&c->erase_completion_lock); in jffs2_erase_block()
56 mutex_unlock(&c->erase_free_sem); in jffs2_erase_block()
62 instr->addr = jeb->offset; in jffs2_erase_block()
63 instr->len = c->sector_size; in jffs2_erase_block()
65 ret = mtd_erase(c->mtd, instr); in jffs2_erase_block()
72 bad_offset = instr->fail_addr; in jffs2_erase_block()
76 if (ret == -ENOMEM || ret == -EAGAIN) { in jffs2_erase_block()
78 jffs2_dbg(1, "Erase at 0x%08x failed: %d. Refiling on erase_pending_list\n", in jffs2_erase_block()
79 jeb->offset, ret); in jffs2_erase_block()
80 mutex_lock(&c->erase_free_sem); in jffs2_erase_block()
81 spin_lock(&c->erase_completion_lock); in jffs2_erase_block()
82 list_move(&jeb->list, &c->erase_pending_list); in jffs2_erase_block()
83 c->erasing_size -= c->sector_size; in jffs2_erase_block()
84 c->dirty_size += c->sector_size; in jffs2_erase_block()
85 jeb->dirty_size = c->sector_size; in jffs2_erase_block()
86 spin_unlock(&c->erase_completion_lock); in jffs2_erase_block()
87 mutex_unlock(&c->erase_free_sem); in jffs2_erase_block()
91 if (ret == -EROFS) in jffs2_erase_block()
92 pr_warn("Erase at 0x%08x failed immediately: -EROFS. Is the sector locked?\n", in jffs2_erase_block()
93 jeb->offset); in jffs2_erase_block()
95 pr_warn("Erase at 0x%08x failed immediately: errno %d\n", in jffs2_erase_block()
96 jeb->offset, ret); in jffs2_erase_block()
106 mutex_lock(&c->erase_free_sem); in jffs2_erase_pending_blocks()
108 spin_lock(&c->erase_completion_lock); in jffs2_erase_pending_blocks()
110 while (!list_empty(&c->erase_complete_list) || in jffs2_erase_pending_blocks()
111 !list_empty(&c->erase_pending_list)) { in jffs2_erase_pending_blocks()
113 if (!list_empty(&c->erase_complete_list)) { in jffs2_erase_pending_blocks()
114 jeb = list_entry(c->erase_complete_list.next, struct jffs2_eraseblock, list); in jffs2_erase_pending_blocks()
115 list_move(&jeb->list, &c->erase_checking_list); in jffs2_erase_pending_blocks()
116 spin_unlock(&c->erase_completion_lock); in jffs2_erase_pending_blocks()
117 mutex_unlock(&c->erase_free_sem); in jffs2_erase_pending_blocks()
121 if (!--count) { in jffs2_erase_pending_blocks()
126 } else if (!list_empty(&c->erase_pending_list)) { in jffs2_erase_pending_blocks()
127 jeb = list_entry(c->erase_pending_list.next, struct jffs2_eraseblock, list); in jffs2_erase_pending_blocks()
128 jffs2_dbg(1, "Starting erase of pending block 0x%08x\n", in jffs2_erase_pending_blocks()
129 jeb->offset); in jffs2_erase_pending_blocks()
130 list_del(&jeb->list); in jffs2_erase_pending_blocks()
131 c->erasing_size += c->sector_size; in jffs2_erase_pending_blocks()
132 c->wasted_size -= jeb->wasted_size; in jffs2_erase_pending_blocks()
133 c->free_size -= jeb->free_size; in jffs2_erase_pending_blocks()
134 c->used_size -= jeb->used_size; in jffs2_erase_pending_blocks()
135 c->dirty_size -= jeb->dirty_size; in jffs2_erase_pending_blocks()
136 jeb->wasted_size = jeb->used_size = jeb->dirty_size = jeb->free_size = 0; in jffs2_erase_pending_blocks()
138 list_add(&jeb->list, &c->erasing_list); in jffs2_erase_pending_blocks()
139 spin_unlock(&c->erase_completion_lock); in jffs2_erase_pending_blocks()
140 mutex_unlock(&c->erase_free_sem); in jffs2_erase_pending_blocks()
150 mutex_lock(&c->erase_free_sem); in jffs2_erase_pending_blocks()
151 spin_lock(&c->erase_completion_lock); in jffs2_erase_pending_blocks()
154 spin_unlock(&c->erase_completion_lock); in jffs2_erase_pending_blocks()
155 mutex_unlock(&c->erase_free_sem); in jffs2_erase_pending_blocks()
163 jffs2_dbg(1, "Erase completed successfully at 0x%08x\n", jeb->offset); in jffs2_erase_succeeded()
164 mutex_lock(&c->erase_free_sem); in jffs2_erase_succeeded()
165 spin_lock(&c->erase_completion_lock); in jffs2_erase_succeeded()
166 list_move_tail(&jeb->list, &c->erase_complete_list); in jffs2_erase_succeeded()
169 spin_unlock(&c->erase_completion_lock); in jffs2_erase_succeeded()
170 mutex_unlock(&c->erase_free_sem); in jffs2_erase_succeeded()
171 wake_up(&c->erase_wait); in jffs2_erase_succeeded()
179 /* We had a device-level failure to erase. Let's see if we've in jffs2_erase_failed()
183 mutex_lock(&c->erase_free_sem); in jffs2_erase_failed()
184 spin_lock(&c->erase_completion_lock); in jffs2_erase_failed()
185 list_move(&jeb->list, &c->erase_pending_list); in jffs2_erase_failed()
186 c->erasing_size -= c->sector_size; in jffs2_erase_failed()
187 c->dirty_size += c->sector_size; in jffs2_erase_failed()
188 jeb->dirty_size = c->sector_size; in jffs2_erase_failed()
189 spin_unlock(&c->erase_completion_lock); in jffs2_erase_failed()
190 mutex_unlock(&c->erase_free_sem); in jffs2_erase_failed()
195 mutex_lock(&c->erase_free_sem); in jffs2_erase_failed()
196 spin_lock(&c->erase_completion_lock); in jffs2_erase_failed()
197 c->erasing_size -= c->sector_size; in jffs2_erase_failed()
198 c->bad_size += c->sector_size; in jffs2_erase_failed()
199 list_move(&jeb->list, &c->bad_list); in jffs2_erase_failed()
200 c->nr_erasing_blocks--; in jffs2_erase_failed()
201 spin_unlock(&c->erase_completion_lock); in jffs2_erase_failed()
202 mutex_unlock(&c->erase_free_sem); in jffs2_erase_failed()
203 wake_up(&c->erase_wait); in jffs2_erase_failed()
207 this a standard doubly-linked list? */
214 prev = &ref->next_in_ino; in jffs2_remove_node_refs_from_ino_list()
218 if (!(*prev)->next_in_ino) { in jffs2_remove_node_refs_from_ino_list()
223 prev = &ic->nodes; in jffs2_remove_node_refs_from_ino_list()
227 if (SECTOR_ADDR((*prev)->flash_offset) == jeb->offset) { in jffs2_remove_node_refs_from_ino_list()
232 *prev = this->next_in_ino; in jffs2_remove_node_refs_from_ino_list()
233 this->next_in_ino = NULL; in jffs2_remove_node_refs_from_ino_list()
241 prev = &((*prev)->next_in_ino); in jffs2_remove_node_refs_from_ino_list()
251 jffs2_dbg(1, "Removed nodes in range 0x%08x-0x%08x from ino #%u\n", in jffs2_remove_node_refs_from_ino_list()
252 jeb->offset, jeb->offset + c->sector_size, ic->ino); in jffs2_remove_node_refs_from_ino_list()
259 this = ic->nodes; in jffs2_remove_node_refs_from_ino_list()
263 pr_cont("0x%08x(%d)->", in jffs2_remove_node_refs_from_ino_list()
269 this = this->next_in_ino; in jffs2_remove_node_refs_from_ino_list()
274 switch (ic->class) { in jffs2_remove_node_refs_from_ino_list()
284 if (ic->nodes == (void *)ic && ic->pino_nlink == 0) in jffs2_remove_node_refs_from_ino_list()
292 jffs2_dbg(1, "Freeing all node refs for eraseblock offset 0x%08x\n", in jffs2_free_jeb_node_refs()
293 jeb->offset); in jffs2_free_jeb_node_refs()
295 block = ref = jeb->first_node; in jffs2_free_jeb_node_refs()
298 if (ref->flash_offset == REF_LINK_NODE) { in jffs2_free_jeb_node_refs()
299 ref = ref->next_in_ino; in jffs2_free_jeb_node_refs()
304 if (ref->flash_offset != REF_EMPTY_NODE && ref->next_in_ino) in jffs2_free_jeb_node_refs()
306 /* else it was a non-inode node or already removed, so don't bother */ in jffs2_free_jeb_node_refs()
310 jeb->first_node = jeb->last_node = NULL; in jffs2_free_jeb_node_refs()
321 ret = mtd_point(c->mtd, jeb->offset, c->sector_size, &retlen, in jffs2_block_check_erase()
323 if (ret != -EOPNOTSUPP) { in jffs2_block_check_erase()
328 if (retlen < c->sector_size) { in jffs2_block_check_erase()
330 jffs2_dbg(1, "MTD point returned len too short: 0x%zx\n", in jffs2_block_check_erase()
332 mtd_unpoint(c->mtd, jeb->offset, retlen); in jffs2_block_check_erase()
335 wordebuf = ebuf-sizeof(*wordebuf); in jffs2_block_check_erase()
340 } while(--retlen); in jffs2_block_check_erase()
341 mtd_unpoint(c->mtd, jeb->offset, c->sector_size); in jffs2_block_check_erase()
343 pr_warn("Newly-erased block contained word 0x%lx at offset 0x%08tx\n", in jffs2_block_check_erase()
345 jeb->offset + in jffs2_block_check_erase()
346 c->sector_size-retlen * sizeof(*wordebuf)); in jffs2_block_check_erase()
347 return -EIO; in jffs2_block_check_erase()
354 pr_warn("Failed to allocate page buffer for verifying erase at 0x%08x. Refiling\n", in jffs2_block_check_erase()
355 jeb->offset); in jffs2_block_check_erase()
356 return -EAGAIN; in jffs2_block_check_erase()
359 jffs2_dbg(1, "Verifying erase at 0x%08x\n", jeb->offset); in jffs2_block_check_erase()
361 for (ofs = jeb->offset; ofs < jeb->offset + c->sector_size; ) { in jffs2_block_check_erase()
362 uint32_t readlen = min((uint32_t)PAGE_SIZE, jeb->offset + c->sector_size - ofs); in jffs2_block_check_erase()
367 ret = mtd_read(c->mtd, ofs, readlen, &retlen, ebuf); in jffs2_block_check_erase()
369 pr_warn("Read of newly-erased block at 0x%08x failed: %d. Putting on bad_list\n", in jffs2_block_check_erase()
371 ret = -EIO; in jffs2_block_check_erase()
375 pr_warn("Short read from newly-erased block at 0x%08x. Wanted %d, got %zd\n", in jffs2_block_check_erase()
377 ret = -EIO; in jffs2_block_check_erase()
385 pr_warn("Newly-erased block contained word 0x%lx at offset 0x%08x\n", in jffs2_block_check_erase()
387 ret = -EIO; in jffs2_block_check_erase()
407 case -EAGAIN: goto refile; in jffs2_mark_erased_block()
408 case -EIO: goto filebad; in jffs2_mark_erased_block()
412 jffs2_dbg(1, "Writing erased marker to block at 0x%08x\n", jeb->offset); in jffs2_mark_erased_block()
413 bad_offset = jeb->offset; in jffs2_mark_erased_block()
416 if (jffs2_cleanmarker_oob(c) || c->cleanmarker_size == 0) { in jffs2_mark_erased_block()
428 .totlen = cpu_to_je32(c->cleanmarker_size) in jffs2_mark_erased_block()
433 marker.hdr_crc = cpu_to_je32(crc32(0, &marker, sizeof(struct jffs2_unknown_node)-4)); in jffs2_mark_erased_block()
437 ret = jffs2_flash_direct_writev(c, vecs, 1, jeb->offset, &retlen); in jffs2_mark_erased_block()
441 pr_warn("Write clean marker to block at 0x%08x failed: %d\n", in jffs2_mark_erased_block()
442 jeb->offset, ret); in jffs2_mark_erased_block()
444 pr_warn("Short write to newly-erased block at 0x%08x: Wanted %zd, got %zd\n", in jffs2_mark_erased_block()
445 jeb->offset, sizeof(marker), retlen); in jffs2_mark_erased_block()
451 jeb->free_size = c->sector_size; in jffs2_mark_erased_block()
453 mutex_lock(&c->erase_free_sem); in jffs2_mark_erased_block()
454 spin_lock(&c->erase_completion_lock); in jffs2_mark_erased_block()
456 c->erasing_size -= c->sector_size; in jffs2_mark_erased_block()
457 c->free_size += c->sector_size; in jffs2_mark_erased_block()
459 /* Account for cleanmarker now, if it's in-band */ in jffs2_mark_erased_block()
460 if (c->cleanmarker_size && !jffs2_cleanmarker_oob(c)) in jffs2_mark_erased_block()
461 jffs2_link_node_ref(c, jeb, jeb->offset | REF_NORMAL, c->cleanmarker_size, NULL); in jffs2_mark_erased_block()
463 list_move_tail(&jeb->list, &c->free_list); in jffs2_mark_erased_block()
464 c->nr_erasing_blocks--; in jffs2_mark_erased_block()
465 c->nr_free_blocks++; in jffs2_mark_erased_block()
470 spin_unlock(&c->erase_completion_lock); in jffs2_mark_erased_block()
471 mutex_unlock(&c->erase_free_sem); in jffs2_mark_erased_block()
472 wake_up(&c->erase_wait); in jffs2_mark_erased_block()
481 mutex_lock(&c->erase_free_sem); in jffs2_mark_erased_block()
482 spin_lock(&c->erase_completion_lock); in jffs2_mark_erased_block()
484 list_move(&jeb->list, &c->erase_complete_list); in jffs2_mark_erased_block()
485 spin_unlock(&c->erase_completion_lock); in jffs2_mark_erased_block()
486 mutex_unlock(&c->erase_free_sem); in jffs2_mark_erased_block()