aboutsummaryrefslogtreecommitdiffstats
path: root/fs/jffs2/wbuf.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/jffs2/wbuf.c')
-rw-r--r--fs/jffs2/wbuf.c83
1 files changed, 42 insertions, 41 deletions
diff --git a/fs/jffs2/wbuf.c b/fs/jffs2/wbuf.c
index d626eb2113e1..89a6ec0fa766 100644
--- a/fs/jffs2/wbuf.c
+++ b/fs/jffs2/wbuf.c
@@ -233,10 +233,12 @@ static int jffs2_verify_write(struct jffs2_sb_info *c, unsigned char *buf,
233 233
234 ret = mtd_read(c->mtd, ofs, c->wbuf_pagesize, &retlen, c->wbuf_verify); 234 ret = mtd_read(c->mtd, ofs, c->wbuf_pagesize, &retlen, c->wbuf_verify);
235 if (ret && ret != -EUCLEAN && ret != -EBADMSG) { 235 if (ret && ret != -EUCLEAN && ret != -EBADMSG) {
236 printk(KERN_WARNING "jffs2_verify_write(): Read back of page at %08x failed: %d\n", c->wbuf_ofs, ret); 236 pr_warn("%s(): Read back of page at %08x failed: %d\n",
237 __func__, c->wbuf_ofs, ret);
237 return ret; 238 return ret;
238 } else if (retlen != c->wbuf_pagesize) { 239 } else if (retlen != c->wbuf_pagesize) {
239 printk(KERN_WARNING "jffs2_verify_write(): Read back of page at %08x gave short read: %zd not %d.\n", ofs, retlen, c->wbuf_pagesize); 240 pr_warn("%s(): Read back of page at %08x gave short read: %zd not %d\n",
241 __func__, ofs, retlen, c->wbuf_pagesize);
240 return -EIO; 242 return -EIO;
241 } 243 }
242 if (!memcmp(buf, c->wbuf_verify, c->wbuf_pagesize)) 244 if (!memcmp(buf, c->wbuf_verify, c->wbuf_pagesize))
@@ -249,12 +251,12 @@ static int jffs2_verify_write(struct jffs2_sb_info *c, unsigned char *buf,
249 else 251 else
250 eccstr = "OK or unused"; 252 eccstr = "OK or unused";
251 253
252 printk(KERN_WARNING "Write verify error (ECC %s) at %08x. Wrote:\n", 254 pr_warn("Write verify error (ECC %s) at %08x. Wrote:\n",
253 eccstr, c->wbuf_ofs); 255 eccstr, c->wbuf_ofs);
254 print_hex_dump(KERN_WARNING, "", DUMP_PREFIX_OFFSET, 16, 1, 256 print_hex_dump(KERN_WARNING, "", DUMP_PREFIX_OFFSET, 16, 1,
255 c->wbuf, c->wbuf_pagesize, 0); 257 c->wbuf, c->wbuf_pagesize, 0);
256 258
257 printk(KERN_WARNING "Read back:\n"); 259 pr_warn("Read back:\n");
258 print_hex_dump(KERN_WARNING, "", DUMP_PREFIX_OFFSET, 16, 1, 260 print_hex_dump(KERN_WARNING, "", DUMP_PREFIX_OFFSET, 16, 1,
259 c->wbuf_verify, c->wbuf_pagesize, 0); 261 c->wbuf_verify, c->wbuf_pagesize, 0);
260 262
@@ -334,7 +336,7 @@ static void jffs2_wbuf_recover(struct jffs2_sb_info *c)
334 336
335 buf = kmalloc(end - start, GFP_KERNEL); 337 buf = kmalloc(end - start, GFP_KERNEL);
336 if (!buf) { 338 if (!buf) {
337 printk(KERN_CRIT "Malloc failure in wbuf recovery. Data loss ensues.\n"); 339 pr_crit("Malloc failure in wbuf recovery. Data loss ensues.\n");
338 340
339 goto read_failed; 341 goto read_failed;
340 } 342 }
@@ -349,7 +351,7 @@ static void jffs2_wbuf_recover(struct jffs2_sb_info *c)
349 ret = 0; 351 ret = 0;
350 352
351 if (ret || retlen != c->wbuf_ofs - start) { 353 if (ret || retlen != c->wbuf_ofs - start) {
352 printk(KERN_CRIT "Old data are already lost in wbuf recovery. Data loss ensues.\n"); 354 pr_crit("Old data are already lost in wbuf recovery. Data loss ensues.\n");
353 355
354 kfree(buf); 356 kfree(buf);
355 buf = NULL; 357 buf = NULL;
@@ -383,7 +385,7 @@ static void jffs2_wbuf_recover(struct jffs2_sb_info *c)
383 /* ... and get an allocation of space from a shiny new block instead */ 385 /* ... and get an allocation of space from a shiny new block instead */
384 ret = jffs2_reserve_space_gc(c, end-start, &len, JFFS2_SUMMARY_NOSUM_SIZE); 386 ret = jffs2_reserve_space_gc(c, end-start, &len, JFFS2_SUMMARY_NOSUM_SIZE);
385 if (ret) { 387 if (ret) {
386 printk(KERN_WARNING "Failed to allocate space for wbuf recovery. Data loss ensues.\n"); 388 pr_warn("Failed to allocate space for wbuf recovery. Data loss ensues.\n");
387 kfree(buf); 389 kfree(buf);
388 return; 390 return;
389 } 391 }
@@ -393,7 +395,7 @@ static void jffs2_wbuf_recover(struct jffs2_sb_info *c)
393 395
394 ret = jffs2_prealloc_raw_node_refs(c, c->nextblock, nr_refile); 396 ret = jffs2_prealloc_raw_node_refs(c, c->nextblock, nr_refile);
395 if (ret) { 397 if (ret) {
396 printk(KERN_WARNING "Failed to allocate node refs for wbuf recovery. Data loss ensues.\n"); 398 pr_warn("Failed to allocate node refs for wbuf recovery. Data loss ensues.\n");
397 kfree(buf); 399 kfree(buf);
398 return; 400 return;
399 } 401 }
@@ -415,7 +417,7 @@ static void jffs2_wbuf_recover(struct jffs2_sb_info *c)
415#ifdef BREAKMEHEADER 417#ifdef BREAKMEHEADER
416 static int breakme; 418 static int breakme;
417 if (breakme++ == 20) { 419 if (breakme++ == 20) {
418 printk(KERN_NOTICE "Faking write error at 0x%08x\n", ofs); 420 pr_notice("Faking write error at 0x%08x\n", ofs);
419 breakme = 0; 421 breakme = 0;
420 mtd_write(c->mtd, ofs, towrite, &retlen, brokenbuf); 422 mtd_write(c->mtd, ofs, towrite, &retlen, brokenbuf);
421 ret = -EIO; 423 ret = -EIO;
@@ -426,7 +428,7 @@ static void jffs2_wbuf_recover(struct jffs2_sb_info *c)
426 428
427 if (ret || retlen != towrite || jffs2_verify_write(c, rewrite_buf, ofs)) { 429 if (ret || retlen != towrite || jffs2_verify_write(c, rewrite_buf, ofs)) {
428 /* Argh. We tried. Really we did. */ 430 /* Argh. We tried. Really we did. */
429 printk(KERN_CRIT "Recovery of wbuf failed due to a second write error\n"); 431 pr_crit("Recovery of wbuf failed due to a second write error\n");
430 kfree(buf); 432 kfree(buf);
431 433
432 if (retlen) 434 if (retlen)
@@ -434,7 +436,7 @@ static void jffs2_wbuf_recover(struct jffs2_sb_info *c)
434 436
435 return; 437 return;
436 } 438 }
437 printk(KERN_NOTICE "Recovery of wbuf succeeded to %08x\n", ofs); 439 pr_notice("Recovery of wbuf succeeded to %08x\n", ofs);
438 440
439 c->wbuf_len = (end - start) - towrite; 441 c->wbuf_len = (end - start) - towrite;
440 c->wbuf_ofs = ofs + towrite; 442 c->wbuf_ofs = ofs + towrite;
@@ -584,7 +586,7 @@ static int __jffs2_flush_wbuf(struct jffs2_sb_info *c, int pad)
584 return 0; 586 return 0;
585 587
586 if (!mutex_is_locked(&c->alloc_sem)) { 588 if (!mutex_is_locked(&c->alloc_sem)) {
587 printk(KERN_CRIT "jffs2_flush_wbuf() called with alloc_sem not locked!\n"); 589 pr_crit("jffs2_flush_wbuf() called with alloc_sem not locked!\n");
588 BUG(); 590 BUG();
589 } 591 }
590 592
@@ -622,7 +624,7 @@ static int __jffs2_flush_wbuf(struct jffs2_sb_info *c, int pad)
622#ifdef BREAKME 624#ifdef BREAKME
623 static int breakme; 625 static int breakme;
624 if (breakme++ == 20) { 626 if (breakme++ == 20) {
625 printk(KERN_NOTICE "Faking write error at 0x%08x\n", c->wbuf_ofs); 627 pr_notice("Faking write error at 0x%08x\n", c->wbuf_ofs);
626 breakme = 0; 628 breakme = 0;
627 mtd_write(c->mtd, c->wbuf_ofs, c->wbuf_pagesize, &retlen, 629 mtd_write(c->mtd, c->wbuf_ofs, c->wbuf_pagesize, &retlen,
628 brokenbuf); 630 brokenbuf);
@@ -634,11 +636,11 @@ static int __jffs2_flush_wbuf(struct jffs2_sb_info *c, int pad)
634 &retlen, c->wbuf); 636 &retlen, c->wbuf);
635 637
636 if (ret) { 638 if (ret) {
637 printk(KERN_WARNING "jffs2_flush_wbuf(): Write failed with %d\n", ret); 639 pr_warn("jffs2_flush_wbuf(): Write failed with %d\n", ret);
638 goto wfail; 640 goto wfail;
639 } else if (retlen != c->wbuf_pagesize) { 641 } else if (retlen != c->wbuf_pagesize) {
640 printk(KERN_WARNING "jffs2_flush_wbuf(): Write was short: %zd instead of %d\n", 642 pr_warn("jffs2_flush_wbuf(): Write was short: %zd instead of %d\n",
641 retlen, c->wbuf_pagesize); 643 retlen, c->wbuf_pagesize);
642 ret = -EIO; 644 ret = -EIO;
643 goto wfail; 645 goto wfail;
644 } else if ((ret = jffs2_verify_write(c, c->wbuf, c->wbuf_ofs))) { 646 } else if ((ret = jffs2_verify_write(c, c->wbuf, c->wbuf_ofs))) {
@@ -660,10 +662,10 @@ static int __jffs2_flush_wbuf(struct jffs2_sb_info *c, int pad)
660 padded. If there is less free space in the block than that, 662 padded. If there is less free space in the block than that,
661 something screwed up */ 663 something screwed up */
662 if (wbuf_jeb->free_size < waste) { 664 if (wbuf_jeb->free_size < waste) {
663 printk(KERN_CRIT "jffs2_flush_wbuf(): Accounting error. wbuf at 0x%08x has 0x%03x bytes, 0x%03x left.\n", 665 pr_crit("jffs2_flush_wbuf(): Accounting error. wbuf at 0x%08x has 0x%03x bytes, 0x%03x left.\n",
664 c->wbuf_ofs, c->wbuf_len, waste); 666 c->wbuf_ofs, c->wbuf_len, waste);
665 printk(KERN_CRIT "jffs2_flush_wbuf(): But free_size for block at 0x%08x is only 0x%08x\n", 667 pr_crit("jffs2_flush_wbuf(): But free_size for block at 0x%08x is only 0x%08x\n",
666 wbuf_jeb->offset, wbuf_jeb->free_size); 668 wbuf_jeb->offset, wbuf_jeb->free_size);
667 BUG(); 669 BUG();
668 } 670 }
669 671
@@ -831,11 +833,11 @@ int jffs2_flash_writev(struct jffs2_sb_info *c, const struct kvec *invecs,
831 833
832 if (to != PAD(c->wbuf_ofs + c->wbuf_len)) { 834 if (to != PAD(c->wbuf_ofs + c->wbuf_len)) {
833 /* We're not writing immediately after the writebuffer. Bad. */ 835 /* We're not writing immediately after the writebuffer. Bad. */
834 printk(KERN_CRIT "%s(): Non-contiguous write to %08lx\n", 836 pr_crit("%s(): Non-contiguous write to %08lx\n",
835 __func__, (unsigned long)to); 837 __func__, (unsigned long)to);
836 if (c->wbuf_len) 838 if (c->wbuf_len)
837 printk(KERN_CRIT "wbuf was previously %08x-%08x\n", 839 pr_crit("wbuf was previously %08x-%08x\n",
838 c->wbuf_ofs, c->wbuf_ofs+c->wbuf_len); 840 c->wbuf_ofs, c->wbuf_ofs + c->wbuf_len);
839 BUG(); 841 BUG();
840 } 842 }
841 843
@@ -963,8 +965,8 @@ int jffs2_flash_read(struct jffs2_sb_info *c, loff_t ofs, size_t len, size_t *re
963 965
964 if ( (ret == -EBADMSG || ret == -EUCLEAN) && (*retlen == len) ) { 966 if ( (ret == -EBADMSG || ret == -EUCLEAN) && (*retlen == len) ) {
965 if (ret == -EBADMSG) 967 if (ret == -EBADMSG)
966 printk(KERN_WARNING "mtd->read(0x%zx bytes from 0x%llx)" 968 pr_warn("mtd->read(0x%zx bytes from 0x%llx) returned ECC error\n",
967 " returned ECC error\n", len, ofs); 969 len, ofs);
968 /* 970 /*
969 * We have the raw data without ECC correction in the buffer, 971 * We have the raw data without ECC correction in the buffer,
970 * maybe we are lucky and all data or parts are correct. We 972 * maybe we are lucky and all data or parts are correct. We
@@ -1040,9 +1042,8 @@ int jffs2_check_oob_empty(struct jffs2_sb_info *c,
1040 1042
1041 ret = mtd_read_oob(c->mtd, jeb->offset, &ops); 1043 ret = mtd_read_oob(c->mtd, jeb->offset, &ops);
1042 if (ret || ops.oobretlen != ops.ooblen) { 1044 if (ret || ops.oobretlen != ops.ooblen) {
1043 printk(KERN_ERR "cannot read OOB for EB at %08x, requested %zd" 1045 pr_err("cannot read OOB for EB at %08x, requested %zd bytes, read %zd bytes, error %d\n",
1044 " bytes, read %zd bytes, error %d\n", 1046 jeb->offset, ops.ooblen, ops.oobretlen, ret);
1045 jeb->offset, ops.ooblen, ops.oobretlen, ret);
1046 if (!ret) 1047 if (!ret)
1047 ret = -EIO; 1048 ret = -EIO;
1048 return ret; 1049 return ret;
@@ -1083,9 +1084,8 @@ int jffs2_check_nand_cleanmarker(struct jffs2_sb_info *c,
1083 1084
1084 ret = mtd_read_oob(c->mtd, jeb->offset, &ops); 1085 ret = mtd_read_oob(c->mtd, jeb->offset, &ops);
1085 if (ret || ops.oobretlen != ops.ooblen) { 1086 if (ret || ops.oobretlen != ops.ooblen) {
1086 printk(KERN_ERR "cannot read OOB for EB at %08x, requested %zd" 1087 pr_err("cannot read OOB for EB at %08x, requested %zd bytes, read %zd bytes, error %d\n",
1087 " bytes, read %zd bytes, error %d\n", 1088 jeb->offset, ops.ooblen, ops.oobretlen, ret);
1088 jeb->offset, ops.ooblen, ops.oobretlen, ret);
1089 if (!ret) 1089 if (!ret)
1090 ret = -EIO; 1090 ret = -EIO;
1091 return ret; 1091 return ret;
@@ -1109,9 +1109,8 @@ int jffs2_write_nand_cleanmarker(struct jffs2_sb_info *c,
1109 1109
1110 ret = mtd_write_oob(c->mtd, jeb->offset, &ops); 1110 ret = mtd_write_oob(c->mtd, jeb->offset, &ops);
1111 if (ret || ops.oobretlen != ops.ooblen) { 1111 if (ret || ops.oobretlen != ops.ooblen) {
1112 printk(KERN_ERR "cannot write OOB for EB at %08x, requested %zd" 1112 pr_err("cannot write OOB for EB at %08x, requested %zd bytes, read %zd bytes, error %d\n",
1113 " bytes, read %zd bytes, error %d\n", 1113 jeb->offset, ops.ooblen, ops.oobretlen, ret);
1114 jeb->offset, ops.ooblen, ops.oobretlen, ret);
1115 if (!ret) 1114 if (!ret)
1116 ret = -EIO; 1115 ret = -EIO;
1117 return ret; 1116 return ret;
@@ -1136,7 +1135,7 @@ int jffs2_write_nand_badblock(struct jffs2_sb_info *c, struct jffs2_eraseblock *
1136 if( ++jeb->bad_count < MAX_ERASE_FAILURES) 1135 if( ++jeb->bad_count < MAX_ERASE_FAILURES)
1137 return 0; 1136 return 0;
1138 1137
1139 printk(KERN_WARNING "JFFS2: marking eraseblock at %08x\n as bad", bad_offset); 1138 pr_warn("JFFS2: marking eraseblock at %08x as bad\n", bad_offset);
1140 ret = mtd_block_markbad(c->mtd, bad_offset); 1139 ret = mtd_block_markbad(c->mtd, bad_offset);
1141 1140
1142 if (ret) { 1141 if (ret) {
@@ -1158,7 +1157,7 @@ int jffs2_nand_flash_setup(struct jffs2_sb_info *c)
1158 c->cleanmarker_size = 0; 1157 c->cleanmarker_size = 0;
1159 1158
1160 if (!oinfo || oinfo->oobavail == 0) { 1159 if (!oinfo || oinfo->oobavail == 0) {
1161 printk(KERN_ERR "inconsistent device description\n"); 1160 pr_err("inconsistent device description\n");
1162 return -EINVAL; 1161 return -EINVAL;
1163 } 1162 }
1164 1163
@@ -1229,7 +1228,7 @@ int jffs2_dataflash_setup(struct jffs2_sb_info *c) {
1229 1228
1230 if ((c->flash_size % c->sector_size) != 0) { 1229 if ((c->flash_size % c->sector_size) != 0) {
1231 c->flash_size = (c->flash_size / c->sector_size) * c->sector_size; 1230 c->flash_size = (c->flash_size / c->sector_size) * c->sector_size;
1232 printk(KERN_WARNING "JFFS2 flash size adjusted to %dKiB\n", c->flash_size); 1231 pr_warn("JFFS2 flash size adjusted to %dKiB\n", c->flash_size);
1233 }; 1232 };
1234 1233
1235 c->wbuf_ofs = 0xFFFFFFFF; 1234 c->wbuf_ofs = 0xFFFFFFFF;
@@ -1246,7 +1245,8 @@ int jffs2_dataflash_setup(struct jffs2_sb_info *c) {
1246 } 1245 }
1247#endif 1246#endif
1248 1247
1249 printk(KERN_INFO "JFFS2 write-buffering enabled buffer (%d) erasesize (%d)\n", c->wbuf_pagesize, c->sector_size); 1248 pr_info("JFFS2 write-buffering enabled buffer (%d) erasesize (%d)\n",
1249 c->wbuf_pagesize, c->sector_size);
1250 1250
1251 return 0; 1251 return 0;
1252} 1252}
@@ -1304,7 +1304,8 @@ int jffs2_ubivol_setup(struct jffs2_sb_info *c) {
1304 if (!c->wbuf) 1304 if (!c->wbuf)
1305 return -ENOMEM; 1305 return -ENOMEM;
1306 1306
1307 printk(KERN_INFO "JFFS2 write-buffering enabled buffer (%d) erasesize (%d)\n", c->wbuf_pagesize, c->sector_size); 1307 pr_info("JFFS2 write-buffering enabled buffer (%d) erasesize (%d)\n",
1308 c->wbuf_pagesize, c->sector_size);
1308 1309
1309 return 0; 1310 return 0;
1310} 1311}