diff options
author | Thomas Gleixner <tglx@cruncher.tec.linutronix.de> | 2006-05-23 06:37:31 -0400 |
---|---|---|
committer | Thomas Gleixner <tglx@cruncher.tec.linutronix.de> | 2006-05-23 06:37:31 -0400 |
commit | 4cbb9b80e171107c6c34116283fe38e5a396c68b (patch) | |
tree | 9463f2e4774f14752cf4bb52431e14e569256f72 /fs/jffs2/gc.c | |
parent | 6dfc6d250d0b7ebaa6423c44dcd09fcfe68deabd (diff) | |
parent | 9fe4854cd1f60273f9a3ece053f4789605f58a5e (diff) |
Merge branch 'master' of /home/tglx/work/kernel/git/mtd-2.6/
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Diffstat (limited to 'fs/jffs2/gc.c')
-rw-r--r-- | fs/jffs2/gc.c | 51 |
1 files changed, 19 insertions, 32 deletions
diff --git a/fs/jffs2/gc.c b/fs/jffs2/gc.c index 4773ba24304f..f9e982a65ac2 100644 --- a/fs/jffs2/gc.c +++ b/fs/jffs2/gc.c | |||
@@ -545,7 +545,7 @@ static int jffs2_garbage_collect_pristine(struct jffs2_sb_info *c, | |||
545 | if (ic && alloclen > sizeof(struct jffs2_raw_inode) + JFFS2_MIN_DATA_LEN) | 545 | if (ic && alloclen > sizeof(struct jffs2_raw_inode) + JFFS2_MIN_DATA_LEN) |
546 | alloclen = sizeof(struct jffs2_raw_inode) + JFFS2_MIN_DATA_LEN; | 546 | alloclen = sizeof(struct jffs2_raw_inode) + JFFS2_MIN_DATA_LEN; |
547 | 547 | ||
548 | ret = jffs2_reserve_space_gc(c, alloclen, &phys_ofs, &alloclen, rawlen); | 548 | ret = jffs2_reserve_space_gc(c, alloclen, &alloclen, rawlen); |
549 | /* 'rawlen' is not the exact summary size; it is only an upper estimation */ | 549 | /* 'rawlen' is not the exact summary size; it is only an upper estimation */ |
550 | 550 | ||
551 | if (ret) | 551 | if (ret) |
@@ -626,19 +626,16 @@ static int jffs2_garbage_collect_pristine(struct jffs2_sb_info *c, | |||
626 | 626 | ||
627 | /* OK, all the CRCs are good; this node can just be copied as-is. */ | 627 | /* OK, all the CRCs are good; this node can just be copied as-is. */ |
628 | retry: | 628 | retry: |
629 | nraw->flash_offset = phys_ofs; | 629 | nraw->flash_offset = phys_ofs = write_ofs(c); |
630 | 630 | ||
631 | ret = jffs2_flash_write(c, phys_ofs, rawlen, &retlen, (char *)node); | 631 | ret = jffs2_flash_write(c, phys_ofs, rawlen, &retlen, (char *)node); |
632 | 632 | ||
633 | if (ret || (retlen != rawlen)) { | 633 | if (ret || (retlen != rawlen)) { |
634 | printk(KERN_NOTICE "Write of %d bytes at 0x%08x failed. returned %d, retlen %zd\n", | 634 | printk(KERN_NOTICE "Write of %d bytes at 0x%08x failed. returned %d, retlen %zd\n", |
635 | rawlen, phys_ofs, ret, retlen); | 635 | rawlen, nraw->flash_offset, ret, retlen); |
636 | if (retlen) { | 636 | if (retlen) { |
637 | /* Doesn't belong to any inode */ | ||
638 | nraw->next_in_ino = NULL; | ||
639 | |||
640 | nraw->flash_offset |= REF_OBSOLETE; | 637 | nraw->flash_offset |= REF_OBSOLETE; |
641 | jffs2_add_physical_node_ref(c, nraw, rawlen); | 638 | jffs2_add_physical_node_ref(c, nraw, rawlen, NULL); |
642 | jffs2_mark_node_obsolete(c, nraw); | 639 | jffs2_mark_node_obsolete(c, nraw); |
643 | } else { | 640 | } else { |
644 | printk(KERN_NOTICE "Not marking the space at 0x%08x as dirty because the flash driver returned retlen zero\n", nraw->flash_offset); | 641 | printk(KERN_NOTICE "Not marking the space at 0x%08x as dirty because the flash driver returned retlen zero\n", nraw->flash_offset); |
@@ -656,7 +653,7 @@ static int jffs2_garbage_collect_pristine(struct jffs2_sb_info *c, | |||
656 | jffs2_dbg_acct_sanity_check(c,jeb); | 653 | jffs2_dbg_acct_sanity_check(c,jeb); |
657 | jffs2_dbg_acct_paranoia_check(c, jeb); | 654 | jffs2_dbg_acct_paranoia_check(c, jeb); |
658 | 655 | ||
659 | ret = jffs2_reserve_space_gc(c, rawlen, &phys_ofs, &dummy, rawlen); | 656 | ret = jffs2_reserve_space_gc(c, rawlen, &dummy, rawlen); |
660 | /* this is not the exact summary size of it, | 657 | /* this is not the exact summary size of it, |
661 | it is only an upper estimation */ | 658 | it is only an upper estimation */ |
662 | 659 | ||
@@ -678,18 +675,8 @@ static int jffs2_garbage_collect_pristine(struct jffs2_sb_info *c, | |||
678 | goto out_node; | 675 | goto out_node; |
679 | } | 676 | } |
680 | nraw->flash_offset |= REF_PRISTINE; | 677 | nraw->flash_offset |= REF_PRISTINE; |
681 | jffs2_add_physical_node_ref(c, nraw, rawlen); | 678 | jffs2_add_physical_node_ref(c, nraw, rawlen, ic); |
682 | 679 | ||
683 | if (ic) { | ||
684 | /* Link into per-inode list. This is safe because of the ic | ||
685 | state being INO_STATE_GC. Note that if we're doing this | ||
686 | for an inode which is in-core, the 'nraw' pointer is then | ||
687 | going to be fetched from ic->nodes by our caller. */ | ||
688 | spin_lock(&c->erase_completion_lock); | ||
689 | nraw->next_in_ino = ic->nodes; | ||
690 | ic->nodes = nraw; | ||
691 | spin_unlock(&c->erase_completion_lock); | ||
692 | } | ||
693 | jffs2_mark_node_obsolete(c, raw); | 680 | jffs2_mark_node_obsolete(c, raw); |
694 | D1(printk(KERN_DEBUG "WHEEE! GC REF_PRISTINE node at 0x%08x succeeded\n", ref_offset(raw))); | 681 | D1(printk(KERN_DEBUG "WHEEE! GC REF_PRISTINE node at 0x%08x succeeded\n", ref_offset(raw))); |
695 | 682 | ||
@@ -709,7 +696,7 @@ static int jffs2_garbage_collect_metadata(struct jffs2_sb_info *c, struct jffs2_ | |||
709 | struct jffs2_node_frag *last_frag; | 696 | struct jffs2_node_frag *last_frag; |
710 | union jffs2_device_node dev; | 697 | union jffs2_device_node dev; |
711 | char *mdata = NULL, mdatalen = 0; | 698 | char *mdata = NULL, mdatalen = 0; |
712 | uint32_t alloclen, phys_ofs, ilen; | 699 | uint32_t alloclen, ilen; |
713 | int ret; | 700 | int ret; |
714 | 701 | ||
715 | if (S_ISBLK(JFFS2_F_I_MODE(f)) || | 702 | if (S_ISBLK(JFFS2_F_I_MODE(f)) || |
@@ -735,7 +722,7 @@ static int jffs2_garbage_collect_metadata(struct jffs2_sb_info *c, struct jffs2_ | |||
735 | 722 | ||
736 | } | 723 | } |
737 | 724 | ||
738 | ret = jffs2_reserve_space_gc(c, sizeof(ri) + mdatalen, &phys_ofs, &alloclen, | 725 | ret = jffs2_reserve_space_gc(c, sizeof(ri) + mdatalen, &alloclen, |
739 | JFFS2_SUMMARY_INODE_SIZE); | 726 | JFFS2_SUMMARY_INODE_SIZE); |
740 | if (ret) { | 727 | if (ret) { |
741 | printk(KERN_WARNING "jffs2_reserve_space_gc of %zd bytes for garbage_collect_metadata failed: %d\n", | 728 | printk(KERN_WARNING "jffs2_reserve_space_gc of %zd bytes for garbage_collect_metadata failed: %d\n", |
@@ -773,7 +760,7 @@ static int jffs2_garbage_collect_metadata(struct jffs2_sb_info *c, struct jffs2_ | |||
773 | ri.node_crc = cpu_to_je32(crc32(0, &ri, sizeof(ri)-8)); | 760 | ri.node_crc = cpu_to_je32(crc32(0, &ri, sizeof(ri)-8)); |
774 | ri.data_crc = cpu_to_je32(crc32(0, mdata, mdatalen)); | 761 | ri.data_crc = cpu_to_je32(crc32(0, mdata, mdatalen)); |
775 | 762 | ||
776 | new_fn = jffs2_write_dnode(c, f, &ri, mdata, mdatalen, phys_ofs, ALLOC_GC); | 763 | new_fn = jffs2_write_dnode(c, f, &ri, mdata, mdatalen, ALLOC_GC); |
777 | 764 | ||
778 | if (IS_ERR(new_fn)) { | 765 | if (IS_ERR(new_fn)) { |
779 | printk(KERN_WARNING "Error writing new dnode: %ld\n", PTR_ERR(new_fn)); | 766 | printk(KERN_WARNING "Error writing new dnode: %ld\n", PTR_ERR(new_fn)); |
@@ -794,7 +781,7 @@ static int jffs2_garbage_collect_dirent(struct jffs2_sb_info *c, struct jffs2_er | |||
794 | { | 781 | { |
795 | struct jffs2_full_dirent *new_fd; | 782 | struct jffs2_full_dirent *new_fd; |
796 | struct jffs2_raw_dirent rd; | 783 | struct jffs2_raw_dirent rd; |
797 | uint32_t alloclen, phys_ofs; | 784 | uint32_t alloclen; |
798 | int ret; | 785 | int ret; |
799 | 786 | ||
800 | rd.magic = cpu_to_je16(JFFS2_MAGIC_BITMASK); | 787 | rd.magic = cpu_to_je16(JFFS2_MAGIC_BITMASK); |
@@ -816,14 +803,14 @@ static int jffs2_garbage_collect_dirent(struct jffs2_sb_info *c, struct jffs2_er | |||
816 | rd.node_crc = cpu_to_je32(crc32(0, &rd, sizeof(rd)-8)); | 803 | rd.node_crc = cpu_to_je32(crc32(0, &rd, sizeof(rd)-8)); |
817 | rd.name_crc = cpu_to_je32(crc32(0, fd->name, rd.nsize)); | 804 | rd.name_crc = cpu_to_je32(crc32(0, fd->name, rd.nsize)); |
818 | 805 | ||
819 | ret = jffs2_reserve_space_gc(c, sizeof(rd)+rd.nsize, &phys_ofs, &alloclen, | 806 | ret = jffs2_reserve_space_gc(c, sizeof(rd)+rd.nsize, &alloclen, |
820 | JFFS2_SUMMARY_DIRENT_SIZE(rd.nsize)); | 807 | JFFS2_SUMMARY_DIRENT_SIZE(rd.nsize)); |
821 | if (ret) { | 808 | if (ret) { |
822 | printk(KERN_WARNING "jffs2_reserve_space_gc of %zd bytes for garbage_collect_dirent failed: %d\n", | 809 | printk(KERN_WARNING "jffs2_reserve_space_gc of %zd bytes for garbage_collect_dirent failed: %d\n", |
823 | sizeof(rd)+rd.nsize, ret); | 810 | sizeof(rd)+rd.nsize, ret); |
824 | return ret; | 811 | return ret; |
825 | } | 812 | } |
826 | new_fd = jffs2_write_dirent(c, f, &rd, fd->name, rd.nsize, phys_ofs, ALLOC_GC); | 813 | new_fd = jffs2_write_dirent(c, f, &rd, fd->name, rd.nsize, ALLOC_GC); |
827 | 814 | ||
828 | if (IS_ERR(new_fd)) { | 815 | if (IS_ERR(new_fd)) { |
829 | printk(KERN_WARNING "jffs2_write_dirent in garbage_collect_dirent failed: %ld\n", PTR_ERR(new_fd)); | 816 | printk(KERN_WARNING "jffs2_write_dirent in garbage_collect_dirent failed: %ld\n", PTR_ERR(new_fd)); |
@@ -951,7 +938,7 @@ static int jffs2_garbage_collect_hole(struct jffs2_sb_info *c, struct jffs2_eras | |||
951 | struct jffs2_raw_inode ri; | 938 | struct jffs2_raw_inode ri; |
952 | struct jffs2_node_frag *frag; | 939 | struct jffs2_node_frag *frag; |
953 | struct jffs2_full_dnode *new_fn; | 940 | struct jffs2_full_dnode *new_fn; |
954 | uint32_t alloclen, phys_ofs, ilen; | 941 | uint32_t alloclen, ilen; |
955 | int ret; | 942 | int ret; |
956 | 943 | ||
957 | D1(printk(KERN_DEBUG "Writing replacement hole node for ino #%u from offset 0x%x to 0x%x\n", | 944 | D1(printk(KERN_DEBUG "Writing replacement hole node for ino #%u from offset 0x%x to 0x%x\n", |
@@ -1030,14 +1017,14 @@ static int jffs2_garbage_collect_hole(struct jffs2_sb_info *c, struct jffs2_eras | |||
1030 | ri.data_crc = cpu_to_je32(0); | 1017 | ri.data_crc = cpu_to_je32(0); |
1031 | ri.node_crc = cpu_to_je32(crc32(0, &ri, sizeof(ri)-8)); | 1018 | ri.node_crc = cpu_to_je32(crc32(0, &ri, sizeof(ri)-8)); |
1032 | 1019 | ||
1033 | ret = jffs2_reserve_space_gc(c, sizeof(ri), &phys_ofs, &alloclen, | 1020 | ret = jffs2_reserve_space_gc(c, sizeof(ri), &alloclen, |
1034 | JFFS2_SUMMARY_INODE_SIZE); | 1021 | JFFS2_SUMMARY_INODE_SIZE); |
1035 | if (ret) { | 1022 | if (ret) { |
1036 | printk(KERN_WARNING "jffs2_reserve_space_gc of %zd bytes for garbage_collect_hole failed: %d\n", | 1023 | printk(KERN_WARNING "jffs2_reserve_space_gc of %zd bytes for garbage_collect_hole failed: %d\n", |
1037 | sizeof(ri), ret); | 1024 | sizeof(ri), ret); |
1038 | return ret; | 1025 | return ret; |
1039 | } | 1026 | } |
1040 | new_fn = jffs2_write_dnode(c, f, &ri, NULL, 0, phys_ofs, ALLOC_GC); | 1027 | new_fn = jffs2_write_dnode(c, f, &ri, NULL, 0, ALLOC_GC); |
1041 | 1028 | ||
1042 | if (IS_ERR(new_fn)) { | 1029 | if (IS_ERR(new_fn)) { |
1043 | printk(KERN_WARNING "Error writing new hole node: %ld\n", PTR_ERR(new_fn)); | 1030 | printk(KERN_WARNING "Error writing new hole node: %ld\n", PTR_ERR(new_fn)); |
@@ -1099,7 +1086,7 @@ static int jffs2_garbage_collect_dnode(struct jffs2_sb_info *c, struct jffs2_era | |||
1099 | { | 1086 | { |
1100 | struct jffs2_full_dnode *new_fn; | 1087 | struct jffs2_full_dnode *new_fn; |
1101 | struct jffs2_raw_inode ri; | 1088 | struct jffs2_raw_inode ri; |
1102 | uint32_t alloclen, phys_ofs, offset, orig_end, orig_start; | 1089 | uint32_t alloclen, offset, orig_end, orig_start; |
1103 | int ret = 0; | 1090 | int ret = 0; |
1104 | unsigned char *comprbuf = NULL, *writebuf; | 1091 | unsigned char *comprbuf = NULL, *writebuf; |
1105 | unsigned long pg; | 1092 | unsigned long pg; |
@@ -1256,7 +1243,7 @@ static int jffs2_garbage_collect_dnode(struct jffs2_sb_info *c, struct jffs2_era | |||
1256 | uint32_t cdatalen; | 1243 | uint32_t cdatalen; |
1257 | uint16_t comprtype = JFFS2_COMPR_NONE; | 1244 | uint16_t comprtype = JFFS2_COMPR_NONE; |
1258 | 1245 | ||
1259 | ret = jffs2_reserve_space_gc(c, sizeof(ri) + JFFS2_MIN_DATA_LEN, &phys_ofs, | 1246 | ret = jffs2_reserve_space_gc(c, sizeof(ri) + JFFS2_MIN_DATA_LEN, |
1260 | &alloclen, JFFS2_SUMMARY_INODE_SIZE); | 1247 | &alloclen, JFFS2_SUMMARY_INODE_SIZE); |
1261 | 1248 | ||
1262 | if (ret) { | 1249 | if (ret) { |
@@ -1293,7 +1280,7 @@ static int jffs2_garbage_collect_dnode(struct jffs2_sb_info *c, struct jffs2_era | |||
1293 | ri.node_crc = cpu_to_je32(crc32(0, &ri, sizeof(ri)-8)); | 1280 | ri.node_crc = cpu_to_je32(crc32(0, &ri, sizeof(ri)-8)); |
1294 | ri.data_crc = cpu_to_je32(crc32(0, comprbuf, cdatalen)); | 1281 | ri.data_crc = cpu_to_je32(crc32(0, comprbuf, cdatalen)); |
1295 | 1282 | ||
1296 | new_fn = jffs2_write_dnode(c, f, &ri, comprbuf, cdatalen, phys_ofs, ALLOC_GC); | 1283 | new_fn = jffs2_write_dnode(c, f, &ri, comprbuf, cdatalen, ALLOC_GC); |
1297 | 1284 | ||
1298 | jffs2_free_comprbuf(comprbuf, writebuf); | 1285 | jffs2_free_comprbuf(comprbuf, writebuf); |
1299 | 1286 | ||