diff options
author | David Woodhouse <dwmw2@infradead.org> | 2006-05-23 21:04:45 -0400 |
---|---|---|
committer | David Woodhouse <dwmw2@infradead.org> | 2006-05-23 21:04:45 -0400 |
commit | 2f785402f39b96a077b6e62bf26164bfb8e0c980 (patch) | |
tree | 3f3a38b484ef2dabda1599d4d8f08b121bd03a76 /fs/jffs2/gc.c | |
parent | 4cbb9b80e171107c6c34116283fe38e5a396c68b (diff) |
[JFFS2] Reduce visibility of raw_node_ref to upper layers of JFFS2 code.
As the first step towards eliminating the ref->next_phys member and saving
memory by using an _array_ of struct jffs2_raw_node_ref per eraseblock,
stop the write functions from allocating their own refs; have them just
_reserve_ the appropriate number instead. Then jffs2_link_node_ref() can
just fill them in.
Use a linked list of pre-allocated refs in the superblock, for now. Once
we switch to an array, it'll just be a case of extending that array.
Signed-off-by: David Woodhouse <dwmw2@infradead.org>
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))); |