aboutsummaryrefslogtreecommitdiff
path: root/fs/jffs2
diff options
context:
space:
mode:
authorDavid Woodhouse <dwmw2@infradead.org>2006-05-24 09:04:17 +0100
committerDavid Woodhouse <dwmw2@infradead.org>2006-05-24 09:04:17 +0100
commit99988f7bbd16b861590dda4631c4db6cb17b5091 (patch)
tree38865d44c905d7f84d7eeb70186482e1e399fe9c /fs/jffs2
parent2f785402f39b96a077b6e62bf26164bfb8e0c980 (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.c14
-rw-r--r--fs/jffs2/gc.c2
-rw-r--r--fs/jffs2/nodelist.c13
-rw-r--r--fs/jffs2/nodelist.h6
-rw-r--r--fs/jffs2/nodemgmt.c22
-rw-r--r--fs/jffs2/scan.c4
6 files changed, 31 insertions, 30 deletions
diff --git a/fs/jffs2/debug.c b/fs/jffs2/debug.c
index 1fe17de713e..72b4fc13a10 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,
else
my_dirty_size += totlen;
- if ((!ref2->next_phys) != (ref2 == jeb->last_node)) {
- 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",
- ref_offset(ref2), ref2, ref_offset(ref2->next_phys), ref2->next_phys,
- ref_offset(jeb->last_node), jeb->last_node);
+ if ((!ref_next(ref2)) != (ref2 == jeb->last_node)) {
+ JFFS2_ERROR("node_ref for node at %#08x (mem %p) has next at %#08x (mem %p), last_node is at %#08x (mem %p).\n",
+ ref_offset(ref2), ref2, ref_offset(ref_next(ref2)), ref_next(ref2),
+ ref_offset(jeb->last_node), jeb->last_node);
goto error;
}
- ref2 = ref2->next_phys;
+ ref2 = ref_next(ref2);
}
if (my_used_size != jeb->used_size) {
@@ -268,9 +268,9 @@ __jffs2_dbg_dump_node_refs_nolock(struct jffs2_sb_info *c,
}
printk(JFFS2_DBG);
- for (ref = jeb->first_node; ; ref = ref->next_phys) {
+ for (ref = jeb->first_node; ; ref = ref_next(ref)) {
printk("%#08x(%#x)", ref_offset(ref), ref->__totlen);
- if (ref->next_phys)
+ if (ref_next(ref))
printk("->");
else
break;
diff --git a/fs/jffs2/gc.c b/fs/jffs2/gc.c
index a22ff5df7fc..477c526d638 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)
while(ref_obsolete(raw)) {
D1(printk(KERN_DEBUG "Node at 0x%08x is obsolete... skipping\n", ref_offset(raw)));
- raw = raw->next_phys;
+ raw = ref_next(raw);
if (unlikely(!raw)) {
printk(KERN_WARNING "eep. End of raw list while still supposedly nodes to GC\n");
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 1e6eabd730f..0e82979c741 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,
struct jffs2_raw_node_ref *ref)
{
uint32_t ref_end;
+ struct jffs2_raw_node_ref *next_ref = ref_next(ref);
- if (ref->next_phys)
- ref_end = ref_offset(ref->next_phys);
+ if (next_ref)
+ ref_end = ref_offset(next_ref);
else {
if (!jeb)
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
printk(KERN_CRIT "Totlen for ref at %p (0x%08x-0x%08x) miscalculated as 0x%x instead of %x\n",
ref, ref_offset(ref), ref_offset(ref)+ref->__totlen,
ret, ref->__totlen);
- if (ref->next_phys) {
- printk(KERN_CRIT "next_phys %p (0x%08x-0x%08x)\n", ref->next_phys, ref_offset(ref->next_phys),
- ref_offset(ref->next_phys)+ref->__totlen);
+ if (ref_next(ref)) {
+ printk(KERN_CRIT "next %p (0x%08x-0x%08x)\n", ref_next(ref), ref_offset(ref_next(ref)),
+ ref_offset(ref_next(ref))+ref->__totlen);
} else
- printk(KERN_CRIT "No next_phys. jeb->last_node is %p\n", jeb->last_node);
+ printk(KERN_CRIT "No next ref. jeb->last_node is %p\n", jeb->last_node);
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);
ret = ref->__totlen;
diff --git a/fs/jffs2/nodelist.h b/fs/jffs2/nodelist.h
index 7cc74d2ab4d..94d152de95e 100644
--- a/fs/jffs2/nodelist.h
+++ b/fs/jffs2/nodelist.h
@@ -88,18 +88,18 @@ struct jffs2_raw_node_ref
#endif
};
+#define ref_next(r) ((r)->next_phys)
+
static inline struct jffs2_inode_cache *jffs2_raw_ref_to_ic(struct jffs2_raw_node_ref *raw)
{
- while(raw->next_in_ino) {
+ while(raw->next_in_ino)
raw = raw->next_in_ino;
- }
/* NB. This can be a jffs2_xattr_datum or jffs2_xattr_ref and
not actually a jffs2_inode_cache. Check ->class */
return ((struct jffs2_inode_cache *)raw);
}
-
/* flash_offset & 3 always has to be zero, because nodes are
always aligned at 4 bytes. So we have a couple of extra bits
to play with, which indicate the node's status; see below: */
diff --git a/fs/jffs2/nodemgmt.c b/fs/jffs2/nodemgmt.c
index 01bf2773fe4..f4649c275fb 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)
void jffs2_mark_node_obsolete(struct jffs2_sb_info *c, struct jffs2_raw_node_ref *ref)
{
struct jffs2_eraseblock *jeb;
+ struct jffs2_raw_node_ref *next_ref;
int blocknr;
struct jffs2_unknown_node n;
int ret, addedsize;
@@ -685,24 +686,23 @@ void jffs2_mark_node_obsolete(struct jffs2_sb_info *c, struct jffs2_raw_node_ref
/* Merge with the next node in the physical list, if there is one
and if it's also obsolete and if it doesn't belong to any inode */
- if (ref->next_phys && ref_obsolete(ref->next_phys) &&
- !ref->next_phys->next_in_ino) {
- struct jffs2_raw_node_ref *n = ref->next_phys;
+ next_ref = ref_next(ref);
+ if (next_ref && ref_obsolete(next_ref) && !next_ref->next_in_ino) {
spin_lock(&c->erase_completion_lock);
#ifdef TEST_TOTLEN
- ref->__totlen += n->__totlen;
+ ref->__totlen += next_ref->__totlen;
#endif
- ref->next_phys = n->next_phys;
- if (jeb->last_node == n) jeb->last_node = ref;
- if (jeb->gc_node == n) {
+ ref->next_phys = ref_next(next_ref);
+ if (jeb->last_node == next_ref) jeb->last_node = ref;
+ if (jeb->gc_node == next_ref) {
/* gc will be happy continuing gc on this node */
jeb->gc_node=ref;
}
spin_unlock(&c->erase_completion_lock);
- __jffs2_free_raw_node_ref(n);
+ __jffs2_free_raw_node_ref(next_ref);
}
/* 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
spin_lock(&c->erase_completion_lock);
- while (p->next_phys != ref)
- p = p->next_phys;
+ while ((next_ref = ref_next(ref)) != ref)
+ p = next_ref;
if (ref_obsolete(p) && !ref->next_in_ino) {
#ifdef TEST_TOTLEN
@@ -726,7 +726,7 @@ void jffs2_mark_node_obsolete(struct jffs2_sb_info *c, struct jffs2_raw_node_ref
/* gc will be happy continuing gc on this node */
jeb->gc_node=p;
}
- p->next_phys = ref->next_phys;
+ p->next_phys = ref_next(ref);
__jffs2_free_raw_node_ref(ref);
}
spin_unlock(&c->erase_completion_lock);
diff --git a/fs/jffs2/scan.c b/fs/jffs2/scan.c
index 87b0a416b6a..3551c39d747 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,
int jffs2_scan_classify_jeb(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb)
{
if ((jeb->used_size + jeb->unchecked_size) == PAD(c->cleanmarker_size) && !jeb->dirty_size
- && (!jeb->first_node || !jeb->first_node->next_phys) )
+ && (!jeb->first_node || !ref_next(jeb->first_node)) )
return BLK_STATE_CLEANMARKER;
/* move blocks with max 4 byte dirty space to cleanlist */
@@ -647,7 +647,7 @@ scan_more:
/* If we're only checking the beginning of a block with a cleanmarker,
bail now */
if (buf_ofs == jeb->offset && jeb->used_size == PAD(c->cleanmarker_size) &&
- c->cleanmarker_size && !jeb->dirty_size && !jeb->first_node->next_phys) {
+ c->cleanmarker_size && !jeb->dirty_size && !ref_next(jeb->first_node)) {
D1(printk(KERN_DEBUG "%d bytes at start of block seems clean... assuming all clean\n", EMPTY_SCAN_SIZE(c->sector_size)));
return BLK_STATE_CLEANMARKER;
}