aboutsummaryrefslogtreecommitdiffstats
path: root/fs/jffs2/erase.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/jffs2/erase.c')
-rw-r--r--fs/jffs2/erase.c37
1 files changed, 19 insertions, 18 deletions
diff --git a/fs/jffs2/erase.c b/fs/jffs2/erase.c
index 787d84ac2bcd..dad68fdffe9e 100644
--- a/fs/jffs2/erase.c
+++ b/fs/jffs2/erase.c
@@ -7,7 +7,7 @@
7 * 7 *
8 * For licensing information, see the file 'LICENCE' in this directory. 8 * For licensing information, see the file 'LICENCE' in this directory.
9 * 9 *
10 * $Id: erase.c,v 1.80 2005/07/14 19:46:24 joern Exp $ 10 * $Id: erase.c,v 1.85 2005/09/20 14:53:15 dedekind Exp $
11 * 11 *
12 */ 12 */
13 13
@@ -24,7 +24,7 @@ struct erase_priv_struct {
24 struct jffs2_eraseblock *jeb; 24 struct jffs2_eraseblock *jeb;
25 struct jffs2_sb_info *c; 25 struct jffs2_sb_info *c;
26}; 26};
27 27
28#ifndef __ECOS 28#ifndef __ECOS
29static void jffs2_erase_callback(struct erase_info *); 29static void jffs2_erase_callback(struct erase_info *);
30#endif 30#endif
@@ -48,7 +48,8 @@ static void jffs2_erase_block(struct jffs2_sb_info *c,
48#else /* Linux */ 48#else /* Linux */
49 struct erase_info *instr; 49 struct erase_info *instr;
50 50
51 D1(printk(KERN_DEBUG "jffs2_erase_block(): erase block %#x (range %#x-%#x)\n", jeb->offset, jeb->offset, jeb->offset + c->sector_size)); 51 D1(printk(KERN_DEBUG "jffs2_erase_block(): erase block %#08x (range %#08x-%#08x)\n",
52 jeb->offset, jeb->offset, jeb->offset + c->sector_size));
52 instr = kmalloc(sizeof(struct erase_info) + sizeof(struct erase_priv_struct), GFP_KERNEL); 53 instr = kmalloc(sizeof(struct erase_info) + sizeof(struct erase_priv_struct), GFP_KERNEL);
53 if (!instr) { 54 if (!instr) {
54 printk(KERN_WARNING "kmalloc for struct erase_info in jffs2_erase_block failed. Refiling block for later\n"); 55 printk(KERN_WARNING "kmalloc for struct erase_info in jffs2_erase_block failed. Refiling block for later\n");
@@ -70,7 +71,7 @@ static void jffs2_erase_block(struct jffs2_sb_info *c,
70 instr->callback = jffs2_erase_callback; 71 instr->callback = jffs2_erase_callback;
71 instr->priv = (unsigned long)(&instr[1]); 72 instr->priv = (unsigned long)(&instr[1]);
72 instr->fail_addr = 0xffffffff; 73 instr->fail_addr = 0xffffffff;
73 74
74 ((struct erase_priv_struct *)instr->priv)->jeb = jeb; 75 ((struct erase_priv_struct *)instr->priv)->jeb = jeb;
75 ((struct erase_priv_struct *)instr->priv)->c = c; 76 ((struct erase_priv_struct *)instr->priv)->c = c;
76 77
@@ -95,7 +96,7 @@ static void jffs2_erase_block(struct jffs2_sb_info *c,
95 return; 96 return;
96 } 97 }
97 98
98 if (ret == -EROFS) 99 if (ret == -EROFS)
99 printk(KERN_WARNING "Erase at 0x%08x failed immediately: -EROFS. Is the sector locked?\n", jeb->offset); 100 printk(KERN_WARNING "Erase at 0x%08x failed immediately: -EROFS. Is the sector locked?\n", jeb->offset);
100 else 101 else
101 printk(KERN_WARNING "Erase at 0x%08x failed immediately: errno %d\n", jeb->offset, ret); 102 printk(KERN_WARNING "Erase at 0x%08x failed immediately: errno %d\n", jeb->offset, ret);
@@ -196,7 +197,7 @@ static void jffs2_erase_failed(struct jffs2_sb_info *c, struct jffs2_eraseblock
196 c->nr_erasing_blocks--; 197 c->nr_erasing_blocks--;
197 spin_unlock(&c->erase_completion_lock); 198 spin_unlock(&c->erase_completion_lock);
198 wake_up(&c->erase_wait); 199 wake_up(&c->erase_wait);
199} 200}
200 201
201#ifndef __ECOS 202#ifndef __ECOS
202static void jffs2_erase_callback(struct erase_info *instr) 203static void jffs2_erase_callback(struct erase_info *instr)
@@ -208,7 +209,7 @@ static void jffs2_erase_callback(struct erase_info *instr)
208 jffs2_erase_failed(priv->c, priv->jeb, instr->fail_addr); 209 jffs2_erase_failed(priv->c, priv->jeb, instr->fail_addr);
209 } else { 210 } else {
210 jffs2_erase_succeeded(priv->c, priv->jeb); 211 jffs2_erase_succeeded(priv->c, priv->jeb);
211 } 212 }
212 kfree(instr); 213 kfree(instr);
213} 214}
214#endif /* !__ECOS */ 215#endif /* !__ECOS */
@@ -226,13 +227,13 @@ static inline void jffs2_remove_node_refs_from_ino_list(struct jffs2_sb_info *c,
226 /* Walk the inode's list once, removing any nodes from this eraseblock */ 227 /* Walk the inode's list once, removing any nodes from this eraseblock */
227 while (1) { 228 while (1) {
228 if (!(*prev)->next_in_ino) { 229 if (!(*prev)->next_in_ino) {
229 /* We're looking at the jffs2_inode_cache, which is 230 /* We're looking at the jffs2_inode_cache, which is
230 at the end of the linked list. Stash it and continue 231 at the end of the linked list. Stash it and continue
231 from the beginning of the list */ 232 from the beginning of the list */
232 ic = (struct jffs2_inode_cache *)(*prev); 233 ic = (struct jffs2_inode_cache *)(*prev);
233 prev = &ic->nodes; 234 prev = &ic->nodes;
234 continue; 235 continue;
235 } 236 }
236 237
237 if (SECTOR_ADDR((*prev)->flash_offset) == jeb->offset) { 238 if (SECTOR_ADDR((*prev)->flash_offset) == jeb->offset) {
238 /* It's in the block we're erasing */ 239 /* It's in the block we're erasing */
@@ -266,7 +267,7 @@ static inline void jffs2_remove_node_refs_from_ino_list(struct jffs2_sb_info *c,
266 printk(KERN_DEBUG "After remove_node_refs_from_ino_list: \n" KERN_DEBUG); 267 printk(KERN_DEBUG "After remove_node_refs_from_ino_list: \n" KERN_DEBUG);
267 268
268 this = ic->nodes; 269 this = ic->nodes;
269 270
270 while(this) { 271 while(this) {
271 printk( "0x%08x(%d)->", ref_offset(this), ref_flags(this)); 272 printk( "0x%08x(%d)->", ref_offset(this), ref_flags(this));
272 if (++i == 5) { 273 if (++i == 5) {
@@ -289,7 +290,7 @@ static void jffs2_free_all_node_refs(struct jffs2_sb_info *c, struct jffs2_erase
289 while(jeb->first_node) { 290 while(jeb->first_node) {
290 ref = jeb->first_node; 291 ref = jeb->first_node;
291 jeb->first_node = ref->next_phys; 292 jeb->first_node = ref->next_phys;
292 293
293 /* Remove from the inode-list */ 294 /* Remove from the inode-list */
294 if (ref->next_in_ino) 295 if (ref->next_in_ino)
295 jffs2_remove_node_refs_from_ino_list(c, ref, jeb); 296 jffs2_remove_node_refs_from_ino_list(c, ref, jeb);
@@ -306,7 +307,7 @@ static int jffs2_block_check_erase(struct jffs2_sb_info *c, struct jffs2_erasebl
306 uint32_t ofs; 307 uint32_t ofs;
307 size_t retlen; 308 size_t retlen;
308 int ret = -EIO; 309 int ret = -EIO;
309 310
310 ebuf = kmalloc(PAGE_SIZE, GFP_KERNEL); 311 ebuf = kmalloc(PAGE_SIZE, GFP_KERNEL);
311 if (!ebuf) { 312 if (!ebuf) {
312 printk(KERN_WARNING "Failed to allocate page buffer for verifying erase at 0x%08x. Refiling\n", jeb->offset); 313 printk(KERN_WARNING "Failed to allocate page buffer for verifying erase at 0x%08x. Refiling\n", jeb->offset);
@@ -360,7 +361,7 @@ static void jffs2_mark_erased_block(struct jffs2_sb_info *c, struct jffs2_eraseb
360 case -EIO: goto filebad; 361 case -EIO: goto filebad;
361 } 362 }
362 363
363 /* Write the erase complete marker */ 364 /* Write the erase complete marker */
364 D1(printk(KERN_DEBUG "Writing erased marker to block at 0x%08x\n", jeb->offset)); 365 D1(printk(KERN_DEBUG "Writing erased marker to block at 0x%08x\n", jeb->offset));
365 bad_offset = jeb->offset; 366 bad_offset = jeb->offset;
366 367
@@ -398,7 +399,7 @@ static void jffs2_mark_erased_block(struct jffs2_sb_info *c, struct jffs2_eraseb
398 vecs[0].iov_base = (unsigned char *) ▮ 399 vecs[0].iov_base = (unsigned char *) ▮
399 vecs[0].iov_len = sizeof(marker); 400 vecs[0].iov_len = sizeof(marker);
400 ret = jffs2_flash_direct_writev(c, vecs, 1, jeb->offset, &retlen); 401 ret = jffs2_flash_direct_writev(c, vecs, 1, jeb->offset, &retlen);
401 402
402 if (ret || retlen != sizeof(marker)) { 403 if (ret || retlen != sizeof(marker)) {
403 if (ret) 404 if (ret)
404 printk(KERN_WARNING "Write clean marker to block at 0x%08x failed: %d\n", 405 printk(KERN_WARNING "Write clean marker to block at 0x%08x failed: %d\n",
@@ -415,9 +416,9 @@ static void jffs2_mark_erased_block(struct jffs2_sb_info *c, struct jffs2_eraseb
415 marker_ref->next_phys = NULL; 416 marker_ref->next_phys = NULL;
416 marker_ref->flash_offset = jeb->offset | REF_NORMAL; 417 marker_ref->flash_offset = jeb->offset | REF_NORMAL;
417 marker_ref->__totlen = c->cleanmarker_size; 418 marker_ref->__totlen = c->cleanmarker_size;
418 419
419 jeb->first_node = jeb->last_node = marker_ref; 420 jeb->first_node = jeb->last_node = marker_ref;
420 421
421 jeb->free_size = c->sector_size - c->cleanmarker_size; 422 jeb->free_size = c->sector_size - c->cleanmarker_size;
422 jeb->used_size = c->cleanmarker_size; 423 jeb->used_size = c->cleanmarker_size;
423 jeb->dirty_size = 0; 424 jeb->dirty_size = 0;
@@ -429,8 +430,8 @@ static void jffs2_mark_erased_block(struct jffs2_sb_info *c, struct jffs2_eraseb
429 c->free_size += jeb->free_size; 430 c->free_size += jeb->free_size;
430 c->used_size += jeb->used_size; 431 c->used_size += jeb->used_size;
431 432
432 ACCT_SANITY_CHECK(c,jeb); 433 jffs2_dbg_acct_sanity_check_nolock(c,jeb);
433 D1(ACCT_PARANOIA_CHECK(jeb)); 434 jffs2_dbg_acct_paranoia_check_nolock(c, jeb);
434 435
435 list_add_tail(&jeb->list, &c->free_list); 436 list_add_tail(&jeb->list, &c->free_list);
436 c->nr_erasing_blocks--; 437 c->nr_erasing_blocks--;