diff options
Diffstat (limited to 'fs/jffs2/gc.c')
-rw-r--r-- | fs/jffs2/gc.c | 25 |
1 files changed, 6 insertions, 19 deletions
diff --git a/fs/jffs2/gc.c b/fs/jffs2/gc.c index f9e982a65ac2..a22ff5df7fcc 100644 --- a/fs/jffs2/gc.c +++ b/fs/jffs2/gc.c | |||
@@ -528,7 +528,6 @@ static int jffs2_garbage_collect_pristine(struct jffs2_sb_info *c, | |||
528 | struct jffs2_raw_node_ref *raw) | 528 | struct jffs2_raw_node_ref *raw) |
529 | { | 529 | { |
530 | union jffs2_node_union *node; | 530 | union jffs2_node_union *node; |
531 | struct jffs2_raw_node_ref *nraw; | ||
532 | size_t retlen; | 531 | size_t retlen; |
533 | int ret; | 532 | int ret; |
534 | uint32_t phys_ofs, alloclen; | 533 | uint32_t phys_ofs, alloclen; |
@@ -618,30 +617,21 @@ static int jffs2_garbage_collect_pristine(struct jffs2_sb_info *c, | |||
618 | } | 617 | } |
619 | } | 618 | } |
620 | 619 | ||
621 | nraw = jffs2_alloc_raw_node_ref(); | ||
622 | if (!nraw) { | ||
623 | ret = -ENOMEM; | ||
624 | goto out_node; | ||
625 | } | ||
626 | |||
627 | /* OK, all the CRCs are good; this node can just be copied as-is. */ | 620 | /* OK, all the CRCs are good; this node can just be copied as-is. */ |
628 | retry: | 621 | retry: |
629 | nraw->flash_offset = phys_ofs = write_ofs(c); | 622 | phys_ofs = write_ofs(c); |
630 | 623 | ||
631 | ret = jffs2_flash_write(c, phys_ofs, rawlen, &retlen, (char *)node); | 624 | ret = jffs2_flash_write(c, phys_ofs, rawlen, &retlen, (char *)node); |
632 | 625 | ||
633 | if (ret || (retlen != rawlen)) { | 626 | if (ret || (retlen != rawlen)) { |
634 | printk(KERN_NOTICE "Write of %d bytes at 0x%08x failed. returned %d, retlen %zd\n", | 627 | printk(KERN_NOTICE "Write of %d bytes at 0x%08x failed. returned %d, retlen %zd\n", |
635 | rawlen, nraw->flash_offset, ret, retlen); | 628 | rawlen, phys_ofs, ret, retlen); |
636 | if (retlen) { | 629 | if (retlen) { |
637 | nraw->flash_offset |= REF_OBSOLETE; | 630 | jffs2_add_physical_node_ref(c, phys_ofs | REF_OBSOLETE, rawlen, NULL); |
638 | jffs2_add_physical_node_ref(c, nraw, rawlen, NULL); | ||
639 | jffs2_mark_node_obsolete(c, nraw); | ||
640 | } else { | 631 | } else { |
641 | printk(KERN_NOTICE "Not marking the space at 0x%08x as dirty because the flash driver returned retlen zero\n", nraw->flash_offset); | 632 | printk(KERN_NOTICE "Not marking the space at 0x%08x as dirty because the flash driver returned retlen zero\n", phys_ofs); |
642 | jffs2_free_raw_node_ref(nraw); | ||
643 | } | 633 | } |
644 | if (!retried && (nraw = jffs2_alloc_raw_node_ref())) { | 634 | if (!retried) { |
645 | /* Try to reallocate space and retry */ | 635 | /* Try to reallocate space and retry */ |
646 | uint32_t dummy; | 636 | uint32_t dummy; |
647 | struct jffs2_eraseblock *jeb = &c->blocks[phys_ofs / c->sector_size]; | 637 | struct jffs2_eraseblock *jeb = &c->blocks[phys_ofs / c->sector_size]; |
@@ -666,16 +656,13 @@ static int jffs2_garbage_collect_pristine(struct jffs2_sb_info *c, | |||
666 | goto retry; | 656 | goto retry; |
667 | } | 657 | } |
668 | D1(printk(KERN_DEBUG "Failed to allocate space to retry failed write: %d!\n", ret)); | 658 | D1(printk(KERN_DEBUG "Failed to allocate space to retry failed write: %d!\n", ret)); |
669 | jffs2_free_raw_node_ref(nraw); | ||
670 | } | 659 | } |
671 | 660 | ||
672 | jffs2_free_raw_node_ref(nraw); | ||
673 | if (!ret) | 661 | if (!ret) |
674 | ret = -EIO; | 662 | ret = -EIO; |
675 | goto out_node; | 663 | goto out_node; |
676 | } | 664 | } |
677 | nraw->flash_offset |= REF_PRISTINE; | 665 | jffs2_add_physical_node_ref(c, phys_ofs | REF_PRISTINE, rawlen, ic); |
678 | jffs2_add_physical_node_ref(c, nraw, rawlen, ic); | ||
679 | 666 | ||
680 | jffs2_mark_node_obsolete(c, raw); | 667 | jffs2_mark_node_obsolete(c, raw); |
681 | D1(printk(KERN_DEBUG "WHEEE! GC REF_PRISTINE node at 0x%08x succeeded\n", ref_offset(raw))); | 668 | D1(printk(KERN_DEBUG "WHEEE! GC REF_PRISTINE node at 0x%08x succeeded\n", ref_offset(raw))); |