diff options
author | David Woodhouse <dwmw2@infradead.org> | 2006-05-24 04:04:17 -0400 |
---|---|---|
committer | David Woodhouse <dwmw2@infradead.org> | 2006-05-24 04:04:17 -0400 |
commit | 99988f7bbd16b861590dda4631c4db6cb17b5091 (patch) | |
tree | 38865d44c905d7f84d7eeb70186482e1e399fe9c /fs/jffs2 | |
parent | 2f785402f39b96a077b6e62bf26164bfb8e0c980 (diff) |
[JFFS2] Introduce ref_next() macro for finding next physical node
Another part of the preparation for switching to an array...
Signed-off-by: David Woodhouse <dwmw2@infradead.org>
Diffstat (limited to 'fs/jffs2')
-rw-r--r-- | fs/jffs2/debug.c | 14 | ||||
-rw-r--r-- | fs/jffs2/gc.c | 2 | ||||
-rw-r--r-- | fs/jffs2/nodelist.c | 13 | ||||
-rw-r--r-- | fs/jffs2/nodelist.h | 6 | ||||
-rw-r--r-- | fs/jffs2/nodemgmt.c | 22 | ||||
-rw-r--r-- | fs/jffs2/scan.c | 4 |
6 files changed, 31 insertions, 30 deletions
diff --git a/fs/jffs2/debug.c b/fs/jffs2/debug.c index 1fe17de713e8..72b4fc13a106 100644 --- a/fs/jffs2/debug.c +++ b/fs/jffs2/debug.c | |||
@@ -192,13 +192,13 @@ __jffs2_dbg_acct_paranoia_check_nolock(struct jffs2_sb_info *c, | |||
192 | else | 192 | else |
193 | my_dirty_size += totlen; | 193 | my_dirty_size += totlen; |
194 | 194 | ||
195 | if ((!ref2->next_phys) != (ref2 == jeb->last_node)) { | 195 | if ((!ref_next(ref2)) != (ref2 == jeb->last_node)) { |
196 | JFFS2_ERROR("node_ref for node at %#08x (mem %p) has next_phys at %#08x (mem %p), last_node is at %#08x (mem %p).\n", | 196 | JFFS2_ERROR("node_ref for node at %#08x (mem %p) has next at %#08x (mem %p), last_node is at %#08x (mem %p).\n", |
197 | ref_offset(ref2), ref2, ref_offset(ref2->next_phys), ref2->next_phys, | 197 | ref_offset(ref2), ref2, ref_offset(ref_next(ref2)), ref_next(ref2), |
198 | ref_offset(jeb->last_node), jeb->last_node); | 198 | ref_offset(jeb->last_node), jeb->last_node); |
199 | goto error; | 199 | goto error; |
200 | } | 200 | } |
201 | ref2 = ref2->next_phys; | 201 | ref2 = ref_next(ref2); |
202 | } | 202 | } |
203 | 203 | ||
204 | if (my_used_size != jeb->used_size) { | 204 | if (my_used_size != jeb->used_size) { |
@@ -268,9 +268,9 @@ __jffs2_dbg_dump_node_refs_nolock(struct jffs2_sb_info *c, | |||
268 | } | 268 | } |
269 | 269 | ||
270 | printk(JFFS2_DBG); | 270 | printk(JFFS2_DBG); |
271 | for (ref = jeb->first_node; ; ref = ref->next_phys) { | 271 | for (ref = jeb->first_node; ; ref = ref_next(ref)) { |
272 | printk("%#08x(%#x)", ref_offset(ref), ref->__totlen); | 272 | printk("%#08x(%#x)", ref_offset(ref), ref->__totlen); |
273 | if (ref->next_phys) | 273 | if (ref_next(ref)) |
274 | printk("->"); | 274 | printk("->"); |
275 | else | 275 | else |
276 | break; | 276 | break; |
diff --git a/fs/jffs2/gc.c b/fs/jffs2/gc.c index a22ff5df7fcc..477c526d638b 100644 --- a/fs/jffs2/gc.c +++ b/fs/jffs2/gc.c | |||
@@ -239,7 +239,7 @@ int jffs2_garbage_collect_pass(struct jffs2_sb_info *c) | |||
239 | 239 | ||
240 | while(ref_obsolete(raw)) { | 240 | while(ref_obsolete(raw)) { |
241 | D1(printk(KERN_DEBUG "Node at 0x%08x is obsolete... skipping\n", ref_offset(raw))); | 241 | D1(printk(KERN_DEBUG "Node at 0x%08x is obsolete... skipping\n", ref_offset(raw))); |
242 | raw = raw->next_phys; | 242 | raw = ref_next(raw); |
243 | if (unlikely(!raw)) { | 243 | if (unlikely(!raw)) { |
244 | printk(KERN_WARNING "eep. End of raw list while still supposedly nodes to GC\n"); | 244 | printk(KERN_WARNING "eep. End of raw list while still supposedly nodes to GC\n"); |
245 | printk(KERN_WARNING "erase block at 0x%08x. free_size 0x%08x, dirty_size 0x%08x, used_size 0x%08x\n", | 245 | printk(KERN_WARNING "erase block at 0x%08x. free_size 0x%08x, dirty_size 0x%08x, used_size 0x%08x\n", |
diff --git a/fs/jffs2/nodelist.c b/fs/jffs2/nodelist.c index 1e6eabd730f2..0e82979c741c 100644 --- a/fs/jffs2/nodelist.c +++ b/fs/jffs2/nodelist.c | |||
@@ -1159,9 +1159,10 @@ static inline uint32_t __ref_totlen(struct jffs2_sb_info *c, | |||
1159 | struct jffs2_raw_node_ref *ref) | 1159 | struct jffs2_raw_node_ref *ref) |
1160 | { | 1160 | { |
1161 | uint32_t ref_end; | 1161 | uint32_t ref_end; |
1162 | struct jffs2_raw_node_ref *next_ref = ref_next(ref); | ||
1162 | 1163 | ||
1163 | if (ref->next_phys) | 1164 | if (next_ref) |
1164 | ref_end = ref_offset(ref->next_phys); | 1165 | ref_end = ref_offset(next_ref); |
1165 | else { | 1166 | else { |
1166 | if (!jeb) | 1167 | if (!jeb) |
1167 | jeb = &c->blocks[ref->flash_offset / c->sector_size]; | 1168 | jeb = &c->blocks[ref->flash_offset / c->sector_size]; |
@@ -1196,11 +1197,11 @@ uint32_t __jffs2_ref_totlen(struct jffs2_sb_info *c, struct jffs2_eraseblock *je | |||
1196 | printk(KERN_CRIT "Totlen for ref at %p (0x%08x-0x%08x) miscalculated as 0x%x instead of %x\n", | 1197 | printk(KERN_CRIT "Totlen for ref at %p (0x%08x-0x%08x) miscalculated as 0x%x instead of %x\n", |
1197 | ref, ref_offset(ref), ref_offset(ref)+ref->__totlen, | 1198 | ref, ref_offset(ref), ref_offset(ref)+ref->__totlen, |
1198 | ret, ref->__totlen); | 1199 | ret, ref->__totlen); |
1199 | if (ref->next_phys) { | 1200 | if (ref_next(ref)) { |
1200 | printk(KERN_CRIT "next_phys %p (0x%08x-0x%08x)\n", ref->next_phys, ref_offset(ref->next_phys), | 1201 | printk(KERN_CRIT "next %p (0x%08x-0x%08x)\n", ref_next(ref), ref_offset(ref_next(ref)), |
1201 | ref_offset(ref->next_phys)+ref->__totlen); | 1202 | ref_offset(ref_next(ref))+ref->__totlen); |
1202 | } else | 1203 | } else |
1203 | printk(KERN_CRIT "No next_phys. jeb->last_node is %p\n", jeb->last_node); | 1204 | printk(KERN_CRIT "No next ref. jeb->last_node is %p\n", jeb->last_node); |
1204 | 1205 | ||
1205 | printk(KERN_CRIT "jeb->wasted_size %x, dirty_size %x, used_size %x, free_size %x\n", jeb->wasted_size, jeb->dirty_size, jeb->used_size, jeb->free_size); | 1206 | printk(KERN_CRIT "jeb->wasted_size %x, dirty_size %x, used_size %x, free_size %x\n", jeb->wasted_size, jeb->dirty_size, jeb->used_size, jeb->free_size); |
1206 | ret = ref->__totlen; | 1207 | ret = ref->__totlen; |
diff --git a/fs/jffs2/nodelist.h b/fs/jffs2/nodelist.h index 7cc74d2ab4dc..94d152de95eb 100644 --- a/fs/jffs2/nodelist.h +++ b/fs/jffs2/nodelist.h | |||
@@ -88,18 +88,18 @@ struct jffs2_raw_node_ref | |||
88 | #endif | 88 | #endif |
89 | }; | 89 | }; |
90 | 90 | ||
91 | #define ref_next(r) ((r)->next_phys) | ||
92 | |||
91 | static inline struct jffs2_inode_cache *jffs2_raw_ref_to_ic(struct jffs2_raw_node_ref *raw) | 93 | static inline struct jffs2_inode_cache *jffs2_raw_ref_to_ic(struct jffs2_raw_node_ref *raw) |
92 | { | 94 | { |
93 | while(raw->next_in_ino) { | 95 | while(raw->next_in_ino) |
94 | raw = raw->next_in_ino; | 96 | raw = raw->next_in_ino; |
95 | } | ||
96 | 97 | ||
97 | /* NB. This can be a jffs2_xattr_datum or jffs2_xattr_ref and | 98 | /* NB. This can be a jffs2_xattr_datum or jffs2_xattr_ref and |
98 | not actually a jffs2_inode_cache. Check ->class */ | 99 | not actually a jffs2_inode_cache. Check ->class */ |
99 | return ((struct jffs2_inode_cache *)raw); | 100 | return ((struct jffs2_inode_cache *)raw); |
100 | } | 101 | } |
101 | 102 | ||
102 | |||
103 | /* flash_offset & 3 always has to be zero, because nodes are | 103 | /* flash_offset & 3 always has to be zero, because nodes are |
104 | always aligned at 4 bytes. So we have a couple of extra bits | 104 | always aligned at 4 bytes. So we have a couple of extra bits |
105 | to play with, which indicate the node's status; see below: */ | 105 | to play with, which indicate the node's status; see below: */ |
diff --git a/fs/jffs2/nodemgmt.c b/fs/jffs2/nodemgmt.c index 01bf2773fe4d..f4649c275fbe 100644 --- a/fs/jffs2/nodemgmt.c +++ b/fs/jffs2/nodemgmt.c | |||
@@ -458,6 +458,7 @@ static inline int on_list(struct list_head *obj, struct list_head *head) | |||
458 | void jffs2_mark_node_obsolete(struct jffs2_sb_info *c, struct jffs2_raw_node_ref *ref) | 458 | void jffs2_mark_node_obsolete(struct jffs2_sb_info *c, struct jffs2_raw_node_ref *ref) |
459 | { | 459 | { |
460 | struct jffs2_eraseblock *jeb; | 460 | struct jffs2_eraseblock *jeb; |
461 | struct jffs2_raw_node_ref *next_ref; | ||
461 | int blocknr; | 462 | int blocknr; |
462 | struct jffs2_unknown_node n; | 463 | struct jffs2_unknown_node n; |
463 | int ret, addedsize; | 464 | int ret, addedsize; |
@@ -685,24 +686,23 @@ void jffs2_mark_node_obsolete(struct jffs2_sb_info *c, struct jffs2_raw_node_ref | |||
685 | 686 | ||
686 | /* Merge with the next node in the physical list, if there is one | 687 | /* Merge with the next node in the physical list, if there is one |
687 | and if it's also obsolete and if it doesn't belong to any inode */ | 688 | and if it's also obsolete and if it doesn't belong to any inode */ |
688 | if (ref->next_phys && ref_obsolete(ref->next_phys) && | 689 | next_ref = ref_next(ref); |
689 | !ref->next_phys->next_in_ino) { | ||
690 | struct jffs2_raw_node_ref *n = ref->next_phys; | ||
691 | 690 | ||
691 | if (next_ref && ref_obsolete(next_ref) && !next_ref->next_in_ino) { | ||
692 | spin_lock(&c->erase_completion_lock); | 692 | spin_lock(&c->erase_completion_lock); |
693 | 693 | ||
694 | #ifdef TEST_TOTLEN | 694 | #ifdef TEST_TOTLEN |
695 | ref->__totlen += n->__totlen; | 695 | ref->__totlen += next_ref->__totlen; |
696 | #endif | 696 | #endif |
697 | ref->next_phys = n->next_phys; | 697 | ref->next_phys = ref_next(next_ref); |
698 | if (jeb->last_node == n) jeb->last_node = ref; | 698 | if (jeb->last_node == next_ref) jeb->last_node = ref; |
699 | if (jeb->gc_node == n) { | 699 | if (jeb->gc_node == next_ref) { |
700 | /* gc will be happy continuing gc on this node */ | 700 | /* gc will be happy continuing gc on this node */ |
701 | jeb->gc_node=ref; | 701 | jeb->gc_node=ref; |
702 | } | 702 | } |
703 | spin_unlock(&c->erase_completion_lock); | 703 | spin_unlock(&c->erase_completion_lock); |
704 | 704 | ||
705 | __jffs2_free_raw_node_ref(n); | 705 | __jffs2_free_raw_node_ref(next_ref); |
706 | } | 706 | } |
707 | 707 | ||
708 | /* Also merge with the previous node in the list, if there is one | 708 | /* Also merge with the previous node in the list, if there is one |
@@ -712,8 +712,8 @@ void jffs2_mark_node_obsolete(struct jffs2_sb_info *c, struct jffs2_raw_node_ref | |||
712 | 712 | ||
713 | spin_lock(&c->erase_completion_lock); | 713 | spin_lock(&c->erase_completion_lock); |
714 | 714 | ||
715 | while (p->next_phys != ref) | 715 | while ((next_ref = ref_next(ref)) != ref) |
716 | p = p->next_phys; | 716 | p = next_ref; |
717 | 717 | ||
718 | if (ref_obsolete(p) && !ref->next_in_ino) { | 718 | if (ref_obsolete(p) && !ref->next_in_ino) { |
719 | #ifdef TEST_TOTLEN | 719 | #ifdef TEST_TOTLEN |
@@ -726,7 +726,7 @@ void jffs2_mark_node_obsolete(struct jffs2_sb_info *c, struct jffs2_raw_node_ref | |||
726 | /* gc will be happy continuing gc on this node */ | 726 | /* gc will be happy continuing gc on this node */ |
727 | jeb->gc_node=p; | 727 | jeb->gc_node=p; |
728 | } | 728 | } |
729 | p->next_phys = ref->next_phys; | 729 | p->next_phys = ref_next(ref); |
730 | __jffs2_free_raw_node_ref(ref); | 730 | __jffs2_free_raw_node_ref(ref); |
731 | } | 731 | } |
732 | spin_unlock(&c->erase_completion_lock); | 732 | spin_unlock(&c->erase_completion_lock); |
diff --git a/fs/jffs2/scan.c b/fs/jffs2/scan.c index 87b0a416b6a0..3551c39d7472 100644 --- a/fs/jffs2/scan.c +++ b/fs/jffs2/scan.c | |||
@@ -295,7 +295,7 @@ int jffs2_fill_scan_buf (struct jffs2_sb_info *c, void *buf, | |||
295 | int jffs2_scan_classify_jeb(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb) | 295 | int jffs2_scan_classify_jeb(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb) |
296 | { | 296 | { |
297 | if ((jeb->used_size + jeb->unchecked_size) == PAD(c->cleanmarker_size) && !jeb->dirty_size | 297 | if ((jeb->used_size + jeb->unchecked_size) == PAD(c->cleanmarker_size) && !jeb->dirty_size |
298 | && (!jeb->first_node || !jeb->first_node->next_phys) ) | 298 | && (!jeb->first_node || !ref_next(jeb->first_node)) ) |
299 | return BLK_STATE_CLEANMARKER; | 299 | return BLK_STATE_CLEANMARKER; |
300 | 300 | ||
301 | /* move blocks with max 4 byte dirty space to cleanlist */ | 301 | /* move blocks with max 4 byte dirty space to cleanlist */ |
@@ -647,7 +647,7 @@ scan_more: | |||
647 | /* If we're only checking the beginning of a block with a cleanmarker, | 647 | /* If we're only checking the beginning of a block with a cleanmarker, |
648 | bail now */ | 648 | bail now */ |
649 | if (buf_ofs == jeb->offset && jeb->used_size == PAD(c->cleanmarker_size) && | 649 | if (buf_ofs == jeb->offset && jeb->used_size == PAD(c->cleanmarker_size) && |
650 | c->cleanmarker_size && !jeb->dirty_size && !jeb->first_node->next_phys) { | 650 | c->cleanmarker_size && !jeb->dirty_size && !ref_next(jeb->first_node)) { |
651 | D1(printk(KERN_DEBUG "%d bytes at start of block seems clean... assuming all clean\n", EMPTY_SCAN_SIZE(c->sector_size))); | 651 | D1(printk(KERN_DEBUG "%d bytes at start of block seems clean... assuming all clean\n", EMPTY_SCAN_SIZE(c->sector_size))); |
652 | return BLK_STATE_CLEANMARKER; | 652 | return BLK_STATE_CLEANMARKER; |
653 | } | 653 | } |