diff options
Diffstat (limited to 'fs/jffs2/wbuf.c')
-rw-r--r-- | fs/jffs2/wbuf.c | 148 |
1 files changed, 79 insertions, 69 deletions
diff --git a/fs/jffs2/wbuf.c b/fs/jffs2/wbuf.c index 30e8f47e8a23..74d9be19df3f 100644 --- a/fs/jffs2/wbuf.c +++ b/fs/jffs2/wbuf.c | |||
@@ -11,6 +11,8 @@ | |||
11 | * | 11 | * |
12 | */ | 12 | */ |
13 | 13 | ||
14 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt | ||
15 | |||
14 | #include <linux/kernel.h> | 16 | #include <linux/kernel.h> |
15 | #include <linux/slab.h> | 17 | #include <linux/slab.h> |
16 | #include <linux/mtd/mtd.h> | 18 | #include <linux/mtd/mtd.h> |
@@ -91,7 +93,7 @@ static void jffs2_wbuf_dirties_inode(struct jffs2_sb_info *c, uint32_t ino) | |||
91 | 93 | ||
92 | new = kmalloc(sizeof(*new), GFP_KERNEL); | 94 | new = kmalloc(sizeof(*new), GFP_KERNEL); |
93 | if (!new) { | 95 | if (!new) { |
94 | D1(printk(KERN_DEBUG "No memory to allocate inodirty. Fallback to all considered dirty\n")); | 96 | jffs2_dbg(1, "No memory to allocate inodirty. Fallback to all considered dirty\n"); |
95 | jffs2_clear_wbuf_ino_list(c); | 97 | jffs2_clear_wbuf_ino_list(c); |
96 | c->wbuf_inodes = &inodirty_nomem; | 98 | c->wbuf_inodes = &inodirty_nomem; |
97 | return; | 99 | return; |
@@ -113,19 +115,20 @@ static inline void jffs2_refile_wbuf_blocks(struct jffs2_sb_info *c) | |||
113 | list_for_each_safe(this, next, &c->erasable_pending_wbuf_list) { | 115 | list_for_each_safe(this, next, &c->erasable_pending_wbuf_list) { |
114 | struct jffs2_eraseblock *jeb = list_entry(this, struct jffs2_eraseblock, list); | 116 | struct jffs2_eraseblock *jeb = list_entry(this, struct jffs2_eraseblock, list); |
115 | 117 | ||
116 | D1(printk(KERN_DEBUG "Removing eraseblock at 0x%08x from erasable_pending_wbuf_list...\n", jeb->offset)); | 118 | jffs2_dbg(1, "Removing eraseblock at 0x%08x from erasable_pending_wbuf_list...\n", |
119 | jeb->offset); | ||
117 | list_del(this); | 120 | list_del(this); |
118 | if ((jiffies + (n++)) & 127) { | 121 | if ((jiffies + (n++)) & 127) { |
119 | /* Most of the time, we just erase it immediately. Otherwise we | 122 | /* Most of the time, we just erase it immediately. Otherwise we |
120 | spend ages scanning it on mount, etc. */ | 123 | spend ages scanning it on mount, etc. */ |
121 | D1(printk(KERN_DEBUG "...and adding to erase_pending_list\n")); | 124 | jffs2_dbg(1, "...and adding to erase_pending_list\n"); |
122 | list_add_tail(&jeb->list, &c->erase_pending_list); | 125 | list_add_tail(&jeb->list, &c->erase_pending_list); |
123 | c->nr_erasing_blocks++; | 126 | c->nr_erasing_blocks++; |
124 | jffs2_garbage_collect_trigger(c); | 127 | jffs2_garbage_collect_trigger(c); |
125 | } else { | 128 | } else { |
126 | /* Sometimes, however, we leave it elsewhere so it doesn't get | 129 | /* Sometimes, however, we leave it elsewhere so it doesn't get |
127 | immediately reused, and we spread the load a bit. */ | 130 | immediately reused, and we spread the load a bit. */ |
128 | D1(printk(KERN_DEBUG "...and adding to erasable_list\n")); | 131 | jffs2_dbg(1, "...and adding to erasable_list\n"); |
129 | list_add_tail(&jeb->list, &c->erasable_list); | 132 | list_add_tail(&jeb->list, &c->erasable_list); |
130 | } | 133 | } |
131 | } | 134 | } |
@@ -136,7 +139,7 @@ static inline void jffs2_refile_wbuf_blocks(struct jffs2_sb_info *c) | |||
136 | 139 | ||
137 | static void jffs2_block_refile(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb, int allow_empty) | 140 | static void jffs2_block_refile(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb, int allow_empty) |
138 | { | 141 | { |
139 | D1(printk("About to refile bad block at %08x\n", jeb->offset)); | 142 | jffs2_dbg(1, "About to refile bad block at %08x\n", jeb->offset); |
140 | 143 | ||
141 | /* File the existing block on the bad_used_list.... */ | 144 | /* File the existing block on the bad_used_list.... */ |
142 | if (c->nextblock == jeb) | 145 | if (c->nextblock == jeb) |
@@ -144,12 +147,14 @@ static void jffs2_block_refile(struct jffs2_sb_info *c, struct jffs2_eraseblock | |||
144 | else /* Not sure this should ever happen... need more coffee */ | 147 | else /* Not sure this should ever happen... need more coffee */ |
145 | list_del(&jeb->list); | 148 | list_del(&jeb->list); |
146 | if (jeb->first_node) { | 149 | if (jeb->first_node) { |
147 | D1(printk("Refiling block at %08x to bad_used_list\n", jeb->offset)); | 150 | jffs2_dbg(1, "Refiling block at %08x to bad_used_list\n", |
151 | jeb->offset); | ||
148 | list_add(&jeb->list, &c->bad_used_list); | 152 | list_add(&jeb->list, &c->bad_used_list); |
149 | } else { | 153 | } else { |
150 | BUG_ON(allow_empty == REFILE_NOTEMPTY); | 154 | BUG_ON(allow_empty == REFILE_NOTEMPTY); |
151 | /* It has to have had some nodes or we couldn't be here */ | 155 | /* It has to have had some nodes or we couldn't be here */ |
152 | D1(printk("Refiling block at %08x to erase_pending_list\n", jeb->offset)); | 156 | jffs2_dbg(1, "Refiling block at %08x to erase_pending_list\n", |
157 | jeb->offset); | ||
153 | list_add(&jeb->list, &c->erase_pending_list); | 158 | list_add(&jeb->list, &c->erase_pending_list); |
154 | c->nr_erasing_blocks++; | 159 | c->nr_erasing_blocks++; |
155 | jffs2_garbage_collect_trigger(c); | 160 | jffs2_garbage_collect_trigger(c); |
@@ -230,10 +235,12 @@ static int jffs2_verify_write(struct jffs2_sb_info *c, unsigned char *buf, | |||
230 | 235 | ||
231 | ret = mtd_read(c->mtd, ofs, c->wbuf_pagesize, &retlen, c->wbuf_verify); | 236 | ret = mtd_read(c->mtd, ofs, c->wbuf_pagesize, &retlen, c->wbuf_verify); |
232 | if (ret && ret != -EUCLEAN && ret != -EBADMSG) { | 237 | if (ret && ret != -EUCLEAN && ret != -EBADMSG) { |
233 | printk(KERN_WARNING "jffs2_verify_write(): Read back of page at %08x failed: %d\n", c->wbuf_ofs, ret); | 238 | pr_warn("%s(): Read back of page at %08x failed: %d\n", |
239 | __func__, c->wbuf_ofs, ret); | ||
234 | return ret; | 240 | return ret; |
235 | } else if (retlen != c->wbuf_pagesize) { | 241 | } else if (retlen != c->wbuf_pagesize) { |
236 | printk(KERN_WARNING "jffs2_verify_write(): Read back of page at %08x gave short read: %zd not %d.\n", ofs, retlen, c->wbuf_pagesize); | 242 | pr_warn("%s(): Read back of page at %08x gave short read: %zd not %d\n", |
243 | __func__, ofs, retlen, c->wbuf_pagesize); | ||
237 | return -EIO; | 244 | return -EIO; |
238 | } | 245 | } |
239 | if (!memcmp(buf, c->wbuf_verify, c->wbuf_pagesize)) | 246 | if (!memcmp(buf, c->wbuf_verify, c->wbuf_pagesize)) |
@@ -246,12 +253,12 @@ static int jffs2_verify_write(struct jffs2_sb_info *c, unsigned char *buf, | |||
246 | else | 253 | else |
247 | eccstr = "OK or unused"; | 254 | eccstr = "OK or unused"; |
248 | 255 | ||
249 | printk(KERN_WARNING "Write verify error (ECC %s) at %08x. Wrote:\n", | 256 | pr_warn("Write verify error (ECC %s) at %08x. Wrote:\n", |
250 | eccstr, c->wbuf_ofs); | 257 | eccstr, c->wbuf_ofs); |
251 | print_hex_dump(KERN_WARNING, "", DUMP_PREFIX_OFFSET, 16, 1, | 258 | print_hex_dump(KERN_WARNING, "", DUMP_PREFIX_OFFSET, 16, 1, |
252 | c->wbuf, c->wbuf_pagesize, 0); | 259 | c->wbuf, c->wbuf_pagesize, 0); |
253 | 260 | ||
254 | printk(KERN_WARNING "Read back:\n"); | 261 | pr_warn("Read back:\n"); |
255 | print_hex_dump(KERN_WARNING, "", DUMP_PREFIX_OFFSET, 16, 1, | 262 | print_hex_dump(KERN_WARNING, "", DUMP_PREFIX_OFFSET, 16, 1, |
256 | c->wbuf_verify, c->wbuf_pagesize, 0); | 263 | c->wbuf_verify, c->wbuf_pagesize, 0); |
257 | 264 | ||
@@ -308,7 +315,7 @@ static void jffs2_wbuf_recover(struct jffs2_sb_info *c) | |||
308 | 315 | ||
309 | if (!first_raw) { | 316 | if (!first_raw) { |
310 | /* All nodes were obsolete. Nothing to recover. */ | 317 | /* All nodes were obsolete. Nothing to recover. */ |
311 | D1(printk(KERN_DEBUG "No non-obsolete nodes to be recovered. Just filing block bad\n")); | 318 | jffs2_dbg(1, "No non-obsolete nodes to be recovered. Just filing block bad\n"); |
312 | c->wbuf_len = 0; | 319 | c->wbuf_len = 0; |
313 | return; | 320 | return; |
314 | } | 321 | } |
@@ -331,7 +338,7 @@ static void jffs2_wbuf_recover(struct jffs2_sb_info *c) | |||
331 | 338 | ||
332 | buf = kmalloc(end - start, GFP_KERNEL); | 339 | buf = kmalloc(end - start, GFP_KERNEL); |
333 | if (!buf) { | 340 | if (!buf) { |
334 | printk(KERN_CRIT "Malloc failure in wbuf recovery. Data loss ensues.\n"); | 341 | pr_crit("Malloc failure in wbuf recovery. Data loss ensues.\n"); |
335 | 342 | ||
336 | goto read_failed; | 343 | goto read_failed; |
337 | } | 344 | } |
@@ -346,7 +353,7 @@ static void jffs2_wbuf_recover(struct jffs2_sb_info *c) | |||
346 | ret = 0; | 353 | ret = 0; |
347 | 354 | ||
348 | if (ret || retlen != c->wbuf_ofs - start) { | 355 | if (ret || retlen != c->wbuf_ofs - start) { |
349 | printk(KERN_CRIT "Old data are already lost in wbuf recovery. Data loss ensues.\n"); | 356 | pr_crit("Old data are already lost in wbuf recovery. Data loss ensues.\n"); |
350 | 357 | ||
351 | kfree(buf); | 358 | kfree(buf); |
352 | buf = NULL; | 359 | buf = NULL; |
@@ -380,7 +387,7 @@ static void jffs2_wbuf_recover(struct jffs2_sb_info *c) | |||
380 | /* ... and get an allocation of space from a shiny new block instead */ | 387 | /* ... and get an allocation of space from a shiny new block instead */ |
381 | ret = jffs2_reserve_space_gc(c, end-start, &len, JFFS2_SUMMARY_NOSUM_SIZE); | 388 | ret = jffs2_reserve_space_gc(c, end-start, &len, JFFS2_SUMMARY_NOSUM_SIZE); |
382 | if (ret) { | 389 | if (ret) { |
383 | printk(KERN_WARNING "Failed to allocate space for wbuf recovery. Data loss ensues.\n"); | 390 | pr_warn("Failed to allocate space for wbuf recovery. Data loss ensues.\n"); |
384 | kfree(buf); | 391 | kfree(buf); |
385 | return; | 392 | return; |
386 | } | 393 | } |
@@ -390,7 +397,7 @@ static void jffs2_wbuf_recover(struct jffs2_sb_info *c) | |||
390 | 397 | ||
391 | ret = jffs2_prealloc_raw_node_refs(c, c->nextblock, nr_refile); | 398 | ret = jffs2_prealloc_raw_node_refs(c, c->nextblock, nr_refile); |
392 | if (ret) { | 399 | if (ret) { |
393 | printk(KERN_WARNING "Failed to allocate node refs for wbuf recovery. Data loss ensues.\n"); | 400 | pr_warn("Failed to allocate node refs for wbuf recovery. Data loss ensues.\n"); |
394 | kfree(buf); | 401 | kfree(buf); |
395 | return; | 402 | return; |
396 | } | 403 | } |
@@ -406,13 +413,13 @@ static void jffs2_wbuf_recover(struct jffs2_sb_info *c) | |||
406 | unsigned char *rewrite_buf = buf?:c->wbuf; | 413 | unsigned char *rewrite_buf = buf?:c->wbuf; |
407 | uint32_t towrite = (end-start) - ((end-start)%c->wbuf_pagesize); | 414 | uint32_t towrite = (end-start) - ((end-start)%c->wbuf_pagesize); |
408 | 415 | ||
409 | D1(printk(KERN_DEBUG "Write 0x%x bytes at 0x%08x in wbuf recover\n", | 416 | jffs2_dbg(1, "Write 0x%x bytes at 0x%08x in wbuf recover\n", |
410 | towrite, ofs)); | 417 | towrite, ofs); |
411 | 418 | ||
412 | #ifdef BREAKMEHEADER | 419 | #ifdef BREAKMEHEADER |
413 | static int breakme; | 420 | static int breakme; |
414 | if (breakme++ == 20) { | 421 | if (breakme++ == 20) { |
415 | printk(KERN_NOTICE "Faking write error at 0x%08x\n", ofs); | 422 | pr_notice("Faking write error at 0x%08x\n", ofs); |
416 | breakme = 0; | 423 | breakme = 0; |
417 | mtd_write(c->mtd, ofs, towrite, &retlen, brokenbuf); | 424 | mtd_write(c->mtd, ofs, towrite, &retlen, brokenbuf); |
418 | ret = -EIO; | 425 | ret = -EIO; |
@@ -423,7 +430,7 @@ static void jffs2_wbuf_recover(struct jffs2_sb_info *c) | |||
423 | 430 | ||
424 | if (ret || retlen != towrite || jffs2_verify_write(c, rewrite_buf, ofs)) { | 431 | if (ret || retlen != towrite || jffs2_verify_write(c, rewrite_buf, ofs)) { |
425 | /* Argh. We tried. Really we did. */ | 432 | /* Argh. We tried. Really we did. */ |
426 | printk(KERN_CRIT "Recovery of wbuf failed due to a second write error\n"); | 433 | pr_crit("Recovery of wbuf failed due to a second write error\n"); |
427 | kfree(buf); | 434 | kfree(buf); |
428 | 435 | ||
429 | if (retlen) | 436 | if (retlen) |
@@ -431,7 +438,7 @@ static void jffs2_wbuf_recover(struct jffs2_sb_info *c) | |||
431 | 438 | ||
432 | return; | 439 | return; |
433 | } | 440 | } |
434 | printk(KERN_NOTICE "Recovery of wbuf succeeded to %08x\n", ofs); | 441 | pr_notice("Recovery of wbuf succeeded to %08x\n", ofs); |
435 | 442 | ||
436 | c->wbuf_len = (end - start) - towrite; | 443 | c->wbuf_len = (end - start) - towrite; |
437 | c->wbuf_ofs = ofs + towrite; | 444 | c->wbuf_ofs = ofs + towrite; |
@@ -459,8 +466,8 @@ static void jffs2_wbuf_recover(struct jffs2_sb_info *c) | |||
459 | struct jffs2_raw_node_ref **adjust_ref = NULL; | 466 | struct jffs2_raw_node_ref **adjust_ref = NULL; |
460 | struct jffs2_inode_info *f = NULL; | 467 | struct jffs2_inode_info *f = NULL; |
461 | 468 | ||
462 | D1(printk(KERN_DEBUG "Refiling block of %08x at %08x(%d) to %08x\n", | 469 | jffs2_dbg(1, "Refiling block of %08x at %08x(%d) to %08x\n", |
463 | rawlen, ref_offset(raw), ref_flags(raw), ofs)); | 470 | rawlen, ref_offset(raw), ref_flags(raw), ofs); |
464 | 471 | ||
465 | ic = jffs2_raw_ref_to_ic(raw); | 472 | ic = jffs2_raw_ref_to_ic(raw); |
466 | 473 | ||
@@ -540,7 +547,8 @@ static void jffs2_wbuf_recover(struct jffs2_sb_info *c) | |||
540 | 547 | ||
541 | /* Fix up the original jeb now it's on the bad_list */ | 548 | /* Fix up the original jeb now it's on the bad_list */ |
542 | if (first_raw == jeb->first_node) { | 549 | if (first_raw == jeb->first_node) { |
543 | D1(printk(KERN_DEBUG "Failing block at %08x is now empty. Moving to erase_pending_list\n", jeb->offset)); | 550 | jffs2_dbg(1, "Failing block at %08x is now empty. Moving to erase_pending_list\n", |
551 | jeb->offset); | ||
544 | list_move(&jeb->list, &c->erase_pending_list); | 552 | list_move(&jeb->list, &c->erase_pending_list); |
545 | c->nr_erasing_blocks++; | 553 | c->nr_erasing_blocks++; |
546 | jffs2_garbage_collect_trigger(c); | 554 | jffs2_garbage_collect_trigger(c); |
@@ -554,7 +562,8 @@ static void jffs2_wbuf_recover(struct jffs2_sb_info *c) | |||
554 | 562 | ||
555 | spin_unlock(&c->erase_completion_lock); | 563 | spin_unlock(&c->erase_completion_lock); |
556 | 564 | ||
557 | D1(printk(KERN_DEBUG "wbuf recovery completed OK. wbuf_ofs 0x%08x, len 0x%x\n", c->wbuf_ofs, c->wbuf_len)); | 565 | jffs2_dbg(1, "wbuf recovery completed OK. wbuf_ofs 0x%08x, len 0x%x\n", |
566 | c->wbuf_ofs, c->wbuf_len); | ||
558 | 567 | ||
559 | } | 568 | } |
560 | 569 | ||
@@ -579,7 +588,7 @@ static int __jffs2_flush_wbuf(struct jffs2_sb_info *c, int pad) | |||
579 | return 0; | 588 | return 0; |
580 | 589 | ||
581 | if (!mutex_is_locked(&c->alloc_sem)) { | 590 | if (!mutex_is_locked(&c->alloc_sem)) { |
582 | printk(KERN_CRIT "jffs2_flush_wbuf() called with alloc_sem not locked!\n"); | 591 | pr_crit("jffs2_flush_wbuf() called with alloc_sem not locked!\n"); |
583 | BUG(); | 592 | BUG(); |
584 | } | 593 | } |
585 | 594 | ||
@@ -617,7 +626,7 @@ static int __jffs2_flush_wbuf(struct jffs2_sb_info *c, int pad) | |||
617 | #ifdef BREAKME | 626 | #ifdef BREAKME |
618 | static int breakme; | 627 | static int breakme; |
619 | if (breakme++ == 20) { | 628 | if (breakme++ == 20) { |
620 | printk(KERN_NOTICE "Faking write error at 0x%08x\n", c->wbuf_ofs); | 629 | pr_notice("Faking write error at 0x%08x\n", c->wbuf_ofs); |
621 | breakme = 0; | 630 | breakme = 0; |
622 | mtd_write(c->mtd, c->wbuf_ofs, c->wbuf_pagesize, &retlen, | 631 | mtd_write(c->mtd, c->wbuf_ofs, c->wbuf_pagesize, &retlen, |
623 | brokenbuf); | 632 | brokenbuf); |
@@ -629,11 +638,11 @@ static int __jffs2_flush_wbuf(struct jffs2_sb_info *c, int pad) | |||
629 | &retlen, c->wbuf); | 638 | &retlen, c->wbuf); |
630 | 639 | ||
631 | if (ret) { | 640 | if (ret) { |
632 | printk(KERN_WARNING "jffs2_flush_wbuf(): Write failed with %d\n", ret); | 641 | pr_warn("jffs2_flush_wbuf(): Write failed with %d\n", ret); |
633 | goto wfail; | 642 | goto wfail; |
634 | } else if (retlen != c->wbuf_pagesize) { | 643 | } else if (retlen != c->wbuf_pagesize) { |
635 | printk(KERN_WARNING "jffs2_flush_wbuf(): Write was short: %zd instead of %d\n", | 644 | pr_warn("jffs2_flush_wbuf(): Write was short: %zd instead of %d\n", |
636 | retlen, c->wbuf_pagesize); | 645 | retlen, c->wbuf_pagesize); |
637 | ret = -EIO; | 646 | ret = -EIO; |
638 | goto wfail; | 647 | goto wfail; |
639 | } else if ((ret = jffs2_verify_write(c, c->wbuf, c->wbuf_ofs))) { | 648 | } else if ((ret = jffs2_verify_write(c, c->wbuf, c->wbuf_ofs))) { |
@@ -647,17 +656,18 @@ static int __jffs2_flush_wbuf(struct jffs2_sb_info *c, int pad) | |||
647 | if (pad) { | 656 | if (pad) { |
648 | uint32_t waste = c->wbuf_pagesize - c->wbuf_len; | 657 | uint32_t waste = c->wbuf_pagesize - c->wbuf_len; |
649 | 658 | ||
650 | D1(printk(KERN_DEBUG "jffs2_flush_wbuf() adjusting free_size of %sblock at %08x\n", | 659 | jffs2_dbg(1, "jffs2_flush_wbuf() adjusting free_size of %sblock at %08x\n", |
651 | (wbuf_jeb==c->nextblock)?"next":"", wbuf_jeb->offset)); | 660 | (wbuf_jeb == c->nextblock) ? "next" : "", |
661 | wbuf_jeb->offset); | ||
652 | 662 | ||
653 | /* wbuf_pagesize - wbuf_len is the amount of space that's to be | 663 | /* wbuf_pagesize - wbuf_len is the amount of space that's to be |
654 | padded. If there is less free space in the block than that, | 664 | padded. If there is less free space in the block than that, |
655 | something screwed up */ | 665 | something screwed up */ |
656 | if (wbuf_jeb->free_size < waste) { | 666 | if (wbuf_jeb->free_size < waste) { |
657 | printk(KERN_CRIT "jffs2_flush_wbuf(): Accounting error. wbuf at 0x%08x has 0x%03x bytes, 0x%03x left.\n", | 667 | pr_crit("jffs2_flush_wbuf(): Accounting error. wbuf at 0x%08x has 0x%03x bytes, 0x%03x left.\n", |
658 | c->wbuf_ofs, c->wbuf_len, waste); | 668 | c->wbuf_ofs, c->wbuf_len, waste); |
659 | printk(KERN_CRIT "jffs2_flush_wbuf(): But free_size for block at 0x%08x is only 0x%08x\n", | 669 | pr_crit("jffs2_flush_wbuf(): But free_size for block at 0x%08x is only 0x%08x\n", |
660 | wbuf_jeb->offset, wbuf_jeb->free_size); | 670 | wbuf_jeb->offset, wbuf_jeb->free_size); |
661 | BUG(); | 671 | BUG(); |
662 | } | 672 | } |
663 | 673 | ||
@@ -694,14 +704,14 @@ int jffs2_flush_wbuf_gc(struct jffs2_sb_info *c, uint32_t ino) | |||
694 | uint32_t old_wbuf_len; | 704 | uint32_t old_wbuf_len; |
695 | int ret = 0; | 705 | int ret = 0; |
696 | 706 | ||
697 | D1(printk(KERN_DEBUG "jffs2_flush_wbuf_gc() called for ino #%u...\n", ino)); | 707 | jffs2_dbg(1, "jffs2_flush_wbuf_gc() called for ino #%u...\n", ino); |
698 | 708 | ||
699 | if (!c->wbuf) | 709 | if (!c->wbuf) |
700 | return 0; | 710 | return 0; |
701 | 711 | ||
702 | mutex_lock(&c->alloc_sem); | 712 | mutex_lock(&c->alloc_sem); |
703 | if (!jffs2_wbuf_pending_for_ino(c, ino)) { | 713 | if (!jffs2_wbuf_pending_for_ino(c, ino)) { |
704 | D1(printk(KERN_DEBUG "Ino #%d not pending in wbuf. Returning\n", ino)); | 714 | jffs2_dbg(1, "Ino #%d not pending in wbuf. Returning\n", ino); |
705 | mutex_unlock(&c->alloc_sem); | 715 | mutex_unlock(&c->alloc_sem); |
706 | return 0; | 716 | return 0; |
707 | } | 717 | } |
@@ -711,7 +721,8 @@ int jffs2_flush_wbuf_gc(struct jffs2_sb_info *c, uint32_t ino) | |||
711 | 721 | ||
712 | if (c->unchecked_size) { | 722 | if (c->unchecked_size) { |
713 | /* GC won't make any progress for a while */ | 723 | /* GC won't make any progress for a while */ |
714 | D1(printk(KERN_DEBUG "jffs2_flush_wbuf_gc() padding. Not finished checking\n")); | 724 | jffs2_dbg(1, "%s(): padding. Not finished checking\n", |
725 | __func__); | ||
715 | down_write(&c->wbuf_sem); | 726 | down_write(&c->wbuf_sem); |
716 | ret = __jffs2_flush_wbuf(c, PAD_ACCOUNTING); | 727 | ret = __jffs2_flush_wbuf(c, PAD_ACCOUNTING); |
717 | /* retry flushing wbuf in case jffs2_wbuf_recover | 728 | /* retry flushing wbuf in case jffs2_wbuf_recover |
@@ -724,7 +735,7 @@ int jffs2_flush_wbuf_gc(struct jffs2_sb_info *c, uint32_t ino) | |||
724 | 735 | ||
725 | mutex_unlock(&c->alloc_sem); | 736 | mutex_unlock(&c->alloc_sem); |
726 | 737 | ||
727 | D1(printk(KERN_DEBUG "jffs2_flush_wbuf_gc() calls gc pass\n")); | 738 | jffs2_dbg(1, "%s(): calls gc pass\n", __func__); |
728 | 739 | ||
729 | ret = jffs2_garbage_collect_pass(c); | 740 | ret = jffs2_garbage_collect_pass(c); |
730 | if (ret) { | 741 | if (ret) { |
@@ -742,7 +753,7 @@ int jffs2_flush_wbuf_gc(struct jffs2_sb_info *c, uint32_t ino) | |||
742 | mutex_lock(&c->alloc_sem); | 753 | mutex_lock(&c->alloc_sem); |
743 | } | 754 | } |
744 | 755 | ||
745 | D1(printk(KERN_DEBUG "jffs2_flush_wbuf_gc() ends...\n")); | 756 | jffs2_dbg(1, "%s(): ends...\n", __func__); |
746 | 757 | ||
747 | mutex_unlock(&c->alloc_sem); | 758 | mutex_unlock(&c->alloc_sem); |
748 | return ret; | 759 | return ret; |
@@ -811,9 +822,8 @@ int jffs2_flash_writev(struct jffs2_sb_info *c, const struct kvec *invecs, | |||
811 | if (SECTOR_ADDR(to) != SECTOR_ADDR(c->wbuf_ofs)) { | 822 | if (SECTOR_ADDR(to) != SECTOR_ADDR(c->wbuf_ofs)) { |
812 | /* It's a write to a new block */ | 823 | /* It's a write to a new block */ |
813 | if (c->wbuf_len) { | 824 | if (c->wbuf_len) { |
814 | D1(printk(KERN_DEBUG "jffs2_flash_writev() to 0x%lx " | 825 | jffs2_dbg(1, "%s(): to 0x%lx causes flush of wbuf at 0x%08x\n", |
815 | "causes flush of wbuf at 0x%08x\n", | 826 | __func__, (unsigned long)to, c->wbuf_ofs); |
816 | (unsigned long)to, c->wbuf_ofs)); | ||
817 | ret = __jffs2_flush_wbuf(c, PAD_NOACCOUNT); | 827 | ret = __jffs2_flush_wbuf(c, PAD_NOACCOUNT); |
818 | if (ret) | 828 | if (ret) |
819 | goto outerr; | 829 | goto outerr; |
@@ -825,11 +835,11 @@ int jffs2_flash_writev(struct jffs2_sb_info *c, const struct kvec *invecs, | |||
825 | 835 | ||
826 | if (to != PAD(c->wbuf_ofs + c->wbuf_len)) { | 836 | if (to != PAD(c->wbuf_ofs + c->wbuf_len)) { |
827 | /* We're not writing immediately after the writebuffer. Bad. */ | 837 | /* We're not writing immediately after the writebuffer. Bad. */ |
828 | printk(KERN_CRIT "jffs2_flash_writev(): Non-contiguous write " | 838 | pr_crit("%s(): Non-contiguous write to %08lx\n", |
829 | "to %08lx\n", (unsigned long)to); | 839 | __func__, (unsigned long)to); |
830 | if (c->wbuf_len) | 840 | if (c->wbuf_len) |
831 | printk(KERN_CRIT "wbuf was previously %08x-%08x\n", | 841 | pr_crit("wbuf was previously %08x-%08x\n", |
832 | c->wbuf_ofs, c->wbuf_ofs+c->wbuf_len); | 842 | c->wbuf_ofs, c->wbuf_ofs + c->wbuf_len); |
833 | BUG(); | 843 | BUG(); |
834 | } | 844 | } |
835 | 845 | ||
@@ -957,8 +967,8 @@ int jffs2_flash_read(struct jffs2_sb_info *c, loff_t ofs, size_t len, size_t *re | |||
957 | 967 | ||
958 | if ( (ret == -EBADMSG || ret == -EUCLEAN) && (*retlen == len) ) { | 968 | if ( (ret == -EBADMSG || ret == -EUCLEAN) && (*retlen == len) ) { |
959 | if (ret == -EBADMSG) | 969 | if (ret == -EBADMSG) |
960 | printk(KERN_WARNING "mtd->read(0x%zx bytes from 0x%llx)" | 970 | pr_warn("mtd->read(0x%zx bytes from 0x%llx) returned ECC error\n", |
961 | " returned ECC error\n", len, ofs); | 971 | len, ofs); |
962 | /* | 972 | /* |
963 | * We have the raw data without ECC correction in the buffer, | 973 | * We have the raw data without ECC correction in the buffer, |
964 | * maybe we are lucky and all data or parts are correct. We | 974 | * maybe we are lucky and all data or parts are correct. We |
@@ -1034,9 +1044,8 @@ int jffs2_check_oob_empty(struct jffs2_sb_info *c, | |||
1034 | 1044 | ||
1035 | ret = mtd_read_oob(c->mtd, jeb->offset, &ops); | 1045 | ret = mtd_read_oob(c->mtd, jeb->offset, &ops); |
1036 | if (ret || ops.oobretlen != ops.ooblen) { | 1046 | if (ret || ops.oobretlen != ops.ooblen) { |
1037 | printk(KERN_ERR "cannot read OOB for EB at %08x, requested %zd" | 1047 | pr_err("cannot read OOB for EB at %08x, requested %zd bytes, read %zd bytes, error %d\n", |
1038 | " bytes, read %zd bytes, error %d\n", | 1048 | jeb->offset, ops.ooblen, ops.oobretlen, ret); |
1039 | jeb->offset, ops.ooblen, ops.oobretlen, ret); | ||
1040 | if (!ret) | 1049 | if (!ret) |
1041 | ret = -EIO; | 1050 | ret = -EIO; |
1042 | return ret; | 1051 | return ret; |
@@ -1048,8 +1057,8 @@ int jffs2_check_oob_empty(struct jffs2_sb_info *c, | |||
1048 | continue; | 1057 | continue; |
1049 | 1058 | ||
1050 | if (ops.oobbuf[i] != 0xFF) { | 1059 | if (ops.oobbuf[i] != 0xFF) { |
1051 | D2(printk(KERN_DEBUG "Found %02x at %x in OOB for " | 1060 | jffs2_dbg(2, "Found %02x at %x in OOB for " |
1052 | "%08x\n", ops.oobbuf[i], i, jeb->offset)); | 1061 | "%08x\n", ops.oobbuf[i], i, jeb->offset); |
1053 | return 1; | 1062 | return 1; |
1054 | } | 1063 | } |
1055 | } | 1064 | } |
@@ -1077,9 +1086,8 @@ int jffs2_check_nand_cleanmarker(struct jffs2_sb_info *c, | |||
1077 | 1086 | ||
1078 | ret = mtd_read_oob(c->mtd, jeb->offset, &ops); | 1087 | ret = mtd_read_oob(c->mtd, jeb->offset, &ops); |
1079 | if (ret || ops.oobretlen != ops.ooblen) { | 1088 | if (ret || ops.oobretlen != ops.ooblen) { |
1080 | printk(KERN_ERR "cannot read OOB for EB at %08x, requested %zd" | 1089 | pr_err("cannot read OOB for EB at %08x, requested %zd bytes, read %zd bytes, error %d\n", |
1081 | " bytes, read %zd bytes, error %d\n", | 1090 | jeb->offset, ops.ooblen, ops.oobretlen, ret); |
1082 | jeb->offset, ops.ooblen, ops.oobretlen, ret); | ||
1083 | if (!ret) | 1091 | if (!ret) |
1084 | ret = -EIO; | 1092 | ret = -EIO; |
1085 | return ret; | 1093 | return ret; |
@@ -1103,9 +1111,8 @@ int jffs2_write_nand_cleanmarker(struct jffs2_sb_info *c, | |||
1103 | 1111 | ||
1104 | ret = mtd_write_oob(c->mtd, jeb->offset, &ops); | 1112 | ret = mtd_write_oob(c->mtd, jeb->offset, &ops); |
1105 | if (ret || ops.oobretlen != ops.ooblen) { | 1113 | if (ret || ops.oobretlen != ops.ooblen) { |
1106 | printk(KERN_ERR "cannot write OOB for EB at %08x, requested %zd" | 1114 | pr_err("cannot write OOB for EB at %08x, requested %zd bytes, read %zd bytes, error %d\n", |
1107 | " bytes, read %zd bytes, error %d\n", | 1115 | jeb->offset, ops.ooblen, ops.oobretlen, ret); |
1108 | jeb->offset, ops.ooblen, ops.oobretlen, ret); | ||
1109 | if (!ret) | 1116 | if (!ret) |
1110 | ret = -EIO; | 1117 | ret = -EIO; |
1111 | return ret; | 1118 | return ret; |
@@ -1130,11 +1137,12 @@ int jffs2_write_nand_badblock(struct jffs2_sb_info *c, struct jffs2_eraseblock * | |||
1130 | if( ++jeb->bad_count < MAX_ERASE_FAILURES) | 1137 | if( ++jeb->bad_count < MAX_ERASE_FAILURES) |
1131 | return 0; | 1138 | return 0; |
1132 | 1139 | ||
1133 | printk(KERN_WARNING "JFFS2: marking eraseblock at %08x\n as bad", bad_offset); | 1140 | pr_warn("marking eraseblock at %08x as bad\n", bad_offset); |
1134 | ret = mtd_block_markbad(c->mtd, bad_offset); | 1141 | ret = mtd_block_markbad(c->mtd, bad_offset); |
1135 | 1142 | ||
1136 | if (ret) { | 1143 | if (ret) { |
1137 | D1(printk(KERN_WARNING "jffs2_write_nand_badblock(): Write failed for block at %08x: error %d\n", jeb->offset, ret)); | 1144 | jffs2_dbg(1, "%s(): Write failed for block at %08x: error %d\n", |
1145 | __func__, jeb->offset, ret); | ||
1138 | return ret; | 1146 | return ret; |
1139 | } | 1147 | } |
1140 | return 1; | 1148 | return 1; |
@@ -1151,11 +1159,11 @@ int jffs2_nand_flash_setup(struct jffs2_sb_info *c) | |||
1151 | c->cleanmarker_size = 0; | 1159 | c->cleanmarker_size = 0; |
1152 | 1160 | ||
1153 | if (!oinfo || oinfo->oobavail == 0) { | 1161 | if (!oinfo || oinfo->oobavail == 0) { |
1154 | printk(KERN_ERR "inconsistent device description\n"); | 1162 | pr_err("inconsistent device description\n"); |
1155 | return -EINVAL; | 1163 | return -EINVAL; |
1156 | } | 1164 | } |
1157 | 1165 | ||
1158 | D1(printk(KERN_DEBUG "JFFS2 using OOB on NAND\n")); | 1166 | jffs2_dbg(1, "using OOB on NAND\n"); |
1159 | 1167 | ||
1160 | c->oobavail = oinfo->oobavail; | 1168 | c->oobavail = oinfo->oobavail; |
1161 | 1169 | ||
@@ -1222,7 +1230,7 @@ int jffs2_dataflash_setup(struct jffs2_sb_info *c) { | |||
1222 | 1230 | ||
1223 | if ((c->flash_size % c->sector_size) != 0) { | 1231 | if ((c->flash_size % c->sector_size) != 0) { |
1224 | c->flash_size = (c->flash_size / c->sector_size) * c->sector_size; | 1232 | c->flash_size = (c->flash_size / c->sector_size) * c->sector_size; |
1225 | printk(KERN_WARNING "JFFS2 flash size adjusted to %dKiB\n", c->flash_size); | 1233 | pr_warn("flash size adjusted to %dKiB\n", c->flash_size); |
1226 | }; | 1234 | }; |
1227 | 1235 | ||
1228 | c->wbuf_ofs = 0xFFFFFFFF; | 1236 | c->wbuf_ofs = 0xFFFFFFFF; |
@@ -1239,7 +1247,8 @@ int jffs2_dataflash_setup(struct jffs2_sb_info *c) { | |||
1239 | } | 1247 | } |
1240 | #endif | 1248 | #endif |
1241 | 1249 | ||
1242 | printk(KERN_INFO "JFFS2 write-buffering enabled buffer (%d) erasesize (%d)\n", c->wbuf_pagesize, c->sector_size); | 1250 | pr_info("write-buffering enabled buffer (%d) erasesize (%d)\n", |
1251 | c->wbuf_pagesize, c->sector_size); | ||
1243 | 1252 | ||
1244 | return 0; | 1253 | return 0; |
1245 | } | 1254 | } |
@@ -1297,7 +1306,8 @@ int jffs2_ubivol_setup(struct jffs2_sb_info *c) { | |||
1297 | if (!c->wbuf) | 1306 | if (!c->wbuf) |
1298 | return -ENOMEM; | 1307 | return -ENOMEM; |
1299 | 1308 | ||
1300 | printk(KERN_INFO "JFFS2 write-buffering enabled buffer (%d) erasesize (%d)\n", c->wbuf_pagesize, c->sector_size); | 1309 | pr_info("write-buffering enabled buffer (%d) erasesize (%d)\n", |
1310 | c->wbuf_pagesize, c->sector_size); | ||
1301 | 1311 | ||
1302 | return 0; | 1312 | return 0; |
1303 | } | 1313 | } |